forked from MapComplete/MapComplete
Add presets to custom theme generator, fix simpleAddUI
This commit is contained in:
parent
9a420efa98
commit
3d05999f85
10 changed files with 90 additions and 36 deletions
58
UI/CustomGenerator/PresetInputPanel.ts
Normal file
58
UI/CustomGenerator/PresetInputPanel.ts
Normal file
|
@ -0,0 +1,58 @@
|
|||
import {InputElement} from "../Input/InputElement";
|
||||
import {UIEventSource} from "../../Logic/UIEventSource";
|
||||
import {UIElement} from "../UIElement";
|
||||
import {MultiTagInput} from "../Input/MultiTagInput";
|
||||
import SettingsTable from "./SettingsTable";
|
||||
import SingleSetting from "./SingleSetting";
|
||||
import MultiLingualTextFields from "../Input/MultiLingualTextFields";
|
||||
import Combine from "../Base/Combine";
|
||||
|
||||
export default class PresetInputPanel extends InputElement<{
|
||||
title: string | any,
|
||||
tags: string[],
|
||||
description?: string | any
|
||||
}> {
|
||||
private readonly _value: UIEventSource<{
|
||||
title: string | any,
|
||||
tags: string[],
|
||||
description?: string | any
|
||||
}>;
|
||||
private readonly panel: UIElement;
|
||||
|
||||
|
||||
constructor(currentlySelected: UIEventSource<SingleSetting<any>>, languages: UIEventSource<string[]>) {
|
||||
super();
|
||||
this._value = new UIEventSource({tags: [], title: {}});
|
||||
|
||||
|
||||
const self = this;
|
||||
function s(input: InputElement<any>, path: string, name: string, description: string){
|
||||
return new SingleSetting(self._value, input, path, name, description)
|
||||
}
|
||||
this.panel = new SettingsTable([
|
||||
s(new MultiTagInput(), "tags","Preset tags","These tags will be applied on the newly created point"),
|
||||
s(new MultiLingualTextFields(languages), "title","Preset title","This little text is shown in bold on the 'create new point'-button" ),
|
||||
s(new MultiLingualTextFields(languages), "description","Description", "This text is shown in the button as description when creating a new point")
|
||||
], currentlySelected);
|
||||
}
|
||||
|
||||
|
||||
InnerRender(): string {
|
||||
return new Combine([this.panel]).Render();
|
||||
}
|
||||
|
||||
GetValue(): UIEventSource<{
|
||||
title: string | any,
|
||||
tags: string[],
|
||||
description?: string | any
|
||||
}> {
|
||||
return this._value;
|
||||
}
|
||||
|
||||
IsSelected: UIEventSource<boolean> = new UIEventSource<boolean>(false);
|
||||
|
||||
IsValid(t: any): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue