Refactoring: port 'MultiApply' to svelte, remove SubtleButton.ts as no longer needed

This commit is contained in:
Pieter Vander Vennet 2025-06-19 02:20:23 +02:00
parent d1f7ae2462
commit b398f0d8bb
4 changed files with 50 additions and 97 deletions

View file

@ -1,14 +1,7 @@
import { Store } from "../../Logic/UIEventSource"
import BaseUIElement from "../BaseUIElement"
import Combine from "../Base/Combine"
import { SubtleButton } from "../Base/SubtleButton"
import { FixedUiElement } from "../Base/FixedUiElement"
import Translations from "../i18n/Translations"
import { VariableUiElement } from "../Base/VariableUIElement"
import ChangeTagAction from "../../Logic/Osm/Actions/ChangeTagAction"
import { Tag } from "../../Logic/Tags/Tag"
import { And } from "../../Logic/Tags/And"
import Toggle from "../Input/Toggle"
import { SpecialVisualizationState } from "../SpecialVisualization"
export interface MultiApplyParams {
@ -21,7 +14,7 @@ export interface MultiApplyParams {
state: SpecialVisualizationState
}
class MultiApplyExecutor {
export class MultiApplyExecutor {
private static executorCache = new Map<string, MultiApplyExecutor>()
private readonly originalValues = new Map<string, string>()
private readonly params: MultiApplyParams
@ -105,46 +98,3 @@ class MultiApplyExecutor {
}
}
export default class MultiApply extends Toggle {
constructor(params: MultiApplyParams) {
const p = params
const t = Translations.t.multi_apply
const featureId = p.tagsSource.data.id
if (featureId === undefined) {
throw "MultiApply needs a feature id"
}
const applicator = MultiApplyExecutor.GetApplicator(featureId, params)
const elems: (string | BaseUIElement)[] = []
if (p.autoapply) {
elems.push(new FixedUiElement(p.text).SetClass("block"))
elems.push(
new VariableUiElement(
p.featureIds.map((featureIds) =>
t.autoApply.Subs({
attr_names: p.keysToApply.join(", "),
count: "" + featureIds.length,
})
)
).SetClass("block subtle text-sm")
)
} else {
elems.push(
new SubtleButton(undefined, p.text).onClick(() =>
applicator.applyTaggingOnOtherFeatures()
)
)
}
const isShown: Store<boolean> = p.state.osmConnection.isLoggedIn.map(
(loggedIn) => {
return loggedIn && p.featureIds.data.length > 0
},
[p.featureIds]
)
super(new Combine(elems), undefined, isShown)
}
}