forked from MapComplete/MapComplete
Various fixes, enabled preciseLocation input by default
This commit is contained in:
parent
8fca373437
commit
8ebfb3de51
6 changed files with 71 additions and 41 deletions
|
@ -63,9 +63,14 @@ export default class UserRelatedState extends ElementsState {
|
|||
);
|
||||
|
||||
if (layoutToUse?.hideFromOverview) {
|
||||
this.osmConnection
|
||||
.GetPreference("hidden-theme-" + layoutToUse?.id + "-enabled")
|
||||
.setData("true");
|
||||
this.osmConnection.isLoggedIn.addCallbackAndRunD(loggedIn => {
|
||||
if(loggedIn){
|
||||
this.osmConnection
|
||||
.GetPreference("hidden-theme-" + layoutToUse?.id + "-enabled")
|
||||
.setData("true");
|
||||
return true;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.installedThemes = new InstalledThemes(
|
||||
|
|
|
@ -162,7 +162,9 @@ export default class LayerConfig {
|
|||
}
|
||||
this.presets = (json.presets ?? []).map((pr, i) => {
|
||||
|
||||
let preciseInput = undefined;
|
||||
let preciseInput = {
|
||||
preferredBackground: "photo"
|
||||
};
|
||||
if (pr.preciseInput !== undefined) {
|
||||
if (pr.preciseInput === true) {
|
||||
pr.preciseInput = {
|
||||
|
|
|
@ -43,52 +43,63 @@ export default class MoreScreen extends Combine {
|
|||
super([
|
||||
intro,
|
||||
MoreScreen.createOfficialThemesList(state, themeButtonStyle).SetClass(themeListStyle),
|
||||
MoreScreen.createPreviouslyVistedHiddenList(state, themeButtonStyle).SetClass(themeListStyle),
|
||||
MoreScreen.createUnofficialThemeList(themeButtonStyle, state)?.SetClass(themeListStyle),
|
||||
MoreScreen.createPreviouslyVistedHiddenList(state, themeButtonStyle, themeListStyle),
|
||||
MoreScreen.createUnofficialThemeList(themeButtonStyle, state, themeListStyle),
|
||||
tr.streetcomplete.Clone().SetClass("block text-base mx-10 my-3 mb-10")
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
private static createUnofficialThemeList(buttonClass: string, state: UserRelatedState): BaseUIElement {
|
||||
private static createUnofficialThemeList(buttonClass: string, state: UserRelatedState, themeListClasses): BaseUIElement {
|
||||
return new VariableUiElement(state.installedThemes.map(customThemes => {
|
||||
const els: BaseUIElement[] = []
|
||||
if (customThemes.length > 0) {
|
||||
els.push(Translations.t.general.customThemeIntro.Clone())
|
||||
|
||||
const customThemesElement = new Combine(
|
||||
customThemes.map(theme => MoreScreen.createLinkButton(state, theme.layout, theme.definition)?.SetClass(buttonClass))
|
||||
)
|
||||
els.push(customThemesElement)
|
||||
}
|
||||
return els;
|
||||
return new Combine([
|
||||
Translations.t.general.customThemeIntro.Clone(),
|
||||
new Combine(els).SetClass(themeListClasses)
|
||||
]);
|
||||
}));
|
||||
}
|
||||
|
||||
private static createPreviouslyVistedHiddenList(state: UserRelatedState, buttonClass: string){
|
||||
const t= Translations.t.general.morescreen
|
||||
|
||||
private static createPreviouslyVistedHiddenList(state: UserRelatedState, buttonClass: string, themeListStyle: string) {
|
||||
const t = Translations.t.general.morescreen
|
||||
console.log("Hidden themes init...")
|
||||
const prefix = "mapcomplete-hidden-theme-"
|
||||
const hiddenTotal = AllKnownLayouts.layoutsList.filter(layout => layout.hideFromOverview).length
|
||||
return new Toggle(
|
||||
new Combine([
|
||||
new Title(t.previouslyHiddenTitle.Clone()),
|
||||
t.hiddenExplanation,
|
||||
|
||||
|
||||
new VariableUiElement(
|
||||
state.osmConnection.preferencesHandler.preferences.map(allPreferences => {
|
||||
const knownThemes = Utils.NoNull( Object.keys(allPreferences).filter(key => key.startsWith("hidden-theme-"))
|
||||
.map(key => key.substr("hidden-theme-".length, key.length - "-enabled".length))
|
||||
.map(theme => AllKnownLayouts.allKnownLayouts.get(theme) ))
|
||||
return new Combine(knownThemes.map(layout =>
|
||||
MoreScreen.createLinkButton(state, layout ).SetClass(buttonClass)
|
||||
))
|
||||
|
||||
const knownThemes = Utils.NoNull(Object.keys(allPreferences)
|
||||
.filter(key => key.startsWith(prefix))
|
||||
.map(key => key.substring(prefix.length, key.length - "-enabled".length))
|
||||
.map(theme => {
|
||||
return AllKnownLayouts.allKnownLayouts.get(theme);
|
||||
}))
|
||||
if (knownThemes.length === 0) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const knownLayouts = new Combine(knownThemes.map(layout =>
|
||||
MoreScreen.createLinkButton(state, layout)?.SetClass(buttonClass)
|
||||
)).SetClass(themeListStyle)
|
||||
|
||||
return new Combine([
|
||||
new Title(t.previouslyHiddenTitle),
|
||||
t.hiddenExplanation.Subs({hidden_discovered: ""+knownThemes.length,total_hidden: ""+hiddenTotal}),
|
||||
knownLayouts
|
||||
])
|
||||
|
||||
})
|
||||
|
||||
)]).SetClass("flex flex-col"),
|
||||
).SetClass("flex flex-col"),
|
||||
undefined,
|
||||
state.osmConnection.isLoggedIn
|
||||
)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -100,6 +111,9 @@ export default class MoreScreen extends Combine {
|
|||
console.trace("Layout is undefined")
|
||||
return undefined
|
||||
}
|
||||
if(layout.hideFromOverview){
|
||||
return undefined;
|
||||
}
|
||||
const button = MoreScreen.createLinkButton(state, layout)?.SetClass(buttonClass);
|
||||
if (layout.id === personal.id) {
|
||||
return new VariableUiElement(
|
||||
|
@ -154,21 +168,14 @@ export default class MoreScreen extends Combine {
|
|||
}, layout: LayoutConfig, customThemeDefinition: string = undefined
|
||||
):
|
||||
BaseUIElement {
|
||||
if (layout
|
||||
|
||||
===
|
||||
undefined
|
||||
) {
|
||||
return
|
||||
undefined;
|
||||
if (layout === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (layout.id === undefined) {
|
||||
console.error("ID is undefined for layout", layout);
|
||||
return undefined;
|
||||
}
|
||||
if (layout.hideFromOverview) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (layout.id === state?.layoutToUse?.id) {
|
||||
return undefined;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import {FixedUiElement} from "../Base/FixedUiElement";
|
|||
import ShowDataLayer from "../ShowDataLayer/ShowDataLayer";
|
||||
import BaseUIElement from "../BaseUIElement";
|
||||
import Toggle from "./Toggle";
|
||||
import {start} from "repl";
|
||||
|
||||
export default class LocationInput extends InputElement<Loc> implements MinimapObj {
|
||||
|
||||
|
@ -71,7 +72,6 @@ export default class LocationInput extends InputElement<Loc> implements MinimapO
|
|||
} else {
|
||||
const self = this;
|
||||
|
||||
|
||||
if (self._snappedPointTags !== undefined) {
|
||||
const layout = State.state.layoutToUse
|
||||
|
||||
|
@ -163,7 +163,14 @@ export default class LocationInput extends InputElement<Loc> implements MinimapO
|
|||
try {
|
||||
const self = this;
|
||||
const hasMoved = new UIEventSource(false)
|
||||
this.GetValue().addCallbackAndRunD(_ => {
|
||||
const startLocation = { ...this._centerLocation.data }
|
||||
this._centerLocation. addCallbackD(newLocation => {
|
||||
const f = 100000
|
||||
console.log(newLocation.lon, startLocation.lon)
|
||||
const diff = (Math.abs(newLocation.lon * f - startLocation.lon* f ) + Math.abs(newLocation.lat* f - startLocation.lat* f ))
|
||||
if(diff < 1){
|
||||
return;
|
||||
}
|
||||
hasMoved.setData(true)
|
||||
return true;
|
||||
})
|
||||
|
|
|
@ -521,6 +521,9 @@
|
|||
"en": "A tree of a species with leaves, such as oak or populus.",
|
||||
"it": "Un albero di una specie con foglie larghe come la quercia o il pioppo.",
|
||||
"fr": "Un arbre d'une espèce avec de larges feuilles, comme le chêne ou le peuplier."
|
||||
},
|
||||
"preciseInput": {
|
||||
"preferredBackground": "photo"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -541,6 +544,9 @@
|
|||
"it": "Un albero di una specie con aghi come il pino o l’abete.",
|
||||
"ru": "Дерево с хвоей (иглами), например, сосна или ель.",
|
||||
"fr": "Une espèce d’arbre avec des épines comme le pin ou l’épicéa."
|
||||
},
|
||||
"preciseInput": {
|
||||
"preferredBackground": "photo"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -561,6 +567,9 @@
|
|||
"it": "Qualora non si sia sicuri se si tratta di un albero latifoglia o aghifoglia.",
|
||||
"fr": "Si vous n'êtes pas sûr(e) de savoir s'il s'agit d'un arbre à feuilles larges ou à aiguilles.",
|
||||
"ru": "Если вы не уверены в том, лиственное это дерево или хвойное."
|
||||
},
|
||||
"preciseInput": {
|
||||
"preferredBackground": "photo"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
|
@ -126,7 +126,7 @@
|
|||
"streetcomplete": "Another, similar application is <a href='https://play.google.com/store/apps/details?id=de.westnordost.streetcomplete' class='underline hover:text-blue-800' class='underline hover:text-blue-800' target='_blank'>StreetComplete</a>.",
|
||||
"createYourOwnTheme": "Create your own MapComplete theme from scratch",
|
||||
"previouslyHiddenTitle": "Previously visited hidden themes",
|
||||
"hiddenExplanation": "These themes are only visible if you know the link..."
|
||||
"hiddenExplanation": "These themes are only visible if you know the link. You have discovered {hidden_discovered} out of {total_hidden} hidden themes"
|
||||
},
|
||||
"sharescreen": {
|
||||
"intro": "<h3>Share this map</h3> Share this map by copying the link below and sending it to friends and family:",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue