Fix dissappearing welcome message, add typing and simplify code
This commit is contained in:
parent
491c46dbc6
commit
a87fa4520b
5 changed files with 32 additions and 35 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import Translations from "../i18n/Translations";
|
|||
export class CheckBox extends InputElementMap<number[], boolean> {
|
||||
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] : [])
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -41,7 +41,7 @@ export default class Translations {
|
|||
* translation.textFor("nl") // => "Nederlands"
|
||||
*
|
||||
*/
|
||||
static T(t: string | any, context = undefined): TypedTranslation<object> {
|
||||
static T(t: string | undefined | null | Translation | TypedTranslation<object>, context = undefined): TypedTranslation<object> {
|
||||
if (t === undefined || t === null) {
|
||||
return undefined
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ export default class Translations {
|
|||
if (typeof t === "string") {
|
||||
return new TypedTranslation<object>({ "*": 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)
|
||||
|
|
Loading…
Reference in a new issue