forked from MapComplete/MapComplete
Improve moreScreen
This commit is contained in:
parent
254098a7e5
commit
d0b6d2419b
2 changed files with 14 additions and 19 deletions
|
@ -49,7 +49,7 @@ export default abstract class BaseUIElement {
|
||||||
*/
|
*/
|
||||||
public SetClass(clss: string) {
|
public SetClass(clss: string) {
|
||||||
if (clss == undefined) {
|
if (clss == undefined) {
|
||||||
return
|
return this
|
||||||
}
|
}
|
||||||
const all = clss.split(" ").map(clsName => clsName.trim());
|
const all = clss.split(" ").map(clsName => clsName.trim());
|
||||||
let recordedChange = false;
|
let recordedChange = false;
|
||||||
|
|
|
@ -90,10 +90,10 @@ export default class MoreScreen extends Combine {
|
||||||
}
|
}
|
||||||
|
|
||||||
let hash = ""
|
let hash = ""
|
||||||
if(layout.definition !== undefined){
|
if (layout.definition !== undefined) {
|
||||||
hash = "#"+btoa(JSON.stringify(layout.definition))
|
hash = "#" + btoa(JSON.stringify(layout.definition))
|
||||||
}
|
}
|
||||||
|
|
||||||
const linkText = currentLocation?.map(currentLocation => {
|
const linkText = currentLocation?.map(currentLocation => {
|
||||||
const params = [
|
const params = [
|
||||||
["z", currentLocation?.zoom],
|
["z", currentLocation?.zoom],
|
||||||
|
@ -106,11 +106,10 @@ export default class MoreScreen extends Combine {
|
||||||
}) ?? new UIEventSource<string>(`${linkPrefix}`)
|
}) ?? new UIEventSource<string>(`${linkPrefix}`)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return new SubtleButton(layout.icon,
|
return new SubtleButton(layout.icon,
|
||||||
new Combine([
|
new Combine([
|
||||||
`<dt class='text-lg leading-6 font-medium text-gray-900 group-hover:text-blue-800'>`,
|
`<dt class='text-lg leading-6 font-medium text-gray-900 group-hover:text-blue-800'>`,
|
||||||
new Translation(layout.title, !isCustom && !layout.mustHaveLanguage ? "themes:"+layout.id+".title" : undefined),
|
new Translation(layout.title, !isCustom && !layout.mustHaveLanguage ? "themes:" + layout.id + ".title" : undefined),
|
||||||
`</dt>`,
|
`</dt>`,
|
||||||
`<dd class='mt-1 text-base text-gray-500 group-hover:text-blue-900 overflow-ellipsis'>`,
|
`<dd class='mt-1 text-base text-gray-500 group-hover:text-blue-900 overflow-ellipsis'>`,
|
||||||
new Translation(layout.shortDescription)?.SetClass("subtle") ?? "",
|
new Translation(layout.shortDescription)?.SetClass("subtle") ?? "",
|
||||||
|
@ -128,15 +127,13 @@ export default class MoreScreen extends Combine {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static createUnofficialButtonFor(state: UserRelatedState, id: string): BaseUIElement {
|
private static createUnofficialButtonFor(state: UserRelatedState, id: string): BaseUIElement {
|
||||||
const allPreferences = state.osmConnection.preferencesHandler.preferences.data;
|
const pref = state.osmConnection.GetLongPreference(id)
|
||||||
const length = Number(allPreferences[id + "-length"])
|
const str = pref.data
|
||||||
let str = "";
|
if (str === undefined || str === "undefined" || str === "") {
|
||||||
for (let i = 0; i < length; i++) {
|
pref.setData(null)
|
||||||
str += allPreferences[id + "-" + i]
|
|
||||||
}
|
|
||||||
if(str === undefined || str === "undefined"){
|
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const value: {
|
const value: {
|
||||||
id: string
|
id: string
|
||||||
|
@ -149,7 +146,8 @@ export default class MoreScreen extends Combine {
|
||||||
value.isOfficial = false
|
value.isOfficial = false
|
||||||
return MoreScreen.createLinkButton(state, value, true)
|
return MoreScreen.createLinkButton(state, value, true)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.debug("Could not parse unofficial theme information for " + id, "The json is: ", str, e)
|
console.warn("Removing theme " + id + " as it could not be parsed from the preferences")
|
||||||
|
pref.setData(null)
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,16 +161,14 @@ export default class MoreScreen extends Combine {
|
||||||
|
|
||||||
for (const key in allPreferences) {
|
for (const key in allPreferences) {
|
||||||
if (key.startsWith(prefix) && key.endsWith("-combined-length")) {
|
if (key.startsWith(prefix) && key.endsWith("-combined-length")) {
|
||||||
const id = key.substring(0, key.length - "-length".length)
|
const id = key.substring("mapcomplete-".length, key.length - "-combined-length".length)
|
||||||
ids.push(id)
|
ids.push(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ids
|
return ids
|
||||||
});
|
});
|
||||||
|
|
||||||
var stableIds = UIEventSource.ListStabilized<string>(currentIds)
|
var stableIds = UIEventSource.ListStabilized<string>(currentIds)
|
||||||
|
|
||||||
return new VariableUiElement(
|
return new VariableUiElement(
|
||||||
stableIds.map(ids => {
|
stableIds.map(ids => {
|
||||||
const allThemes: BaseUIElement[] = []
|
const allThemes: BaseUIElement[] = []
|
||||||
|
@ -182,12 +178,11 @@ export default class MoreScreen extends Combine {
|
||||||
allThemes.push(link.SetClass(buttonClass))
|
allThemes.push(link.SetClass(buttonClass))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allThemes.length <= 0) {
|
if (allThemes.length <= 0) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return new Combine([
|
return new Combine([
|
||||||
Translations.t.general.customThemeIntro.Clone(),
|
Translations.t.general.customThemeIntro,
|
||||||
new Combine(allThemes).SetClass(themeListClasses)
|
new Combine(allThemes).SetClass(themeListClasses)
|
||||||
]);
|
]);
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue