UNPKG

hslayers-ng

Version:
80 lines (76 loc) 6.9 kB
import * as i0 from '@angular/core'; import { input, inject, computed, ChangeDetectionStrategy, Component } from '@angular/core'; import { transform } from 'ol/proj'; import { HsClipboardTextComponent } from 'hslayers-ng/common/clipboard-text'; import { HsMapService } from 'hslayers-ng/services/map'; class HsUiExtensionsRecursiveDdComponent { constructor() { this.value = input(...(ngDevMode ? [undefined, { debugName: "value" }] : [])); this.excludeKeys = input([], ...(ngDevMode ? [{ debugName: "excludeKeys" }] : [])); this.firstLevel = input(false, ...(ngDevMode ? [{ debugName: "firstLevel" }] : [])); this.hsMapService = inject(HsMapService); this.isIterable = computed(() => { return this.value() && typeof this.value() === 'object'; }, ...(ngDevMode ? [{ debugName: "isIterable" }] : [])); this.entries = computed(() => { if (!this.isIterable()) { return []; } if (this.firstLevel()) { // If this is the first level, filter out excluded keys return Object.entries(this.value()).filter(([key]) => !this.excludeKeys().includes(key)); } return Object.entries(this.value()); }, ...(ngDevMode ? [{ debugName: "entries" }] : [])); } /** * * * FIXME: duplicity with HsAddDataCatalogueMapService * however it would be necessary to move many services to shared in case this is imported from * components/add-data * * ZoomTo / MoveTo to selected layer overview * @param bbox - Bounding box of selected layer */ zoomTo(bboxValue) { // Type guard to ensure we have a valid bbox if (!bboxValue) { return; } const bbox = bboxValue; let b = null; if (typeof bbox === 'string') { b = bbox.split(' '); } else if (Array.isArray(bbox)) { b = bbox; } else { // Not a valid bbox format return; } let firstPair = [parseFloat(b[0]), parseFloat(b[1])]; let secondPair = [parseFloat(b[2]), parseFloat(b[3])]; const map = this.hsMapService.getMap(); const projection = map.getView().getProjection(); firstPair = transform(firstPair, 'EPSG:4326', projection); secondPair = transform(secondPair, 'EPSG:4326', projection); if (firstPair.some(isNaN) || secondPair.some(isNaN)) { return; } const extent = [firstPair[0], firstPair[1], secondPair[0], secondPair[1]]; this.hsMapService.fitExtent(extent); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.3", ngImport: i0, type: HsUiExtensionsRecursiveDdComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.3", type: HsUiExtensionsRecursiveDdComponent, isStandalone: true, selector: "hs-widgets-recursive-dd", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, excludeKeys: { classPropertyName: "excludeKeys", publicName: "excludeKeys", isSignal: true, isRequired: false, transformFunction: null }, firstLevel: { classPropertyName: "firstLevel", publicName: "firstLevel", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if (!isIterable()) {\n <dd class=\"ms-2 text-break\">\n <hs-clipboard-text [text]=\"value()\" />\n </dd>\n}\n@for (item of entries(); track item) {\n <dl class=\"border-start ps-3 ms-2 mb-3\">\n <dt class=\"fw-bold text-primary\">{{ item[0] }}</dt>\n <hs-widgets-recursive-dd [value]=\"item[1]\"></hs-widgets-recursive-dd>\n @if (item[0] === \"bbox\") {\n <div class=\"mt-1 mb-2 d-flex justify-content-end\">\n <button\n (click)=\"zoomTo(item[1])\"\n class=\"btn btn-sm btn-outline-primary\"\n i18n\n >\n <i class=\"fa-solid fa-magnifying-glass-location me-1\"></i>Zoom to\n </button>\n </div>\n }\n </dl>\n}\n", styles: [":host dl{position:relative;transition:all .2s}:host dl:hover{background-color:#00000008}:host dl .border-start{border-left-width:2px!important;border-left-color:#dee2e6!important}:host dt{margin-top:.3rem;font-size:1rem}:host dd{color:#6c757d;margin-bottom:.5rem}:host ::ng-deep hs-widgets-recursive-dd hs-widgets-recursive-dd dl{border-left-color:rgba(var(--bs-primary-rgb),.2)!important}:host ::ng-deep hs-widgets-recursive-dd hs-widgets-recursive-dd hs-widgets-recursive-dd hs-widgets-recursive-dd dl{border-left-color:rgba(var(--bs-primary-rgb),.4)!important}\n"], dependencies: [{ kind: "component", type: HsUiExtensionsRecursiveDdComponent, selector: "hs-widgets-recursive-dd", inputs: ["value", "excludeKeys", "firstLevel"] }, { kind: "component", type: HsClipboardTextComponent, selector: "hs-clipboard-text", inputs: ["text", "anchor"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.3", ngImport: i0, type: HsUiExtensionsRecursiveDdComponent, decorators: [{ type: Component, args: [{ selector: 'hs-widgets-recursive-dd', imports: [HsClipboardTextComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (!isIterable()) {\n <dd class=\"ms-2 text-break\">\n <hs-clipboard-text [text]=\"value()\" />\n </dd>\n}\n@for (item of entries(); track item) {\n <dl class=\"border-start ps-3 ms-2 mb-3\">\n <dt class=\"fw-bold text-primary\">{{ item[0] }}</dt>\n <hs-widgets-recursive-dd [value]=\"item[1]\"></hs-widgets-recursive-dd>\n @if (item[0] === \"bbox\") {\n <div class=\"mt-1 mb-2 d-flex justify-content-end\">\n <button\n (click)=\"zoomTo(item[1])\"\n class=\"btn btn-sm btn-outline-primary\"\n i18n\n >\n <i class=\"fa-solid fa-magnifying-glass-location me-1\"></i>Zoom to\n </button>\n </div>\n }\n </dl>\n}\n", styles: [":host dl{position:relative;transition:all .2s}:host dl:hover{background-color:#00000008}:host dl .border-start{border-left-width:2px!important;border-left-color:#dee2e6!important}:host dt{margin-top:.3rem;font-size:1rem}:host dd{color:#6c757d;margin-bottom:.5rem}:host ::ng-deep hs-widgets-recursive-dd hs-widgets-recursive-dd dl{border-left-color:rgba(var(--bs-primary-rgb),.2)!important}:host ::ng-deep hs-widgets-recursive-dd hs-widgets-recursive-dd hs-widgets-recursive-dd hs-widgets-recursive-dd dl{border-left-color:rgba(var(--bs-primary-rgb),.4)!important}\n"] }] }] }); /** * Generated bundle index. Do not edit. */ export { HsUiExtensionsRecursiveDdComponent }; //# sourceMappingURL=hslayers-ng-common-widgets.mjs.map