diff --git a/UI/BaseUIElement.ts b/UI/BaseUIElement.ts index ce720f957..a5541aa4d 100644 --- a/UI/BaseUIElement.ts +++ b/UI/BaseUIElement.ts @@ -148,7 +148,7 @@ export default abstract class BaseUIElement { } catch (e) { const domExc = e as DOMException if (domExc) { - console.log("An exception occured", domExc.code, domExc.message, domExc.name) + console.error("An exception occured", domExc.code, domExc.message, domExc.name, domExc) } console.error(e) } diff --git a/UI/Input/Checkboxes.ts b/UI/Input/Checkboxes.ts index 94e689935..1a9253263 100644 --- a/UI/Input/Checkboxes.ts +++ b/UI/Input/Checkboxes.ts @@ -8,7 +8,7 @@ import Translations from "../i18n/Translations"; export class CheckBox extends InputElementMap { constructor(el: (BaseUIElement | string), defaultValue?: boolean) { super( - new CheckBoxes([Translations.T(el)]), + new CheckBoxes([Translations.W(el)]), (x0, x1) => x0 === x1, (t) => t.length > 0, (x) => (x ? [0] : []) diff --git a/UI/LanguagePicker.ts b/UI/LanguagePicker.ts index 40c6531b0..84fb17467 100644 --- a/UI/LanguagePicker.ts +++ b/UI/LanguagePicker.ts @@ -10,16 +10,15 @@ import Toggle from "./Input/Toggle" export default class LanguagePicker extends Toggle { constructor(languages: string[], label: string | BaseUIElement = "") { + console.log("Constructing a language pîcker for languages", languages) if (languages === undefined || languages.length <= 1) { super(undefined, undefined, undefined) - return undefined + }else { + const normalPicker = LanguagePicker.dropdownFor(languages, label) + const fullPicker = new Lazy(() => LanguagePicker.dropdownFor(allLanguages, label)) + super(fullPicker, normalPicker, Locale.showLinkToWeblate) + const allLanguages: string[] = used_languages.languages } - - const allLanguages: string[] = used_languages.languages - - const normalPicker = LanguagePicker.dropdownFor(languages, label) - const fullPicker = new Lazy(() => LanguagePicker.dropdownFor(allLanguages, label)) - super(fullPicker, normalPicker, Locale.showLinkToWeblate) } private static dropdownFor(languages: string[], label: string | BaseUIElement): BaseUIElement { diff --git a/UI/Popup/FeatureInfoBox.ts b/UI/Popup/FeatureInfoBox.ts index bf40fd32d..be00c7cb9 100644 --- a/UI/Popup/FeatureInfoBox.ts +++ b/UI/Popup/FeatureInfoBox.ts @@ -248,31 +248,29 @@ export default class FeatureInfoBox extends ScrollableFullScreen { ) editElements.push( - new VariableUiElement( - state.featureSwitchIsDebugging.map((isDebugging) => { - if (isDebugging) { - const config_all_tags: TagRenderingConfig = new TagRenderingConfig( - { render: "{all_tags()}" }, - "" - ) - const config_download: TagRenderingConfig = new TagRenderingConfig( - { render: "{export_as_geojson()}" }, - "" - ) - const config_id: TagRenderingConfig = new TagRenderingConfig( - { render: "{open_in_iD()}" }, - "" - ) + Toggle.If(state.featureSwitchIsDebugging, + () => { + const config_all_tags: TagRenderingConfig = new TagRenderingConfig( + { render: "{all_tags()}" }, + "" + ) + const config_download: TagRenderingConfig = new TagRenderingConfig( + { render: "{export_as_geojson()}" }, + "" + ) + const config_id: TagRenderingConfig = new TagRenderingConfig( + { render: "{open_in_iD()}" }, + "" + ) - return new Combine([ - new TagRenderingAnswer(tags, config_all_tags, state), - new TagRenderingAnswer(tags, config_download, state), - new TagRenderingAnswer(tags, config_id, state), - "This is layer " + layerConfig.id, - ]) - } - }) - ) + return new Combine([ + new TagRenderingAnswer(tags, config_all_tags, state), + new TagRenderingAnswer(tags, config_download, state), + new TagRenderingAnswer(tags, config_id, state), + "This is layer " + layerConfig.id, + ]) + } + ) ) return new Combine(editElements).SetClass("flex flex-col") diff --git a/UI/i18n/Translations.ts b/UI/i18n/Translations.ts index 6c5d5922d..f3757507e 100644 --- a/UI/i18n/Translations.ts +++ b/UI/i18n/Translations.ts @@ -41,7 +41,7 @@ export default class Translations { * translation.textFor("nl") // => "Nederlands" * */ - static T(t: string | any, context = undefined): TypedTranslation { + static T(t: string | undefined | null | Translation | TypedTranslation, context = undefined): TypedTranslation { if (t === undefined || t === null) { return undefined } @@ -51,7 +51,7 @@ export default class Translations { if (typeof t === "string") { return new TypedTranslation({ "*": t }, context) } - if (t.render !== undefined) { + if (t["render"] !== undefined) { const msg = "Creating a translation, but this object contains a 'render'-field. Use the translation directly" console.error(msg, t)