@disy/cadenza.js 1.1.0 → 1.3.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.
@@ -20,7 +20,7 @@
20
20
  </div>
21
21
  <div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
22
22
  <ul>
23
- <li>Defined in <a href="https://github.com/DisyInformationssysteme/cadenza.js/blob/b4c918b/src/cadenza.js#L54">src/cadenza.js:54</a></li></ul></aside></div>
23
+ <li>Defined in <a href="https://github.com/DisyInformationssysteme/cadenza.js/blob/23b23d8/src/cadenza.js#L54">src/cadenza.js:54</a></li></ul></aside></div>
24
24
  <div class="col-sidebar">
25
25
  <div class="page-menu">
26
26
  <div class="tsd-navigation settings">
@@ -45,6 +45,7 @@
45
45
  <li><a href="../interfaces/CadenzaEvent.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-256"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-interface)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.51 16V15.016H11.298V8.224H9.51V7.24H14.19V8.224H12.402V15.016H14.19V16H9.51Z" fill="var(--color-text)"></path></g></svg><span>Cadenza<wbr/>Event</span></a></li>
46
46
  <li><a href="../interfaces/ExternalLinkKey.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>External<wbr/>Link<wbr/>Key</span></a></li>
47
47
  <li><a href="../interfaces/Geometry.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Geometry</span></a></li>
48
+ <li><a href="../interfaces/PageSource.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Page<wbr/>Source</span></a></li>
48
49
  <li><a href="../interfaces/WorkbookKey.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Workbook<wbr/>Key</span></a></li>
49
50
  <li><a href="../interfaces/WorkbookViewKey.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Workbook<wbr/>View<wbr/>Key</span></a></li>
50
51
  <li><a href="../interfaces/WorksheetKey.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Worksheet<wbr/>Key</span></a></li>
@@ -55,6 +56,8 @@
55
56
  <li><a href="GlobalId.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Global<wbr/>Id</span></a></li>
56
57
  <li><a href="MediaType.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Media<wbr/>Type</span></a></li>
57
58
  <li><a href="OperationMode.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Operation<wbr/>Mode</span></a></li>
59
+ <li><a href="PageType.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Page<wbr/>Type</span></a></li>
60
+ <li><a href="TablePart.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Table<wbr/>Part</span></a></li>
58
61
  <li><a href="UiFeature.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Ui<wbr/>Feature</span></a></li>
59
62
  <li><a href="WorkbookSource.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Workbook<wbr/>Source</span></a></li>
60
63
  <li><a href="WorkbookViewSource.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Workbook<wbr/>View<wbr/>Source</span></a></li>
package/cadenza.d.ts CHANGED
@@ -48,6 +48,12 @@ export function cadenza(baseUrl: string, options?: {
48
48
  * * 'workbook-design' - The workbook designer
49
49
  * * 'workbook-view-management' - Add/Edit/Remove workbook views (Is included in 'workbook-design'.)
50
50
  * */
51
+ /**
52
+ * @typedef PageSource - A well-known Cadenza page
53
+ * @property {PageType} page - The name of the page
54
+ *
55
+ * @typedef {'welcome'} PageType - A Cadenza well-known page name
56
+ */
51
57
  /**
52
58
  * @typedef Geometry - A [GeoJSON](https://geojson.org/) geometry object
53
59
  * @property {GeometryType} type - The type of the geometry
@@ -85,23 +91,25 @@ export class CadenzaClient {
85
91
  /** The iframe this client is using for embedding Cadenza. */
86
92
  get iframe(): HTMLIFrameElement | undefined;
87
93
  /**
88
- * Show a workbook, worksheet or workbook view in an iframe.
94
+ * Show a page, workbook, worksheet or workbook view in an iframe.
89
95
  *
90
- * @param {WorkbookSource | WorksheetSource | WorkbookViewSource} source - The source to show
96
+ * @param {PageSource | WorkbookSource | WorksheetSource | WorkbookViewSource} source - The source to show
91
97
  * @param {object} [options]
92
98
  * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
99
+ * @param {boolean} [options.expandNavigator] - Indicates if the navigator should be expanded.
93
100
  * @param {boolean} [options.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
94
101
  * @param {boolean} [options.hideWorkbookToolBar] - Whether to hide the workbook toolbar
95
102
  * @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"
103
+ * @param {MediaType} [options.mediaType] - Set to 'application/pdf' for views of type "JasperReports report"
97
104
  * to show the report PDF directly, without any Cadenza headers or footers.
98
105
  * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
99
106
  * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
100
107
  * @return {Promise<void>} A Promise for when the iframe is loaded
101
108
  * @throws For invalid arguments
102
109
  */
103
- show(source: WorkbookSource | WorksheetSource | WorkbookViewSource, { disabledUiFeatures, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, mediaType, operationMode, signal, }?: {
110
+ show(source: PageSource | WorkbookSource | WorksheetSource | WorkbookViewSource, { disabledUiFeatures, expandNavigator, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, mediaType, operationMode, signal, }?: {
104
111
  disabledUiFeatures?: UiFeature[] | undefined;
112
+ expandNavigator?: boolean | undefined;
105
113
  hideMainHeaderAndFooter?: boolean | undefined;
106
114
  hideWorkbookToolBar?: boolean | undefined;
107
115
  highlightGlobalId?: string | undefined;
@@ -115,6 +123,7 @@ export class CadenzaClient {
115
123
  * @param {WorkbookViewSource} mapView - The workbook map view to show
116
124
  * @param {object} [options] - Options
117
125
  * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
126
+ * @param {boolean} [options.expandNavigator] - Indicates if the navigator should be expanded.
118
127
  * @param {Geometry} [options.geometry] - A geometry to show on the map
119
128
  * @param {boolean} [options.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
120
129
  * @param {boolean} [options.hideWorkbookToolBar] - Whether to hide the workbook toolbar
@@ -127,8 +136,9 @@ export class CadenzaClient {
127
136
  * @return {Promise<void>} A Promise for when the iframe is loaded
128
137
  * @throws For invalid arguments
129
138
  */
130
- showMap(mapView: WorkbookViewSource, { disabledUiFeatures, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, signal, }?: {
139
+ showMap(mapView: WorkbookViewSource, { disabledUiFeatures, expandNavigator, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, signal, }?: {
131
140
  disabledUiFeatures?: UiFeature[] | undefined;
141
+ expandNavigator?: boolean | undefined;
132
142
  geometry?: Geometry | undefined;
133
143
  hideMainHeaderAndFooter?: boolean | undefined;
134
144
  hideWorkbookToolBar?: boolean | undefined;
@@ -139,6 +149,12 @@ export class CadenzaClient {
139
149
  useMapSrs?: boolean | undefined;
140
150
  signal?: AbortSignal | undefined;
141
151
  } | undefined): Promise<void>;
152
+ /**
153
+ * Expand/collapse the navigator tree.
154
+ *
155
+ * @param {boolean} expandNavigator - The expansion state of the navigator.
156
+ */
157
+ expandNavigator(expandNavigator: boolean): void;
142
158
  /**
143
159
  * Create a geometry.
144
160
  *
@@ -209,11 +225,13 @@ export class CadenzaClient {
209
225
  * * 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' (Excel)
210
226
  * * 'text/csv'
211
227
  * @param {object} options - Options
228
+ * @param {TablePart[]} [options.parts] - An optional array of table parts to export. If not specified, all parts are exported.
212
229
  * @param {AbortSignal} [options.signal] - A signal to abort the data fetching
213
230
  * @return {Promise<Response>} A Promise for the fetch response
214
231
  * @throws For invalid arguments
215
232
  */
216
- fetchData(source: WorkbookViewSource, mediaType: MediaType, { signal }?: {
233
+ fetchData(source: WorkbookViewSource, mediaType: MediaType, { parts, signal }?: {
234
+ parts?: TablePart[] | undefined;
217
235
  signal?: AbortSignal | undefined;
218
236
  }): Promise<Response>;
219
237
  /**
@@ -229,10 +247,12 @@ export class CadenzaClient {
229
247
  * * 'text/csv'
230
248
  * @param {object} options - Options
231
249
  * @param {string} [options.fileName] - The file name to use; The file extension is appended by Cadenza.
250
+ * @param {TablePart[]} [options.parts] - An optional array of table parts to export. If not specified, all parts are exported.
232
251
  * @throws For invalid arguments
233
252
  */
234
- downloadData(source: WorkbookViewSource, mediaType: MediaType, { fileName }: {
253
+ downloadData(source: WorkbookViewSource, mediaType: MediaType, { fileName, parts }: {
235
254
  fileName?: string | undefined;
255
+ parts?: TablePart[] | undefined;
236
256
  }): void;
237
257
  #private;
238
258
  }
@@ -260,6 +280,10 @@ export class CadenzaError extends Error {
260
280
  get type(): string;
261
281
  #private;
262
282
  }
283
+ /**
284
+ * - A part of a table to export.
285
+ */
286
+ export type TablePart = 'columns' | 'values' | 'totals';
263
287
  /**
264
288
  * - The ID of an embedding target
265
289
  */
@@ -352,6 +376,19 @@ export type OperationMode = 'normal' | 'simplified';
352
376
  * * 'workbook-view-management' - Add/Edit/Remove workbook views (Is included in 'workbook-design'.)
353
377
  */
354
378
  export type UiFeature = 'workbook-design' | 'workbook-view-management';
379
+ /**
380
+ * - A well-known Cadenza page
381
+ */
382
+ export type PageSource = {
383
+ /**
384
+ * - The name of the page
385
+ */
386
+ page: PageType;
387
+ };
388
+ /**
389
+ * - A Cadenza well-known page name
390
+ */
391
+ export type PageType = 'welcome';
355
392
  /**
356
393
  * - A [GeoJSON](https://geojson.org/) geometry object
357
394
  */
package/cadenza.js CHANGED
@@ -54,6 +54,12 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
54
54
  * * 'workbook-design' - The workbook designer
55
55
  * * 'workbook-view-management' - Add/Edit/Remove workbook views (Is included in 'workbook-design'.)
56
56
  * */
57
+ /**
58
+ * @typedef PageSource - A well-known Cadenza page
59
+ * @property {PageType} page - The name of the page
60
+ *
61
+ * @typedef {'welcome'} PageType - A Cadenza well-known page name
62
+ */
57
63
  /**
58
64
  * @typedef Geometry - A [GeoJSON](https://geojson.org/) geometry object
59
65
  * @property {GeometryType} type - The type of the geometry
@@ -133,28 +139,30 @@ export class CadenzaClient {
133
139
  return /** @type {HTMLIFrameElement} */ (iframe);
134
140
  }
135
141
  /**
136
- * Show a workbook, worksheet or workbook view in an iframe.
142
+ * Show a page, workbook, worksheet or workbook view in an iframe.
137
143
  *
138
- * @param {WorkbookSource | WorksheetSource | WorkbookViewSource} source - The source to show
144
+ * @param {PageSource | WorkbookSource | WorksheetSource | WorkbookViewSource} source - The source to show
139
145
  * @param {object} [options]
140
146
  * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
147
+ * @param {boolean} [options.expandNavigator] - Indicates if the navigator should be expanded.
141
148
  * @param {boolean} [options.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
142
149
  * @param {boolean} [options.hideWorkbookToolBar] - Whether to hide the workbook toolbar
143
150
  * @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"
151
+ * @param {MediaType} [options.mediaType] - Set to 'application/pdf' for views of type "JasperReports report"
145
152
  * to show the report PDF directly, without any Cadenza headers or footers.
146
153
  * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
147
154
  * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
148
155
  * @return {Promise<void>} A Promise for when the iframe is loaded
149
156
  * @throws For invalid arguments
150
157
  */
151
- show(source, { disabledUiFeatures, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, mediaType, operationMode, signal, } = {}) {
158
+ show(source, { disabledUiFeatures, expandNavigator, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, mediaType, operationMode, signal, } = {}) {
152
159
  this.#log('CadenzaClient#show', source);
153
160
  if (mediaType) {
154
161
  assertSupportedMediaType(mediaType, [MediaType.PDF]);
155
162
  }
156
163
  const params = createParams({
157
164
  disabledUiFeatures,
165
+ expandNavigator,
158
166
  hideMainHeaderAndFooter,
159
167
  hideWorkbookToolBar,
160
168
  highlightGlobalId,
@@ -170,6 +178,7 @@ export class CadenzaClient {
170
178
  * @param {WorkbookViewSource} mapView - The workbook map view to show
171
179
  * @param {object} [options] - Options
172
180
  * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
181
+ * @param {boolean} [options.expandNavigator] - Indicates if the navigator should be expanded.
173
182
  * @param {Geometry} [options.geometry] - A geometry to show on the map
174
183
  * @param {boolean} [options.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
175
184
  * @param {boolean} [options.hideWorkbookToolBar] - Whether to hide the workbook toolbar
@@ -182,13 +191,14 @@ export class CadenzaClient {
182
191
  * @return {Promise<void>} A Promise for when the iframe is loaded
183
192
  * @throws For invalid arguments
184
193
  */
185
- async showMap(mapView, { disabledUiFeatures, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, signal, } = {}) {
194
+ async showMap(mapView, { disabledUiFeatures, expandNavigator, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, signal, } = {}) {
186
195
  this.#log('CadenzaClient#showMap', mapView, geometry);
187
196
  if (geometry) {
188
197
  assertValidGeometryType(geometry.type);
189
198
  }
190
199
  const params = createParams({
191
200
  disabledUiFeatures,
201
+ expandNavigator,
192
202
  hideMainHeaderAndFooter,
193
203
  hideWorkbookToolBar,
194
204
  highlightGlobalId,
@@ -201,6 +211,15 @@ export class CadenzaClient {
201
211
  await this.#show(resolvePath(mapView), params, signal);
202
212
  this.#postEvent('setGeometry', { geometry });
203
213
  }
214
+ /**
215
+ * Expand/collapse the navigator tree.
216
+ *
217
+ * @param {boolean} expandNavigator - The expansion state of the navigator.
218
+ */
219
+ expandNavigator(expandNavigator) {
220
+ this.#log('CadenzaClient#expandNavigator', expandNavigator);
221
+ this.#postEvent('expandNavigator', { expandNavigator: !!expandNavigator });
222
+ }
204
223
  /**
205
224
  * Create a geometry.
206
225
  *
@@ -366,14 +385,16 @@ export class CadenzaClient {
366
385
  * * 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' (Excel)
367
386
  * * 'text/csv'
368
387
  * @param {object} options - Options
388
+ * @param {TablePart[]} [options.parts] - An optional array of table parts to export. If not specified, all parts are exported.
369
389
  * @param {AbortSignal} [options.signal] - A signal to abort the data fetching
370
390
  * @return {Promise<Response>} A Promise for the fetch response
371
391
  * @throws For invalid arguments
372
392
  */
373
- fetchData(source, mediaType, { signal } = {}) {
393
+ fetchData(source, mediaType, { parts, signal } = {}) {
374
394
  this.#log('CadenzaClient#fetchData', source, mediaType);
375
395
  assertSupportedMediaType(mediaType);
376
- const params = createParams({ mediaType });
396
+ assertValidTableParts(parts);
397
+ const params = createParams({ mediaType, parts });
377
398
  return this.#fetch(resolvePath(source), params, signal);
378
399
  }
379
400
  async #fetch(
@@ -406,12 +427,14 @@ export class CadenzaClient {
406
427
  * * 'text/csv'
407
428
  * @param {object} options - Options
408
429
  * @param {string} [options.fileName] - The file name to use; The file extension is appended by Cadenza.
430
+ * @param {TablePart[]} [options.parts] - An optional array of table parts to export. If not specified, all parts are exported.
409
431
  * @throws For invalid arguments
410
432
  */
411
- downloadData(source, mediaType, { fileName }) {
433
+ downloadData(source, mediaType, { fileName, parts }) {
412
434
  this.#log('CadenzaClient#downloadData', source, mediaType);
413
435
  assertSupportedMediaType(mediaType);
414
- const params = createParams({ fileName, mediaType });
436
+ assertValidTableParts(parts);
437
+ const params = createParams({ fileName, mediaType, parts });
415
438
  this.#download(resolvePath(source), params);
416
439
  }
417
440
  #download(/** @type string */ path, /** @type URLSearchParams */ params) {
@@ -441,11 +464,16 @@ export class CadenzaClient {
441
464
  }
442
465
  }
443
466
  function resolvePath(
444
- /** @type WorkbookSource | WorksheetSource | WorkbookViewSource */ source) {
467
+ /** @type PageSource | WorkbookSource | WorksheetSource | WorkbookViewSource */ source) {
445
468
  if (typeof source === 'string') {
446
469
  assert(validEmbeddingTargetId(source), `Invalid embedding target ID: ${source}`);
447
470
  return `/w/${source}`;
448
471
  }
472
+ else if ('page' in source) {
473
+ const page = source.page;
474
+ assert(validPageName(page), `Invalid page name: ${page}`);
475
+ return `/public/pages/${page}`;
476
+ }
449
477
  else {
450
478
  const { repositoryName, workbookId } = source;
451
479
  assert(validRepositoryName(repositoryName), `Invalid repository name: ${repositoryName}`);
@@ -478,6 +506,9 @@ function validUrl(/** @type string */ value) {
478
506
  return false;
479
507
  }
480
508
  }
509
+ function validPageName(/** @type string */ value) {
510
+ return ['welcome'].includes(value);
511
+ }
481
512
  function validEmbeddingTargetId(/** @type string */ value) {
482
513
  return /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value);
483
514
  }
@@ -512,6 +543,19 @@ function validGeometryType(/** @type string */ value) {
512
543
  'MultiPolygon',
513
544
  ].includes(value);
514
545
  }
546
+ /** @typedef {'columns' | 'values' | 'totals'} TablePart - A part of a table to export. */
547
+ function validTablePart(/** @type TablePart */ value) {
548
+ return ['columns', 'values', 'totals'].includes(value);
549
+ }
550
+ function assertValidTablePart(/** @type TablePart */ value) {
551
+ assert(validTablePart(value));
552
+ }
553
+ function assertValidTableParts(/** @type TablePart[] | undefined */ parts) {
554
+ if (parts) {
555
+ assert(Array.isArray(parts), `'parts' argument must be an array`);
556
+ parts.forEach(assertValidTablePart);
557
+ }
558
+ }
515
559
  function validOperationMode(/** @type string */ value) {
516
560
  return ['normal', 'simplified'].includes(value);
517
561
  }
@@ -532,12 +576,13 @@ const MediaType = /** @type {Record<string, MediaType>} */ {
532
576
  function assertSupportedMediaType(
533
577
  /** @type MediaType */ type,
534
578
  /** @type MediaType[] */ supportedTypes = Object.values(MediaType)) {
535
- return assert(supportedTypes.includes(type), `Invalid media type: ${type}`);
579
+ assert(supportedTypes.includes(type), `Invalid media type: ${type}`);
536
580
  }
537
581
  /**
538
582
  * @param {object} params - Options
539
583
  * @param {string} [params.action]
540
584
  * @param {UiFeature[]} [params.disabledUiFeatures]
585
+ * @param {boolean} [params.expandNavigator]
541
586
  * @param {string} [params.fileName]
542
587
  * @param {GeometryType} [params.geometryType]
543
588
  * @param {boolean} [params.hideMainHeaderAndFooter]
@@ -545,14 +590,15 @@ function assertSupportedMediaType(
545
590
  * @param {GlobalId} [params.highlightGlobalId]
546
591
  * @param {string} [params.locationFinder]
547
592
  * @param {Extent} [params.mapExtent]
548
- * @param {string} [params.mediaType]
593
+ * @param {MediaType} [params.mediaType]
549
594
  * @param {number} [params.minScale]
550
595
  * @param {OperationMode} [params.operationMode]
596
+ * @param {TablePart[]} [params.parts]
551
597
  * @param {boolean} [params.useMapSrs]
552
598
  * @param {ExternalLinkKey} [params.webApplication]
553
599
  * @return {URLSearchParams}
554
600
  */
555
- function createParams({ action, fileName, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, mediaType, minScale, useMapSrs, webApplication, operationMode, disabledUiFeatures, }) {
601
+ function createParams({ action, expandNavigator, fileName, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, mediaType, minScale, parts, useMapSrs, webApplication, operationMode, disabledUiFeatures, }) {
556
602
  if (disabledUiFeatures) {
557
603
  disabledUiFeatures.forEach((feature) => assert(validUiFeature(feature), `Invalid UI feature: ${feature}`));
558
604
  }
@@ -567,6 +613,7 @@ function createParams({ action, fileName, geometryType, hideMainHeaderAndFooter,
567
613
  ...(disabledUiFeatures && {
568
614
  disabledUiFeatures: disabledUiFeatures.join(),
569
615
  }),
616
+ ...(expandNavigator && { expandNavigator: 'true' }),
570
617
  ...(fileName && { fileName }),
571
618
  ...(geometryType && { geometryType }),
572
619
  ...(hideMainHeaderAndFooter && { hideMainHeaderAndFooter: 'true' }),
@@ -577,6 +624,7 @@ function createParams({ action, fileName, geometryType, hideMainHeaderAndFooter,
577
624
  ...(mediaType && { mediaType }),
578
625
  ...(minScale && { minScale: String(minScale) }),
579
626
  ...(operationMode && { operationMode }),
627
+ ...(parts && { parts: parts.join() }),
580
628
  ...(useMapSrs && { useMapSrs: 'true' }),
581
629
  ...(webApplication && {
582
630
  webApplicationLink: webApplication.externalLinkId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@disy/cadenza.js",
3
- "version": "1.1.0",
3
+ "version": "1.3.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 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>