forked from MapComplete/MapComplete
Enable userlayouts in personal theme and morescreen, various small fixes
This commit is contained in:
parent
4a0970a71f
commit
328dc5577c
17 changed files with 164 additions and 150 deletions
|
@ -308,7 +308,7 @@ class LayerGenerator extends UIElement {
|
|||
|
||||
new FixedUiElement("<p>A layer is a collection of related objects which have the same or very similar tags renderings. In general, all objects of one layer have the same icon (or at least very similar icons)</p>"),
|
||||
|
||||
createFieldUI("Name", "id", layerConfig, {description: "The name of this layer"}),
|
||||
createFieldUI("Name", "name", layerConfig, {description: "The name of this layer"}),
|
||||
createFieldUI("A description of objects for this layer", "description", layerConfig, {description: "The description of this layer"}),
|
||||
createFieldUI("Minimum zoom level", "minzoom", layerConfig, {
|
||||
type: "nat",
|
||||
|
|
|
@ -18,7 +18,7 @@ export class MoreScreen extends UIElement {
|
|||
constructor() {
|
||||
super(State.state.locationControl);
|
||||
this.ListenTo(State.state.osmConnection.userDetails);
|
||||
this.ListenTo(State.state.osmConnection._preferencesHandler.preferences);
|
||||
this.ListenTo(State.state.installedThemes);
|
||||
|
||||
}
|
||||
|
||||
|
@ -30,10 +30,6 @@ export class MoreScreen extends UIElement {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
if (layout.name === PersonalLayout.NAME) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const currentLocation = State.state.locationControl.data;
|
||||
let linkText =
|
||||
`./${layout.name}.html?z=${currentLocation.zoom}&lat=${currentLocation.lat}&lon=${currentLocation.lon}`
|
||||
|
@ -80,63 +76,28 @@ export class MoreScreen extends UIElement {
|
|||
})
|
||||
));
|
||||
|
||||
els.push(new VariableUiElement(
|
||||
State.state.osmConnection.userDetails.map(userDetails => {
|
||||
if (userDetails.csCount < State.userJourney.customLayoutUnlock) {
|
||||
return "";
|
||||
}
|
||||
return new SubtleButton("./assets/star.svg",
|
||||
new Combine([
|
||||
"<b>",
|
||||
Translations.t.favourite.title,
|
||||
"</b>",
|
||||
"<br>", Translations.t.favourite.description]), {
|
||||
url: "https://pietervdvn.github.io/MapComplete/personal.html",
|
||||
newTab: false
|
||||
}).Render();
|
||||
})
|
||||
));
|
||||
|
||||
|
||||
for (const k in AllKnownLayouts.allSets) {
|
||||
|
||||
|
||||
if (k === PersonalLayout.NAME) {
|
||||
if (State.state.osmConnection.userDetails.data.csCount < State.userJourney.customLayoutUnlock) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
els.push(this.createLinkButton(AllKnownLayouts.allSets[k]));
|
||||
}
|
||||
|
||||
const installedThemes = State.state.osmConnection._preferencesHandler.preferences.map(allPreferences => {
|
||||
const installedThemes = [];
|
||||
if(allPreferences === undefined){
|
||||
return installedThemes;
|
||||
}
|
||||
|
||||
for (const allPreferencesKey in allPreferences) {
|
||||
"mapcomplete-installed-theme-Superficie-combined-length"
|
||||
const themename = allPreferencesKey.match(/^mapcomplete-installed-theme-(.*)-combined-length$/);
|
||||
if(themename){
|
||||
installedThemes.push(themename[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return installedThemes;
|
||||
|
||||
})
|
||||
const customThemesNames = installedThemes.data ?? [];
|
||||
const customThemesNames = State.state.installedThemes.data ?? [];
|
||||
if (customThemesNames !== []) {
|
||||
els.push(Translations.t.general.customThemeIntro)
|
||||
}
|
||||
|
||||
console.log(customThemesNames);
|
||||
for (const installedThemeName of customThemesNames) {
|
||||
if(installedThemeName === ""){
|
||||
continue;
|
||||
}
|
||||
const customThemeDefinition = State.state.osmConnection.GetLongPreference("installed-theme-" + installedThemeName);
|
||||
try {
|
||||
const layout = CustomLayoutFromJSON.FromQueryParam(customThemeDefinition.data);
|
||||
els.push(this.createLinkButton(layout, customThemeDefinition.data));
|
||||
} catch (e) {
|
||||
console.log(customThemeDefinition.data);
|
||||
console.warn("Could not parse custom layout from preferences: ", installedThemeName, e);
|
||||
}
|
||||
for (const installed of State.state.installedThemes.data) {
|
||||
els.push(this.createLinkButton(installed.layout, installed.definition));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -135,8 +135,7 @@ export class ShareScreen extends UIElement {
|
|||
|
||||
let literalText = "https://pietervdvn.github.io/MapComplete/" + layout.name + ".html"
|
||||
|
||||
const parts =
|
||||
Utils.NoEmpty(Utils.NoNull(optionParts.map((eventSource) => eventSource.data)));
|
||||
const parts = Utils.NoEmpty(Utils.NoNull(optionParts.map((eventSource) => eventSource.data)));
|
||||
|
||||
let hash = "";
|
||||
if (State.state.layoutDefinition !== undefined) {
|
||||
|
@ -161,11 +160,7 @@ export class ShareScreen extends UIElement {
|
|||
);
|
||||
|
||||
|
||||
this._link = new VariableUiElement(
|
||||
url.map((url) => {
|
||||
return `<input type="text" value=" ${url}" id="code-link--copyable" style="width:90%"readonly>`
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
this._editLayout = new FixedUiElement("");
|
||||
if ((State.state.layoutDefinition !== undefined)) {
|
||||
|
@ -177,7 +172,7 @@ export class ShareScreen extends UIElement {
|
|||
return "";
|
||||
}
|
||||
return `<h3>Edit this theme</h3>` +
|
||||
`<a target='_blank' href='https://pietervdvn.github.io/MapComplete/customGenerator.html#${State.state.layoutDefinition}'>Click here to edit</a>`
|
||||
`<a target='_blank' href='./customGenerator.html#${State.state.layoutDefinition}'>Click here to edit</a>`
|
||||
|
||||
}
|
||||
));
|
||||
|
@ -187,11 +182,15 @@ export class ShareScreen extends UIElement {
|
|||
const status = new UIEventSource(" ");
|
||||
this._linkStatus = new VariableUiElement(status);
|
||||
const self = this;
|
||||
this._link.onClick(async () => {
|
||||
this._link = new VariableUiElement(
|
||||
url.map((url) => {
|
||||
return `<input type="text" value=" ${url}" id="code-link--copyable" style="width:90%"readonly>`
|
||||
})
|
||||
).onClick(async () => {
|
||||
|
||||
const shareData = {
|
||||
title: Translations.W(layout.name).InnerRender(),
|
||||
text: Translations.W(layout.description).InnerRender(),
|
||||
title: Translations.W(layout.name)?.InnerRender() ?? "",
|
||||
text: Translations.W(layout.description)?.InnerRender() ?? "",
|
||||
url: self._link.data,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue