@disy/cadenza.js 10.4.8 → 10.4.9
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/CHANGELOG.md +13 -0
- package/apidoc/assets/navigation.js +1 -1
- package/apidoc/assets/search.js +1 -1
- package/apidoc/classes/AbortError.html +3 -3
- package/apidoc/classes/CadenzaClient.html +63 -23
- package/apidoc/classes/CadenzaError.html +5 -5
- package/apidoc/functions/cadenza.html +4 -4
- package/apidoc/index.html +2 -2
- package/apidoc/interfaces/AreaIntersectionsResult.html +4 -4
- package/apidoc/interfaces/CadenzaClientOptions.html +6 -6
- package/apidoc/interfaces/CadenzaEvent.html +4 -4
- package/apidoc/interfaces/CommonEditGeometryOptions.html +11 -11
- package/apidoc/interfaces/Distance.html +2 -2
- package/apidoc/interfaces/ExternalLinkKey.html +4 -4
- package/apidoc/interfaces/Feature.html +9 -9
- package/apidoc/interfaces/FeatureCollection.html +4 -4
- package/apidoc/interfaces/Geometry.html +4 -4
- package/apidoc/interfaces/GeometryExtentStrategy.html +4 -4
- package/apidoc/interfaces/LayerDataExtentStrategy.html +4 -4
- package/apidoc/interfaces/LayerDefinition.html +4 -4
- package/apidoc/interfaces/LocationFinderExtentStrategy.html +4 -4
- package/apidoc/interfaces/PageSource.html +3 -3
- package/apidoc/interfaces/ProblemDetails.html +6 -6
- package/apidoc/interfaces/SnappingOptions.html +3 -3
- package/apidoc/interfaces/SpatialFilterValue.html +4 -4
- package/apidoc/interfaces/StaticExtentStrategy.html +4 -4
- package/apidoc/modules.html +1 -1
- package/apidoc/types/CadenzaActionEvent.html +2 -2
- package/apidoc/types/CadenzaChangeExtentEvent.html +3 -0
- package/apidoc/types/CadenzaChangeSelectionEvent.html +2 -2
- package/apidoc/types/CadenzaDrillThroughEvent.html +2 -2
- package/apidoc/types/CadenzaEditGeometryCancelEvent.html +2 -2
- package/apidoc/types/CadenzaEditGeometryCreateEvent.html +2 -2
- package/apidoc/types/CadenzaEditGeometryDeleteEvent.html +2 -2
- package/apidoc/types/CadenzaEditGeometryEditEvent.html +2 -2
- package/apidoc/types/CadenzaEditGeometryOkEvent.html +2 -2
- package/apidoc/types/CadenzaEditGeometryUpdateEvent.html +2 -2
- package/apidoc/types/CadenzaErrorEvent.html +2 -2
- package/apidoc/types/CadenzaEventByType.html +1 -1
- package/apidoc/types/CadenzaEventType.html +2 -2
- package/apidoc/types/CadenzaReloadEvent.html +2 -2
- package/apidoc/types/CadenzaSelectObjectsCancelEvent.html +2 -2
- package/apidoc/types/CadenzaSelectObjectsOkEvent.html +2 -2
- package/apidoc/types/Coordinate.html +2 -2
- package/apidoc/types/CustomValidityType.html +2 -2
- package/apidoc/types/DataType.html +2 -2
- package/apidoc/types/EmbeddingTargetId.html +2 -2
- package/apidoc/types/Extent.html +2 -2
- package/apidoc/types/ExtentStrategy.html +2 -2
- package/apidoc/types/FilterVariables.html +2 -2
- package/apidoc/types/GeometryType.html +2 -2
- package/apidoc/types/GlobalId.html +2 -2
- package/apidoc/types/Layout.html +2 -2
- package/apidoc/types/LengthUnit.html +1 -1
- package/apidoc/types/OpaqueString.html +2 -2
- package/apidoc/types/OperationMode.html +2 -2
- package/apidoc/types/Polygon.html +1 -1
- package/apidoc/types/SpatialRelation.html +2 -2
- package/apidoc/types/TablePart.html +2 -2
- package/apidoc/types/UiFeature.html +2 -2
- package/apidoc/types/WorkbookLayerPath.html +2 -2
- package/cadenza.d.ts +25 -7
- package/cadenza.js +63 -14
- package/package.json +1 -1
package/cadenza.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
// This placeholder is replaced when Cadenza JS is released,
|
|
20
20
|
// i.e. during development, the version is not available.
|
|
21
|
-
const CADENZAJS_VERSION = '10.4.
|
|
21
|
+
const CADENZAJS_VERSION = '10.4.9';
|
|
22
22
|
/**
|
|
23
23
|
* Creates an instance of the Cadenza JS client.
|
|
24
24
|
*
|
|
@@ -422,6 +422,8 @@ export class CadenzaClient {
|
|
|
422
422
|
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
423
423
|
* @throws For invalid arguments
|
|
424
424
|
* @fires
|
|
425
|
+
* - {@link CadenzaChangeExtentEvent}
|
|
426
|
+
* - {@link CadenzaChangeSelectionEvent}
|
|
425
427
|
* - {@link CadenzaDrillThroughEvent}
|
|
426
428
|
* - {@link CadenzaActionEvent}
|
|
427
429
|
* @embed
|
|
@@ -492,7 +494,6 @@ export class CadenzaClient {
|
|
|
492
494
|
/**
|
|
493
495
|
* Set filter variables in the currently shown workbook.
|
|
494
496
|
*
|
|
495
|
-
* @hidden
|
|
496
497
|
* @param {FilterVariables} filter - The variable values
|
|
497
498
|
* @return {Promise<void>} A `Promise` for when the filter variables were set.
|
|
498
499
|
* @postMessage
|
|
@@ -508,7 +509,6 @@ export class CadenzaClient {
|
|
|
508
509
|
* When making a layer visible, its ancestors will be made visible, too.
|
|
509
510
|
* When hiding a layer, the ancestors are not affected.
|
|
510
511
|
*
|
|
511
|
-
* @hidden
|
|
512
512
|
* @param {WorkbookLayerPath | string} layer - The layer to show or hide
|
|
513
513
|
* (identified using a layer path or a print name)
|
|
514
514
|
* @param {boolean} visible - The visibility state of the layer
|
|
@@ -525,7 +525,6 @@ export class CadenzaClient {
|
|
|
525
525
|
/**
|
|
526
526
|
* Set the selection in the currently shown workbook map view.
|
|
527
527
|
*
|
|
528
|
-
* @hidden
|
|
529
528
|
* @param {WorkbookLayerPath | string} layer - The data view layer to set the selection in
|
|
530
529
|
* @param {unknown[][]} values - The IDs of the objects to select
|
|
531
530
|
* @param {object} [__namedParameters]
|
|
@@ -545,7 +544,6 @@ export class CadenzaClient {
|
|
|
545
544
|
/**
|
|
546
545
|
* Add to the selection in the currently shown workbook map view.
|
|
547
546
|
*
|
|
548
|
-
* @hidden
|
|
549
547
|
* @param {WorkbookLayerPath | string} layer - The data view layer to change the selection in
|
|
550
548
|
* @param {unknown[][]} values - The IDs of the objects to select
|
|
551
549
|
* @param {object} [__namedParameters]
|
|
@@ -565,7 +563,6 @@ export class CadenzaClient {
|
|
|
565
563
|
/**
|
|
566
564
|
* Remove from the selection in the currently shown workbook map view.
|
|
567
565
|
*
|
|
568
|
-
* @hidden
|
|
569
566
|
* @param {WorkbookLayerPath | string} layer - The data view layer to change the selection in
|
|
570
567
|
* @param {unknown[][]} values - The IDs of the objects to unselect
|
|
571
568
|
* @param {object} [__namedParameters]
|
|
@@ -593,6 +590,8 @@ export class CadenzaClient {
|
|
|
593
590
|
* @param {CommonEditGeometryOptions} [editGeometryOptions] - Options for the initialization of the geometry editor.
|
|
594
591
|
* @throws For invalid arguments
|
|
595
592
|
* @fires
|
|
593
|
+
* - {@link CadenzaChangeExtentEvent}
|
|
594
|
+
* - {@link CadenzaChangeSelectionEvent}
|
|
596
595
|
* - {@link CadenzaEditGeometryUpdateEvent}
|
|
597
596
|
* - {@link CadenzaEditGeometryOkEvent}
|
|
598
597
|
* - {@link CadenzaEditGeometryCancelEvent}
|
|
@@ -630,6 +629,8 @@ export class CadenzaClient {
|
|
|
630
629
|
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
631
630
|
* @throws For invalid arguments
|
|
632
631
|
* @fires
|
|
632
|
+
* - {@link CadenzaChangeExtentEvent}
|
|
633
|
+
* - {@link CadenzaChangeSelectionEvent}
|
|
633
634
|
* - {@link CadenzaEditGeometryUpdateEvent}
|
|
634
635
|
* - {@link CadenzaEditGeometryOkEvent}
|
|
635
636
|
* - {@link CadenzaEditGeometryCancelEvent}
|
|
@@ -671,6 +672,8 @@ export class CadenzaClient {
|
|
|
671
672
|
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
672
673
|
* @throws For invalid arguments
|
|
673
674
|
* @fires
|
|
675
|
+
* - {@link CadenzaChangeExtentEvent}
|
|
676
|
+
* - {@link CadenzaChangeSelectionEvent}
|
|
674
677
|
* - {@link CadenzaEditGeometryUpdateEvent}
|
|
675
678
|
* - {@link CadenzaEditGeometryOkEvent}
|
|
676
679
|
* - {@link CadenzaEditGeometryCreateEvent}
|
|
@@ -713,6 +716,8 @@ export class CadenzaClient {
|
|
|
713
716
|
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
714
717
|
* @throws For invalid arguments
|
|
715
718
|
* @fires
|
|
719
|
+
* - {@link CadenzaChangeExtentEvent}
|
|
720
|
+
* - {@link CadenzaChangeSelectionEvent}
|
|
716
721
|
* - {@link CadenzaEditGeometryUpdateEvent}
|
|
717
722
|
* - {@link CadenzaEditGeometryOkEvent}
|
|
718
723
|
* - {@link CadenzaEditGeometryCreateEvent}
|
|
@@ -744,8 +749,8 @@ export class CadenzaClient {
|
|
|
744
749
|
await this.#setupEditorViaPostRequests({
|
|
745
750
|
additionalLayers,
|
|
746
751
|
validExtentStrategy,
|
|
747
|
-
features,
|
|
748
752
|
});
|
|
753
|
+
await this.#createFeaturesAndEditLastCreatedFeature(features);
|
|
749
754
|
await this.#setEditorStateToReady();
|
|
750
755
|
}
|
|
751
756
|
/**
|
|
@@ -753,10 +758,9 @@ export class CadenzaClient {
|
|
|
753
758
|
* @param [__namedParameters.geometry] {Geometry} - The geometry to edit
|
|
754
759
|
* @param [__namedParameters.additionalLayers] {LayerDefinition[]} - Layer definitions to be imported and shown in the background, as a basis for the drawing. IMPORTANT: The Cadenza referenced with `cadenzaClient` must be configured to support the import of GeoJSON, and the (system) privileges of the corresponding user must also be set in such a way that the import of GeoJSON is possible.
|
|
755
760
|
* @param [__namedParameters.validExtentStrategy] {ExtentStrategy} - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
756
|
-
* @param [__namedParameters.features] {FeatureCollection} - The features to edit. The last feature in this collection is directly set up for editing.
|
|
757
761
|
* @returns {Promise<Awaited<unknown>[]>}
|
|
758
762
|
*/
|
|
759
|
-
#setupEditorViaPostRequests({ geometry, additionalLayers, validExtentStrategy,
|
|
763
|
+
#setupEditorViaPostRequests({ geometry, additionalLayers, validExtentStrategy, }) {
|
|
760
764
|
const postRequests = [];
|
|
761
765
|
postRequests.push(this.#setExtentStrategy(validExtentStrategy));
|
|
762
766
|
if (geometry) {
|
|
@@ -769,11 +773,41 @@ export class CadenzaClient {
|
|
|
769
773
|
postRequests.push(this.#postRequest('importLayer', layer));
|
|
770
774
|
}
|
|
771
775
|
}
|
|
772
|
-
if (features) {
|
|
773
|
-
postRequests.push(this.#postRequest('addFeatures', features));
|
|
774
|
-
}
|
|
775
776
|
return Promise.all(postRequests);
|
|
776
777
|
}
|
|
778
|
+
/**
|
|
779
|
+
* @param {FeatureCollection} features - The features to edit.
|
|
780
|
+
*/
|
|
781
|
+
async #createFeaturesAndEditLastCreatedFeature(features) {
|
|
782
|
+
const editFeaturePromise = new Promise((resolve) => {
|
|
783
|
+
this.#once('editGeometry:create',
|
|
784
|
+
/** @param {CadenzaEditGeometryCreateEvent} event */ async (event) => {
|
|
785
|
+
const featureOrCollection = event.detail;
|
|
786
|
+
let lastAddedFeature;
|
|
787
|
+
if (featureOrCollection.type === 'Feature') {
|
|
788
|
+
lastAddedFeature = featureOrCollection;
|
|
789
|
+
}
|
|
790
|
+
else {
|
|
791
|
+
const addedFeatures = featureOrCollection.features;
|
|
792
|
+
lastAddedFeature = addedFeatures[addedFeatures.length - 1];
|
|
793
|
+
}
|
|
794
|
+
await this.#setEditFeature(lastAddedFeature.objectId);
|
|
795
|
+
resolve(undefined);
|
|
796
|
+
});
|
|
797
|
+
});
|
|
798
|
+
await this.#postRequest('createFeatures', features);
|
|
799
|
+
return editFeaturePromise;
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Send a request to the geometry editor to edit the feature with the given ID.
|
|
803
|
+
* If another feature is currently being edited or created,
|
|
804
|
+
* the user is prompted to save (if possible), discard the current changes, or to abort the request.
|
|
805
|
+
*
|
|
806
|
+
* @param {any[]} objectId - The id of the feature
|
|
807
|
+
*/
|
|
808
|
+
#setEditFeature(objectId) {
|
|
809
|
+
return this.#postRequest('requestEditFeature', objectId);
|
|
810
|
+
}
|
|
777
811
|
#setEditorStateToReady() {
|
|
778
812
|
return this.#postRequest('setEditorState', 'READY');
|
|
779
813
|
}
|
|
@@ -948,6 +982,20 @@ export class CadenzaClient {
|
|
|
948
982
|
}
|
|
949
983
|
};
|
|
950
984
|
}
|
|
985
|
+
/**
|
|
986
|
+
* @template {CadenzaEventType | string} TYPE
|
|
987
|
+
* @template [DETAIL=unknown]
|
|
988
|
+
* @param {TYPE} type
|
|
989
|
+
* @param {(event: CadenzaEvent<TYPE, DETAIL>) => void} subscriber
|
|
990
|
+
* @return {() => void} An unsubscribe function
|
|
991
|
+
*/
|
|
992
|
+
#once(type, subscriber) {
|
|
993
|
+
const unsubscribe = this.#on(type, (event) => {
|
|
994
|
+
subscriber(/** @type {CadenzaEvent<TYPE, DETAIL>} */ (event));
|
|
995
|
+
unsubscribe();
|
|
996
|
+
});
|
|
997
|
+
return unsubscribe;
|
|
998
|
+
}
|
|
951
999
|
// Use arrow function so that it's bound to this.
|
|
952
1000
|
#onMessage = (
|
|
953
1001
|
/** @type MessageEvent<CadenzaEvent<never, never>> */ event) => {
|
|
@@ -1447,6 +1495,7 @@ function getGeometryTypeFromFeatureCollection(featureCollection) {
|
|
|
1447
1495
|
// Please do not add internal event types like 'ready' here.
|
|
1448
1496
|
/**
|
|
1449
1497
|
* @typedef {'action'
|
|
1498
|
+
* | 'change:extent'
|
|
1450
1499
|
* | 'change:selection'
|
|
1451
1500
|
* | 'drillThrough'
|
|
1452
1501
|
* | 'editGeometry:ok'
|
|
@@ -1463,6 +1512,7 @@ function getGeometryTypeFromFeatureCollection(featureCollection) {
|
|
|
1463
1512
|
/**
|
|
1464
1513
|
* @template {CadenzaEventType} T
|
|
1465
1514
|
* @typedef {T extends 'action' ? CadenzaActionEvent
|
|
1515
|
+
* : T extends 'change:extent' ? CadenzaChangeExtentEvent
|
|
1466
1516
|
* : T extends 'change:selection' ? CadenzaChangeSelectionEvent
|
|
1467
1517
|
* : T extends 'drillThrough' ? CadenzaDrillThroughEvent
|
|
1468
1518
|
* : T extends 'editGeometry:update' ? CadenzaEditGeometryUpdateEvent
|
|
@@ -1487,8 +1537,7 @@ function getGeometryTypeFromFeatureCollection(featureCollection) {
|
|
|
1487
1537
|
/**
|
|
1488
1538
|
* @typedef {CadenzaEvent<'action', {context: string}>} CadenzaActionEvent - When the user executed a POST message action, which is defined on an external link in the Cadenza management center.
|
|
1489
1539
|
*/
|
|
1490
|
-
|
|
1491
|
-
* @hidden
|
|
1540
|
+
/**
|
|
1492
1541
|
* @typedef {CadenzaEvent<'change:extent', {extent: Extent}>} CadenzaChangeExtentEvent - When the user moved the map.
|
|
1493
1542
|
* The extent is transformed according to the `useMapSrs` option.
|
|
1494
1543
|
*/
|