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`
diff --git a/README.md b/README.md
index 09c53e11..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']
});
```
diff --git a/sandbox.html b/sandbox.html
index 81de7ddc..5ed24f8f 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
+
+
+
+
+
+
+
diff --git a/src/cadenza.js b/src/cadenza.js
index 20c2583d..19d4b6b5 100644
--- a/src/cadenza.js
+++ b/src/cadenza.js
@@ -64,6 +64,14 @@ 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 {'workbook-design'|'workbook-view-management'} UiFeature - The name of a Cadenza UI feature
+ *
+ * _Note:_ Supported features are:
+ * * 'workbook-design' - Disable the designer
+ * * 'workbook-view-management' - Disable workbook layout/design editing (is included in 'workbook-design').
+ * */
/**
* _Notes:_
@@ -165,6 +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 {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
@@ -176,6 +186,8 @@ export class CadenzaClient {
hideWorkbookToolBar,
highlightGlobalId,
mediaType,
+ operationMode,
+ disabledUiFeatures,
signal,
} = {},
) {
@@ -183,10 +195,15 @@ export class CadenzaClient {
if (mediaType) {
assertSupportedMediaType(mediaType, [MediaType.PDF]);
}
+ if (disabledUiFeatures) {
+ assertValidUiFeatures(disabledUiFeatures);
+ }
const params = createParams({
hideMainHeaderAndFooter,
hideWorkbookToolBar,
highlightGlobalId,
+ operationMode,
+ disabledUiFeatures,
mediaType,
webApplication: this.#webApplication,
});
@@ -608,6 +625,16 @@ function validGeometryType(/** @type string */ value) {
].includes(value);
}
+function assertValidUiFeatures(/** @type UiFeature[] */ features) {
+ features.forEach((feature) =>
+ assert(validUiFeatures(feature), 'Invalid UI feature'),
+ );
+}
+
+function validUiFeatures(/** @type string */ value) {
+ return ['workbook-design', 'workbook-view-management'].includes(value);
+}
+
/**
* @typedef {string} MediaType - A media type
*
@@ -641,6 +668,8 @@ function assertSupportedMediaType(
* @param {string} [params.mediaType]
* @param {number} [params.minScale]
* @param {boolean} [params.useMapSrs]
+ * @param {OperationMode} [params.operationMode]
+ * @param {UiFeature[]} [params.disabledUiFeatures]
* @param {ExternalLinkKey} [params.webApplication]
* @return {URLSearchParams}
*/
@@ -657,6 +686,8 @@ function createParams({
minScale,
useMapSrs,
webApplication,
+ operationMode,
+ disabledUiFeatures,
}) {
if (geometryType) {
assertValidGeometryType(geometryType);
@@ -677,6 +708,10 @@ function createParams({
webApplicationLink: webApplication.externalLinkId,
webApplicationLinkRepository: webApplication.repositoryName,
}),
+ ...(operationMode && { operationMode }),
+ ...(disabledUiFeatures && {
+ disabledUiFeatures: disabledUiFeatures.join(),
+ }),
});
}