forked from MapComplete/MapComplete
Add overview of all themes if none are defined
This commit is contained in:
parent
7a2b99a566
commit
092c12a449
12 changed files with 94 additions and 53 deletions
|
@ -78,7 +78,6 @@ export default class FullWelcomePaneWithTabs extends UIElement {
|
|||
]).SetClass("only-on-mobile")
|
||||
.onClick(() => State.state.fullScreenMessage.setData(undefined));
|
||||
|
||||
tabbedPart.SetStyle("overflow-y: auto; max-height: calc( 100vh - 4em);display:block;")
|
||||
this._component = new Combine([tabbedPart, backButton]).SetStyle("width:100%;");
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,17 @@ import {SubtleButton} from "../Base/SubtleButton";
|
|||
import Translations from "../i18n/Translations";
|
||||
import * as personal from "../../assets/themes/personalLayout/personalLayout.json"
|
||||
import Constants from "../../Models/Constants";
|
||||
import LanguagePicker from "../LanguagePicker";
|
||||
|
||||
export default class MoreScreen extends UIElement {
|
||||
private readonly _onMainScreen: boolean;
|
||||
|
||||
private _component: UIElement;
|
||||
|
||||
|
||||
constructor() {
|
||||
constructor(onMainScreen: boolean = false) {
|
||||
super(State.state.locationControl);
|
||||
this._onMainScreen = onMainScreen;
|
||||
this.ListenTo(State.state.osmConnection.userDetails);
|
||||
this.ListenTo(State.state.installedThemes);
|
||||
}
|
||||
|
@ -35,7 +40,7 @@ export default class MoreScreen extends UIElement {
|
|||
return undefined;
|
||||
}
|
||||
}
|
||||
if (layout.id === State.state.layoutToUse.data.id) {
|
||||
if (layout.id === State.state.layoutToUse.data?.id) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -115,12 +120,23 @@ export default class MoreScreen extends UIElement {
|
|||
}
|
||||
}
|
||||
|
||||
let intro : UIElement= tr.intro;
|
||||
if(this._onMainScreen){
|
||||
intro = new Combine([
|
||||
|
||||
LanguagePicker.CreateLanguagePicker(Translations.t.general.index.SupportedLanguages())
|
||||
.SetStyle("position: absolute; right: 1.5em; top: 1.5em;"),
|
||||
Translations.t.general.index.SetStyle("margin-top: 2em;display:block; margin-bottom: 1em;")
|
||||
])
|
||||
}
|
||||
|
||||
|
||||
return new VerticalCombine([
|
||||
tr.intro,
|
||||
this._component = new VerticalCombine([
|
||||
intro,
|
||||
new VerticalCombine(els),
|
||||
tr.streetcomplete
|
||||
]).Render();
|
||||
]);
|
||||
return this._component.Render();
|
||||
}
|
||||
|
||||
}
|
|
@ -42,7 +42,7 @@ export default class SharePanel extends UIElement {
|
|||
"Copy the json configuration from the 'save-tab', paste it between the 'nowiki'-tags in the Wiki",
|
||||
"Click 'save' to save the wiki page",
|
||||
"Share the link with the url parameter <span class='literal-code'>userlayout=wiki:YOURWIKIPAGE</span>, e.g. " +
|
||||
`<a href='./index.html?userlayout=${proposedNameEnc}' target='_blank'>https://${window.location.host}?userlayout=${proposedNameEnc}</a>`
|
||||
`<a href='./custom?userlayout=${proposedNameEnc}' target='_blank'>https://${window.location.host}?userlayout=${proposedNameEnc}</a>`
|
||||
].map(li => `<li>${li}</li>`),
|
||||
|
||||
"</ol>",
|
||||
|
|
|
@ -11,7 +11,7 @@ export class Translation extends UIElement {
|
|||
|
||||
constructor(translations: object, context?: string) {
|
||||
super(Locale.language)
|
||||
if(translations === undefined){
|
||||
if (translations === undefined) {
|
||||
throw `Translation without content (${context})`
|
||||
}
|
||||
let count = 0;
|
||||
|
@ -19,11 +19,40 @@ export class Translation extends UIElement {
|
|||
count++;
|
||||
}
|
||||
this.translations = translations;
|
||||
if(count === 0){
|
||||
if (count === 0) {
|
||||
throw `No translations given in the object (${context})`
|
||||
}
|
||||
}
|
||||
|
||||
get txt(): string {
|
||||
if (this.translations["*"]) {
|
||||
return this.translations["*"];
|
||||
}
|
||||
const txt = this.translations[Translation.forcedLanguage ?? Locale.language.data];
|
||||
if (txt !== undefined) {
|
||||
return txt;
|
||||
}
|
||||
const en = this.translations["en"];
|
||||
if (en !== undefined) {
|
||||
return en;
|
||||
}
|
||||
for (const i in this.translations) {
|
||||
return this.translations[i]; // Return a random language
|
||||
}
|
||||
console.error("Missing language ", Locale.language.data, "for", this.translations)
|
||||
return "";
|
||||
}
|
||||
|
||||
public SupportedLanguages(): string[] {
|
||||
const langs = []
|
||||
for (const translationsKey in this.translations) {
|
||||
if(translationsKey === "#"){
|
||||
continue;
|
||||
}
|
||||
langs.push(translationsKey)
|
||||
}
|
||||
return langs;
|
||||
}
|
||||
|
||||
public Subs(text: any): Translation {
|
||||
const newTranslations = {};
|
||||
|
@ -57,27 +86,6 @@ export class Translation extends UIElement {
|
|||
|
||||
}
|
||||
|
||||
|
||||
get txt(): string {
|
||||
if (this.translations["*"]) {
|
||||
return this.translations["*"];
|
||||
}
|
||||
const txt = this.translations[Translation.forcedLanguage ?? Locale.language.data];
|
||||
if (txt !== undefined) {
|
||||
return txt;
|
||||
}
|
||||
const en = this.translations["en"];
|
||||
if (en !== undefined) {
|
||||
return en;
|
||||
}
|
||||
for (const i in this.translations) {
|
||||
return this.translations[i]; // Return a random language
|
||||
}
|
||||
console.error("Missing language ", Locale.language.data, "for", this.translations)
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
InnerRender(): string {
|
||||
return this.txt
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue