mapcomplete/UI/LayerSelection.ts

35 lines
927 B
TypeScript
Raw Normal View History

2020-07-22 11:49:01 +02:00
import { UIElement } from "./UIElement";
import { FilteredLayer } from "../Logic/FilteredLayer";
import { CheckBox } from "./Base/CheckBox";
2020-07-22 11:56:40 +02:00
import Combine from "./Base/Combine";
2020-07-22 11:49:01 +02:00
export class LayerSelection extends UIElement{
private readonly _checkboxes: UIElement[];
constructor(layers: FilteredLayer[]) {
super(undefined);
this._checkboxes = [];
for (const layer of layers) {
2020-07-22 11:56:40 +02:00
this._checkboxes.push(new CheckBox(
2020-07-22 12:05:29 +02:00
new Combine([layer.layerDef.name, `<img src="${layer.layerDef.icon}" alt="layer.layerDef.icon">`]),
layer.layerDef.name,
layer.isDisplayed));
2020-07-22 11:49:01 +02:00
}
}
InnerRender(): string {
let html = ``;
for (const checkBox of this._checkboxes) {
const checkBoxHTML = checkBox.Render();
const checkBoxListItem = `<li>${checkBoxHTML}</li>`;
html = html + checkBoxListItem;
}
return `<ul>${html}</ul>`;
}
}