UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

52 lines (51 loc) 1.51 kB
import ThemeLayer from './layers/themelayer'; import StateSerializer from '../tools/share/stateserializer'; import CustomIcon from '../components/themes/images/custom.svg'; export default class CustomTheme { get hasThemes() { for (const layer of this.layers) { if (layer instanceof ThemeLayer) { return true; } } return false; } constructor(name) { Object.defineProperty(this, "id", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "layers", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "icon", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.id = Date.now(); this.name = name; this.layers = []; this.icon = CustomIcon; } getSerialized() { return new StateSerializer().getSerializedLayerTree(this.layers); } getThemeLayer(id = 1000000) { const theme = new ThemeLayer(id, this.name, 0); theme.children.push(...this.layers); return theme; } }