@disy/cadenza.js 1.2.0 → 1.4.0

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/cadenza.d.ts CHANGED
@@ -37,6 +37,10 @@ export function cadenza(baseUrl: string, options?: {
37
37
  * @property {string} workbookId - The ID of the workbook
38
38
  * @property {string} viewId - The ID of the view
39
39
  */
40
+ /**
41
+ * @typedef PageSource - A well-known Cadenza page
42
+ * @property {'welcome'} page - The name of the page (Only `"welcome"` is currently supported.)
43
+ */
40
44
  /** @typedef {EmbeddingTargetId | WorkbookKey} WorkbookSource - A workbook source */
41
45
  /** @typedef {EmbeddingTargetId | WorksheetKey} WorksheetSource - A worksheet source */
42
46
  /** @typedef {EmbeddingTargetId | WorkbookViewKey} WorkbookViewSource - A workbook view source */
@@ -58,6 +62,12 @@ export function cadenza(baseUrl: string, options?: {
58
62
  * _Note:_ The GeoJSON geometry type "GeometryCollection" is currently not supported.
59
63
  */
60
64
  /** @typedef {[number,number,number,number]} Extent - An array of numbers representing an extent: [minx, miny, maxx, maxy] */
65
+ /**
66
+ * @typedef {string} MediaType - A media type
67
+ *
68
+ * See {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types}
69
+ */
70
+ /** @typedef {'columns' | 'values' | 'totals'} TablePart - A part of a table to export. */
61
71
  /**
62
72
  * _Notes:_
63
73
  * * Most public methods can be aborted using an [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
@@ -85,26 +95,30 @@ export class CadenzaClient {
85
95
  /** The iframe this client is using for embedding Cadenza. */
86
96
  get iframe(): HTMLIFrameElement | undefined;
87
97
  /**
88
- * Show a workbook, worksheet or workbook view in an iframe.
98
+ * Show a page, workbook, worksheet or workbook view in an iframe.
89
99
  *
90
- * @param {WorkbookSource | WorksheetSource | WorkbookViewSource} source - The source to show
100
+ * @param {PageSource | WorkbookSource | WorksheetSource | WorkbookViewSource} source - The source to show
91
101
  * @param {object} [options]
92
102
  * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
103
+ * @param {boolean} [options.expandNavigator] - Indicates if the navigator should be expanded.
93
104
  * @param {boolean} [options.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
94
105
  * @param {boolean} [options.hideWorkbookToolBar] - Whether to hide the workbook toolbar
95
106
  * @param {GlobalId} [options.highlightGlobalId] - The ID of an item to highlight / expand in the navigator
96
- * @param {string} [options.mediaType] - Set to 'application/pdf' for views of type "JasperReports report"
107
+ * @param {String} [options.labelSet] - The name of a label set defined in the `basicweb-config.xml` (only supported for the welcome page)
108
+ * @param {MediaType} [options.mediaType] - Set to 'application/pdf' for views of type "JasperReports report"
97
109
  * to show the report PDF directly, without any Cadenza headers or footers.
98
110
  * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
99
111
  * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
100
112
  * @return {Promise<void>} A Promise for when the iframe is loaded
101
113
  * @throws For invalid arguments
102
114
  */
103
- show(source: WorkbookSource | WorksheetSource | WorkbookViewSource, { disabledUiFeatures, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, mediaType, operationMode, signal, }?: {
115
+ show(source: PageSource | WorkbookSource | WorksheetSource | WorkbookViewSource, { disabledUiFeatures, expandNavigator, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, mediaType, operationMode, signal, }?: {
104
116
  disabledUiFeatures?: UiFeature[] | undefined;
117
+ expandNavigator?: boolean | undefined;
105
118
  hideMainHeaderAndFooter?: boolean | undefined;
106
119
  hideWorkbookToolBar?: boolean | undefined;
107
120
  highlightGlobalId?: string | undefined;
121
+ labelSet?: string | undefined;
108
122
  mediaType?: string | undefined;
109
123
  operationMode?: OperationMode | undefined;
110
124
  signal?: AbortSignal | undefined;
@@ -115,6 +129,7 @@ export class CadenzaClient {
115
129
  * @param {WorkbookViewSource} mapView - The workbook map view to show
116
130
  * @param {object} [options] - Options
117
131
  * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
132
+ * @param {boolean} [options.expandNavigator] - Indicates if the navigator should be expanded.
118
133
  * @param {Geometry} [options.geometry] - A geometry to show on the map
119
134
  * @param {boolean} [options.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
120
135
  * @param {boolean} [options.hideWorkbookToolBar] - Whether to hide the workbook toolbar
@@ -127,8 +142,9 @@ export class CadenzaClient {
127
142
  * @return {Promise<void>} A Promise for when the iframe is loaded
128
143
  * @throws For invalid arguments
129
144
  */
130
- showMap(mapView: WorkbookViewSource, { disabledUiFeatures, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, signal, }?: {
145
+ showMap(mapView: WorkbookViewSource, { disabledUiFeatures, expandNavigator, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, signal, }?: {
131
146
  disabledUiFeatures?: UiFeature[] | undefined;
147
+ expandNavigator?: boolean | undefined;
132
148
  geometry?: Geometry | undefined;
133
149
  hideMainHeaderAndFooter?: boolean | undefined;
134
150
  hideWorkbookToolBar?: boolean | undefined;
@@ -139,6 +155,12 @@ export class CadenzaClient {
139
155
  useMapSrs?: boolean | undefined;
140
156
  signal?: AbortSignal | undefined;
141
157
  } | undefined): Promise<void>;
158
+ /**
159
+ * Expand/collapse the navigator.
160
+ *
161
+ * @param {boolean} expanded - The expansion state of the navigator
162
+ */
163
+ expandNavigator(expanded?: boolean): void;
142
164
  /**
143
165
  * Create a geometry.
144
166
  *
@@ -209,11 +231,13 @@ export class CadenzaClient {
209
231
  * * 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' (Excel)
210
232
  * * 'text/csv'
211
233
  * @param {object} options - Options
234
+ * @param {TablePart[]} [options.parts] - Table parts to export; If not specified, all parts are exported.
212
235
  * @param {AbortSignal} [options.signal] - A signal to abort the data fetching
213
236
  * @return {Promise<Response>} A Promise for the fetch response
214
237
  * @throws For invalid arguments
215
238
  */
216
- fetchData(source: WorkbookViewSource, mediaType: MediaType, { signal }?: {
239
+ fetchData(source: WorkbookViewSource, mediaType: MediaType, { parts, signal }?: {
240
+ parts?: TablePart[] | undefined;
217
241
  signal?: AbortSignal | undefined;
218
242
  }): Promise<Response>;
219
243
  /**
@@ -229,10 +253,12 @@ export class CadenzaClient {
229
253
  * * 'text/csv'
230
254
  * @param {object} options - Options
231
255
  * @param {string} [options.fileName] - The file name to use; The file extension is appended by Cadenza.
256
+ * @param {TablePart[]} [options.parts] - Table parts to export; If not specified, all parts are exported.
232
257
  * @throws For invalid arguments
233
258
  */
234
- downloadData(source: WorkbookViewSource, mediaType: MediaType, { fileName }: {
259
+ downloadData(source: WorkbookViewSource, mediaType: MediaType, { fileName, parts }: {
235
260
  fileName?: string | undefined;
261
+ parts?: TablePart[] | undefined;
236
262
  }): void;
237
263
  #private;
238
264
  }
@@ -328,6 +354,15 @@ export type WorkbookViewKey = {
328
354
  */
329
355
  viewId: string;
330
356
  };
357
+ /**
358
+ * - A well-known Cadenza page
359
+ */
360
+ export type PageSource = {
361
+ /**
362
+ * - The name of the page (Only `"welcome"` is currently supported.)
363
+ */
364
+ page: 'welcome';
365
+ };
331
366
  /**
332
367
  * - A workbook source
333
368
  */
@@ -377,6 +412,10 @@ export type Extent = [number, number, number, number];
377
412
  * See {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types}
378
413
  */
379
414
  export type MediaType = string;
415
+ /**
416
+ * - A part of a table to export.
417
+ */
418
+ export type TablePart = 'columns' | 'values' | 'totals';
380
419
  /**
381
420
  * - A Cadenza `postMessage()` event
382
421
  */
package/cadenza.js CHANGED
@@ -43,6 +43,10 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
43
43
  * @property {string} workbookId - The ID of the workbook
44
44
  * @property {string} viewId - The ID of the view
45
45
  */
46
+ /**
47
+ * @typedef PageSource - A well-known Cadenza page
48
+ * @property {'welcome'} page - The name of the page (Only `"welcome"` is currently supported.)
49
+ */
46
50
  /** @typedef {EmbeddingTargetId | WorkbookKey} WorkbookSource - A workbook source */
47
51
  /** @typedef {EmbeddingTargetId | WorksheetKey} WorksheetSource - A worksheet source */
48
52
  /** @typedef {EmbeddingTargetId | WorkbookViewKey} WorkbookViewSource - A workbook view source */
@@ -64,6 +68,12 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
64
68
  * _Note:_ The GeoJSON geometry type "GeometryCollection" is currently not supported.
65
69
  */
66
70
  /** @typedef {[number,number,number,number]} Extent - An array of numbers representing an extent: [minx, miny, maxx, maxy] */
71
+ /**
72
+ * @typedef {string} MediaType - A media type
73
+ *
74
+ * See {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types}
75
+ */
76
+ /** @typedef {'columns' | 'values' | 'totals'} TablePart - A part of a table to export. */
67
77
  /**
68
78
  * _Notes:_
69
79
  * * Most public methods can be aborted using an [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
@@ -133,33 +143,42 @@ export class CadenzaClient {
133
143
  return /** @type {HTMLIFrameElement} */ (iframe);
134
144
  }
135
145
  /**
136
- * Show a workbook, worksheet or workbook view in an iframe.
146
+ * Show a page, workbook, worksheet or workbook view in an iframe.
137
147
  *
138
- * @param {WorkbookSource | WorksheetSource | WorkbookViewSource} source - The source to show
148
+ * @param {PageSource | WorkbookSource | WorksheetSource | WorkbookViewSource} source - The source to show
139
149
  * @param {object} [options]
140
150
  * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
151
+ * @param {boolean} [options.expandNavigator] - Indicates if the navigator should be expanded.
141
152
  * @param {boolean} [options.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
142
153
  * @param {boolean} [options.hideWorkbookToolBar] - Whether to hide the workbook toolbar
143
154
  * @param {GlobalId} [options.highlightGlobalId] - The ID of an item to highlight / expand in the navigator
144
- * @param {string} [options.mediaType] - Set to 'application/pdf' for views of type "JasperReports report"
155
+ * @param {String} [options.labelSet] - The name of a label set defined in the `basicweb-config.xml` (only supported for the welcome page)
156
+ * @param {MediaType} [options.mediaType] - Set to 'application/pdf' for views of type "JasperReports report"
145
157
  * to show the report PDF directly, without any Cadenza headers or footers.
146
158
  * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
147
159
  * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
148
160
  * @return {Promise<void>} A Promise for when the iframe is loaded
149
161
  * @throws For invalid arguments
150
162
  */
151
- show(source, { disabledUiFeatures, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, mediaType, operationMode, signal, } = {}) {
163
+ show(source, { disabledUiFeatures, expandNavigator, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, mediaType, operationMode, signal, } = {}) {
152
164
  this.#log('CadenzaClient#show', source);
153
165
  if (mediaType) {
154
166
  assertSupportedMediaType(mediaType, [MediaType.PDF]);
155
167
  }
168
+ if (labelSet) {
169
+ assert(typeof source !== 'string' &&
170
+ 'page' in source &&
171
+ source.page === 'welcome', 'labelSet is only supported on the welcome page');
172
+ }
156
173
  const params = createParams({
157
174
  disabledUiFeatures,
175
+ expandNavigator,
158
176
  hideMainHeaderAndFooter,
159
177
  hideWorkbookToolBar,
160
178
  highlightGlobalId,
161
- operationMode,
179
+ labelSet,
162
180
  mediaType,
181
+ operationMode,
163
182
  webApplication: this.#webApplication,
164
183
  });
165
184
  return this.#show(resolvePath(source), params, signal);
@@ -170,6 +189,7 @@ export class CadenzaClient {
170
189
  * @param {WorkbookViewSource} mapView - The workbook map view to show
171
190
  * @param {object} [options] - Options
172
191
  * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
192
+ * @param {boolean} [options.expandNavigator] - Indicates if the navigator should be expanded.
173
193
  * @param {Geometry} [options.geometry] - A geometry to show on the map
174
194
  * @param {boolean} [options.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
175
195
  * @param {boolean} [options.hideWorkbookToolBar] - Whether to hide the workbook toolbar
@@ -182,13 +202,14 @@ export class CadenzaClient {
182
202
  * @return {Promise<void>} A Promise for when the iframe is loaded
183
203
  * @throws For invalid arguments
184
204
  */
185
- async showMap(mapView, { disabledUiFeatures, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, signal, } = {}) {
205
+ async showMap(mapView, { disabledUiFeatures, expandNavigator, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, signal, } = {}) {
186
206
  this.#log('CadenzaClient#showMap', mapView, geometry);
187
207
  if (geometry) {
188
208
  assertValidGeometryType(geometry.type);
189
209
  }
190
210
  const params = createParams({
191
211
  disabledUiFeatures,
212
+ expandNavigator,
192
213
  hideMainHeaderAndFooter,
193
214
  hideWorkbookToolBar,
194
215
  highlightGlobalId,
@@ -201,6 +222,15 @@ export class CadenzaClient {
201
222
  await this.#show(resolvePath(mapView), params, signal);
202
223
  this.#postEvent('setGeometry', { geometry });
203
224
  }
225
+ /**
226
+ * Expand/collapse the navigator.
227
+ *
228
+ * @param {boolean} expanded - The expansion state of the navigator
229
+ */
230
+ expandNavigator(expanded = true) {
231
+ this.#log('CadenzaClient#expandNavigator', expanded);
232
+ this.#postEvent('expandNavigator', { expandNavigator: Boolean(expanded) });
233
+ }
204
234
  /**
205
235
  * Create a geometry.
206
236
  *
@@ -366,14 +396,15 @@ export class CadenzaClient {
366
396
  * * 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' (Excel)
367
397
  * * 'text/csv'
368
398
  * @param {object} options - Options
399
+ * @param {TablePart[]} [options.parts] - Table parts to export; If not specified, all parts are exported.
369
400
  * @param {AbortSignal} [options.signal] - A signal to abort the data fetching
370
401
  * @return {Promise<Response>} A Promise for the fetch response
371
402
  * @throws For invalid arguments
372
403
  */
373
- fetchData(source, mediaType, { signal } = {}) {
404
+ fetchData(source, mediaType, { parts, signal } = {}) {
374
405
  this.#log('CadenzaClient#fetchData', source, mediaType);
375
406
  assertSupportedMediaType(mediaType);
376
- const params = createParams({ mediaType });
407
+ const params = createParams({ mediaType, parts });
377
408
  return this.#fetch(resolvePath(source), params, signal);
378
409
  }
379
410
  async #fetch(
@@ -406,12 +437,13 @@ export class CadenzaClient {
406
437
  * * 'text/csv'
407
438
  * @param {object} options - Options
408
439
  * @param {string} [options.fileName] - The file name to use; The file extension is appended by Cadenza.
440
+ * @param {TablePart[]} [options.parts] - Table parts to export; If not specified, all parts are exported.
409
441
  * @throws For invalid arguments
410
442
  */
411
- downloadData(source, mediaType, { fileName }) {
443
+ downloadData(source, mediaType, { fileName, parts }) {
412
444
  this.#log('CadenzaClient#downloadData', source, mediaType);
413
445
  assertSupportedMediaType(mediaType);
414
- const params = createParams({ fileName, mediaType });
446
+ const params = createParams({ fileName, mediaType, parts });
415
447
  this.#download(resolvePath(source), params);
416
448
  }
417
449
  #download(/** @type string */ path, /** @type URLSearchParams */ params) {
@@ -441,11 +473,16 @@ export class CadenzaClient {
441
473
  }
442
474
  }
443
475
  function resolvePath(
444
- /** @type WorkbookSource | WorksheetSource | WorkbookViewSource */ source) {
476
+ /** @type PageSource | WorkbookSource | WorksheetSource | WorkbookViewSource */ source) {
445
477
  if (typeof source === 'string') {
446
478
  assert(validEmbeddingTargetId(source), `Invalid embedding target ID: ${source}`);
447
479
  return `/w/${source}`;
448
480
  }
481
+ else if ('page' in source) {
482
+ const page = source.page;
483
+ assert(validPageName(page), `Invalid page name: ${page}`);
484
+ return `/public/pages/${page}`;
485
+ }
449
486
  else {
450
487
  const { repositoryName, workbookId } = source;
451
488
  assert(validRepositoryName(repositoryName), `Invalid repository name: ${repositoryName}`);
@@ -478,6 +515,9 @@ function validUrl(/** @type string */ value) {
478
515
  return false;
479
516
  }
480
517
  }
518
+ function validPageName(/** @type string */ value) {
519
+ return ['welcome'].includes(value);
520
+ }
481
521
  function validEmbeddingTargetId(/** @type string */ value) {
482
522
  return /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value);
483
523
  }
@@ -512,17 +552,15 @@ function validGeometryType(/** @type string */ value) {
512
552
  'MultiPolygon',
513
553
  ].includes(value);
514
554
  }
555
+ function validTablePart(/** @type TablePart */ value) {
556
+ return ['columns', 'values', 'totals'].includes(value);
557
+ }
515
558
  function validOperationMode(/** @type string */ value) {
516
559
  return ['normal', 'simplified'].includes(value);
517
560
  }
518
561
  function validUiFeature(/** @type string */ value) {
519
562
  return ['workbook-design', 'workbook-view-management'].includes(value);
520
563
  }
521
- /**
522
- * @typedef {string} MediaType - A media type
523
- *
524
- * See {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types}
525
- */
526
564
  const MediaType = /** @type {Record<string, MediaType>} */ {
527
565
  CSV: 'text/csv',
528
566
  EXCEL: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
@@ -532,27 +570,30 @@ const MediaType = /** @type {Record<string, MediaType>} */ {
532
570
  function assertSupportedMediaType(
533
571
  /** @type MediaType */ type,
534
572
  /** @type MediaType[] */ supportedTypes = Object.values(MediaType)) {
535
- return assert(supportedTypes.includes(type), `Invalid media type: ${type}`);
573
+ assert(supportedTypes.includes(type), `Invalid media type: ${type}`);
536
574
  }
537
575
  /**
538
576
  * @param {object} params - Options
539
577
  * @param {string} [params.action]
540
578
  * @param {UiFeature[]} [params.disabledUiFeatures]
579
+ * @param {boolean} [params.expandNavigator]
541
580
  * @param {string} [params.fileName]
542
581
  * @param {GeometryType} [params.geometryType]
543
582
  * @param {boolean} [params.hideMainHeaderAndFooter]
544
583
  * @param {boolean} [params.hideWorkbookToolBar]
545
584
  * @param {GlobalId} [params.highlightGlobalId]
585
+ * @param {string} [params.labelSet]
546
586
  * @param {string} [params.locationFinder]
547
587
  * @param {Extent} [params.mapExtent]
548
- * @param {string} [params.mediaType]
588
+ * @param {MediaType} [params.mediaType]
549
589
  * @param {number} [params.minScale]
550
590
  * @param {OperationMode} [params.operationMode]
591
+ * @param {TablePart[]} [params.parts]
551
592
  * @param {boolean} [params.useMapSrs]
552
593
  * @param {ExternalLinkKey} [params.webApplication]
553
594
  * @return {URLSearchParams}
554
595
  */
555
- function createParams({ action, fileName, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, mediaType, minScale, useMapSrs, webApplication, operationMode, disabledUiFeatures, }) {
596
+ function createParams({ action, expandNavigator, fileName, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, locationFinder, mapExtent, mediaType, minScale, parts, useMapSrs, webApplication, operationMode, disabledUiFeatures, }) {
556
597
  if (disabledUiFeatures) {
557
598
  disabledUiFeatures.forEach((feature) => assert(validUiFeature(feature), `Invalid UI feature: ${feature}`));
558
599
  }
@@ -562,21 +603,27 @@ function createParams({ action, fileName, geometryType, hideMainHeaderAndFooter,
562
603
  if (operationMode) {
563
604
  assert(validOperationMode(operationMode), `Invalid operation mode: ${operationMode}`);
564
605
  }
606
+ if (parts) {
607
+ parts.forEach((part) => assert(validTablePart(part), `Invalid table part: ${part}`));
608
+ }
565
609
  return new URLSearchParams({
566
610
  ...(action && { action }),
567
611
  ...(disabledUiFeatures && {
568
612
  disabledUiFeatures: disabledUiFeatures.join(),
569
613
  }),
614
+ ...(expandNavigator && { expandNavigator: 'true' }),
570
615
  ...(fileName && { fileName }),
571
616
  ...(geometryType && { geometryType }),
572
617
  ...(hideMainHeaderAndFooter && { hideMainHeaderAndFooter: 'true' }),
573
618
  ...(hideWorkbookToolBar && { hideWorkbookToolBar: 'true' }),
574
619
  ...(highlightGlobalId && { highlightGlobalId }),
620
+ ...(labelSet && { labelSet }),
575
621
  ...(locationFinder && { locationFinder }),
576
622
  ...(mapExtent && { mapExtent: mapExtent.join() }),
577
623
  ...(mediaType && { mediaType }),
578
624
  ...(minScale && { minScale: String(minScale) }),
579
625
  ...(operationMode && { operationMode }),
626
+ ...(parts && { parts: parts.join() }),
580
627
  ...(useMapSrs && { useMapSrs: 'true' }),
581
628
  ...(webApplication && {
582
629
  webApplicationLink: webApplication.externalLinkId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@disy/cadenza.js",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": "github:DisyInformationssysteme/cadenza.js",
6
6
  "type": "module",
@@ -11,6 +11,7 @@
11
11
  "cadenza.js",
12
12
  "cadenza.d.ts",
13
13
  "CHANGELOG.md",
14
+ "sandbox.cjs",
14
15
  "sandbox.html"
15
16
  ],
16
17
  "scripts": {
package/sandbox.cjs ADDED
@@ -0,0 +1,7 @@
1
+ const { execSync } = require('child_process');
2
+ const { URL } = require('url');
3
+
4
+ const DEFAULT_CADENZA_URL = 'http://localhost:8080/cadenza';
5
+ const cadenzaUrl = new URL((process.argv[2] === '--cadenza-url' && process.argv[3]) || process.env.CADENZA_URL || DEFAULT_CADENZA_URL);
6
+
7
+ execSync(`npx --yes http-server -a localhost -c-1 -d false --proxy ${cadenzaUrl.origin} --proxy-options.headers.Origin ${cadenzaUrl.origin} -o /sandbox.html${cadenzaUrl.pathname !== '/' ? `?contextPath=${cadenzaUrl.pathname}` : ''}`, { stdio: 'inherit' });
package/sandbox.html CHANGED
@@ -41,7 +41,7 @@
41
41
  label {
42
42
  font-weight: 600;
43
43
  }
44
- select, input:is(:not([type], [type=text])), textarea {
44
+ select, input:is(:not([type]), [type=text], [type=number]), textarea {
45
45
  display: block;
46
46
  width: 100%
47
47
  }
@@ -71,8 +71,9 @@
71
71
  const contextPath = new URLSearchParams(location.search).get('contextPath') ?? '';
72
72
  const cadenzaClient = cadenza(location.origin + contextPath, { iframe: 'iframe', debug: true });
73
73
  const actionHandlers = {
74
- show ({ embeddingTargetId, hideMainHeaderAndFooter, hideWorkbookToolBar, jasperReportAsPdf, highlightGlobalId, operationMode, disabledUiFeatures }) {
74
+ show ({ embeddingTargetId, expandNavigator, hideMainHeaderAndFooter, hideWorkbookToolBar, jasperReportAsPdf, highlightGlobalId, operationMode, disabledUiFeatures }) {
75
75
  cadenzaClient.show(embeddingTargetId, {
76
+ expandNavigator: (expandNavigator === 'on'),
76
77
  hideMainHeaderAndFooter: (hideMainHeaderAndFooter === 'on'),
77
78
  hideWorkbookToolBar: (hideWorkbookToolBar === 'on'),
78
79
  highlightGlobalId,
@@ -81,6 +82,15 @@
81
82
  disabledUiFeatures: disabledUiFeatures && disabledUiFeatures.split(',')
82
83
  });
83
84
  },
85
+ showPage ({ page, expandNavigator, highlightGlobalId }) {
86
+ cadenzaClient.show({ page: page }, {
87
+ expandNavigator: (expandNavigator === 'on'),
88
+ highlightGlobalId
89
+ });
90
+ },
91
+ expandNavigator ({ expandNavigator }) {
92
+ cadenzaClient.expandNavigator(expandNavigator === 'on');
93
+ },
84
94
  showMap ({ embeddingTargetId, useMapSrs, geometry, mapExtent, locationFinder, highlightGlobalId }) {
85
95
  cadenzaClient.showMap(embeddingTargetId, {
86
96
  useMapSrs: useMapSrs === 'on',
@@ -106,13 +116,16 @@
106
116
  locationFinder
107
117
  });
108
118
  },
109
- fetchData ({ embeddingTargetId, mediaType }) {
119
+ fetchData ({ embeddingTargetId, mediaType, parts }) {
110
120
  console.log('Inspect the fetchData() request in the devtools.');
111
- cadenzaClient.fetchData(embeddingTargetId, mediaType);
121
+ cadenzaClient.fetchData(embeddingTargetId, mediaType, {
122
+ parts: parts && parts.split(',')
123
+ });
112
124
  },
113
- downloadData ({ embeddingTargetId, mediaType, fileName }) {
125
+ downloadData ({ embeddingTargetId, mediaType, fileName, parts }) {
114
126
  cadenzaClient.downloadData(embeddingTargetId, mediaType, {
115
- fileName
127
+ fileName,
128
+ parts: parts && parts.split(',')
116
129
  });
117
130
  }
118
131
  };
@@ -150,6 +163,8 @@
150
163
  <label for="action">Action</label>
151
164
  <select name="action" id="action">
152
165
  <option value="show">Show</option>
166
+ <option value="showPage">Show Page</option>
167
+ <option value="expandNavigator">Expand Navigator</option>
153
168
  <option value="showMap">Show Map</option>
154
169
  <option value="createGeometry">Create Geometry</option>
155
170
  <option value="editGeometry">Edit Geometry</option>
@@ -180,6 +195,12 @@
180
195
  Show Jasper Report as PDF
181
196
  </label>
182
197
  </div>
198
+ <div>
199
+ <label>
200
+ <input type="checkbox" name="expandNavigator">
201
+ Expand navigator tree
202
+ </label>
203
+ </div>
183
204
  <div>
184
205
  <label>
185
206
  <input type="checkbox" name="hideMainHeaderAndFooter">
@@ -208,6 +229,35 @@
208
229
  </div>
209
230
  </template>
210
231
 
232
+ <template data-action="showPage">
233
+ <div>
234
+ <label for="page">Page *</label>
235
+ <select name="page" id="page" required>
236
+ <option>welcome</option>
237
+ <option>an-invalid-page-name</option>
238
+ </select>
239
+ </div>
240
+ <div>
241
+ <label>
242
+ <input type="checkbox" name="expandNavigator">
243
+ Expand navigator tree
244
+ </label>
245
+ </div>
246
+ <div>
247
+ <label for="highlightGlobalId">Highlighted Global ID</label>
248
+ <input name="highlightGlobalId" id="highlightGlobalId">
249
+ </div>
250
+ </template>
251
+
252
+ <template data-action="expandNavigator">
253
+ <div>
254
+ <label>
255
+ <input type="checkbox" name="expandNavigator">
256
+ Expand navigator tree
257
+ </label>
258
+ </div>
259
+ </template>
260
+
211
261
  <template data-action="showMap">
212
262
  <div>
213
263
  <label for="embeddingTargetId">Embedding target ID of the map view *</label>
@@ -223,10 +273,6 @@
223
273
  <label for="geometry">Geometry (GeoJSON)</label>
224
274
  <textarea name="geometry" id="geometry" rows="5"></textarea>
225
275
  </div>
226
- <div>
227
- <label for="useMapSrs">Use map SRS</label>
228
- <input type="checkbox" name="useMapSrs" id="useMapSrs" />
229
- </div>
230
276
  <div>
231
277
  <label for="mapExtent">Map extent coordinates</label>
232
278
  <input name="mapExtent" id="mapExtent" placeholder="minX,minY,maxX,maxY">
@@ -246,6 +292,12 @@
246
292
  <label for="embeddingTargetId">Embedding target ID of the map view *</label>
247
293
  <input name="embeddingTargetId" id="embeddingTargetId" required>
248
294
  </div>
295
+ <div>
296
+ <label>
297
+ <input type="checkbox" name="useMapSrs">
298
+ Use map SRS
299
+ </label>
300
+ </div>
249
301
  <div>
250
302
  <label for="geometryType">Geometry type</label>
251
303
  <select name="geometryType" id="geometryType">
@@ -261,10 +313,6 @@
261
313
  <label for="minScale">Minimum Scale</label>
262
314
  <input type="number" name="minScale" id="minScale">
263
315
  </div>
264
- <div>
265
- <label for="useMapSrs">Use map SRS</label>
266
- <input type="checkbox" name="useMapSrs" id="useMapSrs" />
267
- </div>
268
316
  <div>
269
317
  <label for="mapExtent">Map extent coordinates</label>
270
318
  <input name="mapExtent" id="mapExtent" placeholder="minX,minY,maxX,maxY">
@@ -280,6 +328,12 @@
280
328
  <label for="embeddingTargetId">Embedding target ID of the map view *</label>
281
329
  <input name="embeddingTargetId" id="embeddingTargetId" required>
282
330
  </div>
331
+ <div>
332
+ <label>
333
+ <input type="checkbox" name="useMapSrs">
334
+ Use map SRS
335
+ </label>
336
+ </div>
283
337
  <div>
284
338
  <label for="geometry">Geometry (GeoJSON) *</label>
285
339
  <textarea name="geometry" id="geometry" rows="5" required></textarea>
@@ -288,10 +342,6 @@
288
342
  <label for="minScale">Minimum Scale</label>
289
343
  <input type="number" name="minScale" id="minScale">
290
344
  </div>
291
- <div>
292
- <label for="useMapSrs">Use map SRS</label>
293
- <input type="checkbox" name="useMapSrs" id="useMapSrs" />
294
- </div>
295
345
  <div>
296
346
  <label for="mapExtent">Map extent coordinates</label>
297
347
  <input name="mapExtent" id="mapExtent" placeholder="minX,minY,maxX,maxY">
@@ -307,6 +357,10 @@
307
357
  <label for="embeddingTargetId">Embedding target ID *</label>
308
358
  <input name="embeddingTargetId" id="embeddingTargetId" required>
309
359
  </div>
360
+ <div>
361
+ <label for="parts">Parts</label>
362
+ <input name="parts" id="parts" placeholder="columns,values,totals">
363
+ </div>
310
364
  <div>
311
365
  <label for="mediaType">Media type *</label>
312
366
  <select name="mediaType" id="mediaType" required>
@@ -327,6 +381,10 @@
327
381
  <label for="embeddingTargetId">Embedding target ID *</label>
328
382
  <input name="embeddingTargetId" id="embeddingTargetId" required>
329
383
  </div>
384
+ <div>
385
+ <label for="parts">Parts</label>
386
+ <input name="parts" id="parts" placeholder="columns,values,totals">
387
+ </div>
330
388
  <div>
331
389
  <label for="mediaType">Media type *</label>
332
390
  <select name="mediaType" id="mediaType" required>