@disy/cadenza.js 1.5.0 → 1.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@disy/cadenza.js",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": "github:DisyInformationssysteme/cadenza.js",
6
6
  "type": "module",
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], [type=number]), textarea {
44
+ select, input:is(:not([type]), [type=text], [type=number]), textarea, hr {
45
45
  display: block;
46
46
  width: 100%
47
47
  }
@@ -57,6 +57,12 @@
57
57
  const action = actionSelect.value;
58
58
  const settingsTemplate = document.querySelector(`[data-action=${action}]`);
59
59
  settingsContainer.append(settingsTemplate.content.cloneNode(true));
60
+ const commonSettingsTemplate = document.getElementById(`common-${settingsTemplate.dataset.common}`);
61
+ if (commonSettingsTemplate) {
62
+ settingsContainer.append(
63
+ document.createElement('hr'),
64
+ commonSettingsTemplate.content.cloneNode(true));
65
+ }
60
66
 
61
67
  const data = localStorage.getItem(`cadenzajs-sandbox-${action}`);
62
68
  if (data) {
@@ -68,67 +74,21 @@
68
74
  history.replaceState(null, '', url);
69
75
  };
70
76
 
71
- const contextPath = new URLSearchParams(location.search).get('contextPath') ?? '';
77
+ const contextPath = new URLSearchParams(location.search).get('contextPath')
78
+ ?? location.pathname.slice(0, location.pathname.indexOf('/sandbox'));
72
79
  const cadenzaClient = cadenza(location.origin + contextPath, { iframe: 'iframe', debug: true });
73
80
  const actionHandlers = {
74
- show ({ embeddingTargetId, expandNavigator, hideMainHeaderAndFooter, hideWorkbookToolBar, jasperReportAsPdf, highlightGlobalId, operationMode, disabledUiFeatures }) {
75
- cadenzaClient.show(embeddingTargetId, {
76
- expandNavigator: (expandNavigator === 'on'),
77
- hideMainHeaderAndFooter: (hideMainHeaderAndFooter === 'on'),
78
- hideWorkbookToolBar: (hideWorkbookToolBar === 'on'),
79
- highlightGlobalId,
80
- ...(jasperReportAsPdf === 'on' && { mediaType: 'application/pdf' }),
81
- ...(operationMode === 'on' && { operationMode: 'normal' }),
82
- disabledUiFeatures: disabledUiFeatures && disabledUiFeatures.split(',')
83
- });
84
- },
85
- showPage ({ page, expandNavigator, highlightGlobalId, labelSet }) {
86
- cadenzaClient.show({ page: page }, {
87
- expandNavigator: (expandNavigator === 'on'),
88
- highlightGlobalId,
89
- labelSet
90
- });
91
- },
92
- expandNavigator ({ expandNavigator }) {
93
- cadenzaClient.expandNavigator(expandNavigator === 'on');
94
- },
95
- showMap ({ embeddingTargetId, useMapSrs, geometry, mapExtent, locationFinder, highlightGlobalId }) {
96
- cadenzaClient.showMap(embeddingTargetId, {
97
- useMapSrs: useMapSrs === 'on',
98
- geometry: geometry && JSON.parse(geometry),
99
- mapExtent: mapExtent && mapExtent.split(','),
100
- locationFinder,
101
- highlightGlobalId
102
- });
103
- },
104
- createGeometry ({ embeddingTargetId, geometryType, useMapSrs, minScale, mapExtent, locationFinder }) {
105
- cadenzaClient.createGeometry(embeddingTargetId, geometryType, {
106
- useMapSrs: useMapSrs === 'on',
107
- minScale,
108
- mapExtent: mapExtent && mapExtent.split(','),
109
- locationFinder
110
- });
111
- },
112
- editGeometry ({ embeddingTargetId, geometry, useMapSrs, minScale, mapExtent, locationFinder }) {
113
- cadenzaClient.editGeometry(embeddingTargetId, JSON.parse(geometry), {
114
- useMapSrs: useMapSrs === 'on',
115
- minScale,
116
- mapExtent: mapExtent && mapExtent.split(','),
117
- locationFinder
118
- });
119
- },
120
- fetchData ({ embeddingTargetId, mediaType, parts }) {
81
+ show: data => cadenzaClient.show(data.embeddingTargetId, getOptions(data)),
82
+ showPage: data => cadenzaClient.show({ page: data.page }, getOptions(data)),
83
+ expandNavigator: data => cadenzaClient.expandNavigator(data.expandNavigator === 'on'),
84
+ showMap: data => cadenzaClient.showMap(data.embeddingTargetId, getOptions(data)),
85
+ createGeometry: data => cadenzaClient.createGeometry(data.embeddingTargetId, data.geometryType, getOptions(data)),
86
+ editGeometry: data => cadenzaClient.editGeometry(data.embeddingTargetId, JSON.parse(data.geometry), getOptions(data)),
87
+ fetchData: data => {
121
88
  console.log('Inspect the fetchData() request in the devtools.');
122
- cadenzaClient.fetchData(embeddingTargetId, mediaType, {
123
- parts: parts && parts.split(',')
124
- });
89
+ cadenzaClient.fetchData(data.embeddingTargetId, data.mediaType, getOptions(data));
125
90
  },
126
- downloadData ({ embeddingTargetId, mediaType, fileName, parts }) {
127
- cadenzaClient.downloadData(embeddingTargetId, mediaType, {
128
- fileName,
129
- parts: parts && parts.split(',')
130
- });
131
- }
91
+ downloadData: data => cadenzaClient.downloadData(data.embeddingTargetId, data.mediaType, getOptions(data))
132
92
  };
133
93
 
134
94
  const form = document.getElementById('form');
@@ -154,6 +114,40 @@
154
114
  }
155
115
  }
156
116
  }
117
+
118
+ function getOptions ({
119
+ disabledUiFeatures,
120
+ expandNavigator,
121
+ geometry,
122
+ hideMainHeaderAndFooter,
123
+ hideWorkbookToolBar,
124
+ highlightGlobalId,
125
+ jasperReportAsPdf,
126
+ labelSet,
127
+ locationFinder,
128
+ mapExtent,
129
+ minScale,
130
+ parts,
131
+ simplifiedOperationMode,
132
+ useMapSrs
133
+ }) {
134
+ return {
135
+ disabledUiFeatures: disabledUiFeatures && disabledUiFeatures.split(','),
136
+ expandNavigator: (expandNavigator === 'on'),
137
+ geometry: geometry && JSON.parse(geometry),
138
+ hideMainHeaderAndFooter: (hideMainHeaderAndFooter === 'on'),
139
+ hideWorkbookToolBar: (hideWorkbookToolBar === 'on'),
140
+ highlightGlobalId,
141
+ ...(jasperReportAsPdf === 'on' && { mediaType: 'application/pdf' }),
142
+ labelSet,
143
+ locationFinder,
144
+ mapExtent: mapExtent && mapExtent.split(','),
145
+ minScale,
146
+ parts: parts && parts.split(','),
147
+ ...(simplifiedOperationMode === 'on' && { operationMode: 'simplified' }),
148
+ useMapSrs: useMapSrs === 'on'
149
+ };
150
+ }
157
151
  </script>
158
152
  </head>
159
153
  <body>
@@ -185,17 +179,7 @@
185
179
  <iframe id="iframe"></iframe>
186
180
  </main>
187
181
 
188
- <template data-action="show">
189
- <div>
190
- <label for="embeddingTargetId">Embedding target ID *</label>
191
- <input name="embeddingTargetId" id="embeddingTargetId" required>
192
- </div>
193
- <div>
194
- <label>
195
- <input type="checkbox" name="jasperReportAsPdf" id="jasperReportAsPdf"/>
196
- Show Jasper Report as PDF
197
- </label>
198
- </div>
182
+ <template id="common-show">
199
183
  <div>
200
184
  <label>
201
185
  <input type="checkbox" name="expandNavigator">
@@ -216,8 +200,8 @@
216
200
  </div>
217
201
  <div>
218
202
  <label>
219
- <input type="checkbox" name="operationMode">
220
- Enable simplified operation mode
203
+ <input type="checkbox" name="simplifiedOperationMode">
204
+ Simplified operation mode
221
205
  </label>
222
206
  </div>
223
207
  <div>
@@ -230,23 +214,59 @@
230
214
  </div>
231
215
  </template>
232
216
 
233
- <template data-action="showPage">
217
+ <template id="common-map">
234
218
  <div>
235
- <label for="page">Page *</label>
236
- <select name="page" id="page" required>
237
- <option>welcome</option>
238
- <option>an-invalid-page-name</option>
219
+ <label>
220
+ <input type="checkbox" name="useMapSrs">
221
+ Use map SRS
222
+ </label>
223
+ </div>
224
+ <div>
225
+ <label for="mapExtent">Map extent coordinates</label>
226
+ <input name="mapExtent" id="mapExtent" placeholder="minX,minY,maxX,maxY">
227
+ </div>
228
+ <div>
229
+ <label for="locationFinder">Location finder search query</label>
230
+ <input name="locationFinder" id="locationFinder">
231
+ </div>
232
+ </template>
233
+
234
+ <template id="common-data">
235
+ <div>
236
+ <label for="mediaType">Media type *</label>
237
+ <select name="mediaType" id="mediaType" required>
238
+ <option>text/csv</option>
239
+ <option>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</option>
240
+ <option>application/json</option>
241
+ <option>application/pdf</option>
239
242
  </select>
240
243
  </div>
244
+ <div>
245
+ <label for="parts">Parts</label>
246
+ <input name="parts" id="parts" placeholder="columns,values,totals">
247
+ </div>
248
+ </template>
249
+
250
+ <template data-action="show" data-common="show">
251
+ <div>
252
+ <label for="embeddingTargetId">Embedding target ID *</label>
253
+ <input name="embeddingTargetId" id="embeddingTargetId" required>
254
+ </div>
241
255
  <div>
242
256
  <label>
243
- <input type="checkbox" name="expandNavigator">
244
- Expand navigator tree
257
+ <input type="checkbox" name="jasperReportAsPdf" id="jasperReportAsPdf"/>
258
+ Show Jasper Report as PDF
245
259
  </label>
246
260
  </div>
261
+ </template>
262
+
263
+ <template data-action="showPage" data-common="show">
247
264
  <div>
248
- <label for="highlightGlobalId">Highlighted Global ID</label>
249
- <input name="highlightGlobalId" id="highlightGlobalId">
265
+ <label for="page">Page *</label>
266
+ <select name="page" id="page" required>
267
+ <option>welcome</option>
268
+ <option>an-invalid-page-name</option>
269
+ </select>
250
270
  </div>
251
271
  <div>
252
272
  <label for="labelSet">Label Set</label>
@@ -263,46 +283,22 @@
263
283
  </div>
264
284
  </template>
265
285
 
266
- <template data-action="showMap">
286
+ <template data-action="showMap" data-common="show">
267
287
  <div>
268
288
  <label for="embeddingTargetId">Embedding target ID of the map view *</label>
269
289
  <input name="embeddingTargetId" id="embeddingTargetId" required>
270
290
  </div>
271
- <div>
272
- <label>
273
- <input type="checkbox" name="useMapSrs">
274
- Use map SRS
275
- </label>
276
- </div>
277
291
  <div>
278
292
  <label for="geometry">Geometry (GeoJSON)</label>
279
293
  <textarea name="geometry" id="geometry" rows="5"></textarea>
280
294
  </div>
281
- <div>
282
- <label for="mapExtent">Map extent coordinates</label>
283
- <input name="mapExtent" id="mapExtent" placeholder="minX,minY,maxX,maxY">
284
- </div>
285
- <div>
286
- <label for="locationFinder">Location finder search query</label>
287
- <input name="locationFinder" id="locationFinder">
288
- </div>
289
- <div>
290
- <label for="highlightGlobalId">Highlighted Global ID</label>
291
- <input name="highlightGlobalId" id="highlightGlobalId">
292
- </div>
293
295
  </template>
294
296
 
295
- <template data-action="createGeometry">
297
+ <template data-action="createGeometry" data-common="map">
296
298
  <div>
297
299
  <label for="embeddingTargetId">Embedding target ID of the map view *</label>
298
300
  <input name="embeddingTargetId" id="embeddingTargetId" required>
299
301
  </div>
300
- <div>
301
- <label>
302
- <input type="checkbox" name="useMapSrs">
303
- Use map SRS
304
- </label>
305
- </div>
306
302
  <div>
307
303
  <label for="geometryType">Geometry type</label>
308
304
  <select name="geometryType" id="geometryType">
@@ -318,27 +314,13 @@
318
314
  <label for="minScale">Minimum Scale</label>
319
315
  <input type="number" name="minScale" id="minScale">
320
316
  </div>
321
- <div>
322
- <label for="mapExtent">Map extent coordinates</label>
323
- <input name="mapExtent" id="mapExtent" placeholder="minX,minY,maxX,maxY">
324
- </div>
325
- <div>
326
- <label for="locationFinder">Location finder search query</label>
327
- <input name="locationFinder" id="locationFinder">
328
- </div>
329
317
  </template>
330
318
 
331
- <template data-action="editGeometry">
319
+ <template data-action="editGeometry" data-common="map">
332
320
  <div>
333
321
  <label for="embeddingTargetId">Embedding target ID of the map view *</label>
334
322
  <input name="embeddingTargetId" id="embeddingTargetId" required>
335
323
  </div>
336
- <div>
337
- <label>
338
- <input type="checkbox" name="useMapSrs">
339
- Use map SRS
340
- </label>
341
- </div>
342
324
  <div>
343
325
  <label for="geometry">Geometry (GeoJSON) *</label>
344
326
  <textarea name="geometry" id="geometry" rows="5" required></textarea>
@@ -347,58 +329,24 @@
347
329
  <label for="minScale">Minimum Scale</label>
348
330
  <input type="number" name="minScale" id="minScale">
349
331
  </div>
350
- <div>
351
- <label for="mapExtent">Map extent coordinates</label>
352
- <input name="mapExtent" id="mapExtent" placeholder="minX,minY,maxX,maxY">
353
- </div>
354
- <div>
355
- <label for="locationFinder">Location finder search query</label>
356
- <input name="locationFinder" id="locationFinder">
357
- </div>
358
332
  </template>
359
333
 
360
- <template data-action="downloadData">
334
+ <template data-action="downloadData" data-common="data">
361
335
  <div>
362
336
  <label for="embeddingTargetId">Embedding target ID *</label>
363
337
  <input name="embeddingTargetId" id="embeddingTargetId" required>
364
338
  </div>
365
- <div>
366
- <label for="parts">Parts</label>
367
- <input name="parts" id="parts" placeholder="columns,values,totals">
368
- </div>
369
- <div>
370
- <label for="mediaType">Media type *</label>
371
- <select name="mediaType" id="mediaType" required>
372
- <option>text/csv</option>
373
- <option>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</option>
374
- <option>application/json</option>
375
- <option>application/pdf</option>
376
- </select>
377
- </div>
378
339
  <div>
379
340
  <label for="fileName">Filename</label>
380
341
  <input name="fileName" id="fileName">
381
342
  </div>
382
343
  </template>
383
344
 
384
- <template data-action="fetchData">
345
+ <template data-action="fetchData" data-common="data">
385
346
  <div>
386
347
  <label for="embeddingTargetId">Embedding target ID *</label>
387
348
  <input name="embeddingTargetId" id="embeddingTargetId" required>
388
349
  </div>
389
- <div>
390
- <label for="parts">Parts</label>
391
- <input name="parts" id="parts" placeholder="columns,values,totals">
392
- </div>
393
- <div>
394
- <label for="mediaType">Media type *</label>
395
- <select name="mediaType" id="mediaType" required>
396
- <option>text/csv</option>
397
- <option>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</option>
398
- <option>application/json</option>
399
- <option>application/pdf</option>
400
- </select>
401
- </div>
402
350
  </template>
403
351
 
404
352
  </body>