@disy/cadenza.js 10.2.0 → 10.2.2

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/apidoc/assets/navigation.js +1 -1
  3. package/apidoc/assets/search.js +1 -1
  4. package/apidoc/classes/AbortError.html +3 -3
  5. package/apidoc/classes/CadenzaClient.html +33 -25
  6. package/apidoc/classes/CadenzaError.html +5 -5
  7. package/apidoc/functions/cadenza.html +3 -3
  8. package/apidoc/index.html +7 -4
  9. package/apidoc/interfaces/CadenzaClientOptions.html +5 -5
  10. package/apidoc/interfaces/CadenzaEvent.html +4 -4
  11. package/apidoc/interfaces/Distance.html +2 -2
  12. package/apidoc/interfaces/ExternalLinkKey.html +4 -4
  13. package/apidoc/interfaces/Feature.html +7 -7
  14. package/apidoc/interfaces/FeatureCollection.html +3 -3
  15. package/apidoc/interfaces/Geometry.html +3 -3
  16. package/apidoc/interfaces/GeometryZoomTarget.html +3 -3
  17. package/apidoc/interfaces/PageSource.html +3 -3
  18. package/apidoc/modules.html +4 -2
  19. package/apidoc/types/CadenzaActionEvent.html +2 -2
  20. package/apidoc/types/CadenzaChangeSelectionEvent.html +2 -2
  21. package/apidoc/types/CadenzaDrillThroughEvent.html +2 -2
  22. package/apidoc/types/CadenzaEditGeometryCancelEvent.html +2 -2
  23. package/apidoc/types/CadenzaEditGeometryOkEvent.html +2 -2
  24. package/apidoc/types/CadenzaEditGeometryUpdateEvent.html +2 -2
  25. package/apidoc/types/CadenzaErrorEvent.html +2 -2
  26. package/apidoc/types/CadenzaEventByType.html +1 -1
  27. package/apidoc/types/CadenzaEventType.html +2 -2
  28. package/apidoc/types/CadenzaObjectInfoEvent.html +2 -2
  29. package/apidoc/types/CadenzaReloadEvent.html +5 -0
  30. package/apidoc/types/CadenzaSelectObjectsCancelEvent.html +2 -2
  31. package/apidoc/types/CadenzaSelectObjectsOkEvent.html +2 -2
  32. package/apidoc/types/CustomValidityType.html +2 -0
  33. package/apidoc/types/DataType.html +2 -2
  34. package/apidoc/types/EmbeddingTargetId.html +2 -2
  35. package/apidoc/types/Extent.html +2 -2
  36. package/apidoc/types/FilterVariables.html +2 -2
  37. package/apidoc/types/GeometryType.html +2 -2
  38. package/apidoc/types/GlobalId.html +2 -2
  39. package/apidoc/types/LengthUnit.html +1 -1
  40. package/apidoc/types/OpaqueString.html +2 -2
  41. package/apidoc/types/OperationMode.html +2 -2
  42. package/apidoc/types/TablePart.html +2 -2
  43. package/apidoc/types/UiFeature.html +3 -2
  44. package/apidoc/types/WorkbookLayerPath.html +2 -2
  45. package/apidoc/types/ZoomTarget.html +2 -2
  46. package/cadenza.d.ts +64 -5
  47. package/cadenza.js +51 -5
  48. package/package.json +1 -1
  49. package/sandbox.html +43 -13
package/cadenza.d.ts CHANGED
@@ -205,6 +205,12 @@ export class CadenzaClient {
205
205
  * @postMessage
206
206
  */
207
207
  removeSelection(layer: WorkbookLayerPath | string, values: unknown[][], ...args: any[]): Promise<void>;
208
+ /**
209
+ * @typedef {Object} LayerDefinition
210
+ * @property {string} name - The layer's name.
211
+ * @property {'geojson'} type - The layer's type.
212
+ * @property {FeatureCollection} content - The layer's content in geojson format.
213
+ */
208
214
  /**
209
215
  * Create a geometry.
210
216
  *
@@ -214,6 +220,7 @@ export class CadenzaClient {
214
220
  * @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
215
221
  * @param {GeometryType} geometryType - The geometry type
216
222
  * @param {object} [options] - Options
223
+ * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
217
224
  * @param {FilterVariables} [options.filter] - Filter variables
218
225
  * @param {string} [options.locationFinder] - A search query for the location finder
219
226
  * @param {Extent} [options.mapExtent] - A map extent to set
@@ -221,6 +228,7 @@ export class CadenzaClient {
221
228
  * @param {boolean} [options.useMapSrs] - Whether the created geometry should use the map's SRS (otherwise EPSG:4326 will be used)
222
229
  * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
223
230
  * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
231
+ * @param {LayerDefinition[]} [options.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
224
232
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
225
233
  * @throws For invalid arguments
226
234
  * @fires
@@ -229,7 +237,8 @@ export class CadenzaClient {
229
237
  * - {@link CadenzaEditGeometryCancelEvent}
230
238
  * @embed
231
239
  */
232
- createGeometry(backgroundMapView: EmbeddingTargetId, geometryType: GeometryType, { filter, locationFinder, mapExtent, minScale, useMapSrs, operationMode, signal, }?: {
240
+ createGeometry(backgroundMapView: EmbeddingTargetId, geometryType: GeometryType, { disabledUiFeatures, filter, locationFinder, mapExtent, minScale, useMapSrs, operationMode, signal, additionalLayers, }?: {
241
+ disabledUiFeatures?: UiFeature[] | undefined;
233
242
  filter?: FilterVariables | undefined;
234
243
  locationFinder?: string | undefined;
235
244
  mapExtent?: Extent | undefined;
@@ -237,6 +246,20 @@ export class CadenzaClient {
237
246
  useMapSrs?: boolean | undefined;
238
247
  operationMode?: OperationMode | undefined;
239
248
  signal?: AbortSignal | undefined;
249
+ additionalLayers?: {
250
+ /**
251
+ * - The layer's name.
252
+ */
253
+ name: string;
254
+ /**
255
+ * - The layer's type.
256
+ */
257
+ type: 'geojson';
258
+ /**
259
+ * - The layer's content in geojson format.
260
+ */
261
+ content: FeatureCollection;
262
+ }[] | undefined;
240
263
  } | undefined, ...args: any[]): Promise<void>;
241
264
  /**
242
265
  * Edit a geometry.
@@ -244,6 +267,7 @@ export class CadenzaClient {
244
267
  * @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
245
268
  * @param {Geometry} geometry - The geometry
246
269
  * @param {object} [options] - Options
270
+ * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
247
271
  * @param {FilterVariables} [options.filter] - Filter variables
248
272
  * @param {string} [options.locationFinder] - A search query for the location finder
249
273
  * @param {Extent} [options.mapExtent] - A map extent to set
@@ -252,6 +276,7 @@ export class CadenzaClient {
252
276
  * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
253
277
  * @param {ZoomTarget} [options.zoomTarget] - A target Cadenza should zoom to
254
278
  * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
279
+ * @param {Object[]} [options.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing. Each is a layer definition, with name, type and content (a Geojson featureCollection).
255
280
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
256
281
  * @throws For invalid arguments
257
282
  * @fires
@@ -260,7 +285,8 @@ export class CadenzaClient {
260
285
  * - {@link CadenzaEditGeometryCancelEvent}
261
286
  * @embed
262
287
  */
263
- editGeometry(backgroundMapView: EmbeddingTargetId, geometry: Geometry, { filter, locationFinder, mapExtent, minScale, useMapSrs, zoomTarget, operationMode, signal, }?: {
288
+ editGeometry(backgroundMapView: EmbeddingTargetId, geometry: Geometry, { disabledUiFeatures, filter, locationFinder, mapExtent, minScale, useMapSrs, zoomTarget, operationMode, signal, additionalLayers, }?: {
289
+ disabledUiFeatures?: UiFeature[] | undefined;
264
290
  filter?: FilterVariables | undefined;
265
291
  locationFinder?: string | undefined;
266
292
  mapExtent?: Extent | undefined;
@@ -269,7 +295,18 @@ export class CadenzaClient {
269
295
  operationMode?: OperationMode | undefined;
270
296
  zoomTarget?: GeometryZoomTarget | undefined;
271
297
  signal?: AbortSignal | undefined;
298
+ additionalLayers?: Object[] | undefined;
272
299
  } | undefined, ...args: any[]): Promise<void>;
300
+ /**
301
+ * Set custom validity state of the geometry editor in addition to the default validation state (including errors and
302
+ * warnings). When set to error the dialog submission is blocked.
303
+ * If there already is a custom state set it will override it.
304
+ * Passing '' will reset the custom state to undefined, meaning no custom state is displayed.
305
+ * If no geometry editing is started, the method call has no effect.
306
+ * @param {string} message The message to show in the dialog
307
+ * @param {CustomValidityType} [type] The type of message (defaults to 'error')
308
+ */
309
+ setCustomValidity(message: string, type?: CustomValidityType | undefined): void;
273
310
  /**
274
311
  * Select objects in a workbook map.
275
312
  *
@@ -409,6 +446,7 @@ export class CadenzaClient {
409
446
  * | 'objectInfo'
410
447
  * | 'selectObjects:ok'
411
448
  * | 'selectObjects:cancel'
449
+ * | 'reload'
412
450
  * } CadenzaEventType - An event type to subscribe to using {@link CadenzaClient#on}
413
451
  */
414
452
  /**
@@ -422,6 +460,7 @@ export class CadenzaClient {
422
460
  * : T extends 'objectInfo' ? CadenzaObjectInfoEvent
423
461
  * : T extends 'selectObjects:ok' ? CadenzaSelectObjectsOkEvent
424
462
  * : T extends 'selectObjects:cancel' ? CadenzaSelectObjectsCancelEvent
463
+ * : T extends 'reload' ? CadenzaReloadEvent
425
464
  * : never
426
465
  * } CadenzaEventByType
427
466
  */
@@ -460,6 +499,13 @@ export class CadenzaClient {
460
499
  * For a selection in a workbook map view with activated feature info, the values also include the simplified geometries of the selected objects.
461
500
  */
462
501
  /** @typedef {CadenzaEvent<'selectObjects:cancel'>} CadenzaSelectObjectsCancelEvent - When the user cancelled the selection. */
502
+ /**
503
+ * @typedef {CadenzaEvent<'reload'>} CadenzaReloadEvent - When the user clicked on the 'reload' button in the embedding standby page
504
+ *
505
+ * If a user does not interact with the iframe displaying the Cadenza content for a while, a standby embed page is displayed
506
+ * and the user can click a reload button there. Then the application using Cadenza JS can re-trigger the loading of the iframe
507
+ * with the correct original URL and parameters and do what was originally done when displaying that iframe.
508
+ */
463
509
  export class AbortError extends DOMException {
464
510
  constructor();
465
511
  }
@@ -568,9 +614,10 @@ export type OperationMode = 'normal' | 'simplified';
568
614
  *
569
615
  * _Note:_ Supported features are:
570
616
  * * `"workbook-design"` - The workbook designer
617
+ * * `"workbook-map-add-layer"`- Add layers to the map
571
618
  * * `"workbook-view-management"` - Add/Edit/Remove workbook views (Is included in 'workbook-design'.)
572
619
  */
573
- export type UiFeature = 'workbook-design' | 'workbook-view-management';
620
+ export type UiFeature = 'workbook-design' | 'workbook-map-add-layer' | 'workbook-view-management';
574
621
  export type Distance = {
575
622
  value: number;
576
623
  lengthUnit: LengthUnit;
@@ -661,11 +708,15 @@ export type FeatureCollection = {
661
708
  */
662
709
  features: Feature[];
663
710
  };
711
+ /**
712
+ * - The type of custom validity used for disclose on visual presentation and form submission behavior
713
+ */
714
+ export type CustomValidityType = 'error' | 'warning' | 'info' | 'success';
664
715
  /**
665
716
  * - An event type to subscribe to using {@link CadenzaClienton }
666
717
  */
667
- export type CadenzaEventType = 'action' | 'change:selection' | 'drillThrough' | 'editGeometry:ok' | 'editGeometry:update' | 'editGeometry:cancel' | 'objectInfo' | 'selectObjects:ok' | 'selectObjects:cancel';
668
- export type CadenzaEventByType<T extends CadenzaEventType> = T extends 'action' ? CadenzaActionEvent : T extends 'change:selection' ? CadenzaChangeSelectionEvent : T extends 'drillThrough' ? CadenzaDrillThroughEvent : T extends 'editGeometry:update' ? CadenzaEditGeometryUpdateEvent : T extends 'editGeometry:ok' ? CadenzaEditGeometryOkEvent : T extends 'editGeometry:cancel' ? CadenzaEditGeometryCancelEvent : T extends 'objectInfo' ? CadenzaObjectInfoEvent : T extends 'selectObjects:ok' ? CadenzaSelectObjectsOkEvent : T extends 'selectObjects:cancel' ? CadenzaSelectObjectsCancelEvent : never;
718
+ export type CadenzaEventType = 'action' | 'change:selection' | 'drillThrough' | 'editGeometry:ok' | 'editGeometry:update' | 'editGeometry:cancel' | 'objectInfo' | 'selectObjects:ok' | 'selectObjects:cancel' | 'reload';
719
+ export type CadenzaEventByType<T extends CadenzaEventType> = T extends 'action' ? CadenzaActionEvent : T extends 'change:selection' ? CadenzaChangeSelectionEvent : T extends 'drillThrough' ? CadenzaDrillThroughEvent : T extends 'editGeometry:update' ? CadenzaEditGeometryUpdateEvent : T extends 'editGeometry:ok' ? CadenzaEditGeometryOkEvent : T extends 'editGeometry:cancel' ? CadenzaEditGeometryCancelEvent : T extends 'objectInfo' ? CadenzaObjectInfoEvent : T extends 'selectObjects:ok' ? CadenzaSelectObjectsOkEvent : T extends 'selectObjects:cancel' ? CadenzaSelectObjectsCancelEvent : T extends 'reload' ? CadenzaReloadEvent : never;
669
720
  /**
670
721
  * - A Cadenza `postMessage()` event
671
722
  */
@@ -756,3 +807,11 @@ export type CadenzaSelectObjectsOkEvent = CadenzaEvent<'selectObjects:ok', {
756
807
  * - When the user cancelled the selection.
757
808
  */
758
809
  export type CadenzaSelectObjectsCancelEvent = CadenzaEvent<'selectObjects:cancel'>;
810
+ /**
811
+ * - When the user clicked on the 'reload' button in the embedding standby page
812
+ *
813
+ * If a user does not interact with the iframe displaying the Cadenza content for a while, a standby embed page is displayed
814
+ * and the user can click a reload button there. Then the application using Cadenza JS can re-trigger the loading of the iframe
815
+ * with the correct original URL and parameters and do what was originally done when displaying that iframe.
816
+ */
817
+ export type CadenzaReloadEvent = CadenzaEvent<'reload'>;
package/cadenza.js CHANGED
@@ -90,10 +90,11 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
90
90
  */
91
91
  /** @typedef {'normal'|'simplified'} OperationMode - The mode in which a workbook should be operated */
92
92
  /**
93
- * @typedef {'workbook-design'|'workbook-view-management'} UiFeature - The name of a Cadenza UI feature
93
+ * @typedef {'workbook-design'|'workbook-map-add-layer'|'workbook-view-management'} UiFeature - The name of a Cadenza UI feature
94
94
  *
95
95
  * _Note:_ Supported features are:
96
96
  * * `"workbook-design"` - The workbook designer
97
+ * * `"workbook-map-add-layer"`- Add layers to the map
97
98
  * * `"workbook-view-management"` - Add/Edit/Remove workbook views (Is included in 'workbook-design'.)
98
99
  * */
99
100
  /**
@@ -147,6 +148,7 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
147
148
  * @typedef FeatureCollection - A adapted [GeoJSON](https://geojson.org/) feature collection object
148
149
  * @property {Feature[]} features - The features within this collection
149
150
  */
151
+ /** @typedef {'error'|'warning'|'info'|'success'} CustomValidityType - The type of custom validity used for disclose on visual presentation and form submission behavior */
150
152
  let hasCadenzaSession = false;
151
153
  /** @type {Promise<void> | undefined} */
152
154
  let firstEmbeddingTargetShown;
@@ -455,6 +457,12 @@ export class CadenzaClient {
455
457
  values,
456
458
  });
457
459
  }
460
+ /**
461
+ * @typedef {Object} LayerDefinition
462
+ * @property {string} name - The layer's name.
463
+ * @property {'geojson'} type - The layer's type.
464
+ * @property {FeatureCollection} content - The layer's content in geojson format.
465
+ */
458
466
  /**
459
467
  * Create a geometry.
460
468
  *
@@ -464,6 +472,7 @@ export class CadenzaClient {
464
472
  * @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
465
473
  * @param {GeometryType} geometryType - The geometry type
466
474
  * @param {object} [options] - Options
475
+ * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
467
476
  * @param {FilterVariables} [options.filter] - Filter variables
468
477
  * @param {string} [options.locationFinder] - A search query for the location finder
469
478
  * @param {Extent} [options.mapExtent] - A map extent to set
@@ -471,6 +480,7 @@ export class CadenzaClient {
471
480
  * @param {boolean} [options.useMapSrs] - Whether the created geometry should use the map's SRS (otherwise EPSG:4326 will be used)
472
481
  * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
473
482
  * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
483
+ * @param {LayerDefinition[]} [options.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
474
484
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
475
485
  * @throws For invalid arguments
476
486
  * @fires
@@ -479,10 +489,11 @@ export class CadenzaClient {
479
489
  * - {@link CadenzaEditGeometryCancelEvent}
480
490
  * @embed
481
491
  */
482
- createGeometry(backgroundMapView, geometryType, { filter, locationFinder, mapExtent, minScale, useMapSrs, operationMode, signal, } = {}) {
492
+ async createGeometry(backgroundMapView, geometryType, { disabledUiFeatures, filter, locationFinder, mapExtent, minScale, useMapSrs, operationMode, signal, additionalLayers, } = {}) {
483
493
  this.#log('CadenzaClient#createGeometry', ...arguments);
484
494
  const params = createParams({
485
495
  action: 'editGeometry',
496
+ disabledUiFeatures,
486
497
  filter,
487
498
  geometryType,
488
499
  locationFinder,
@@ -491,7 +502,10 @@ export class CadenzaClient {
491
502
  useMapSrs,
492
503
  operationMode,
493
504
  });
494
- return this.#show(resolvePath(backgroundMapView), params, signal);
505
+ await this.#show(resolvePath(backgroundMapView), params, signal);
506
+ if (additionalLayers) {
507
+ additionalLayers.forEach((layer) => this.#postEvent('importLayer', layer));
508
+ }
495
509
  }
496
510
  /**
497
511
  * Edit a geometry.
@@ -499,6 +513,7 @@ export class CadenzaClient {
499
513
  * @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
500
514
  * @param {Geometry} geometry - The geometry
501
515
  * @param {object} [options] - Options
516
+ * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
502
517
  * @param {FilterVariables} [options.filter] - Filter variables
503
518
  * @param {string} [options.locationFinder] - A search query for the location finder
504
519
  * @param {Extent} [options.mapExtent] - A map extent to set
@@ -507,6 +522,7 @@ export class CadenzaClient {
507
522
  * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
508
523
  * @param {ZoomTarget} [options.zoomTarget] - A target Cadenza should zoom to
509
524
  * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
525
+ * @param {Object[]} [options.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing. Each is a layer definition, with name, type and content (a Geojson featureCollection).
510
526
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
511
527
  * @throws For invalid arguments
512
528
  * @fires
@@ -515,12 +531,13 @@ export class CadenzaClient {
515
531
  * - {@link CadenzaEditGeometryCancelEvent}
516
532
  * @embed
517
533
  */
518
- async editGeometry(backgroundMapView, geometry, { filter, locationFinder, mapExtent, minScale, useMapSrs, zoomTarget, operationMode, signal, } = {}) {
534
+ async editGeometry(backgroundMapView, geometry, { disabledUiFeatures, filter, locationFinder, mapExtent, minScale, useMapSrs, zoomTarget, operationMode, signal, additionalLayers, } = {}) {
519
535
  this.#log('CadenzaClient#editGeometry', ...arguments);
520
536
  assertValidGeometryType(geometry.type);
521
537
  const zoomToGeometry = geometry && zoomTarget?.type === 'geometry';
522
538
  const params = createParams({
523
539
  action: 'editGeometry',
540
+ disabledUiFeatures,
524
541
  filter,
525
542
  // only use locationFinder if zoom to geometry is not set, to avoid
526
543
  // zooming race condition for Cadenza versions below 10.1
@@ -537,6 +554,22 @@ export class CadenzaClient {
537
554
  zoomToGeometry,
538
555
  });
539
556
  }
557
+ if (additionalLayers) {
558
+ additionalLayers.forEach((layer) => this.#postEvent('importLayer', layer));
559
+ }
560
+ }
561
+ /**
562
+ * Set custom validity state of the geometry editor in addition to the default validation state (including errors and
563
+ * warnings). When set to error the dialog submission is blocked.
564
+ * If there already is a custom state set it will override it.
565
+ * Passing '' will reset the custom state to undefined, meaning no custom state is displayed.
566
+ * If no geometry editing is started, the method call has no effect.
567
+ * @param {string} message The message to show in the dialog
568
+ * @param {CustomValidityType} [type] The type of message (defaults to 'error')
569
+ */
570
+ setCustomValidity(message, type = 'error') {
571
+ assert(['error', 'warning', 'info', 'success'].includes(type), `Invalid validity type: ${type}`);
572
+ this.#postEvent('setCustomValidity', { message, type });
540
573
  }
541
574
  /**
542
575
  * Select objects in a workbook map.
@@ -981,7 +1014,11 @@ function validOperationMode(/** @type string */ value) {
981
1014
  return ['normal', 'simplified'].includes(value);
982
1015
  }
983
1016
  function validUiFeature(/** @type string */ value) {
984
- return ['workbook-design', 'workbook-view-management'].includes(value);
1017
+ return [
1018
+ 'workbook-design',
1019
+ 'workbook-map-add-layer',
1020
+ 'workbook-view-management',
1021
+ ].includes(value);
985
1022
  }
986
1023
  function assertSupportedDataType(
987
1024
  /** @type DataType */ type,
@@ -1072,6 +1109,7 @@ function array(/** @type unknown */ value) {
1072
1109
  * | 'objectInfo'
1073
1110
  * | 'selectObjects:ok'
1074
1111
  * | 'selectObjects:cancel'
1112
+ * | 'reload'
1075
1113
  * } CadenzaEventType - An event type to subscribe to using {@link CadenzaClient#on}
1076
1114
  */
1077
1115
  /**
@@ -1085,6 +1123,7 @@ function array(/** @type unknown */ value) {
1085
1123
  * : T extends 'objectInfo' ? CadenzaObjectInfoEvent
1086
1124
  * : T extends 'selectObjects:ok' ? CadenzaSelectObjectsOkEvent
1087
1125
  * : T extends 'selectObjects:cancel' ? CadenzaSelectObjectsCancelEvent
1126
+ * : T extends 'reload' ? CadenzaReloadEvent
1088
1127
  * : never
1089
1128
  * } CadenzaEventByType
1090
1129
  */
@@ -1128,6 +1167,13 @@ function array(/** @type unknown */ value) {
1128
1167
  * For a selection in a workbook map view with activated feature info, the values also include the simplified geometries of the selected objects.
1129
1168
  */
1130
1169
  /** @typedef {CadenzaEvent<'selectObjects:cancel'>} CadenzaSelectObjectsCancelEvent - When the user cancelled the selection. */
1170
+ /**
1171
+ * @typedef {CadenzaEvent<'reload'>} CadenzaReloadEvent - When the user clicked on the 'reload' button in the embedding standby page
1172
+ *
1173
+ * If a user does not interact with the iframe displaying the Cadenza content for a while, a standby embed page is displayed
1174
+ * and the user can click a reload button there. Then the application using Cadenza JS can re-trigger the loading of the iframe
1175
+ * with the correct original URL and parameters and do what was originally done when displaying that iframe.
1176
+ */
1131
1177
  export class AbortError extends DOMException {
1132
1178
  constructor() {
1133
1179
  super('Aborted', 'AbortError');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@disy/cadenza.js",
3
- "version": "10.2.0",
3
+ "version": "10.2.2",
4
4
  "license": "Apache-2.0",
5
5
  "repository": "github:DisyInformationssysteme/cadenza.js",
6
6
  "type": "module",
package/sandbox.html CHANGED
@@ -181,7 +181,8 @@
181
181
  cadenzaClient.fetchAreaIntersections(data.embeddingTargetId, JSON.parse(data.layer), JSON.parse(data.geometry), getOptions(data))
182
182
  .then(console.log);
183
183
  },
184
- downloadData: data => cadenzaClient.downloadData(data.embeddingTargetId, data.dataType, getOptions(data))
184
+ downloadData: data => cadenzaClient.downloadData(data.embeddingTargetId, data.dataType, getOptions(data)),
185
+ setCustomValidity: data => cadenzaClient.setCustomValidity(data.message, data.type || undefined)
185
186
  };
186
187
 
187
188
  const form = document.getElementById('form');
@@ -230,7 +231,8 @@
230
231
  fullGeometries,
231
232
  zoomToGeometry,
232
233
  distance,
233
- lengthUnit
234
+ lengthUnit,
235
+ additionalLayers
234
236
  }) {
235
237
  return {
236
238
  disabledUiFeatures: disabledUiFeatures && disabledUiFeatures.split(','),
@@ -252,7 +254,8 @@
252
254
  useMapSrs: useMapSrs === 'on',
253
255
  fullGeometries: fullGeometries === 'on',
254
256
  zoomTarget: zoomToGeometry === 'on' ? { type: 'geometry' } : undefined,
255
- buffer: distance ? { value: Number(distance), lengthUnit: lengthUnit ? lengthUnit : 'm' } : undefined
257
+ buffer: distance ? { value: Number(distance), lengthUnit: lengthUnit ? lengthUnit : 'm' } : undefined,
258
+ additionalLayers: additionalLayers && JSON.parse(additionalLayers)
256
259
  };
257
260
  }
258
261
 
@@ -297,6 +300,7 @@
297
300
  <option value="createGeometry">Create Geometry</option>
298
301
  <option value="editGeometry">Edit Geometry</option>
299
302
  <option value="selectObjects">Select Objects</option>
303
+ <option value="setCustomValidity">Set Custom Validity</option>
300
304
  </optgroup>
301
305
  <optgroup label="Without Iframe">
302
306
  <option value="downloadData">Download data</option>
@@ -349,6 +353,15 @@
349
353
  Simplified operation mode
350
354
  </label>
351
355
  </div>
356
+ <div>
357
+ <label>
358
+ <input type="checkbox" name="expandNavigator">
359
+ Expand navigator tree
360
+ </label>
361
+ </div>
362
+ </template>
363
+
364
+ <template id="common-disabledUiFeatures">
352
365
  <div>
353
366
  <label for="disabledUiFeatures">Disabled UI features</label>
354
367
  <input name="disabledUiFeatures" id="disabledUiFeatures" placeholder="feature1,feature2,...">
@@ -359,16 +372,11 @@
359
372
  Supported features:
360
373
  <ul>
361
374
  <li>workbook-design</li>
375
+ <li>workbook-map-add-layer</li>
362
376
  <li>workbook-view-management</li>
363
377
  </ul>
364
378
  </small>
365
379
  </div>
366
- <div>
367
- <label>
368
- <input type="checkbox" name="expandNavigator">
369
- Expand navigator tree
370
- </label>
371
- </div>
372
380
  </template>
373
381
 
374
382
  <template id="common-filter">
@@ -425,7 +433,7 @@
425
433
  </div>
426
434
  </template>
427
435
 
428
- <template data-action="show" data-common="showWorkbook,filter,show">
436
+ <template data-action="show" data-common="showWorkbook,disabledUiFeatures,filter,show">
429
437
  <div>
430
438
  <label for="embeddingTargetId">Embedding target ID *</label>
431
439
  <input name="embeddingTargetId" id="embeddingTargetId" required>
@@ -461,7 +469,7 @@
461
469
  </div>
462
470
  </template>
463
471
 
464
- <template data-action="showMap" data-common="zoomTo,map,showWorkbook,filter,show">
472
+ <template data-action="showMap" data-common="zoomTo,map,showWorkbook,disabledUiFeatures,filter,show">
465
473
  <div>
466
474
  <label for="embeddingTargetId">Embedding target ID of the map view *</label>
467
475
  <input name="embeddingTargetId" id="embeddingTargetId" required>
@@ -472,13 +480,31 @@
472
480
  </div>
473
481
  </template>
474
482
 
483
+ <template data-action="setCustomValidity">
484
+ <p>Requires a geometry editing UI (Create / Edit Geometry actions) to be opened first.</p>
485
+ <label for="message">Message</label>
486
+ <input type="text" name="message" id="message">
487
+ <label for="type">Type</label>
488
+ <select name="type" id="type">
489
+ <option selected></option>
490
+ <option>success</option>
491
+ <option>info</option>
492
+ <option>warning</option>
493
+ <option>error</option>
494
+ </select>
495
+ </template>
496
+
475
497
  <template data-action="setFilter" data-common="filter"></template>
476
498
 
477
- <template data-action="createGeometry" data-common="map,filter">
499
+ <template data-action="createGeometry" data-common="map,disabledUiFeatures,filter">
478
500
  <div>
479
501
  <label for="embeddingTargetId">Embedding target ID of the map view *</label>
480
502
  <input name="embeddingTargetId" id="embeddingTargetId" required>
481
503
  </div>
504
+ <div>
505
+ <label for="geometry">Additional layers (GeoJSON)</label>
506
+ <textarea name="additionalLayers" id="additionalLayers" rows="10"></textarea>
507
+ </div>
482
508
  <div>
483
509
  <label for="geometryType">Geometry type</label>
484
510
  <select name="geometryType" id="geometryType">
@@ -502,11 +528,15 @@
502
528
  </div>
503
529
  </template>
504
530
 
505
- <template data-action="editGeometry" data-common="zoomTo,map,filter">
531
+ <template data-action="editGeometry" data-common="zoomTo,map,disabledUiFeatures,filter">
506
532
  <div>
507
533
  <label for="embeddingTargetId">Embedding target ID of the map view *</label>
508
534
  <input name="embeddingTargetId" id="embeddingTargetId" required>
509
535
  </div>
536
+ <div>
537
+ <label for="geometry">Additional layers (GeoJSON)</label>
538
+ <textarea name="additionalLayers" id="additionalLayers" rows="10"></textarea>
539
+ </div>
510
540
  <div>
511
541
  <label for="geometry">Geometry (GeoJSON) *</label>
512
542
  <textarea name="geometry" id="geometry" rows="5" required></textarea>