import {UIElement} from "../UIElement"; import {UIEventSource} from "../../Logic/UIEventSource"; import {LayoutConfigJson} from "../../Customizations/JSON/LayoutConfigJson"; import SettingsTable from "./SettingsTable"; import SingleSetting from "./SingleSetting"; import {SubtleButton} from "../Base/SubtleButton"; import Combine from "../Base/Combine"; import {TextField} from "../Input/TextField"; import {InputElement} from "../Input/InputElement"; import MultiLingualTextFields from "../Input/MultiLingualTextFields"; import {CheckBox} from "../Input/CheckBox"; import {MultiTagInput} from "../Input/MultiTagInput"; /** * Shows the configuration for a single layer */ export default class LayerPanel extends UIElement { private _config: UIEventSource; private settingsTable: UIElement; private deleteButton: UIElement; constructor(config: UIEventSource, languages: UIEventSource, index: number, currentlySelected: UIEventSource>) { super(undefined); this._config = config; const actualDeleteButton = new SubtleButton( "./assets/delete.svg", "Yes, delete this layer" ).onClick(() => { config.data.layers.splice(index, 1); config.ping(); }); this.deleteButton = new CheckBox( new Combine( [ "

Confirm layer deletion

", new SubtleButton( "./assets/close.svg", "No, don't delete" ), "Deleting a layer can not be undone!", actualDeleteButton ] ), new SubtleButton( "./assets/delete.svg", "Remove this layer" ) ) function setting(input: InputElement, path: string | string[], name: string, description: string | UIElement): SingleSetting { let pathPre = ["layers", index]; if (typeof (path) === "string") { pathPre.push(path); } else { pathPre = pathPre.concat(path); } return new SingleSetting(config, input, pathPre, name, description); } this.settingsTable = new SettingsTable([ setting(TextField.StringInput(), "id", "Id", "An identifier for this layer
This should be a simple, lowercase, human readable string that is used to identify the layer."), setting(new MultiLingualTextFields(languages), "title", "Title", "The human-readable name of this layer
Used in the layer control panel and the 'Personal theme'"), setting(new MultiLingualTextFields(languages, true), "description", "Description", "A description for this layer.
Shown in the layer selections and in the personal theme"), setting(new MultiTagInput(), "overpassTags","Overpass query", new Combine(["The tags to load from overpass. ", MultiTagInput.tagExplanation])) ], currentlySelected ) ; } InnerRender(): string { return new Combine([ this.settingsTable, this.deleteButton ]).Render(); } }