import {UIElement} from "./UIElement"; import {UIEventSource} from "./UIEventSource"; import {Tag} from "../Logic/TagsFilter"; import {FilteredLayer} from "../Logic/FilteredLayer"; import {FixedUiElement} from "./Base/FixedUiElement"; import {Button} from "./Base/Button"; import Translations from "./i18n/Translations"; import Combine from "./Base/Combine"; import {SubtleButton} from "./Base/SubtleButton"; import {VerticalCombine} from "./Base/VerticalCombine"; import Locale from "./i18n/Locale"; import {Changes} from "../Logic/Osm/Changes"; import {UserDetails} from "../Logic/Osm/OsmConnection"; import {State} from "../State"; /** * Asks to add a feature at the last clicked location, at least if zoom is sufficient */ export class SimpleAddUI extends UIElement { private _addButtons: UIElement[]; private _loginButton : UIElement; private _confirmPreset: UIEventSource<{ description: string | UIElement, name: string | UIElement, icon: string, tags: Tag[], layerToAddTo: FilteredLayer }> = new UIEventSource(undefined); private confirmButton: UIElement = undefined; private cancelButton: UIElement; private goToInboxButton: UIElement = new SubtleButton("./assets/envelope.svg", Translations.t.general.goToInbox, {url:"https://www.openstreetmap.org/messages/inbox", newTab: false}); constructor() { super(State.state.locationControl); this.ListenTo(Locale.language); this.ListenTo(State.state.osmConnection.userDetails); this.ListenTo(State.state.layerUpdater.runningQuery); this.ListenTo(this._confirmPreset); this._loginButton = Translations.t.general.add.pleaseLogin.Clone().onClick(() => State.state.osmConnection.AttemptLogin()); this._addButtons = []; this.clss = "add-ui" const self = this; for (const layer of State.state.filteredLayers.data) { for (const preset of layer.layerDef.presets) { //