@eox/layercontrol 1.10.0 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eox/layercontrol",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -334,19 +334,25 @@ export class EOxLayerControlLayerConfig extends LitElement {
334
334
  render() {
335
335
  // Fetch initial values for the layer and its configuration
336
336
  const freshStartVals = getStartVals(this.layer, this.layerConfig) || {};
337
- this.#startVals = { ...freshStartVals, ...this.#data };
337
+ const startVals = { ...freshStartVals, ...this.#data };
338
338
  const schemaProps = this.layerConfig?.schema?.properties;
339
339
  const isAutofill =
340
340
  this.layerConfig?.autofill === true ||
341
341
  this.layerConfig?.schema?.autofill === true;
342
342
  if (schemaProps && !isAutofill) {
343
343
  const allowedKeys = new Set(Object.keys(schemaProps));
344
- for (const k of Object.keys(this.#startVals)) {
344
+ for (const k of Object.keys(startVals)) {
345
345
  if (!allowedKeys.has(k)) {
346
- delete this.#startVals[k];
346
+ delete startVals[k];
347
347
  }
348
348
  }
349
349
  }
350
+ // without start values, null lets eox-jsonform build the form from the schema defaults
351
+ const nextStartVals = Object.keys(startVals).length ? startVals : null;
352
+ // a new object on every render makes eox-jsonform reset the form to it
353
+ if (JSON.stringify(nextStartVals) !== JSON.stringify(this.#startVals)) {
354
+ this.#startVals = nextStartVals;
355
+ }
350
356
  this.#data = { ...this.#startVals };
351
357
  if (!customElements.get("eox-jsonform")) {
352
358
  console.error("Please import @eox/jsonform in order to use layerconfig");
@@ -1,5 +1,7 @@
1
1
  import { LitElement, html } from "lit";
2
2
  import { when } from "lit/directives/when.js";
3
+ import _debounce from "lodash.debounce";
4
+ import { updateLayerSlice } from "../helpers/handle-datetime-update";
3
5
 
4
6
  /**
5
7
  * `EOxLayerControlLayerDatetime` is a component that handles date time options for layers using eox-timecontrol.
@@ -67,6 +69,14 @@ export class EOxLayerControlLayerDatetime extends LitElement {
67
69
  return this.noShadow ? this : super.createRenderRoot();
68
70
  }
69
71
 
72
+ disconnectedCallback() {
73
+ // runs a pending slice update before removal
74
+ this.#updateSlice.flush();
75
+ super.disconnectedCallback();
76
+ }
77
+
78
+ #updateSlice = _debounce(updateLayerSlice, 300);
79
+
70
80
  /**
71
81
  * Handles timecontrol Stepchange &
72
82
  * triggers `datetime:updated` event on step change
@@ -103,6 +113,8 @@ export class EOxLayerControlLayerDatetime extends LitElement {
103
113
  }),
104
114
  );
105
115
 
116
+ this.#updateSlice(this.layer, currentStep);
117
+
106
118
  this.layerDatetime.currentStep = currentStep;
107
119
  this.requestUpdate();
108
120
  }
@@ -122,7 +134,7 @@ export class EOxLayerControlLayerDatetime extends LitElement {
122
134
  ${!this.unstyled && this.#styleEOX}
123
135
  </style>
124
136
  ${when(
125
- this.layerDatetime,
137
+ this.layerDatetime?.controlValues,
126
138
  () => html`
127
139
  <eox-timecontrol
128
140
  .initDate=${this.layerDatetime.currentStep
@@ -1,20 +1,22 @@
1
+ /**
2
+ * Moves a sliced layer (e.g. GeoZarr) to the time slice mapped to the given datetime
3
+ * @param {import("ol/layer").Layer} layer
4
+ * @param {string} datetime
5
+ */
6
+ export function updateLayerSlice(layer, datetime) {
7
+ const sliceMap = layer.get("layerDatetime")?.sliceMap;
8
+ if (!sliceMap || !(datetime in sliceMap)) return;
9
+ const source = /** @type {any} */ (layer.getSource?.());
10
+ if (typeof source?.updateDimensions !== "function") return;
11
+ source.updateDimensions({ time: sliceMap[datetime] });
12
+ }
13
+
1
14
  /**
2
15
  * Dispatches datetime updates from layer datetime to the layercontrol
3
16
  * @param {CustomEvent} evt
4
17
  * @param {HTMLElement} element
5
18
  */
6
19
  export function handleDatetimeUpdate(evt, element) {
7
- const { datetime, layer } = evt.detail || {};
8
- if (layer && datetime) {
9
- const sliceMap = layer.get("layerDatetime")?.sliceMap;
10
- if (sliceMap && datetime in sliceMap) {
11
- const sliceIndex = sliceMap[datetime];
12
- const source = layer.getSource ? layer.getSource() : null;
13
- if (source && typeof source.updateDimensions === "function") {
14
- source.updateDimensions({ time: sliceIndex });
15
- }
16
- }
17
- }
18
20
  element.dispatchEvent(
19
21
  new CustomEvent("datetime:updated", { detail: evt.detail, bubbles: true }),
20
22
  );
@@ -28,7 +28,7 @@ export const _parseTools = (tools, layer) =>
28
28
  if (["remove", "sort"].includes(t)) pass = false;
29
29
  if (t === "info") pass = layer.get("description");
30
30
  if (t === "config") pass = layer.get("layerConfig");
31
- if (t === "datetime") pass = layer.get("layerDatetime");
31
+ if (t === "datetime") pass = layer.get("layerDatetime")?.controlValues;
32
32
  if (t === "legend") pass = layer.get("layerLegend");
33
33
  return pass;
34
34
  });
@@ -1 +1 @@
1
- {"version":3,"file":"layer-config.d.ts","sourceRoot":"","sources":["../../src/components/layer-config.js"],"names":[],"mappings":"AAMA;;;;;;IAMI;AAEJ;;;;;;;GAOG;AACH;IAEE;;;;;;;;;;;;;;;;;;;;;MAOE;IA0BA;;;;;OAKG;IACH,OAHU,OAAO,UAAU,EAAE,KAAK,CAGjB;IAEjB;;;;OAIG;IACH,kBAAqB;IAErB;;;;OAIG;IACH,kBAAqB;IAErB;;;;;;;;;;;OAWG;IACH,aATU;QACN,MAAM,EAAE,MAAM,CAAC,MAAM,EAAC,GAAG,CAAC,CAAC;QAC3B,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;QAC3B,KAAK,CAAC,EAAE,OAAO,oBAAoB,EAAE,KAAK,CAAC;QAC3C,MAAM,CAAC,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,CAAC;QACpD,CAAI,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KAClB,CAEkB;IAEvB;;OAEG;IACH,8DAiHS;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAAE,oBAjHwB;IAEj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,MAAM,EAAE,CAAC,CAEL;IA0N9B;;OAEG;IACH,+CAqEC;;CA8BF;gCAzaY,OAAO,CAAC,OAAO,gBAAgB,EAAE,YAAY,CAAC,GAAG;IACvD,OAAO,CAAC,EAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAA,KAAK,EAAE,MAAM,GAAC,MAAM,GAAC,OAAO,CAAA;KAAC,CAAA;IACnD,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAA;CACtB;2BAX+B,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"layer-datetime.d.ts","sourceRoot":"","sources":["../../src/components/layer-datetime.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH;IAEE;;;;;;;;;;;;;MAKE;IAKA;;;;OAIG;IACH,kBAAqB;IAErB;;;;OAIG;IACH,kBAAqB;IAErB;;;;;;;;;;;;;OAaG;IACH,eAXU;QACL,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,WAAW,EAAE,MAAM,GAAC,MAAM,CAAC;QAC3B,aAAa,EAAE,CAAC,MAAM,GAAC,MAAM,CAAC,EAAE,CAAC;QACjC,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,sBAAsB,CAAC,EAAE,MAAM,CAAC;KACjC,CAEqB;IAEzB;;;;;OAKG;IACH,OAHU,OAAO,UAAU,EAAE,KAAK,CAGjB;IAkDnB;;OAEG;IACH,+CA0CC;;CAIF;2BA9JgC,KAAK"}
1
+ {"version":3,"file":"layer-datetime.d.ts","sourceRoot":"","sources":["../../src/components/layer-datetime.js"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH;IAEE;;;;;;;;;;;;;MAKE;IAKA;;;;OAIG;IACH,kBAAqB;IAErB;;;;OAIG;IACH,kBAAqB;IAErB;;;;;;;;;;;;;OAaG;IACH,eAXU;QACL,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,WAAW,EAAE,MAAM,GAAC,MAAM,CAAC;QAC3B,aAAa,EAAE,CAAC,MAAM,GAAC,MAAM,CAAC,EAAE,CAAC;QACjC,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,sBAAsB,CAAC,EAAE,MAAM,CAAC;KACjC,CAEqB;IAEzB;;;;;OAKG;IACH,OAHU,OAAO,UAAU,EAAE,KAAK,CAGjB;IA4DnB;;OAEG;IACH,+CA0CC;;CAIF;2BA1KgC,KAAK"}
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Moves a sliced layer (e.g. GeoZarr) to the time slice mapped to the given datetime
3
+ * @param {import("ol/layer").Layer} layer
4
+ * @param {string} datetime
5
+ */
6
+ export function updateLayerSlice(layer: import("ol/layer").Layer, datetime: string): void;
1
7
  /**
2
8
  * Dispatches datetime updates from layer datetime to the layercontrol
3
9
  * @param {CustomEvent} evt
@@ -1 +1 @@
1
- {"version":3,"file":"handle-datetime-update.d.ts","sourceRoot":"","sources":["../../src/helpers/handle-datetime-update.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,0CAHW,WAAW,WACX,WAAW,QAiBrB"}
1
+ {"version":3,"file":"handle-datetime-update.d.ts","sourceRoot":"","sources":["../../src/helpers/handle-datetime-update.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wCAHW,OAAO,UAAU,EAAE,KAAK,YACxB,MAAM,QAQhB;AAED;;;;GAIG;AACH,0CAHW,WAAW,WACX,WAAW,QAMrB"}