forked from MapComplete/MapComplete
Refactoring: Translation is no longer a BaseUIElement
This commit is contained in:
parent
5ea2414204
commit
020a1f8c3b
3 changed files with 7 additions and 18 deletions
|
@ -318,9 +318,9 @@ export default class PointRenderingConfig extends WithContextLoader {
|
||||||
const cssClassesLabel = this.labelCssClasses?.GetRenderValue(tags.data)?.txt
|
const cssClassesLabel = this.labelCssClasses?.GetRenderValue(tags.data)?.txt
|
||||||
return new VariableUiElement(
|
return new VariableUiElement(
|
||||||
tags.map((tags) => {
|
tags.map((tags) => {
|
||||||
const label = this.label
|
const label = new VariableUiElement(this.label
|
||||||
?.GetRenderValue(tags)
|
?.GetRenderValue(tags)
|
||||||
?.Subs(tags)
|
?.Subs(tags).current)
|
||||||
?.SetClass("flex items-center justify-center absolute marker-label")
|
?.SetClass("flex items-center justify-center absolute marker-label")
|
||||||
?.SetClass(cssClassesLabel)
|
?.SetClass(cssClassesLabel)
|
||||||
if (cssLabel) {
|
if (cssLabel) {
|
||||||
|
|
|
@ -18,11 +18,10 @@ import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
||||||
import NearbyFeatureSource from "../../Logic/FeatureSource/Sources/NearbyFeatureSource"
|
import NearbyFeatureSource from "../../Logic/FeatureSource/Sources/NearbyFeatureSource"
|
||||||
import {
|
import {
|
||||||
SummaryTileSource,
|
SummaryTileSource,
|
||||||
SummaryTileSourceRewriter,
|
SummaryTileSourceRewriter
|
||||||
} from "../../Logic/FeatureSource/TiledFeatureSource/SummaryTileSource"
|
} from "../../Logic/FeatureSource/TiledFeatureSource/SummaryTileSource"
|
||||||
import { ShowDataLayerOptions } from "../../UI/Map/ShowDataLayerOptions"
|
import { ShowDataLayerOptions } from "../../UI/Map/ShowDataLayerOptions"
|
||||||
import { ClusterGrouping } from "../../Logic/FeatureSource/TiledFeatureSource/ClusteringFeatureSource"
|
import { ClusterGrouping } from "../../Logic/FeatureSource/TiledFeatureSource/ClusteringFeatureSource"
|
||||||
import { OsmTags } from "../OsmFeature"
|
|
||||||
|
|
||||||
export class WithSpecialLayers extends WithChangesState {
|
export class WithSpecialLayers extends WithChangesState {
|
||||||
readonly favourites: FavouritesFeatureSource
|
readonly favourites: FavouritesFeatureSource
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import Locale from "./Locale"
|
import Locale from "./Locale"
|
||||||
import { Utils } from "../../Utils"
|
import { Utils } from "../../Utils"
|
||||||
import BaseUIElement from "../BaseUIElement"
|
|
||||||
import { Store } from "../../Logic/UIEventSource"
|
import { Store } from "../../Logic/UIEventSource"
|
||||||
import { VariableUiElement } from "../Base/VariableUIElement"
|
|
||||||
|
|
||||||
export class Translation extends BaseUIElement {
|
export class Translation {
|
||||||
public static forcedLanguage = undefined
|
public static forcedLanguage = undefined
|
||||||
|
|
||||||
public readonly translations: Record<string, string>
|
public readonly translations: Record<string, string>
|
||||||
|
@ -27,8 +25,6 @@ export class Translation extends BaseUIElement {
|
||||||
context?: string,
|
context?: string,
|
||||||
strictLanguages?: boolean
|
strictLanguages?: boolean
|
||||||
) {
|
) {
|
||||||
super()
|
|
||||||
|
|
||||||
this._strictLanguages = strictLanguages
|
this._strictLanguages = strictLanguages
|
||||||
|
|
||||||
if (translations === undefined) {
|
if (translations === undefined) {
|
||||||
|
@ -217,9 +213,9 @@ export class Translation extends BaseUIElement {
|
||||||
return this.OnEveryLanguage((str) => str.replace(new RegExp(a, "g"), b))
|
return this.OnEveryLanguage((str) => str.replace(new RegExp(a, "g"), b))
|
||||||
}
|
}
|
||||||
|
|
||||||
InnerConstructElement() {
|
/*InnerConstructElement() {
|
||||||
return new VariableUiElement(this.current).InnerConstructElement()
|
return new VariableUiElement(this.current).SetClass("border border-red-500").InnerConstructElement()
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build a new translation which only contains the first sentence of every language
|
* Build a new translation which only contains the first sentence of every language
|
||||||
|
@ -269,9 +265,6 @@ export class Translation extends BaseUIElement {
|
||||||
public ExtractImages(isIcon = false): string[] {
|
public ExtractImages(isIcon = false): string[] {
|
||||||
const allIcons: string[] = []
|
const allIcons: string[] = []
|
||||||
for (const key in this.translations) {
|
for (const key in this.translations) {
|
||||||
if (!this.translations.hasOwnProperty(key)) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
const render = this.translations[key]
|
const render = this.translations[key]
|
||||||
|
|
||||||
if (isIcon) {
|
if (isIcon) {
|
||||||
|
@ -310,9 +303,6 @@ export class Translation extends BaseUIElement {
|
||||||
return allIcons.filter((icon) => icon != undefined)
|
return allIcons.filter((icon) => icon != undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
AsMarkdown(): string {
|
|
||||||
return this.txt
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TypedTranslation<T extends Record<string, any>> extends Translation {
|
export class TypedTranslation<T extends Record<string, any>> extends Translation {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue