forked from MapComplete/MapComplete
More refactoring
This commit is contained in:
parent
849c61c8a1
commit
e4a2fd1daf
15 changed files with 75 additions and 44 deletions
|
@ -3,7 +3,7 @@ import {DropDown} from "./Input/DropDown";
|
|||
import Translations from "./i18n/Translations";
|
||||
import State from "../State";
|
||||
import {UIEventSource} from "../Logic/UIEventSource";
|
||||
import {BaseLayer} from "../Logic/BaseLayer";
|
||||
import {BaseLayer} from "../Models/BaseLayer";
|
||||
|
||||
export default class BackgroundSelector extends UIElement {
|
||||
|
||||
|
@ -28,7 +28,7 @@ export default class BackgroundSelector extends UIElement {
|
|||
baseLayers.push({value: layer, shown: layer.name ?? "id:" + layer.id});
|
||||
}
|
||||
|
||||
this._dropdown = new DropDown(Translations.t.general.backgroundMap, baseLayers, State.state.bm.CurrentLayer);
|
||||
this._dropdown = new DropDown(Translations.t.general.backgroundMap, baseLayers, State.state.backgroundLayer);
|
||||
}
|
||||
|
||||
InnerRender(): string {
|
||||
|
|
|
@ -17,6 +17,7 @@ import SavePanel from "./SavePanel";
|
|||
import {LocalStorageSource} from "../../Logic/Web/LocalStorageSource";
|
||||
import HelpText from "./HelpText";
|
||||
import Svg from "../../Svg";
|
||||
import Constants from "../../Models/Constants";
|
||||
|
||||
|
||||
export default class CustomGeneratorPanel extends UIElement {
|
||||
|
@ -103,11 +104,12 @@ export default class CustomGeneratorPanel extends UIElement {
|
|||
this.loginButton
|
||||
]).Render();
|
||||
}
|
||||
if (ud.csCount <= State.userJourney.themeGeneratorReadOnlyUnlock) {
|
||||
const journey = Constants.userJourney;
|
||||
if (ud.csCount <= journey.themeGeneratorReadOnlyUnlock) {
|
||||
return new Combine([
|
||||
"<h3>Too little experience</h3>",
|
||||
`<p>Creating your own (readonly) themes can only be done if you have more then <b>${State.userJourney.themeGeneratorReadOnlyUnlock}</b> changesets made</p>`,
|
||||
`<p>Making a theme including survey options can be done at <b>${State.userJourney.themeGeneratorFullUnlock}</b> changesets</p>`
|
||||
`<p>Creating your own (readonly) themes can only be done if you have more then <b>${journey.themeGeneratorReadOnlyUnlock}</b> changesets made</p>`,
|
||||
`<p>Making a theme including survey options can be done at <b>${journey.themeGeneratorFullUnlock}</b> changesets</p>`
|
||||
]).Render();
|
||||
}
|
||||
return this.mainPanel.Render()
|
||||
|
|
|
@ -21,6 +21,7 @@ import State from "../../State";
|
|||
import {FixedUiElement} from "../Base/FixedUiElement";
|
||||
import ValidatedTextField from "../Input/ValidatedTextField";
|
||||
import Svg from "../../Svg";
|
||||
import Constants from "../../Models/Constants";
|
||||
|
||||
/**
|
||||
* Shows the configuration for a single layer
|
||||
|
@ -142,7 +143,7 @@ export default class LayerPanel extends UIElement {
|
|||
}
|
||||
)
|
||||
|
||||
if (userDetails.csCount >= State.userJourney.themeGeneratorFullUnlock) {
|
||||
if (userDetails.csCount >= Constants.userJourney.themeGeneratorFullUnlock) {
|
||||
|
||||
const presetPanel = new MultiInput("Add a preset",
|
||||
() => ({tags: [], title: {}}),
|
||||
|
@ -151,7 +152,7 @@ export default class LayerPanel extends UIElement {
|
|||
new SingleSetting(config, presetPanel, ["layers", index, "presets"], "Presets", "")
|
||||
this.presetsPanel = presetPanel;
|
||||
} else {
|
||||
this.presetsPanel = new FixedUiElement(`Creating a custom theme which also edits OSM is only unlocked after ${State.userJourney.themeGeneratorFullUnlock} changesets`).SetClass("alert");
|
||||
this.presetsPanel = new FixedUiElement(`Creating a custom theme which also edits OSM is only unlocked after ${Constants.userJourney.themeGeneratorFullUnlock} changesets`).SetClass("alert");
|
||||
}
|
||||
|
||||
function loadTagRenderings() {
|
||||
|
|
|
@ -18,6 +18,7 @@ import {VariableUiElement} from "../Base/VariableUIElement";
|
|||
import ValidatedTextField from "../Input/ValidatedTextField";
|
||||
import SpecialVisualizations from "../SpecialVisualizations";
|
||||
import TagRenderingConfig from "../../Customizations/JSON/TagRenderingConfig";
|
||||
import Constants from "../../Models/Constants";
|
||||
|
||||
export default class TagRenderingPanel extends InputElement<TagRenderingConfigJson> {
|
||||
|
||||
|
@ -46,7 +47,7 @@ export default class TagRenderingPanel extends InputElement<TagRenderingConfigJs
|
|||
this.SetClass("min-height");
|
||||
|
||||
this.options = options ?? {};
|
||||
const questionsNotUnlocked = userDetails.csCount < State.userJourney.themeGeneratorFullUnlock;
|
||||
const questionsNotUnlocked = userDetails.csCount < Constants.userJourney.themeGeneratorFullUnlock;
|
||||
this.options.disableQuestions =
|
||||
(this.options.disableQuestions ?? false) ||
|
||||
questionsNotUnlocked;
|
||||
|
@ -89,7 +90,7 @@ export default class TagRenderingPanel extends InputElement<TagRenderingConfigJs
|
|||
"<br/><br/>" +
|
||||
"Furhtermore, some special functions are supported:"+SpecialVisualizations.HelpMessage.Render()),
|
||||
|
||||
questionsNotUnlocked ? `You need at least ${State.userJourney.themeGeneratorFullUnlock} changesets to unlock the 'question'-field and to use your theme to edit OSM data` : "",
|
||||
questionsNotUnlocked ? `You need at least ${Constants.userJourney.themeGeneratorFullUnlock} changesets to unlock the 'question'-field and to use your theme to edit OSM data` : "",
|
||||
...(options?.disableQuestions ? [] : questionSettings),
|
||||
|
||||
"<h3>Mappings</h3>",
|
||||
|
|
|
@ -9,6 +9,7 @@ import {VariableUiElement} from "./Base/VariableUIElement";
|
|||
import Svg from "../Svg";
|
||||
import LayoutConfig from "../Customizations/JSON/LayoutConfig";
|
||||
import * as personal from "../assets/themes/personalLayout/personalLayout.json"
|
||||
import Constants from "../Models/Constants";
|
||||
|
||||
export class MoreScreen extends UIElement {
|
||||
|
||||
|
@ -74,7 +75,7 @@ export class MoreScreen extends UIElement {
|
|||
|
||||
els.push(new VariableUiElement(
|
||||
State.state.osmConnection.userDetails.map(userDetails => {
|
||||
if (userDetails.csCount < State.userJourney.themeGeneratorReadOnlyUnlock) {
|
||||
if (userDetails.csCount < Constants.userJourney.themeGeneratorReadOnlyUnlock) {
|
||||
return tr.requestATheme.Render();
|
||||
}
|
||||
return new SubtleButton(Svg.pencil_ui(), tr.createYourOwnTheme, {
|
||||
|
@ -88,7 +89,7 @@ export class MoreScreen extends UIElement {
|
|||
for (const k in AllKnownLayouts.allSets) {
|
||||
const layout : LayoutConfig = AllKnownLayouts.allSets[k];
|
||||
if (k === personal.id) {
|
||||
if (State.state.osmConnection.userDetails.data.csCount < State.userJourney.personalLayoutUnlock) {
|
||||
if (State.state.osmConnection.userDetails.data.csCount < Constants.userJourney.personalLayoutUnlock) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import State from "../../State";
|
|||
import {FixedUiElement} from "../Base/FixedUiElement";
|
||||
import {OH} from "./OpeningHours";
|
||||
import Translations from "../i18n/Translations";
|
||||
import Constants from "../../Models/Constants";
|
||||
|
||||
export default class OpeningHoursVisualization extends UIElement {
|
||||
private readonly _key: string;
|
||||
|
@ -166,7 +167,7 @@ export default class OpeningHoursVisualization extends UIElement {
|
|||
} catch (e) {
|
||||
console.log(e);
|
||||
const msg = new Combine([Translations.t.general.opening_hours.error_loading,
|
||||
State.state?.osmConnection?.userDetails?.data?.csCount >= State.userJourney.tagsVisibleAndWikiLinked ?
|
||||
State.state?.osmConnection?.userDetails?.data?.csCount >= Constants.userJourney.tagsVisibleAndWikiLinked ?
|
||||
`<span class='subtle'>${e}</span>`
|
||||
: ""
|
||||
]);
|
||||
|
|
|
@ -18,6 +18,7 @@ import {VariableUiElement} from "../Base/VariableUIElement";
|
|||
import Translations from "../i18n/Translations";
|
||||
import {FixedUiElement} from "../Base/FixedUiElement";
|
||||
import {Translation} from "../i18n/Translation";
|
||||
import Constants from "../../Models/Constants";
|
||||
|
||||
/**
|
||||
* Shows the question element.
|
||||
|
@ -72,14 +73,14 @@ export default class TagRenderingQuestion extends UIElement {
|
|||
self._inputElement.GetValue().map(
|
||||
(tags: TagsFilter) => {
|
||||
const csCount = State.state?.osmConnection?.userDetails?.data?.csCount ?? 1000;
|
||||
if (csCount < State.userJourney.tagsVisibleAt) {
|
||||
if (csCount < Constants.userJourney.tagsVisibleAt) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (tags === undefined) {
|
||||
return Translations.t.general.noTagsSelected.SetClass("subtle").Render();
|
||||
}
|
||||
if (csCount < State.userJourney.tagsVisibleAndWikiLinked) {
|
||||
if (csCount < Constants.userJourney.tagsVisibleAndWikiLinked) {
|
||||
const tagsStr = tags.asHumanString(false, true);
|
||||
return new FixedUiElement(tagsStr).SetClass("subtle").Render();
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import {SubtleButton} from "./Base/SubtleButton";
|
|||
import Svg from "../Svg";
|
||||
import {Translation} from "./i18n/Translation";
|
||||
import LayoutConfig from "../Customizations/JSON/LayoutConfig";
|
||||
import Constants from "../Models/Constants";
|
||||
|
||||
export class ShareScreen extends UIElement {
|
||||
private readonly _options: UIElement;
|
||||
|
@ -71,7 +72,7 @@ export class ShareScreen extends UIElement {
|
|||
|
||||
if (State.state !== undefined) {
|
||||
|
||||
const currentLayer: UIEventSource<{ id: string, name: string, layer: any }> = (State.state.bm as Basemap).CurrentLayer;
|
||||
const currentLayer: UIEventSource<{ id: string, name: string, layer: any }> = State.state.backgroundLayer;
|
||||
const currentBackground = new VariableUiElement(currentLayer.map(layer => {
|
||||
return tr.fsIncludeCurrentBackgroundMap.Subs({name: layer?.name ?? ""}).Render();
|
||||
}));
|
||||
|
@ -190,7 +191,7 @@ export class ShareScreen extends UIElement {
|
|||
new VariableUiElement(
|
||||
State.state.osmConnection.userDetails.map(
|
||||
userDetails => {
|
||||
if (userDetails.csCount <= State.userJourney.themeGeneratorReadOnlyUnlock) {
|
||||
if (userDetails.csCount <= Constants.userJourney.themeGeneratorReadOnlyUnlock) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import State from "../State";
|
|||
import {UIEventSource} from "../Logic/UIEventSource";
|
||||
import Svg from "../Svg";
|
||||
import {FixedUiElement} from "./Base/FixedUiElement";
|
||||
import Constants from "../Models/Constants";
|
||||
|
||||
/**
|
||||
* Asks to add a feature at the last clicked location, at least if zoom is sufficient
|
||||
|
@ -59,7 +60,7 @@ export class SimpleAddUI extends UIElement {
|
|||
|
||||
const csCount = State.state.osmConnection.userDetails.data.csCount;
|
||||
let tagInfo = "";
|
||||
if (csCount > State.userJourney.tagsVisibleAt) {
|
||||
if (csCount > Constants.userJourney.tagsVisibleAt) {
|
||||
tagInfo = preset.tags.map(t => t.asHumanString(false, true)).join("&");
|
||||
tagInfo = `<br/><span class='subtle'>${tagInfo}</span>`
|
||||
}
|
||||
|
@ -139,8 +140,8 @@ export class SimpleAddUI extends UIElement {
|
|||
|
||||
let tagInfo = "";
|
||||
const csCount = State.state.osmConnection.userDetails.data.csCount;
|
||||
if (csCount > State.userJourney.tagsVisibleAt) {
|
||||
tagInfo = this._confirmPreset.data .tags.map(t => t.asHumanString(csCount > State.userJourney.tagsVisibleAndWikiLinked, true)).join("&");
|
||||
if (csCount > Constants.userJourney.tagsVisibleAt) {
|
||||
tagInfo = this._confirmPreset.data .tags.map(t => t.asHumanString(csCount > Constants.userJourney.tagsVisibleAndWikiLinked, true)).join("&");
|
||||
tagInfo = `<br/>More information about the preset: ${tagInfo}`
|
||||
}
|
||||
|
||||
|
@ -169,7 +170,7 @@ export class SimpleAddUI extends UIElement {
|
|||
return new Combine([header, this._loginButton]).Render()
|
||||
}
|
||||
|
||||
if (userDetails.data.unreadMessages > 0 && userDetails.data.csCount < State.userJourney.addNewPointWithUnreadMessagesUnlock) {
|
||||
if (userDetails.data.unreadMessages > 0 && userDetails.data.csCount < Constants.userJourney.addNewPointWithUnreadMessagesUnlock) {
|
||||
return new Combine([header,
|
||||
Translations.t.general.readYourMessages.Clone().SetClass("alert"),
|
||||
this.goToInboxButton
|
||||
|
@ -185,13 +186,13 @@ export class SimpleAddUI extends UIElement {
|
|||
]);
|
||||
}
|
||||
|
||||
if (userDetails.data.csCount < State.userJourney.addNewPointsUnlock) {
|
||||
if (userDetails.data.csCount < Constants.userJourney.addNewPointsUnlock) {
|
||||
return new Combine([header, "<span class='alert'>",
|
||||
Translations.t.general.fewChangesBefore,
|
||||
"</span>"]).Render();
|
||||
}
|
||||
|
||||
if (State.state.locationControl.data.zoom < State.userJourney.minZoomLevelToAddNewPoints) {
|
||||
if (State.state.locationControl.data.zoom < Constants.userJourney.minZoomLevelToAddNewPoints) {
|
||||
return new Combine([header, Translations.t.general.add.zoomInFurther.SetClass("alert")]).Render()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue