import {UIElement} from "./UIElement"; import {UIEventSource} from "./UIEventSource"; import {Tag} from "../Logic/TagsFilter"; import {FilteredLayer} from "../Logic/FilteredLayer"; import {Changes} from "../Logic/Changes"; import {FixedUiElement} from "./Base/FixedUiElement"; import {Button} from "./Base/Button"; import {UserDetails} from "../Logic/OsmConnection"; import Translations from "./i18n/Translations"; import Combine from "./Base/Combine"; import {SubtleButton} from "./Base/SubtleButton"; import {VerticalCombine} from "./Base/VerticalCombine"; interface Preset { description: string | UIElement, name: string | UIElement, icon: string, tags: Tag[], layerToAddTo: FilteredLayer } /** * Asks to add a feature at the last clicked location, at least if zoom is sufficient */ export class SimpleAddUI extends UIElement { private _zoomlevel: UIEventSource<{ zoom: number }>; private _addButtons: UIElement[]; private _lastClickLocation: UIEventSource<{ lat: number; lon: number }>; private _changes: Changes; private _selectedElement: UIEventSource<{ feature: any }>; private _dataIsLoading: UIEventSource; private _userDetails: UIEventSource; private _confirmPreset: UIEventSource = new UIEventSource(undefined); private confirmButton: UIElement = undefined; private cancelButton: UIElement; constructor(zoomlevel: UIEventSource<{ zoom: number }>, lastClickLocation: UIEventSource<{ lat: number, lon: number }>, changes: Changes, selectedElement: UIEventSource<{ feature: any }>, dataIsLoading: UIEventSource, userDetails: UIEventSource, addButtons: { description: string | UIElement, name: string | UIElement; icon: string; tags: Tag[]; layerToAddTo: FilteredLayer }[], ) { super(zoomlevel); this._zoomlevel = zoomlevel; this._lastClickLocation = lastClickLocation; this._changes = changes; this._selectedElement = selectedElement; this._dataIsLoading = dataIsLoading; this._userDetails = userDetails; this.ListenTo(userDetails); this.ListenTo(dataIsLoading); this._addButtons = []; this.ListenTo(this._confirmPreset); this.clss = "add-ui" const self = this; for (const option of addButtons) { //