forked from MapComplete/MapComplete
Way to much fixes and improvements
This commit is contained in:
parent
e68d9d99a5
commit
5ed0bb431c
41 changed files with 1244 additions and 402 deletions
|
@ -1,27 +1,33 @@
|
|||
import SingleSetting from "./SingleSetting";
|
||||
import {UIElement} from "../UIElement";
|
||||
import {FixedUiElement} from "../Base/FixedUiElement";
|
||||
import {InputElement} from "../Input/InputElement";
|
||||
import {UIEventSource} from "../../Logic/UIEventSource";
|
||||
import PageSplit from "../Base/PageSplit";
|
||||
import Combine from "../Base/Combine";
|
||||
import {VariableUiElement} from "../Base/VariableUIElement";
|
||||
|
||||
export default class SettingsTable extends UIElement {
|
||||
|
||||
private _col1: UIElement[] = [];
|
||||
private _col2: InputElement<any>[] = [];
|
||||
private _col2: UIElement[] = [];
|
||||
|
||||
public selectedSetting: UIEventSource<SingleSetting<any>>;
|
||||
|
||||
constructor(elements: SingleSetting<any>[],
|
||||
constructor(elements: (SingleSetting<any> | string)[],
|
||||
currentSelectedSetting: UIEventSource<SingleSetting<any>>) {
|
||||
super(undefined);
|
||||
const self = this;
|
||||
this.selectedSetting = currentSelectedSetting ?? new UIEventSource<SingleSetting<any>>(undefined);
|
||||
for (const element of elements) {
|
||||
let title: UIElement = new FixedUiElement(element._name);
|
||||
if(typeof element === "string"){
|
||||
this._col1.push(new FixedUiElement(element));
|
||||
this._col2.push(null);
|
||||
continue;
|
||||
}
|
||||
|
||||
let title: UIElement = element._name === undefined ? null : new FixedUiElement(element._name);
|
||||
this._col1.push(title);
|
||||
this._col2.push(element._value);
|
||||
element._value.SetStyle("display:block");
|
||||
element._value.IsSelected.addCallback(isSelected => {
|
||||
if (isSelected) {
|
||||
self.selectedSetting.setData(element);
|
||||
|
@ -34,13 +40,19 @@ export default class SettingsTable extends UIElement {
|
|||
}
|
||||
|
||||
InnerRender(): string {
|
||||
let html = "";
|
||||
let elements = [];
|
||||
|
||||
for (let i = 0; i < this._col1.length; i++) {
|
||||
html += `<tr><td>${this._col1[i].Render()}</td><td>${this._col2[i].Render()}</td></tr>`
|
||||
if(this._col1[i] !== null && this._col2[i] !== null){
|
||||
elements.push(new PageSplit(this._col1[i], this._col2[i], 25));
|
||||
}else if(this._col1[i] !== null){
|
||||
elements.push(this._col1[i])
|
||||
}else{
|
||||
elements.push(this._col2[i])
|
||||
}
|
||||
}
|
||||
|
||||
return `<table><tr>${html}</tr></table>`;
|
||||
return new Combine(elements).Render();
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue