From c6edbfa17b808dd7ba06a05f687c43369571582b Mon Sep 17 00:00:00 2001 From: linaker Date: Fri, 27 Oct 2023 10:57:27 +0200 Subject: [PATCH 1/5] Introduce support for new parameters "operationMode" and "disabledUiFeatures" --- README.md | 20 ++++++++++++++++++++ sandbox.html | 14 +++++++++++++- src/cadenza.js | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 09c53e11..4bfd9880 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,26 @@ cadenzaClient.show('{embeddingTargetId}', { }); ``` +#### Show an Embedding Target in Simplified Operation Mode + +Workbook embedding targets can be shown with simplified operation mode enabled by setting the "operationMode" option to "simplified". + +```javascript +cadenzaClient.show('{embeddingTargetId}', { + operationMode: 'simplified' +}); +``` + +#### Show an Embedding Target with Disabled Features + +Embedding targets can be shown with certain UI features disabled. To disable the designer, add "workbook-design" to the "disabledUiFeatures" option. To disable editing of workbook layout and design, add "workbook-view-management". + +```javascript +cadenzaClient.show('{embeddingTargetId}', { + disabledUiFeatures: ['workbook-design', 'workbook-view-management'] +}); +``` + ### Abort (Iframe) Loading Cadenza JS uses the [AbortController Web API](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) for aborting requests. This is supported by most of the public methods. diff --git a/sandbox.html b/sandbox.html index 81de7ddc..ffab13d8 100644 --- a/sandbox.html +++ b/sandbox.html @@ -70,12 +70,14 @@ const cadenzaClient = cadenza(location.origin + '/trunk', { iframe: 'iframe', debug: true }); const actionHandlers = { - show ({ embeddingTargetId, hideMainHeaderAndFooter, hideWorkbookToolBar, jasperReportAsPdf, highlightGlobalId }) { + show ({ embeddingTargetId, hideMainHeaderAndFooter, hideWorkbookToolBar, jasperReportAsPdf, highlightGlobalId, operationMode, disabledUiFeatures }) { cadenzaClient.show(embeddingTargetId, { hideMainHeaderAndFooter: (hideMainHeaderAndFooter === 'on'), hideWorkbookToolBar: (hideWorkbookToolBar === 'on'), highlightGlobalId, ...(jasperReportAsPdf === 'on' && { mediaType: 'application/pdf' }), + operationMode: operationMode === 'on' ? 'simplified' : 'normal', + disabledUiFeatures: disabledUiFeatures && disabledUiFeatures.split(',') }); }, showMap ({ embeddingTargetId, useMapSrs, geometry, mapExtent, locationFinder, highlightGlobalId }) { @@ -189,10 +191,20 @@ Hide workbook toolbar +
+ +
+
+ + +
From 6b97e0aff2c18612bbab4dc08c3cabfc25648e88 Mon Sep 17 00:00:00 2001 From: linaker Date: Fri, 3 Nov 2023 15:23:20 +0100 Subject: [PATCH 3/5] Various improvements from code review --- README.md | 24 +++--------------------- src/cadenza.js | 13 +++++++------ 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 4bfd9880..568ce405 100644 --- a/README.md +++ b/README.md @@ -65,12 +65,14 @@ const cadenza = window.cadenza.noConflict(); API: [CadenzaClient#show](./classes/CadenzaClient.html#show) -Show an embedding target in an iframe and hide Cadenza's main header and footer as well as the workbook toolbar: +Show an embedding target in an iframe and hide Cadenza's main header and footer as well as the workbook toolbar. Additionally, enable simplified operation mode and disable the designer. ```javascript cadenzaClient.show('{embeddingTargetId}', { hideMainHeaderAndFooter: true, hideWorkbookToolBar: true, + operationMode: 'simplified', + disabledUiFeatures: ['workbook-design'] }); ``` @@ -87,26 +89,6 @@ cadenzaClient.show('{embeddingTargetId}', { }); ``` -#### Show an Embedding Target in Simplified Operation Mode - -Workbook embedding targets can be shown with simplified operation mode enabled by setting the "operationMode" option to "simplified". - -```javascript -cadenzaClient.show('{embeddingTargetId}', { - operationMode: 'simplified' -}); -``` - -#### Show an Embedding Target with Disabled Features - -Embedding targets can be shown with certain UI features disabled. To disable the designer, add "workbook-design" to the "disabledUiFeatures" option. To disable editing of workbook layout and design, add "workbook-view-management". - -```javascript -cadenzaClient.show('{embeddingTargetId}', { - disabledUiFeatures: ['workbook-design', 'workbook-view-management'] -}); -``` - ### Abort (Iframe) Loading Cadenza JS uses the [AbortController Web API](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) for aborting requests. This is supported by most of the public methods. diff --git a/src/cadenza.js b/src/cadenza.js index 08b9698c..c663f19d 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -64,8 +64,9 @@ globalThis.cadenza = Object.assign( * _Note:_ The GeoJSON geometry type "GeometryCollection" is currently not supported. */ /** @typedef {[number,number,number,number]} Extent - An array of numbers representing an extent: [minx, miny, maxx, maxy] */ +/** @typedef {'normal'|'simplified'} OperationMode - The mode in which a workbook should be operated */ /** - * @typedef {[string]} DisabledUiFeatures - An array of strings representing Cadenza UI features to disable + * @typedef {'workbook-design'|'workbook-view-management'} UiFeature - The name of a Cadenza UI feature * * _Note:_ Supported features are: * * 'workbook-design' - Disable the designer @@ -172,8 +173,8 @@ export class CadenzaClient { * @param {GlobalId} [options.highlightGlobalId] - The ID of an item to highlight / expand in the navigator * @param {string} [options.mediaType] - Set to 'application/pdf' for views of type "JasperReports report" * to show the report PDF directly, without any Cadenza headers or footers. - * @param {string} [options.operationMode] - Whether to enable simplified operation mode - * @param {DisabledUiFeatures} [options.disabledUiFeatures] - Cadenza UI features to disable + * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated + * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading * @return {Promise} A Promise for when the iframe is loaded * @throws For an invalid source @@ -624,7 +625,7 @@ function validGeometryType(/** @type string */ value) { ].includes(value); } -function assertValidUiFeatures(/** @type DisabledUiFeatures */ features) { +function assertValidUiFeatures(/** @type UiFeature[] */ features) { features.forEach((feature) => assert(validUiFeatures(feature), 'Invalid UI feature'), ); @@ -667,8 +668,8 @@ function assertSupportedMediaType( * @param {string} [params.mediaType] * @param {number} [params.minScale] * @param {boolean} [params.useMapSrs] - * @param {string} [params.operationMode] - * @param {DisabledUiFeatures} [params.disabledUiFeatures] + * @param {OperationMode} [params.operationMode] + * @param {UiFeature[]} [params.disabledUiFeatures] * @param {ExternalLinkKey} [params.webApplication] * @return {URLSearchParams} */ From ba23b4281e92fddc706b0496a67547eefced62f6 Mon Sep 17 00:00:00 2001 From: linaker Date: Fri, 3 Nov 2023 15:43:42 +0100 Subject: [PATCH 4/5] Improve note --- src/cadenza.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cadenza.js b/src/cadenza.js index c663f19d..19d4b6b5 100644 --- a/src/cadenza.js +++ b/src/cadenza.js @@ -70,7 +70,7 @@ globalThis.cadenza = Object.assign( * * _Note:_ Supported features are: * * 'workbook-design' - Disable the designer - * * 'workbook-view-management' - Disable workbook layout/design editing + * * 'workbook-view-management' - Disable workbook layout/design editing (is included in 'workbook-design'). * */ /** From 61fabb03b2fa41f60a94132160d4768c66f6359a Mon Sep 17 00:00:00 2001 From: linaker Date: Fri, 3 Nov 2023 15:49:32 +0100 Subject: [PATCH 5/5] Add changes to changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4013f476..12be7aab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- `operationMode` option for `CadenzaClient#show` +- `disabledUiFeatures` option for `CadenzaClient#show` - `webApplication` constructor option - `mediaType` option for `CadenzaClient#show` - `CadenzaClient#fetchData`