From 573cba394f52e6d59665cb6cc83809a5421f5735 Mon Sep 17 00:00:00 2001 From: schmidt Date: Tue, 19 Nov 2024 15:11:36 +0100 Subject: [PATCH 01/21] CADENZA-37531 and CADENZA-38242: - Cleanup of type definition 'LayerDefinition' - Fix displaying of parameter descriptions in case of an options object being destructured immediately (in this case the parameter descriptions weren't visible in the documentation) - Order the parameters in alphabetical order - Add the Cadenza JS part for zooming extensions --- src/cadenza.js | 412 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 295 insertions(+), 117 deletions(-) diff --git a/src/cadenza.js b/src/cadenza.js index 582a2186..2f9ffda1 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -1,21 +1,21 @@ /** * @typedef CadenzaClientOptions * @property {string} [baseUrl] - The base URL of the Cadenza server - * @property {HTMLIFrameElement | string} [options.iframe] - An iframe for embedding Cadenza or the iframe's ID. + * @property {HTMLIFrameElement | string} [__namedParameters.iframe] - An iframe for embedding Cadenza or the iframe's ID. * The iframe is required only for methods that embed Cadenza in an iframe, so e.g. not for {@link CadenzaClient#fetchData}. * If you want to embed Cadenza in multiple iframes, you need to create an instance of the `CadenzaClient` per iframe. - * @property {ExternalLinkKey} [options.webApplication] - An external link that Cadenza uses to resolve the + * @property {ExternalLinkKey} [__namedParameters.webApplication] - An external link that Cadenza uses to resolve the * [target origin](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#targetorigin) when posting events. * This is required if Cadenza and your application are not running on the same origin. * Please ensure that the user has view privilege for that link! - * @property {boolean} [options.debug] - Whether to enable debug logging + * @property {boolean} [__namedParameters.debug] - Whether to enable debug logging */ /** * Creates an instance of the Cadenza JS client. * * @overload - * @param {CadenzaClientOptions} [options] - Options + * @param {CadenzaClientOptions} [__namedParameters] - Options * @return {CadenzaClient} * @throws For invalid arguments */ @@ -26,20 +26,20 @@ * Please use the other overload. * @overload * @param {string} baseUrl - The base URL of the Cadenza server - * @param {Exclude} [options] - Options + * @param {Exclude} [__namedParameters] - Options * @return {CadenzaClient} * @throws For invalid arguments */ /** * @param {string | CadenzaClientOptions} [baseUrlOrOptions] - * @param {CadenzaClientOptions} [options] + * @param {CadenzaClientOptions} [__namedParameters] */ -export function cadenza(baseUrlOrOptions, options) { - options = +export function cadenza(baseUrlOrOptions, __namedParameters) { + __namedParameters = typeof baseUrlOrOptions === 'string' - ? { baseUrl: baseUrlOrOptions, ...options } + ? { baseUrl: baseUrlOrOptions, ...__namedParameters } : baseUrlOrOptions; - return new CadenzaClient(options); + return new CadenzaClient(__namedParameters); } /* @ts-ignore */ @@ -109,6 +109,13 @@ globalThis.cadenza = Object.assign( * * `"workbook-view-management"` - Add/Edit/Remove workbook views (Is included in 'workbook-design'.) * */ +/** + * @typedef LayerDefinition + * @property {string} name - The layer's name. + * @property {'geojson'} type - The layer's type. + * @property {FeatureCollection} content - The layer's content in geojson format. + */ + /** * @typedef Distance * @property {number} value @@ -130,11 +137,65 @@ globalThis.cadenza = Object.assign( /** @typedef {[number,number,number,number]} Extent - An array of numbers representing an extent: [minx, miny, maxx, maxy] */ /** - * @typedef {GeometryZoomTarget} ZoomTarget - An object describing a target to zoom to + * @typedef {DefaultZoomTarget| + * GeometryZoomTarget| + * LocationFinderZoomTarget| + * MapExtentZoomTarget| + * DataExtentZoomTarget| + * LayerDataExtentZoomTarget} ZoomTarget - An object describing a target to zoom to + */ +/** + * @typedef DefaultZoomTarget - Instructs Cadenza to use its default zoom mechanism. If no {@link ZoomTarget} is specified + * in an API call supporting this parameter then this also is the default behaviour of initial zooming. + * The map will zoom in the way the underlying workbook map view was configured to initially zoom (including all auto + * zooming configurations for the initial zoom). + * It will be overridden by zooming to the first result of a location finder query done with the value specified as + * 'locationFinder' parameter. + * And both will be overridden by zooming to the given 'mapExtent' parameter value. + * @property {'default'} type - The type of the zoom target */ /** - * @typedef GeometryZoomTarget - Instructs Cadenza to zoom to a provided {@Link Geometry} - * @property {'geometry'} type The type of the zoom target + * @typedef GeometryZoomTarget - Instructs Cadenza to zoom to a provided {@Link Geometry}. + * If no geometry is specified, the {@link DefaultZoomTarget} is used. + * @property {'geometry'} type - The type of the zoom target + * @property {Geometry} [__namedParameters.geometry] - The geometry to zoom to. This property overrides zooming to the geometry + * provided by the API call. If not specified, the geometry provided by the API call is used. + * If this also is not specified, the {@link DefaultZoomTarget} is used instead. + * @property {Geometry} [__namedParameters.useMapSrs] - Whether the geometry is specified in the map's SRS (otherwise EPSG:4326 is assumed) + */ +/** + * @typedef LocationFinderZoomTarget - Instructs Cadenza to zoom to the first result of a location finder search query. + * If there is no result after querying the locationFinder, the {@link DefaultZoomTarget} is used. + * @property {'locationFinder'} type - The type of the zoom target + * @property {string} [__namedParameters.searchQuery] - A search query for the location finder, the first result of which the map + * initially is zoomed when opening the map. This property overrides the API call parameter 'locationFinder'. + * If not specified, the value provided by the API call parameter 'locationFinder' is used. + * If this also is not specified, the {@link DefaultZoomTarget} is used instead. + */ +/** + * @typedef MapExtentZoomTarget - Instructs Cadenza to zoom to a specified map extent. + * If no map extent is specified, the {@link DefaultZoomTarget} is used instead. + * @property {'mapExtent'} type - The type of the zoom target + * @property {Extent} [__namedParameters.extent] - A map extent to which the map is initially zoomed when opened. This property + * overrides the API call parameter 'mapExtent'. + * If not specified, the value provided by the API call parameter 'mapExtent' is used. + * If this also is not specified, the {@link DefaultZoomTarget} is used instead. + */ +/** + * @typedef DataExtentZoomTarget - Instructs Cadenza to zoom to the data extent of all layers contained in the map for + * which the data extent can be calculated by Cadenza. + * If it is not possible for Cadenza to calculate the extent the {@link DefaultZoomTarget} is used for zooming instead. + * @property {'dataExtent'} type - The type of the zoom target + */ +/** + * @typedef LayerDataExtentZoomTarget - Instructs Cadenza to zoom to the extent of one or multiple layers. + * @property {'layerDataExtent'} type - The type of the zoom target + * @property {(WorkbookLayerPath | string)[]} layers - The workbook layer paths of the layers which should be considered + * for calculating the wanted extent. + * If it is not possible for Cadenza to calculate the extent of a specified layer (of multiple layers) or a specified + * layer (of multiple layers) is not available in the map, this layer is ignored when calculating the extent. + * If it is not possible for Cadenza to calculate the extent of any given layer the {@link DefaultZoomTarget} is used + * for zooming instead. */ /** @@ -209,7 +270,7 @@ export class CadenzaClient { /** * * @hidden - * @param {CadenzaClientOptions} [options] + * @param {CadenzaClientOptions} [__namedParameters] */ constructor({ baseUrl, debug = false, iframe, webApplication } = {}) { if (webApplication) { @@ -279,18 +340,18 @@ export class CadenzaClient { * Show a page, workbook, worksheet or workbook view in an iframe. * * @param {PageSource | EmbeddingTargetId} source - The source to show - * @param {object} [options] - * @param {DataType} [options.dataType] - Set to 'pdf' for views of type "JasperReports report" + * @param {object} [__namedParameters] + * @param {DataType} [__namedParameters.dataType] - Set to 'pdf' for views of type "JasperReports report" * to show the report PDF directly, without any Cadenza headers or footers. - * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable - * @param {boolean} [options.expandNavigator] - Indicates if the navigator should be expanded. - * @param {FilterVariables} [options.filter] - Filter variables - * @param {boolean} [options.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer - * @param {boolean} [options.hideWorkbookToolBar] - Whether to hide the workbook toolbar - * @param {GlobalId} [options.highlightGlobalId] - The ID of an item to highlight / expand in the navigator - * @param {String} [options.labelSet] - The name of a label set defined in the `basicweb-config.xml` (only supported for the welcome page) - * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated - * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading + * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable + * @param {boolean} [__namedParameters.expandNavigator] - Indicates if the navigator should be expanded. + * @param {FilterVariables} [__namedParameters.filter] - Filter variables + * @param {boolean} [__namedParameters.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer + * @param {boolean} [__namedParameters.hideWorkbookToolBar] - Whether to hide the workbook toolbar + * @param {GlobalId} [__namedParameters.highlightGlobalId] - The ID of an item to highlight / expand in the navigator + * @param {String} [__namedParameters.labelSet] - The name of a label set defined in the `basicweb-config.xml` (only supported for the welcome page) + * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated + * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading * @return {Promise} A `Promise` for when the iframe is loaded * @throws For invalid arguments * @fires @@ -341,8 +402,8 @@ export class CadenzaClient { /** * Reload the views of a worksheet. - * @param {object} [options] - Options - * @param {boolean} [options.invalidateCaches] - When true, caches will be invalidated for objecttypes used + * @param {object} [__namedParameters] - Options + * @param {boolean} [__namedParameters.invalidateCaches] - When true, caches will be invalidated for objecttypes used * in the worksheet * @postMessage */ @@ -365,20 +426,20 @@ export class CadenzaClient { * Show a workbook map view in an iframe. * * @param {EmbeddingTargetId} mapView - The workbook map view to show - * @param {object} [options] - Options - * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable - * @param {boolean} [options.expandNavigator] - Indicates if the navigator should be expanded. - * @param {FilterVariables} [options.filter] - Filter variables - * @param {Geometry} [options.geometry] - A geometry to show on the map - * @param {boolean} [options.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer - * @param {boolean} [options.hideWorkbookToolBar] - Whether to hide the workbook toolbar - * @param {GlobalId} [options.highlightGlobalId] - The ID of an item to highlight / expand in the navigator - * @param {string} [options.locationFinder] - A search query for the location finder - * @param {Extent} [options.mapExtent] - A map extent to set - * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated - * @param {boolean} [options.useMapSrs] - Whether the geometry and the extent are in the map's SRS (otherwise EPSG:4326 is assumed) - * @param {ZoomTarget} [options.zoomTarget] - A target Cadenza should zoom to - * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading + * @param {object} [__namedParameters] - Options + * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable + * @param {boolean} [__namedParameters.expandNavigator] - Indicates if the navigator should be expanded. + * @param {FilterVariables} [__namedParameters.filter] - Filter variables + * @param {Geometry} [__namedParameters.geometry] - A geometry to show on the map + * @param {boolean} [__namedParameters.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer + * @param {boolean} [__namedParameters.hideWorkbookToolBar] - Whether to hide the workbook toolbar + * @param {GlobalId} [__namedParameters.highlightGlobalId] - The ID of an item to highlight / expand in the navigator + * @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderZoomTarget} as {@link zoomTarget} instead. + * @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link MapExtentZoomTarget} as {@link zoomTarget} instead. + * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated + * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading + * @param {boolean} [__namedParameters.useMapSrs] - Whether the geometry and the extent are in the map's SRS (otherwise EPSG:4326 is assumed) + * @param {ZoomTarget} [__namedParameters.zoomTarget] - A target Cadenza should zoom to - If not specified, the {@link DefaultZoomTarget} is used. * @return {Promise} A `Promise` for when the iframe is loaded * @throws For invalid arguments * @fires @@ -408,7 +469,13 @@ export class CadenzaClient { if (geometry) { assertValidGeometryType(geometry.type); } - const zoomToGeometry = geometry && zoomTarget?.type === 'geometry'; + const validZoomTarget = createValidZoomTarget({ + geometry, + locationFinder, + mapExtent, + useMapSrs, + zoomTarget + }); const params = createParams({ disabledUiFeatures, expandNavigator, @@ -416,21 +483,22 @@ export class CadenzaClient { hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, - // only use locationFinder if zoom to geometry is not set, to avoid - // zooming race condition for Cadenza versions below 10.1 - locationFinder: zoomToGeometry ? undefined : locationFinder, + locationFinder, mapExtent, operationMode, targetType: 'MAP', useMapSrs, + validZoomTarget }); await this.#show(resolvePath(mapView), params, signal); if (geometry) { this.#postEvent('setGeometry', { geometry, - zoomToGeometry, }); } + if (isSetZoomTargetNeeded(validZoomTarget)) { + this.#postEvent('setZoomTarget', validZoomTarget); + } } /** @@ -540,13 +608,6 @@ export class CadenzaClient { }); } - /** - * @typedef LayerDefinition - * @property {string} name - The layer's name. - * @property {'geojson'} type - The layer's type. - * @property {FeatureCollection} content - The layer's content in geojson format. - */ - /** * Create a geometry. * @@ -555,16 +616,17 @@ export class CadenzaClient { * * @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background * @param {GeometryType} geometryType - The geometry type - * @param {object} [options] - Options - * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable - * @param {FilterVariables} [options.filter] - Filter variables - * @param {string} [options.locationFinder] - A search query for the location finder - * @param {Extent} [options.mapExtent] - A map extent to set - * @param {number} [options.minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold. - * @param {boolean} [options.useMapSrs] - Whether the created geometry should use the map's SRS (otherwise EPSG:4326 will be used) - * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated - * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading - * @param {LayerDefinition[]} [options.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing. + * @param {object} [__namedParameters] - Options + * @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing. + * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable + * @param {FilterVariables} [__namedParameters.filter] - Filter variables + * @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderZoomTarget} as {@link zoomTarget} instead. + * @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link MapExtentZoomTarget} as {@link zoomTarget} instead. + * @param {number} [__namedParameters.minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold. + * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated + * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading + * @param {boolean} [__namedParameters.useMapSrs] - Whether the created geometry should use the map's SRS (otherwise EPSG:4326 will be used) + * @param {ZoomTarget} [__namedParameters.zoomTarget] - A target Cadenza should zoom to - If not specified, the {@link DefaultZoomTarget} is used. * @return {Promise} A `Promise` for when the iframe is loaded * @throws For invalid arguments * @fires @@ -577,6 +639,7 @@ export class CadenzaClient { backgroundMapView, geometryType, { + additionalLayers, disabledUiFeatures, filter, locationFinder, @@ -585,10 +648,16 @@ export class CadenzaClient { useMapSrs, operationMode, signal, - additionalLayers, + zoomTarget } = {}, ) { this.#log('CadenzaClient#createGeometry', ...arguments); + const validZoomTarget = createValidZoomTarget({ + locationFinder, + mapExtent, + useMapSrs, + zoomTarget + }); const params = createParams({ action: 'editGeometry', disabledUiFeatures, @@ -597,14 +666,18 @@ export class CadenzaClient { locationFinder, mapExtent, minScale, - useMapSrs, operationMode, + useMapSrs, + validZoomTarget }); await this.#show(resolvePath(backgroundMapView), params, signal); if (additionalLayers) { - additionalLayers.forEach((layer) => - this.#postEvent('importLayer', layer), - ); + for (const layer of additionalLayers) { + await this.#postRequest('importLayer', layer); + } + } + if (isSetZoomTargetNeeded(validZoomTarget)) { + this.#postEvent('setZoomTarget', validZoomTarget); } } @@ -613,17 +686,17 @@ export class CadenzaClient { * * @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background * @param {Geometry} geometry - The geometry - * @param {object} [options] - Options - * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable - * @param {FilterVariables} [options.filter] - Filter variables - * @param {string} [options.locationFinder] - A search query for the location finder - * @param {Extent} [options.mapExtent] - A map extent to set - * @param {number} [options.minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold. - * @param {boolean} [options.useMapSrs] - Whether the geometry is in the map's SRS (otherwise EPSG:4326 is assumed) - * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated - * @param {ZoomTarget} [options.zoomTarget] - A target Cadenza should zoom to - * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading - * @param {LayerDefinition[]} [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). + * @param {object} [__namedParameters] - Options + * @param {LayerDefinition[]} [__namedParameters.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). + * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable + * @param {FilterVariables} [__namedParameters.filter] - Filter variables + * @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderZoomTarget} as {@link zoomTarget} instead. + * @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link MapExtentZoomTarget} as {@link zoomTarget} instead. + * @param {number} [__namedParameters.minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold. + * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated + * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading + * @param {boolean} [__namedParameters.useMapSrs] - Whether the geometry is in the map's SRS (otherwise EPSG:4326 is assumed) + * @param {ZoomTarget} [__namedParameters.zoomTarget] - A target Cadenza should zoom to - If not specified, the {@link DefaultZoomTarget} is used. * @return {Promise} A `Promise` for when the iframe is loaded * @throws For invalid arguments * @fires @@ -636,44 +709,51 @@ export class CadenzaClient { backgroundMapView, geometry, { + additionalLayers, disabledUiFeatures, filter, locationFinder, mapExtent, minScale, - useMapSrs, - zoomTarget, operationMode, signal, - additionalLayers, + useMapSrs, + zoomTarget, } = {}, ) { this.#log('CadenzaClient#editGeometry', ...arguments); assertValidGeometryType(geometry.type); - const zoomToGeometry = geometry && zoomTarget?.type === 'geometry'; + const validZoomTarget = createValidZoomTarget({ + geometry, + locationFinder, + mapExtent, + useMapSrs, + zoomTarget + }); const params = createParams({ action: 'editGeometry', disabledUiFeatures, filter, - // only use locationFinder if zoom to geometry is not set, to avoid - // zooming race condition for Cadenza versions below 10.1 - locationFinder: zoomToGeometry ? undefined : locationFinder, + locationFinder, mapExtent, minScale, - useMapSrs, operationMode, + useMapSrs, + validZoomTarget }); await this.#show(resolvePath(backgroundMapView), params, signal); if (geometry) { this.#postEvent('setGeometry', { - geometry, - zoomToGeometry, + geometry }); } if (additionalLayers) { - additionalLayers.forEach((layer) => - this.#postEvent('importLayer', layer), - ); + for (const layer of additionalLayers) { + await this.#postRequest('importLayer', layer); + } + } + if (isSetZoomTargetNeeded(validZoomTarget)) { + this.#postEvent('setZoomTarget', validZoomTarget); } } @@ -698,15 +778,15 @@ export class CadenzaClient { * Select objects in a workbook map. * * @param {EmbeddingTargetId} backgroundMapView - The workbook map view - * @param {object} [options] - Options - * @param {FilterVariables} [options.filter] - Filter variables - * @param {(WorkbookLayerPath | string)[]} [options.layers] - Layers to restrict the selection to + * @param {object} [__namedParameters] - Options + * @param {FilterVariables} [__namedParameters.filter] - Filter variables + * @param {(WorkbookLayerPath | string)[]} [__namedParameters.layers] - Layers to restrict the selection to * (identified using layer paths or print names) - * @param {string} [options.locationFinder] - A search query for the location finder - * @param {Extent} [options.mapExtent] - A map extent to set - * @param {boolean} [options.useMapSrs] - Whether the geometry is in the map's SRS (otherwise EPSG:4326 is assumed) - * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated - * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading + * @param {string} [__namedParameters.locationFinder] - A search query for the location finder + * @param {Extent} [__namedParameters.mapExtent] - A map extent to set + * @param {boolean} [__namedParameters.useMapSrs] - Whether the geometry is in the map's SRS (otherwise EPSG:4326 is assumed) + * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated + * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading * @return {Promise} A `Promise` for when the iframe is loaded * @throws For invalid arguments * @fires @@ -954,10 +1034,10 @@ export class CadenzaClient { * @param {DataType} dataType - The data type you want to get back from the server. * Currently, `"csv"`, `"excel"` and `"json"` are supported for table and indicator views * and `"pdf"` for views of type "JasperReports report". - * @param {object} [options] - Options - * @param {FilterVariables} [options.filter] - Filter variables - * @param {TablePart[]} [options.parts] - Table parts to export; If not specified, all parts are exported. - * @param {AbortSignal} [options.signal] - A signal to abort the data fetching + * @param {object} [__namedParameters] - Options + * @param {FilterVariables} [__namedParameters.filter] - Filter variables + * @param {TablePart[]} [__namedParameters.parts] - Table parts to export; If not specified, all parts are exported. + * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the data fetching * @return {Promise} A `Promise` for the fetch response * @throws For invalid arguments * @server @@ -976,11 +1056,11 @@ export class CadenzaClient { * @param {(WorkbookLayerPath | string)[]} layerPath - Layer path to identify the layer * (identified using layer paths or print names) * @param {unknown[][]} objectIds - The IDs of the objects to select - * @param {object} [options] - Options - * @param {FilterVariables} [options.filter] - Filter variables - * @param {AbortSignal} [options.signal] - A signal to abort the data fetching - * @param {Boolean} [options.useMapSrs] - Use the map SRS instead of WGS84 - * @param {Boolean} [options.fullGeometries] - Return non-simplified geometries + * @param {object} [__namedParameters] - Options + * @param {FilterVariables} [__namedParameters.filter] - Filter variables + * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the data fetching + * @param {Boolean} [__namedParameters.useMapSrs] - Use the map SRS instead of WGS84 + * @param {Boolean} [__namedParameters.fullGeometries] - Return non-simplified geometries * @return {Promise} A `Promise` for the fetch response * @throws For invalid arguments */ @@ -1014,10 +1094,10 @@ export class CadenzaClient { * @param {(WorkbookLayerPath | string)[]} layerPath - Layer path to identify the layer * (identified using layer paths or print names) * @param {Geometry} geometry - The intersection geometry - * @param {object} [options] - Options - * @param {boolean} [options.useMapSrs] - The intersection geometry and the result geometries are in the map's SRS (otherwise EPSG:4326 is assumed) - * @param {Distance} [options.buffer] - Buffer size for geometry of the transition - * @param {AbortSignal} [options.signal] - A signal to abort the data fetching + * @param {object} [__namedParameters] - Options + * @param {boolean} [__namedParameters.useMapSrs] - The intersection geometry and the result geometries are in the map's SRS (otherwise EPSG:4326 is assumed) + * @param {Distance} [__namedParameters.buffer] - Buffer size for geometry of the transition + * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the data fetching * @return {Promise} A `Promise` for the fetch response * @server */ @@ -1083,10 +1163,10 @@ export class CadenzaClient { * @param {DataType} dataType - The data type you want to get back from the server. * Currently, `"csv"`, `"excel"` and `"json"` are supported for table and indicator views * and `"pdf"` for views of type "JasperReports report". - * @param {object} [options] - Options - * @param {string} [options.fileName] - The file name to use; The file extension is appended by Cadenza. - * @param {FilterVariables} [options.filter] - Filter variables - * @param {TablePart[]} [options.parts] - Table parts to export; If not specified, all parts are exported. + * @param {object} [__namedParameters] - Options + * @param {string} [__namedParameters.fileName] - The file name to use; The file extension is appended by Cadenza. + * @param {FilterVariables} [__namedParameters.filter] - Filter variables + * @param {TablePart[]} [__namedParameters.parts] - Table parts to export; If not specified, all parts are exported. * @throws For invalid arguments * @server */ @@ -1266,6 +1346,7 @@ function assertSupportedDataType( * @param {TablePart[]} [params.parts] * @param {'MAP'} [params.targetType] * @param {boolean} [params.useMapSrs] + * @param {ZoomTarget | undefined} [params.validZoomTarget] * @return {URLSearchParams} */ function createParams({ @@ -1288,6 +1369,7 @@ function createParams({ parts, targetType, useMapSrs, + validZoomTarget }) { if (disabledUiFeatures) { disabledUiFeatures.forEach((feature) => @@ -1316,6 +1398,15 @@ function createParams({ assert(validTablePart(part), `Invalid table part: ${part}`), ); } + if (validZoomTarget) { + if (validZoomTarget.type === 'mapExtent') { + locationFinder = undefined; + mapExtent = validZoomTarget.extent; + } else if (validZoomTarget.type === 'locationFinder') { + mapExtent = undefined; + locationFinder = validZoomTarget.searchQuery; + } + } return new URLSearchParams({ ...(action && { action }), ...(dataType && { dataType }), @@ -1354,6 +1445,93 @@ function array(/** @type unknown */ value) { return Array.isArray(value) ? value : [value]; } +/** + * Depending on the input values create the zoomTarget to apply. + * + * In which priorization & order the zoomTarget is applied is explained in the description of the + * various possible {@link ZoomTarget} types. + * In short: + * - Fallback always is the {@link DefaultZoomTarget}, also when no {@link ZoomTarget} is specified (and the parameters + * 'locationFinder' and 'mapExtent' are specified). This means Cadenza default zooming behaviour applies (including + * auto zooming etc) + * - If no {@link ZoomTarget} is specified, the 'mapExtent' overrides the 'locationFinder' (implemented in Cadenza). + * - All other {@link ZoomTarget} types override the described mechanism, if they are specified correctly. This means + * the {@link GeometryZoomTarget} always needs a geometry to zoom on, the {@link MapExtentZoomTarget} always needs + * a mapExtent to zoom on, the {@link LocationFinderZoomTarget} always needs a query string and the {@link LayerDataExtentZoomTarget} + * always needs layer(s) to zoom on. If an incomplete configuration is specified or it cannot be applied on Cadenza side + * (i.e. if the query string of the locationFinder doesn't return a result), the {@link DefaultZoomTarget} is applied + * again. + * + * @param {object} __namedParameters + * @param {Geometry} [__namedParameters.geometry] + * @param {string} [__namedParameters.locationFinder] + * @param {Extent} [__namedParameters.mapExtent] + * @param {boolean} [__namedParameters.useMapSrs] + * @param {ZoomTarget} [__namedParameters.zoomTarget] + * @return {ZoomTarget | undefined} + */ +function createValidZoomTarget (__namedParameters = {}) { + if (Object.keys(__namedParameters).length === 0 || !__namedParameters.zoomTarget){ + return { type: 'default' }; + } + const zoomTarget = __namedParameters.zoomTarget; + if (zoomTarget.type === 'default') { + if (__namedParameters.mapExtent) { + return {type: 'mapExtent', extent: __namedParameters.mapExtent}; + } + if (__namedParameters.locationFinder) { + return {type: 'locationFinder', searchQuery: __namedParameters.locationFinder}; + } + return { type: 'default' }; + } else if (zoomTarget.type === 'mapExtent') { + if (zoomTarget.extent) { + return zoomTarget; + } + if (__namedParameters.mapExtent) { + return {type:'mapExtent', extent: __namedParameters.mapExtent} + } + return { type:'default'}; + } else if (zoomTarget.type === 'locationFinder') { + if (zoomTarget.searchQuery) { + return zoomTarget; + } + if (__namedParameters.locationFinder) { + return {type: 'locationFinder', searchQuery: __namedParameters.locationFinder}; + } + return {type: 'default'}; + } else if (zoomTarget.type === 'geometry') { + if (zoomTarget.geometry && validGeometryType(zoomTarget.geometry.type)) { + return zoomTarget; + } + if (__namedParameters.geometry) { + return {type: 'geometry', geometry: __namedParameters.geometry}; + } + return { type: 'default' }; + } else if (zoomTarget.type === 'layerDataExtent') { + if (!zoomTarget.layers || zoomTarget.layers.length === 0) { + return { type: 'default' }; + } + } + return zoomTarget; +} + +/** + * Checks whether or not we need to explicitely need to set a zoomTarget on the loaded map. + * It's not needed, when there is no {@link ZoomTarget} at all. + * And it's not needed, when the {@link DefaultZoomTarget} has to be applied. + * And it also isn't needed, when the {@link MapExtentZoomTarget} or {@link LocationFinderZoomTarget} + * has to be applied, because this is handled via parameters for now (so even if these are specified, + * the parameters will be filled with the value set in the zoomTarget and used by Cadenza). + * + * @param {ZoomTarget | undefined} zoomTargetToApply + */ +function isSetZoomTargetNeeded (zoomTargetToApply) { + return !!(zoomTargetToApply && + zoomTargetToApply.type !== 'default' && + zoomTargetToApply.type !== 'mapExtent' && + zoomTargetToApply.type !== 'locationFinder'); +} + // Please do not add internal event types like 'ready' here. /** * @typedef {'action' From bb07d4f15ce835b356e7eae08111fcbcfe2d0cf5 Mon Sep 17 00:00:00 2001 From: Alex <40277484+qulol@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:03:33 +0100 Subject: [PATCH 02/21] Slb/cadenza 37667 (#61) * CADENZA-37667 fix: update version in package-lock.json * CADENZA-37667 doc: typo * CADENZA-37667 doc: update docs * CADENZA-37667 doc: introduce Feature property: circumference, which was missing * CADENZA-37667 doc: adjusted CHANGELOG.md * CADENZA-37667 doc: better typing for Coordinate type * CADENZA-37667 doc: fix indent --- CHANGELOG.md | 9 +++++++++ src/cadenza.js | 11 ++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e59e569c..0905b5ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project uses a version scheme based on the Cadenza main version in the format x.x.y, where x.x is the Cadenza main version and y a functional change or bugfix. ## Unreleased +### Added +- `Feature#type` property. +- `Feature#circumference` property. +- `FeatureCollection#type` property +- `Geometry#coordinates` property + +### Changed +- **BREAKING CHANGE** `CadenzaEditGeometryUpdateEvent#detail` is now typed as `FeatureCollection | Feature | undefined`. (Before: `{ geometry: Geometry }`) +- `CadenzaEditGeometryOkEvent#detail` is now typed as `Feature` to align it with the rest of the API. (Before: `{ geometry: Geometry }`) ## 10.2.2 - 2024-10-24 ### Added diff --git a/src/cadenza.js b/src/cadenza.js index 2f9ffda1..ec53590d 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -125,9 +125,11 @@ globalThis.cadenza = Object.assign( * @typedef {'m'|'km'} LengthUnit */ +/** @typedef {[number, number]} Coordinate - A tuple with an x and y value */ /** * @typedef Geometry - A [GeoJSON](https://geojson.org/) geometry object * @property {GeometryType} type - The type of the geometry + * @property {Coordinate | Coordinate[] | Coordinate[][] | Coordinate[][][]} coordinates - The coordinates of the geometry */ /** * @typedef {'Point'|'MultiPoint'|'LineString'|'MultiLineString'|'Polygon'|'MultiPolygon'} GeometryType - A GeoJSON geometry type @@ -214,14 +216,17 @@ globalThis.cadenza = Object.assign( */ /** * @typedef Feature - A adapted [GeoJSON](https://geojson.org/) feature object. + * @property {'Feature'} type - The object's type * @property {any[]} objectId - The id of the feature * @property {Geometry} geometry - The geometry * @property {Record} properties - The formated properties * @property {number} [area] - The area of a `Polygon` feature - * @property {number} [length] - The area of a `LineString` feature + * @property {number} [circumference] - The circumference of a `Polygon` feature + * @property {number} [length] - The length of a `LineString` feature */ /** * @typedef FeatureCollection - A adapted [GeoJSON](https://geojson.org/) feature collection object + * @property {'FeatureCollection'} type - The object's type * @property {Feature[]} features - The features within this collection */ /** @typedef {'error'|'warning'|'info'|'success'} CustomValidityType - The type of custom validity used for disclose on visual presentation and form submission behavior */ @@ -1592,8 +1597,8 @@ function isSetZoomTargetNeeded (zoomTargetToApply) { *

* See also: JSON Representation of Cadenza Object Data */ -/** @typedef {CadenzaEvent<'editGeometry:update', {geometry: Geometry}>} CadenzaEditGeometryUpdateEvent - When the user changed the geometry. */ -/** @typedef {CadenzaEvent<'editGeometry:ok', {geometry: Geometry}>} CadenzaEditGeometryOkEvent - When the user submitted the geometry. */ +/** @typedef {CadenzaEvent<'editGeometry:update', FeatureCollection | Feature | undefined>} CadenzaEditGeometryUpdateEvent - When the user changed the geometry. `FeatureCollection` if multiple features are present on the edit layer, but the original defined type is not multi-geometry. This is also the case if the dialog was instantiated from a geometry and the original defined type is inherited. `undefined` if no feature is present on the edit layer. */ +/** @typedef {CadenzaEvent<'editGeometry:ok', Feature>} CadenzaEditGeometryOkEvent - When the user submitted the geometry. */ /** @typedef {CadenzaEvent<'editGeometry:cancel'>} CadenzaEditGeometryCancelEvent - When the user cancelled the geometry editing. */ /** @typedef {CadenzaEvent<'error', {type: string, message?: string}>} CadenzaErrorEvent - An error event that is mapped to a {@link CadenzaError} */ /** @typedef {CadenzaEvent<'objectInfo', {layer: WorkbookLayerPath, objectInfos: {selectionIndex: number, elements: {attributePrintName: string, formattedValue: string}[]}}>} CadenzaObjectInfoEvent - When the user opened the object info flyout. */ From 6d734e65709f4ed02a387f42b0f43c58a7708926 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 7 Nov 2024 14:22:01 +0000 Subject: [PATCH 03/21] chore: release 10.2.3 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0905b5ed..bf25729f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project uses a version scheme based on the Cadenza main version in the format x.x.y, where x.x is the Cadenza main version and y a functional change or bugfix. ## Unreleased + +## 10.2.3 - 2024-11-07 ### Added - `Feature#type` property. - `Feature#circumference` property. diff --git a/package.json b/package.json index 6605de26..489e8b7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@disy/cadenza.js", - "version": "10.2.3-dev", + "version": "10.2.3", "license": "Apache-2.0", "repository": "github:DisyInformationssysteme/cadenza.js", "type": "module", From dac77566c6ba05c0e5c98d797734f5e8d4fdae0c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 7 Nov 2024 14:22:02 +0000 Subject: [PATCH 04/21] chore: bump up version to 10.2.4-dev --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 489e8b7c..60e303c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@disy/cadenza.js", - "version": "10.2.3", + "version": "10.2.4-dev", "license": "Apache-2.0", "repository": "github:DisyInformationssysteme/cadenza.js", "type": "module", From d0f5d30663fb6332de1139a1bc55be136192b00e Mon Sep 17 00:00:00 2001 From: Johannes Kissel Date: Thu, 7 Nov 2024 15:48:15 +0100 Subject: [PATCH 05/21] undo broken release --- CHANGELOG.md | 2 -- package.json | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf25729f..0905b5ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project uses a version scheme based on the Cadenza main version in the format x.x.y, where x.x is the Cadenza main version and y a functional change or bugfix. ## Unreleased - -## 10.2.3 - 2024-11-07 ### Added - `Feature#type` property. - `Feature#circumference` property. diff --git a/package.json b/package.json index 60e303c9..6605de26 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@disy/cadenza.js", - "version": "10.2.4-dev", + "version": "10.2.3-dev", "license": "Apache-2.0", "repository": "github:DisyInformationssysteme/cadenza.js", "type": "module", From 2913f2ebb7f7510db1cf62fd9197afbab802b82a Mon Sep 17 00:00:00 2001 From: Sebastian Barth Date: Thu, 7 Nov 2024 15:59:09 +0100 Subject: [PATCH 06/21] TENT-5976 fix: Release to NPM before bumping up project version to next dev version (#64) --- .github/workflows/release.yml | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 94f8fb69..abfc8eb4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -57,17 +57,6 @@ jobs: git commit -m "chore: release ${{ env.RELEASE_VERSION }}" git tag ${{ env.RELEASE_VERSION }} - - name: Bump package version to new dev version (e.g. 1.2.3 => 1.2.4-dev) - run: | - npm --no-git-tag-version version patch # Determine next release version - DEV_VERSION=$(npm pkg get version | tr -d \")-dev && echo "DEV_VERSION=$DEV_VERSION" >> $GITHUB_ENV # Determine DEV_VERSION with -dev suffix - npm --no-git-tag-version version $DEV_VERSION # Set main to $DEV_VERSION - - - name: Commit version bump - run: | - git add "package.json" - git commit -m "chore: bump up version to ${{ env.DEV_VERSION }}" - - name: Push changes env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -95,3 +84,19 @@ jobs: npm publish --verbose --access=public --tag=${{ env.RELEASE_TAG }} env: NPM_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }} + + - name: Bump package version to new dev version (e.g. 1.2.3 => 1.2.4-dev) + run: | + npm --no-git-tag-version version patch # Determine next release version + DEV_VERSION=$(npm pkg get version | tr -d \")-dev && echo "DEV_VERSION=$DEV_VERSION" >> $GITHUB_ENV # Determine DEV_VERSION with -dev suffix + npm --no-git-tag-version version $DEV_VERSION # Set main to $DEV_VERSION + + - name: Commit version bump + run: | + git add "package.json" + git commit -m "chore: bump up version to ${{ env.DEV_VERSION }}" + + - name: Push changes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: git push origin From faabf5dfd523737e7d788712c74e1ac1c09268de Mon Sep 17 00:00:00 2001 From: barth Date: Thu, 7 Nov 2024 16:53:26 +0100 Subject: [PATCH 07/21] TENT-5976 fix: Also commit changes to package-log.json after version bumps in release workflow --- .github/workflows/branchOffCadenzaVersion.yml | 1 + .github/workflows/release.yml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/branchOffCadenzaVersion.yml b/.github/workflows/branchOffCadenzaVersion.yml index b2c6ba81..7eed9aa8 100644 --- a/.github/workflows/branchOffCadenzaVersion.yml +++ b/.github/workflows/branchOffCadenzaVersion.yml @@ -58,6 +58,7 @@ jobs: - name: Commit and tag changes run: | git add "package.json" + git add "package-lock.json" git commit -m "chore: branch off main as ${{ env.BRANCH_NAME }} and bump main version to ${{ env.NEW_VERSION }}" - name: Push changes diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index abfc8eb4..f1de3320 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,6 +53,7 @@ jobs: - name: Commit release and tag it run: | git add "package.json" + git add "package-lock.json" git add "CHANGELOG.md" git commit -m "chore: release ${{ env.RELEASE_VERSION }}" git tag ${{ env.RELEASE_VERSION }} @@ -94,6 +95,7 @@ jobs: - name: Commit version bump run: | git add "package.json" + git add "package-lock.json" git commit -m "chore: bump up version to ${{ env.DEV_VERSION }}" - name: Push changes From 3949d270096adc6a74ecd3fd2f1547219f2a62eb Mon Sep 17 00:00:00 2001 From: barth Date: Thu, 7 Nov 2024 17:52:53 +0100 Subject: [PATCH 08/21] TENT-5976 fix: Use v prefix for tags and release upload on GitHub --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f1de3320..0cb3d92c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,7 +56,7 @@ jobs: git add "package-lock.json" git add "CHANGELOG.md" git commit -m "chore: release ${{ env.RELEASE_VERSION }}" - git tag ${{ env.RELEASE_VERSION }} + git tag v${{ env.RELEASE_VERSION }} - name: Push changes env: @@ -74,7 +74,7 @@ jobs: - name: Update GitHub release documentation uses: softprops/action-gh-release@v1 with: - tag_name: ${{ env.RELEASE_VERSION }} + tag_name: v${{ env.RELEASE_VERSION }} body: ${{ steps.get-changelog.outputs.changelog }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -82,7 +82,7 @@ jobs: - name: Publish npm package run: | npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" - npm publish --verbose --access=public --tag=${{ env.RELEASE_TAG }} + npm publish --verbose --access=public --tag=v${{ env.RELEASE_TAG }} env: NPM_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }} From 9ff7d71030daf5ef293a37fcfd164ebd0572418b Mon Sep 17 00:00:00 2001 From: barth Date: Wed, 6 Nov 2024 09:26:40 +0100 Subject: [PATCH 09/21] CADENZA-37830 CADENZA-37929 feat: Document support to show, fetch and download reports generated from report template embedding targets as PDF --- CHANGELOG.md | 1 + sandbox.html | 8 ++++---- src/cadenza.js | 15 +++++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0905b5ed..0afaacf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This project uses a version scheme based on the Cadenza main version in the form - `Feature#circumference` property. - `FeatureCollection#type` property - `Geometry#coordinates` property +- Documentation for how to show, fetch and download embedding targets of type report as PDF (via the existing dataType=pdf option). ### Changed - **BREAKING CHANGE** `CadenzaEditGeometryUpdateEvent#detail` is now typed as `FeatureCollection | Feature | undefined`. (Before: `{ geometry: Geometry }`) diff --git a/sandbox.html b/sandbox.html index 41cdb9c2..7769cd9b 100644 --- a/sandbox.html +++ b/sandbox.html @@ -219,7 +219,7 @@ hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, - jasperReportAsPdf, + requestAsPdf, labelSet, locationFinder, mapExtent, @@ -243,7 +243,7 @@ hideMainHeaderAndFooter: (hideMainHeaderAndFooter === 'on'), hideWorkbookToolBar: (hideWorkbookToolBar === 'on'), highlightGlobalId, - ...(jasperReportAsPdf === 'on' && { dataType: 'pdf' }), + ...(requestAsPdf === 'on' && { dataType: 'pdf' }), labelSet, locationFinder, mapExtent: mapExtent && mapExtent.split(',').map(Number), @@ -440,8 +440,8 @@

diff --git a/src/cadenza.js b/src/cadenza.js index ec53590d..5239fecb 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -346,8 +346,9 @@ export class CadenzaClient { * * @param {PageSource | EmbeddingTargetId} source - The source to show * @param {object} [__namedParameters] - * @param {DataType} [__namedParameters.dataType] - Set to 'pdf' for views of type "JasperReports report" - * to show the report PDF directly, without any Cadenza headers or footers. + * @param {DataType} [__namedParameters.dataType] - Set to 'pdf' for embedding targets of type report and of views with view + * type of "JasperReports report" to show the generated report PDF directly (without any Cadenza headers or + * footers). * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable * @param {boolean} [__namedParameters.expandNavigator] - Indicates if the navigator should be expanded. * @param {FilterVariables} [__namedParameters.filter] - Filter variables @@ -1037,8 +1038,9 @@ export class CadenzaClient { * * @param {EmbeddingTargetId} source - The workbook view to fetch data from. * @param {DataType} dataType - The data type you want to get back from the server. - * Currently, `"csv"`, `"excel"` and `"json"` are supported for table and indicator views - * and `"pdf"` for views of type "JasperReports report". + * Currently, `"csv"`, `"excel"` and `"json"` are supported for embedding targets of type view with a view type of + * table and indicator. `"pdf"` is supported for embedding targets of type report and of type view with a view type + * of "JasperReports report". * @param {object} [__namedParameters] - Options * @param {FilterVariables} [__namedParameters.filter] - Filter variables * @param {TablePart[]} [__namedParameters.parts] - Table parts to export; If not specified, all parts are exported. @@ -1166,8 +1168,9 @@ export class CadenzaClient { * * @param {EmbeddingTargetId} source - The workbook view to fetch data from. * @param {DataType} dataType - The data type you want to get back from the server. - * Currently, `"csv"`, `"excel"` and `"json"` are supported for table and indicator views - * and `"pdf"` for views of type "JasperReports report". + * Currently, `"csv"`, `"excel"` and `"json"` are supported for embedding targets of type view with a view type of + * table and indicator. `"pdf"` is supported for embedding targets of type report and of type view with a view type + * of "JasperReports report". * @param {object} [__namedParameters] - Options * @param {string} [__namedParameters.fileName] - The file name to use; The file extension is appended by Cadenza. * @param {FilterVariables} [__namedParameters.filter] - Filter variables From 5297e90670d318998a03bf2cb1fe674cc2731a8d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 8 Nov 2024 10:02:52 +0000 Subject: [PATCH 10/21] chore: release 10.2.3 --- CHANGELOG.md | 2 ++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0afaacf0..5aff67e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project uses a version scheme based on the Cadenza main version in the format x.x.y, where x.x is the Cadenza main version and y a functional change or bugfix. ## Unreleased + +## 10.2.3 - 2024-11-08 ### Added - `Feature#type` property. - `Feature#circumference` property. diff --git a/package-lock.json b/package-lock.json index 6099e355..cfd8b839 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@disy/cadenza.js", - "version": "10.2.3-dev", + "version": "10.2.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@disy/cadenza.js", - "version": "10.2.3-dev", + "version": "10.2.3", "license": "Apache-2.0", "devDependencies": { "@types/jest": "29.5.12", diff --git a/package.json b/package.json index 6605de26..489e8b7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@disy/cadenza.js", - "version": "10.2.3-dev", + "version": "10.2.3", "license": "Apache-2.0", "repository": "github:DisyInformationssysteme/cadenza.js", "type": "module", From 0a3e3e304f9d1f1bdcdec5fe5e9315423d217dd0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 8 Nov 2024 10:02:58 +0000 Subject: [PATCH 11/21] chore: bump up version to 10.2.4-dev --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index cfd8b839..94787eb5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@disy/cadenza.js", - "version": "10.2.3", + "version": "10.2.4-dev", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@disy/cadenza.js", - "version": "10.2.3", + "version": "10.2.4-dev", "license": "Apache-2.0", "devDependencies": { "@types/jest": "29.5.12", diff --git a/package.json b/package.json index 489e8b7c..60e303c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@disy/cadenza.js", - "version": "10.2.3", + "version": "10.2.4-dev", "license": "Apache-2.0", "repository": "github:DisyInformationssysteme/cadenza.js", "type": "module", From fd2f73d5a2b80dfa8a75b1ec529698dbc0f2d184 Mon Sep 17 00:00:00 2001 From: barth Date: Fri, 8 Nov 2024 11:32:15 +0100 Subject: [PATCH 12/21] TENT-5976 fix: Remove v prefix for NPM RELEASE_TAG --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0cb3d92c..bc65cf0f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,7 +82,7 @@ jobs: - name: Publish npm package run: | npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" - npm publish --verbose --access=public --tag=v${{ env.RELEASE_TAG }} + npm publish --verbose --access=public --tag=${{ env.RELEASE_TAG }} env: NPM_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }} From cc08b7e6049306f8c7cafcc3273484f5fa74ff95 Mon Sep 17 00:00:00 2001 From: schmidt Date: Tue, 19 Nov 2024 17:21:20 +0100 Subject: [PATCH 13/21] CADENZA-37531 and CADENZA-38242: - Fix CadenzaClientOptions to use options again instead of __namedParameter --- src/cadenza.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cadenza.js b/src/cadenza.js index 5239fecb..c626a2e7 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -1,21 +1,21 @@ /** * @typedef CadenzaClientOptions * @property {string} [baseUrl] - The base URL of the Cadenza server - * @property {HTMLIFrameElement | string} [__namedParameters.iframe] - An iframe for embedding Cadenza or the iframe's ID. + * @property {HTMLIFrameElement | string} [options.iframe] - An iframe for embedding Cadenza or the iframe's ID. * The iframe is required only for methods that embed Cadenza in an iframe, so e.g. not for {@link CadenzaClient#fetchData}. * If you want to embed Cadenza in multiple iframes, you need to create an instance of the `CadenzaClient` per iframe. - * @property {ExternalLinkKey} [__namedParameters.webApplication] - An external link that Cadenza uses to resolve the + * @property {ExternalLinkKey} [options.webApplication] - An external link that Cadenza uses to resolve the * [target origin](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#targetorigin) when posting events. * This is required if Cadenza and your application are not running on the same origin. * Please ensure that the user has view privilege for that link! - * @property {boolean} [__namedParameters.debug] - Whether to enable debug logging + * @property {boolean} [options.debug] - Whether to enable debug logging */ /** * Creates an instance of the Cadenza JS client. * * @overload - * @param {CadenzaClientOptions} [__namedParameters] - Options + * @param {CadenzaClientOptions} [options] - Options * @return {CadenzaClient} * @throws For invalid arguments */ @@ -26,20 +26,20 @@ * Please use the other overload. * @overload * @param {string} baseUrl - The base URL of the Cadenza server - * @param {Exclude} [__namedParameters] - Options + * @param {Exclude} [options] - Options * @return {CadenzaClient} * @throws For invalid arguments */ /** * @param {string | CadenzaClientOptions} [baseUrlOrOptions] - * @param {CadenzaClientOptions} [__namedParameters] + * @param {CadenzaClientOptions} [options] */ -export function cadenza(baseUrlOrOptions, __namedParameters) { - __namedParameters = +export function cadenza(baseUrlOrOptions, options) { + options = typeof baseUrlOrOptions === 'string' - ? { baseUrl: baseUrlOrOptions, ...__namedParameters } + ? { baseUrl: baseUrlOrOptions, ...options } : baseUrlOrOptions; - return new CadenzaClient(__namedParameters); + return new CadenzaClient(options); } /* @ts-ignore */ From 352baecc11aa10c7b956d0e5b89d5e83c1cf82b7 Mon Sep 17 00:00:00 2001 From: schmidt Date: Tue, 19 Nov 2024 17:51:57 +0100 Subject: [PATCH 14/21] CADENZA-37531 and CADENZA-38242: - Ran prettier now - Added Changelog entries --- CHANGELOG.md | 16 +++++++++++++++ src/cadenza.js | 53 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 48 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5aff67e7..952ca455 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,22 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project uses a version scheme based on the Cadenza main version in the format x.x.y, where x.x is the Cadenza main version and y a functional change or bugfix. ## Unreleased +### Added +- Multiple `ZoomTarget` types added + +### Deprecated +- The optional zooming parameters `locationFinder` and `mapExtent` in `CadenzaClient#showMap`, `CadenzaClient#createGeometry` and `CadenzaClient#editGeometry` + +## 10.2.3 - 2024-11-07 +### Added +- `Feature#type` property. +- `Feature#circumference` property. +- `FeatureCollection#type` property +- `Geometry#coordinates` property + +### Changed +- **BREAKING CHANGE** `CadenzaEditGeometryUpdateEvent#detail` is now typed as `FeatureCollection | Feature | undefined`. (Before: `{ geometry: Geometry }`) +- `CadenzaEditGeometryOkEvent#detail` is now typed as `Feature` to align it with the rest of the API. (Before: `{ geometry: Geometry }`) ## 10.2.3 - 2024-11-08 ### Added diff --git a/src/cadenza.js b/src/cadenza.js index c626a2e7..fc84926c 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -480,7 +480,7 @@ export class CadenzaClient { locationFinder, mapExtent, useMapSrs, - zoomTarget + zoomTarget, }); const params = createParams({ disabledUiFeatures, @@ -494,7 +494,7 @@ export class CadenzaClient { operationMode, targetType: 'MAP', useMapSrs, - validZoomTarget + validZoomTarget, }); await this.#show(resolvePath(mapView), params, signal); if (geometry) { @@ -654,7 +654,7 @@ export class CadenzaClient { useMapSrs, operationMode, signal, - zoomTarget + zoomTarget, } = {}, ) { this.#log('CadenzaClient#createGeometry', ...arguments); @@ -662,7 +662,7 @@ export class CadenzaClient { locationFinder, mapExtent, useMapSrs, - zoomTarget + zoomTarget, }); const params = createParams({ action: 'editGeometry', @@ -674,7 +674,7 @@ export class CadenzaClient { minScale, operationMode, useMapSrs, - validZoomTarget + validZoomTarget, }); await this.#show(resolvePath(backgroundMapView), params, signal); if (additionalLayers) { @@ -734,7 +734,7 @@ export class CadenzaClient { locationFinder, mapExtent, useMapSrs, - zoomTarget + zoomTarget, }); const params = createParams({ action: 'editGeometry', @@ -745,12 +745,12 @@ export class CadenzaClient { minScale, operationMode, useMapSrs, - validZoomTarget + validZoomTarget, }); await this.#show(resolvePath(backgroundMapView), params, signal); if (geometry) { this.#postEvent('setGeometry', { - geometry + geometry, }); } if (additionalLayers) { @@ -1377,7 +1377,7 @@ function createParams({ parts, targetType, useMapSrs, - validZoomTarget + validZoomTarget, }) { if (disabledUiFeatures) { disabledUiFeatures.forEach((feature) => @@ -1478,17 +1478,23 @@ function array(/** @type unknown */ value) { * @param {ZoomTarget} [__namedParameters.zoomTarget] * @return {ZoomTarget | undefined} */ -function createValidZoomTarget (__namedParameters = {}) { - if (Object.keys(__namedParameters).length === 0 || !__namedParameters.zoomTarget){ +function createValidZoomTarget(__namedParameters = {}) { + if ( + Object.keys(__namedParameters).length === 0 || + !__namedParameters.zoomTarget + ) { return { type: 'default' }; } const zoomTarget = __namedParameters.zoomTarget; if (zoomTarget.type === 'default') { if (__namedParameters.mapExtent) { - return {type: 'mapExtent', extent: __namedParameters.mapExtent}; + return { type: 'mapExtent', extent: __namedParameters.mapExtent }; } if (__namedParameters.locationFinder) { - return {type: 'locationFinder', searchQuery: __namedParameters.locationFinder}; + return { + type: 'locationFinder', + searchQuery: __namedParameters.locationFinder, + }; } return { type: 'default' }; } else if (zoomTarget.type === 'mapExtent') { @@ -1496,23 +1502,26 @@ function createValidZoomTarget (__namedParameters = {}) { return zoomTarget; } if (__namedParameters.mapExtent) { - return {type:'mapExtent', extent: __namedParameters.mapExtent} + return { type: 'mapExtent', extent: __namedParameters.mapExtent }; } - return { type:'default'}; + return { type: 'default' }; } else if (zoomTarget.type === 'locationFinder') { if (zoomTarget.searchQuery) { return zoomTarget; } if (__namedParameters.locationFinder) { - return {type: 'locationFinder', searchQuery: __namedParameters.locationFinder}; + return { + type: 'locationFinder', + searchQuery: __namedParameters.locationFinder, + }; } - return {type: 'default'}; + return { type: 'default' }; } else if (zoomTarget.type === 'geometry') { if (zoomTarget.geometry && validGeometryType(zoomTarget.geometry.type)) { return zoomTarget; } if (__namedParameters.geometry) { - return {type: 'geometry', geometry: __namedParameters.geometry}; + return { type: 'geometry', geometry: __namedParameters.geometry }; } return { type: 'default' }; } else if (zoomTarget.type === 'layerDataExtent') { @@ -1533,11 +1542,13 @@ function createValidZoomTarget (__namedParameters = {}) { * * @param {ZoomTarget | undefined} zoomTargetToApply */ -function isSetZoomTargetNeeded (zoomTargetToApply) { - return !!(zoomTargetToApply && +function isSetZoomTargetNeeded(zoomTargetToApply) { + return !!( + zoomTargetToApply && zoomTargetToApply.type !== 'default' && zoomTargetToApply.type !== 'mapExtent' && - zoomTargetToApply.type !== 'locationFinder'); + zoomTargetToApply.type !== 'locationFinder' + ); } // Please do not add internal event types like 'ready' here. From 1f8afe7c881663a17c1ae8faf398cf3a8774f8b0 Mon Sep 17 00:00:00 2001 From: schmidt Date: Tue, 19 Nov 2024 17:55:12 +0100 Subject: [PATCH 15/21] CADENZA-37531 and CADENZA-38242: - Remove duplicated Changelog entry --- CHANGELOG.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 952ca455..e890a944 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,17 +11,6 @@ This project uses a version scheme based on the Cadenza main version in the form ### Deprecated - The optional zooming parameters `locationFinder` and `mapExtent` in `CadenzaClient#showMap`, `CadenzaClient#createGeometry` and `CadenzaClient#editGeometry` -## 10.2.3 - 2024-11-07 -### Added -- `Feature#type` property. -- `Feature#circumference` property. -- `FeatureCollection#type` property -- `Geometry#coordinates` property - -### Changed -- **BREAKING CHANGE** `CadenzaEditGeometryUpdateEvent#detail` is now typed as `FeatureCollection | Feature | undefined`. (Before: `{ geometry: Geometry }`) -- `CadenzaEditGeometryOkEvent#detail` is now typed as `Feature` to align it with the rest of the API. (Before: `{ geometry: Geometry }`) - ## 10.2.3 - 2024-11-08 ### Added - `Feature#type` property. From 5a2689ccad9265921764936edddfcd9971a36c56 Mon Sep 17 00:00:00 2001 From: schmidt Date: Wed, 20 Nov 2024 10:37:24 +0100 Subject: [PATCH 16/21] CADENZA-37531 and CADENZA-38242: - Add overriding of locationFinder by mapExtent also explicitely in the code like it was before the story CADENZA-37531 --- src/cadenza.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cadenza.js b/src/cadenza.js index fc84926c..26457ba6 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -1413,6 +1413,8 @@ function createParams({ } else if (validZoomTarget.type === 'locationFinder') { mapExtent = undefined; locationFinder = validZoomTarget.searchQuery; + } else if (validZoomTarget.type === 'default' && mapExtent) { + locationFinder = undefined; } } return new URLSearchParams({ From 1811f722a89bb830238184d65b896b7e2093ffb5 Mon Sep 17 00:00:00 2001 From: schmidt Date: Wed, 20 Nov 2024 17:03:34 +0100 Subject: [PATCH 17/21] CADENZA-37531 and CADENZA-38242: - Fix handling useMapSrs parameter for creating a valid GeometryZoomTarget --- src/cadenza.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cadenza.js b/src/cadenza.js index 26457ba6..19b03d2a 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -163,7 +163,7 @@ globalThis.cadenza = Object.assign( * @property {Geometry} [__namedParameters.geometry] - The geometry to zoom to. This property overrides zooming to the geometry * provided by the API call. If not specified, the geometry provided by the API call is used. * If this also is not specified, the {@link DefaultZoomTarget} is used instead. - * @property {Geometry} [__namedParameters.useMapSrs] - Whether the geometry is specified in the map's SRS (otherwise EPSG:4326 is assumed) + * @property {boolean} [__namedParameters.useMapSrs] - Whether the geometry is specified in the map's SRS (otherwise EPSG:4326 is assumed) */ /** * @typedef LocationFinderZoomTarget - Instructs Cadenza to zoom to the first result of a location finder search query. @@ -1523,7 +1523,11 @@ function createValidZoomTarget(__namedParameters = {}) { return zoomTarget; } if (__namedParameters.geometry) { - return { type: 'geometry', geometry: __namedParameters.geometry }; + return { + type: 'geometry', + geometry: __namedParameters.geometry, + useMapSrs: __namedParameters.useMapSrs, + }; } return { type: 'default' }; } else if (zoomTarget.type === 'layerDataExtent') { From 3656ef81550313c1d6ad0cdfab704236341cea56 Mon Sep 17 00:00:00 2001 From: schmidt Date: Thu, 21 Nov 2024 17:08:45 +0100 Subject: [PATCH 18/21] CADENZA-37531 and CADENZA-38242: - Change Sandbox to be usable with all supported ZoomTargets --- CHANGELOG.md | 1 + sandbox.html | 56 ++++++++++++++++++++++++++++++---------------------- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e890a944..afa5660f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This project uses a version scheme based on the Cadenza main version in the form ## Unreleased ### Added - Multiple `ZoomTarget` types added +- Added the 'ZoomTarget' also to the sandbox ### Deprecated - The optional zooming parameters `locationFinder` and `mapExtent` in `CadenzaClient#showMap`, `CadenzaClient#createGeometry` and `CadenzaClient#editGeometry` diff --git a/sandbox.html b/sandbox.html index 7769cd9b..91e70cc1 100644 --- a/sandbox.html +++ b/sandbox.html @@ -1,5 +1,5 @@ - + @@ -39,6 +39,7 @@ display: flex; flex-direction: column; gap: var(--gap); + overflow: scroll; } fieldset > div { display: flex; @@ -121,7 +122,7 @@ settingsContainer.append( document.createElement('hr'), commonSettingsTemplate.content.cloneNode(true)); - }) + }); } const data = localStorage.getItem(`cadenzajs-sandbox-${action}`); @@ -193,7 +194,7 @@ localStorage.setItem(`cadenzajs-sandbox-${action}`, JSON.stringify(data)); }; - actionSelect.classList.toggle('show-unpublished', urlParams.has('showUnpublished')) + actionSelect.classList.toggle('show-unpublished', urlParams.has('showUnpublished')); actionSelect.value = urlParams.get('action') || 'show'; actionSelect.onchange(); @@ -221,15 +222,13 @@ highlightGlobalId, requestAsPdf, labelSet, - locationFinder, - mapExtent, minScale, parts, layers, simplifiedOperationMode, useMapSrs, fullGeometries, - zoomToGeometry, + zoomTarget, distance, lengthUnit, additionalLayers @@ -245,15 +244,13 @@ highlightGlobalId, ...(requestAsPdf === 'on' && { dataType: 'pdf' }), labelSet, - locationFinder, - mapExtent: mapExtent && mapExtent.split(',').map(Number), minScale: minScale && Number(minScale), parts: parts && parts.split(','), operationMode: (simplifiedOperationMode === 'on' ? 'simplified' : 'normal' ), layers: layers ? JSON.parse(layers) : undefined, useMapSrs: useMapSrs === 'on', fullGeometries: fullGeometries === 'on', - zoomTarget: zoomToGeometry === 'on' ? { type: 'geometry' } : undefined, + zoomTarget: zoomTarget && JSON.parse(zoomTarget), buffer: distance ? { value: Number(distance), lengthUnit: lengthUnit ? lengthUnit : 'm' } : undefined, additionalLayers: additionalLayers && JSON.parse(additionalLayers) }; @@ -399,14 +396,6 @@ Use map SRS -
- - -
-
- - -
-