@schukai/monster 3.54.0 → 3.55.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +25 -0
- package/package.json +1 -1
- package/source/components/datatable/datasource/rest.mjs +93 -57
- package/source/components/datatable/datatable/header.mjs +8 -0
- package/source/components/datatable/datatable.mjs +88 -44
- package/source/components/datatable/embedded-pagination.mjs +24 -43
- package/source/components/datatable/filter/util.mjs +138 -0
- package/source/components/datatable/filter.mjs +418 -174
- package/source/components/datatable/pagination.mjs +26 -2
- package/source/components/datatable/status.mjs +226 -0
- package/source/components/datatable/style/datatable.pcss +1 -0
- package/source/components/datatable/style/embedded-pagination.pcss +59 -2
- package/source/components/datatable/style/filter.pcss +4 -0
- package/source/components/datatable/style/pagination.pcss +28 -4
- package/source/components/datatable/style/status.pcss +42 -0
- package/source/components/datatable/stylesheet/column-bar.mjs +15 -9
- package/source/components/datatable/stylesheet/dataset.mjs +14 -8
- package/source/components/datatable/stylesheet/datasource.mjs +14 -8
- package/source/components/datatable/stylesheet/datatable.mjs +15 -9
- package/source/components/datatable/stylesheet/embedded-pagination.mjs +14 -8
- package/source/components/datatable/stylesheet/filter-button.mjs +15 -9
- package/source/components/datatable/stylesheet/filter-controls-defaults.mjs +14 -8
- package/source/components/datatable/stylesheet/filter-date-range.mjs +14 -8
- package/source/components/datatable/stylesheet/filter-range.mjs +14 -8
- package/source/components/datatable/stylesheet/filter.mjs +15 -9
- package/source/components/datatable/stylesheet/pagination.mjs +15 -9
- package/source/components/datatable/stylesheet/select-filter.mjs +14 -8
- package/source/components/datatable/stylesheet/status.mjs +33 -0
- package/source/components/form/action-button.mjs +3 -1
- package/source/components/form/api-button.mjs +1 -1
- package/source/components/form/button-bar.mjs +1 -1
- package/source/components/form/button.mjs +1 -1
- package/source/components/form/confirm-button.mjs +3 -1
- package/source/components/form/context-error.mjs +272 -0
- package/source/components/form/context-help.mjs +7 -5
- package/source/components/form/form.mjs +4 -2
- package/source/components/form/message-state-button.mjs +4 -2
- package/source/components/form/popper-button.mjs +9 -4
- package/source/components/form/popper.mjs +11 -3
- package/source/components/form/reload.mjs +1 -1
- package/source/components/form/select.mjs +3 -3
- package/source/components/form/shadow-reload.mjs +1 -1
- package/source/components/form/state-button.mjs +4 -1
- package/source/components/form/style/context-error.pcss +32 -0
- package/source/components/form/style/context-help.pcss +22 -5
- package/source/components/form/stylesheet/action-button.mjs +14 -8
- package/source/components/form/stylesheet/api-button.mjs +14 -8
- package/source/components/form/stylesheet/button-bar.mjs +14 -8
- package/source/components/form/stylesheet/button.mjs +14 -8
- package/source/components/form/stylesheet/confirm-button.mjs +14 -8
- package/source/components/form/stylesheet/context-error.mjs +33 -0
- package/source/components/form/stylesheet/context-help.mjs +15 -9
- package/source/components/form/stylesheet/form.mjs +14 -8
- package/source/components/form/stylesheet/message-state-button.mjs +14 -8
- package/source/components/form/stylesheet/popper-button.mjs +14 -8
- package/source/components/form/stylesheet/popper.mjs +14 -8
- package/source/components/form/stylesheet/select.mjs +15 -9
- package/source/components/form/stylesheet/state-button.mjs +14 -8
- package/source/components/form/stylesheet/tabs.mjs +15 -9
- package/source/components/form/stylesheet/tree-select.mjs +14 -8
- package/source/components/form/tabs.mjs +53 -7
- package/source/components/form/template.mjs +1 -1
- package/source/components/form/tree-select.mjs +1 -1
- package/source/components/host/collapse.mjs +20 -5
- package/source/components/host/config-manager.mjs +41 -2
- package/source/components/host/host.mjs +14 -0
- package/source/components/host/stylesheet/call-button.mjs +15 -9
- package/source/components/host/stylesheet/collapse.mjs +14 -8
- package/source/components/host/stylesheet/config-manager.mjs +14 -8
- package/source/components/host/stylesheet/details.mjs +14 -8
- package/source/components/host/stylesheet/host.mjs +14 -8
- package/source/components/host/stylesheet/overlay.mjs +15 -9
- package/source/components/host/stylesheet/toggle-button.mjs +15 -9
- package/source/components/host/stylesheet/viewer.mjs +14 -8
- package/source/components/host/util.mjs +6 -1
- package/source/components/notify/stylesheet/message.mjs +15 -9
- package/source/components/notify/stylesheet/notify.mjs +14 -8
- package/source/components/state/stylesheet/log.mjs +14 -8
- package/source/components/state/stylesheet/state.mjs +14 -8
- package/source/components/stylesheet/badge.mjs +14 -8
- package/source/components/stylesheet/border.mjs +14 -8
- package/source/components/stylesheet/button.mjs +14 -8
- package/source/components/stylesheet/card.mjs +14 -8
- package/source/components/stylesheet/color.mjs +14 -8
- package/source/components/stylesheet/common.mjs +14 -8
- package/source/components/stylesheet/control.mjs +14 -8
- package/source/components/stylesheet/data-grid.mjs +14 -8
- package/source/components/stylesheet/display.mjs +14 -8
- package/source/components/stylesheet/floating-ui.mjs +14 -8
- package/source/components/stylesheet/form.mjs +14 -8
- package/source/components/stylesheet/host.mjs +14 -8
- package/source/components/stylesheet/icons.mjs +15 -9
- package/source/components/stylesheet/link.mjs +14 -8
- package/source/components/stylesheet/normalize.mjs +14 -8
- package/source/components/stylesheet/popper.mjs +14 -8
- package/source/components/stylesheet/property.mjs +14 -8
- package/source/components/stylesheet/ripple.mjs +14 -8
- package/source/components/stylesheet/skeleton.mjs +14 -8
- package/source/components/stylesheet/space.mjs +14 -8
- package/source/components/stylesheet/spinner.mjs +14 -8
- package/source/components/stylesheet/table.mjs +14 -8
- package/source/components/stylesheet/theme.mjs +14 -8
- package/source/components/stylesheet/typography.mjs +14 -8
- package/source/components/tree-menu/stylesheet/tree-menu.mjs +14 -8
- package/source/data/transformer.mjs +38 -43
- package/source/dom/attributes.mjs +5 -5
- package/source/dom/customelement.mjs +1 -1
- package/source/dom/updater.mjs +14 -5
- package/source/dom/util.mjs +42 -0
- package/source/i18n/providers/embed.mjs +3 -3
- package/source/monster.mjs +5 -0
- package/source/text/formatter.mjs +2 -2
- package/source/types/noderecursiveiterator.mjs +9 -7
- package/source/types/observer.mjs +1 -1
- package/source/types/version.mjs +1 -1
- package/source/util/sleep.mjs +17 -0
- package/test/cases/components/form/button.mjs +2 -1
- package/test/cases/components/form/select.mjs +1 -1
- package/test/cases/components/form/tree-select.mjs +1 -1
- package/test/cases/data/transformer.mjs +2 -2
- package/test/cases/dom/updater.mjs +67 -46
- package/test/cases/monster.mjs +1 -1
- package/test/web/test.html +2 -2
- package/test/web/tests.js +18 -13
package/CHANGELOG.md
CHANGED
@@ -1,9 +1,34 @@
|
|
1
1
|
|
2
|
+
## [3.55.1] - 2024-01-22
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
- catch errors [#133](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/133)
|
7
|
+
- catch errors [#133](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/133)
|
8
|
+
- check parameter [#132](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/132)
|
9
|
+
### Changes
|
10
|
+
|
11
|
+
- doc
|
12
|
+
- lint + formatt
|
13
|
+
- update nixos to 23-11
|
14
|
+
|
15
|
+
## [3.55.0] - 2023-11-29
|
16
|
+
|
17
|
+
### Add Features
|
18
|
+
|
19
|
+
- various changes [#131](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/131)
|
20
|
+
### Changes
|
21
|
+
|
22
|
+
- release and publish to npm new version 3.55.0
|
23
|
+
|
2
24
|
## [3.54.0] - 2023-11-23
|
3
25
|
|
4
26
|
### Add Features
|
5
27
|
|
6
28
|
- new closeOnSelect feature
|
29
|
+
### Changes
|
30
|
+
|
31
|
+
- release and publish to npm new version 3.54.0
|
7
32
|
|
8
33
|
## [3.53.0] - 2023-11-11
|
9
34
|
|
package/package.json
CHANGED
@@ -80,24 +80,35 @@ class Rest extends Datasource {
|
|
80
80
|
}
|
81
81
|
|
82
82
|
/**
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
83
|
+
* To set the options via the html tag the attribute `data-monster-options` must be used.
|
84
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
85
|
+
*
|
86
|
+
* The individual configuration values can be found in the table.
|
87
|
+
*
|
88
|
+
* @property {Object} templates Template definitions
|
89
|
+
* @property {string} templates.main Main template
|
90
|
+
* @property {Object} features Feature definitions
|
91
|
+
* @property {boolean} features.autoInit If true, the component is initialized automatically
|
92
|
+
* @property {boolean} features.filter If true, the component is initialized automatically
|
93
|
+
* @property {Object} autoInit Auto init definitions
|
94
|
+
* @property {boolean} autoInit.intersectionObserver If true, the intersection observer is initialized automatically
|
95
|
+
* @property {boolean} autoInit.oneTime If true, the intersection observer is initialized only once
|
96
|
+
* @property {Object} filter Filter definitions
|
97
|
+
* @property {string} filter.id The id of the filter control
|
98
|
+
* @property {Object} datatable Datatable definitions
|
99
|
+
* @property {string} datatable.id The id of the datatable control
|
100
|
+
* @property {Object} response Response definitions
|
101
|
+
* @property {string} response.errorMessagePath The path to the error message in the response
|
102
|
+
* @property {Object} read Read configuration
|
103
|
+
* @property {string} read.url The url of the rest api
|
104
|
+
* @property {string} read.method The method of the rest api
|
105
|
+
* @property {Object} read.parameters The parameters of the rest api
|
106
|
+
* @property {Object} read.parameters.filter The filter of the rest api
|
107
|
+
* @property {Object} read.parameters.orderBy The order by of the rest api
|
108
|
+
* @property {Object} read.parameters.page The page of the rest api
|
109
|
+
* @property {Object} write Write configuration
|
110
|
+
|
111
|
+
*/
|
101
112
|
get defaults() {
|
102
113
|
const restOptions = new RestAPI().defaults;
|
103
114
|
|
@@ -126,6 +137,10 @@ class Rest extends Datasource {
|
|
126
137
|
id: undefined,
|
127
138
|
},
|
128
139
|
|
140
|
+
datatable: {
|
141
|
+
id: undefined,
|
142
|
+
},
|
143
|
+
|
129
144
|
response: {
|
130
145
|
errorMessagePath: "sys.message",
|
131
146
|
},
|
@@ -176,7 +191,7 @@ class Rest extends Datasource {
|
|
176
191
|
* Fetches the data from the rest api
|
177
192
|
* @returns {Promise<never>|*}
|
178
193
|
*/
|
179
|
-
fetch() {
|
194
|
+
fetch() {;
|
180
195
|
const opt = clone(this.getOption("read"));
|
181
196
|
this[dataSourceSymbol].setOption("read", opt);
|
182
197
|
|
@@ -190,7 +205,32 @@ class Rest extends Datasource {
|
|
190
205
|
url = formatter.format(url);
|
191
206
|
|
192
207
|
this[dataSourceSymbol].setOption("read.url", url);
|
193
|
-
|
208
|
+
|
209
|
+
return new Promise((resolve, reject) => {
|
210
|
+
fireCustomEvent(this, "monster-datasource-fetch", {
|
211
|
+
datasource: this,
|
212
|
+
});
|
213
|
+
|
214
|
+
setTimeout(() => {
|
215
|
+
this[dataSourceSymbol]
|
216
|
+
.read()
|
217
|
+
.then((response) => {
|
218
|
+
fireCustomEvent(this, "monster-datasource-fetched", {
|
219
|
+
datasource: this,
|
220
|
+
});
|
221
|
+
|
222
|
+
resolve(response);
|
223
|
+
})
|
224
|
+
.catch((error) => {
|
225
|
+
fireCustomEvent(this, "monster-datasource-error", {
|
226
|
+
error: error,
|
227
|
+
});
|
228
|
+
|
229
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, error.toString());
|
230
|
+
reject(error);
|
231
|
+
});
|
232
|
+
}, 0);
|
233
|
+
});
|
194
234
|
}
|
195
235
|
|
196
236
|
/**
|
@@ -277,37 +317,45 @@ function initFilter() {
|
|
277
317
|
const query = filterControl.getOption("query", undefined);
|
278
318
|
this.setParameters({ query: query });
|
279
319
|
this.fetch()
|
280
|
-
.then(() => {
|
281
|
-
|
282
|
-
|
320
|
+
.then((response) => {
|
321
|
+
if (!(response instanceof Response)) {
|
322
|
+
throw new Error("Response is not an instance of Response");
|
323
|
+
}
|
324
|
+
|
325
|
+
if (response?.ok === true) {
|
326
|
+
this.dispatchEvent(new CustomEvent("reload", { bubbles: true }));
|
327
|
+
filterControl?.showSuccess();
|
328
|
+
}
|
329
|
+
|
330
|
+
response
|
331
|
+
.json()
|
332
|
+
.then((json) => {
|
333
|
+
const path = new Pathfinder(json);
|
334
|
+
const error = path.getVia(
|
335
|
+
this.getOption("response.errorMessagePath"),
|
336
|
+
);
|
337
|
+
if (error) {
|
338
|
+
filterControl?.showFailureMessage(error);
|
339
|
+
return;
|
340
|
+
}
|
341
|
+
|
342
|
+
filterControl?.showFailureMessage(e.message);
|
343
|
+
})
|
344
|
+
.catch((e) => {
|
345
|
+
filterControl?.showFailureMessage(e.message);
|
346
|
+
});
|
283
347
|
})
|
284
348
|
.catch((e) => {
|
285
349
|
this.dispatchEvent(
|
286
350
|
new CustomEvent("error", { bubbles: true, detail: e }),
|
287
351
|
);
|
288
352
|
|
289
|
-
|
290
|
-
|
291
|
-
response
|
292
|
-
.json()
|
293
|
-
.then((json) => {
|
294
|
-
const path = new Pathfinder(json);
|
295
|
-
const error = path.getVia(
|
296
|
-
this.getOption("response.errorMessagePath"),
|
297
|
-
);
|
298
|
-
if (error) {
|
299
|
-
filterControl?.showFailureMessage(error);
|
300
|
-
return;
|
301
|
-
}
|
302
|
-
|
303
|
-
filterControl?.showFailureMessage(e.message);
|
304
|
-
})
|
305
|
-
.catch((e) => {
|
306
|
-
filterControl?.showFailureMessage(e.message);
|
307
|
-
});
|
308
|
-
} else {
|
309
|
-
filterControl?.showFailureMessage(e.message);
|
353
|
+
if (!(e instanceof Error)) {
|
354
|
+
e = new Error(e);
|
310
355
|
}
|
356
|
+
|
357
|
+
filterControl?.showFailureMessage(e.message);
|
358
|
+
return Promise.reject(e);
|
311
359
|
});
|
312
360
|
});
|
313
361
|
|
@@ -329,19 +377,7 @@ function initAutoInit() {
|
|
329
377
|
}
|
330
378
|
|
331
379
|
setTimeout(() => {
|
332
|
-
this.fetch()
|
333
|
-
.then(() => {
|
334
|
-
fireCustomEvent(this, "monster-datasource-fetched", {
|
335
|
-
datasource: this,
|
336
|
-
});
|
337
|
-
})
|
338
|
-
.catch((error) => {
|
339
|
-
fireCustomEvent(this, "monster-datasource-error", {
|
340
|
-
error: error,
|
341
|
-
});
|
342
|
-
|
343
|
-
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, String(error));
|
344
|
-
});
|
380
|
+
this.fetch().catch(() => {});
|
345
381
|
}, 0);
|
346
382
|
}
|
347
383
|
|
@@ -110,6 +110,14 @@ class Header extends Base {
|
|
110
110
|
this.setInternal("direction", direction);
|
111
111
|
}
|
112
112
|
|
113
|
+
/**
|
114
|
+
*
|
115
|
+
* @param direction
|
116
|
+
*/
|
117
|
+
setDirection(direction) {
|
118
|
+
this.setInternal("direction", direction);
|
119
|
+
}
|
120
|
+
|
113
121
|
/**
|
114
122
|
* @param {string} field
|
115
123
|
*/
|
@@ -40,6 +40,7 @@ import {
|
|
40
40
|
DIRECTION_DESC,
|
41
41
|
DIRECTION_NONE,
|
42
42
|
} from "./datatable/header.mjs";
|
43
|
+
import { getStoredFilterConfigKey } from "./filter/util.mjs";
|
43
44
|
import { DatatableStyleSheet } from "./stylesheet/datatable.mjs";
|
44
45
|
import {
|
45
46
|
handleDataSourceChanges,
|
@@ -270,31 +271,48 @@ class DataTable extends CustomElement {
|
|
270
271
|
getHostConfig
|
271
272
|
.call(this, getColumnVisibilityConfigKey)
|
272
273
|
.then((config) => {
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
274
|
+
const headerOrderMap = new Map();
|
275
|
+
|
276
|
+
getHostConfig
|
277
|
+
.call(this, getStoredOrderConfigKey)
|
278
|
+
.then((orderConfig) => {
|
279
|
+
if (isArray(orderConfig) || orderConfig.length > 0) {
|
280
|
+
for (let i = 0; i < orderConfig.length; i++) {
|
281
|
+
const item = orderConfig[i];
|
282
|
+
const parts = item.split(" ");
|
283
|
+
const field = parts[0];
|
284
|
+
const direction = parts[1] || DIRECTION_ASC;
|
285
|
+
headerOrderMap.set(field, direction);
|
286
|
+
}
|
287
|
+
}
|
288
|
+
})
|
289
|
+
.then(() => {
|
290
|
+
try {
|
291
|
+
initGridAndStructs.call(this, config, headerOrderMap);
|
292
|
+
} catch (error) {
|
293
|
+
addAttributeToken(
|
294
|
+
this,
|
295
|
+
ATTRIBUTE_ERRORMESSAGE,
|
296
|
+
error?.message || error.toString(),
|
297
|
+
);
|
298
|
+
}
|
299
|
+
|
300
|
+
updateColumnBar.call(this);
|
301
|
+
})
|
302
|
+
.catch((error) => {
|
303
|
+
addAttributeToken(
|
304
|
+
this,
|
305
|
+
ATTRIBUTE_ERRORMESSAGE,
|
306
|
+
error?.message || error.toString(),
|
307
|
+
);
|
308
|
+
});
|
280
309
|
})
|
281
310
|
.catch((error) => {
|
282
|
-
addAttributeToken(
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
.then((config) => {
|
288
|
-
try {
|
289
|
-
// initGridAndStructs.call(self, config);
|
290
|
-
} catch (error) {
|
291
|
-
// addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, String(error));
|
292
|
-
}
|
293
|
-
|
294
|
-
//updateColumnBar.call(self);
|
295
|
-
})
|
296
|
-
.catch((error) => {
|
297
|
-
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, String(error));
|
311
|
+
addAttributeToken(
|
312
|
+
this,
|
313
|
+
ATTRIBUTE_ERRORMESSAGE,
|
314
|
+
error?.message || error.toString(),
|
315
|
+
);
|
298
316
|
});
|
299
317
|
}
|
300
318
|
|
@@ -340,14 +358,13 @@ function getHostConfig(callback) {
|
|
340
358
|
}
|
341
359
|
|
342
360
|
const configKey = callback.call(this);
|
343
|
-
return host
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
})
|
348
|
-
.catch(() => {
|
361
|
+
return host.hasConfig(configKey).then((hasConfig) => {
|
362
|
+
if (hasConfig) {
|
363
|
+
return host.getConfig(configKey);
|
364
|
+
} else {
|
349
365
|
return {};
|
350
|
-
}
|
366
|
+
}
|
367
|
+
});
|
351
368
|
}
|
352
369
|
|
353
370
|
/**
|
@@ -367,7 +384,7 @@ function updateColumnBar() {
|
|
367
384
|
}
|
368
385
|
|
369
386
|
columns.push({
|
370
|
-
visible: mode
|
387
|
+
visible: mode !== ATTRIBUTE_DATATABLE_MODE_HIDDEN,
|
371
388
|
name: header.label,
|
372
389
|
index: header.index,
|
373
390
|
});
|
@@ -480,11 +497,8 @@ function initEventHandler() {
|
|
480
497
|
ATTRIBUTE_DATATABLE_SORTABLE,
|
481
498
|
`${headers[index].field} ${headers[index].direction}`,
|
482
499
|
);
|
483
|
-
|
484
|
-
|
485
|
-
{ orderBy: createOrderStatement(headers) },
|
486
|
-
true,
|
487
|
-
);
|
500
|
+
|
501
|
+
storeOrderStatement.call(self, true);
|
488
502
|
}, 0);
|
489
503
|
}
|
490
504
|
});
|
@@ -493,7 +507,7 @@ function initEventHandler() {
|
|
493
507
|
/**
|
494
508
|
* @private
|
495
509
|
*/
|
496
|
-
function initGridAndStructs(hostConfig) {
|
510
|
+
function initGridAndStructs(hostConfig, headerOrderMap) {
|
497
511
|
const rowID = this.getOption("templateMapping.row-key");
|
498
512
|
|
499
513
|
if (!this[gridElementSymbol]) {
|
@@ -597,18 +611,48 @@ function initGridAndStructs(hostConfig) {
|
|
597
611
|
mode: mode,
|
598
612
|
grid: grid,
|
599
613
|
labelKey: labelKey,
|
614
|
+
direction: headerOrderMap.get(field) || DIRECTION_NONE,
|
600
615
|
});
|
601
616
|
|
602
617
|
headers.push(header);
|
603
618
|
}
|
604
619
|
|
605
|
-
const statement = createOrderStatement(headers);
|
606
|
-
setDataSource.call(
|
607
|
-
this,
|
608
|
-
{ orderBy: statement },
|
609
|
-
this.getOption("features.autoInit"),
|
610
|
-
);
|
611
620
|
this.setOption("headers", headers);
|
621
|
+
storeOrderStatement.call(this, this.getOption("features.autoInit"));
|
622
|
+
}
|
623
|
+
|
624
|
+
/**
|
625
|
+
* @private
|
626
|
+
* @returns {string}
|
627
|
+
*/
|
628
|
+
export function getStoredOrderConfigKey() {
|
629
|
+
return generateUniqueConfigKey("datatable", this?.id, "stored-order");
|
630
|
+
}
|
631
|
+
|
632
|
+
/**
|
633
|
+
* @private
|
634
|
+
*/
|
635
|
+
function storeOrderStatement(doFetch) {
|
636
|
+
const headers = this.getOption("headers");
|
637
|
+
const statement = createOrderStatement(headers);
|
638
|
+
setDataSource.call(this, { orderBy: statement }, doFetch);
|
639
|
+
|
640
|
+
const document = getDocument();
|
641
|
+
const host = document.querySelector("monster-host");
|
642
|
+
if (!(host && this.id)) {
|
643
|
+
return;
|
644
|
+
}
|
645
|
+
|
646
|
+
const configKey = getStoredOrderConfigKey.call(this);
|
647
|
+
|
648
|
+
// statement explode with , and remove all empty
|
649
|
+
const list = statement.split(",").filter((item) => item.trim() !== "");
|
650
|
+
if (list.length === 0) {
|
651
|
+
// host.deleteConfig(configKey);
|
652
|
+
return;
|
653
|
+
}
|
654
|
+
|
655
|
+
host.setConfig(configKey, list);
|
612
656
|
}
|
613
657
|
|
614
658
|
/**
|
@@ -736,7 +780,7 @@ function getEmptyTemplate() {
|
|
736
780
|
<path d="m16.807 17h-9.614c-.622 0-1.186-.391-1.404-.973l-1.014-2.703c-.072-.194-.26-.324-.468-.324h-3.557c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h3.557c.622 0 1.186.391 1.405.973l1.013 2.703c.073.194.261.324.468.324h9.613c.208 0 .396-.13.468-.324l1.013-2.703c.22-.582.784-.973 1.406-.973h3.807c.276 0 .5.224.5.5s-.224.5-.5.5h-3.807c-.208 0-.396.13-.468.324l-1.013 2.703c-.219.582-.784.973-1.405.973z"/>
|
737
781
|
</svg>
|
738
782
|
</div>
|
739
|
-
<div part="content" monster-replace="path:labels.theListContainsNoEntries">
|
783
|
+
<div part="content" data-monster-replace="path:labels.theListContainsNoEntries">
|
740
784
|
The list contains no entries.
|
741
785
|
</div>
|
742
786
|
</monster-state>`;
|
@@ -3,9 +3,13 @@
|
|
3
3
|
* SPDX-License-Identifier: AGPL-3.0
|
4
4
|
*/
|
5
5
|
|
6
|
-
import {
|
6
|
+
import {
|
7
|
+
assembleMethodSymbol,
|
8
|
+
registerCustomElement,
|
9
|
+
} from "../../dom/customelement.mjs";
|
7
10
|
import { EmbeddedPaginationStyleSheet } from "./stylesheet/embedded-pagination.mjs";
|
8
11
|
import { instanceSymbol } from "../../constants.mjs";
|
12
|
+
|
9
13
|
import "../form/select.mjs";
|
10
14
|
import { Pagination } from "./pagination.mjs";
|
11
15
|
|
@@ -55,6 +59,21 @@ class EmbeddedPagination extends Pagination {
|
|
55
59
|
return Symbol.for("@schukai/monster/components/embedded-pagination");
|
56
60
|
}
|
57
61
|
|
62
|
+
[assembleMethodSymbol]() {
|
63
|
+
super[assembleMethodSymbol]();
|
64
|
+
}
|
65
|
+
|
66
|
+
get defaults() {
|
67
|
+
return Object.assign({}, super.defaults, {
|
68
|
+
classes: {
|
69
|
+
spinner: "monster-spinner monster-theme-primary-3",
|
70
|
+
spinnerContainer: "monster-theme-primary-2 ",
|
71
|
+
error: "monster-theme-error-2 monster-bg-color-primary-2",
|
72
|
+
errorContainer: "monster-theme-primary-2",
|
73
|
+
},
|
74
|
+
});
|
75
|
+
}
|
76
|
+
|
58
77
|
/**
|
59
78
|
*
|
60
79
|
* @return {string}
|
@@ -64,50 +83,12 @@ class EmbeddedPagination extends Pagination {
|
|
64
83
|
}
|
65
84
|
|
66
85
|
/**
|
67
|
-
*
|
68
|
-
* @
|
86
|
+
* @private
|
87
|
+
* @returns {CSSStyleSheet}
|
69
88
|
*/
|
70
|
-
static
|
71
|
-
return
|
89
|
+
static getControlCSSStyleSheet() {
|
90
|
+
return EmbeddedPaginationStyleSheet;
|
72
91
|
}
|
73
92
|
}
|
74
93
|
|
75
|
-
/**
|
76
|
-
* @private
|
77
|
-
* @return {string}
|
78
|
-
*/
|
79
|
-
function getTemplate() {
|
80
|
-
// language=HTML
|
81
|
-
return `
|
82
|
-
<template id="items">
|
83
|
-
<li><a data-monster-attributes="class path:items.class,
|
84
|
-
href path:items.href,
|
85
|
-
aria-label path:items.description,
|
86
|
-
disabled path:items.disabled:?disabled:undefined,
|
87
|
-
data-page-no path:items.pageNo,
|
88
|
-
aria-current path:items.current"
|
89
|
-
data-monster-role="pagination-item"
|
90
|
-
data-monster-replace="path:items.label"></a></li>
|
91
|
-
</template>
|
92
|
-
|
93
|
-
<div data-monster-role="control">
|
94
|
-
<nav data-monster-role="pagination" role="navigation" aria-label="pagination">
|
95
|
-
<ul class="pagination-list" data-monster-insert="items path:pagination.items">
|
96
|
-
<li part="pagination-prev"><a data-monster-role="pagination-prev"
|
97
|
-
data-monster-attributes="
|
98
|
-
class path:pagination.prevClass | prefix: previous,
|
99
|
-
data-page-no path:pagination.prevNo,
|
100
|
-
href path:pagination.prevHref | prefix: #"
|
101
|
-
data-monster-replace="path:labels.previous">Previous</a></li>
|
102
|
-
<li part="pagination-next"><a data-monster-role="pagination-next"
|
103
|
-
data-monster-attributes="class path:pagination.nextClass | prefix: next,
|
104
|
-
data-page-no path:pagination.nextNo,
|
105
|
-
href path:pagination.nextHref | prefix: #"
|
106
|
-
data-monster-replace="path:labels.next">Next</a></li>
|
107
|
-
</ul>
|
108
|
-
</nav>
|
109
|
-
</div>
|
110
|
-
`;
|
111
|
-
}
|
112
|
-
|
113
94
|
registerCustomElement(EmbeddedPagination);
|
@@ -0,0 +1,138 @@
|
|
1
|
+
import { generateUniqueConfigKey } from "../../host/util.mjs";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @private
|
5
|
+
* @returns {string}
|
6
|
+
*/
|
7
|
+
export function getFilterConfigKey() {
|
8
|
+
return generateUniqueConfigKey("datatable", this?.id, "filter");
|
9
|
+
}
|
10
|
+
|
11
|
+
/**
|
12
|
+
* @private
|
13
|
+
* @returns {string}
|
14
|
+
*/
|
15
|
+
export function getStoredFilterConfigKey() {
|
16
|
+
return generateUniqueConfigKey("datatable", this?.id, "stored-filter");
|
17
|
+
}
|
18
|
+
|
19
|
+
/**
|
20
|
+
* @private
|
21
|
+
* @param {String} str
|
22
|
+
* @param {String} field
|
23
|
+
* @returns {String}
|
24
|
+
* @throws {Error} if no field is defined
|
25
|
+
*/
|
26
|
+
export function parseDateInput(str, field) {
|
27
|
+
if (!str) {
|
28
|
+
return "";
|
29
|
+
}
|
30
|
+
|
31
|
+
if (!field) {
|
32
|
+
throw new Error("no field is defined");
|
33
|
+
}
|
34
|
+
|
35
|
+
// Define the supported formats
|
36
|
+
//let formats = ['DD-MM-YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD', 'YYYY/MM/DD', 'DD.MM.YYYY'];
|
37
|
+
const formats = ["YYYY-MM-DD"];
|
38
|
+
// Determine the current date format of the localization
|
39
|
+
const currentDateFormat = new Intl.DateTimeFormat()
|
40
|
+
.format(new Date())
|
41
|
+
.replace(/\d/g, "D");
|
42
|
+
// formats.push(currentDateFormat);
|
43
|
+
|
44
|
+
// Run through the supported formats and try to parse the date
|
45
|
+
for (let i = 0; i < formats.length; i++) {
|
46
|
+
const format = formats[i];
|
47
|
+
// Replace the corresponding placeholders in the format string with regular expressions
|
48
|
+
|
49
|
+
try {
|
50
|
+
const pattern = format
|
51
|
+
.replace("DD", "\\d{2}")
|
52
|
+
.replace("MM", "\\d{2}")
|
53
|
+
.replace("YYYY", "\\d{4}");
|
54
|
+
const rangePattern =
|
55
|
+
"(?<from>" + pattern + ")\\s*-\\s*(?<to>" + pattern + ")";
|
56
|
+
|
57
|
+
const rangeRegex = new RegExp("^" + rangePattern + "$", "g");
|
58
|
+
|
59
|
+
if (rangeRegex.test(str)) {
|
60
|
+
rangeRegex.lastIndex = 0;
|
61
|
+
|
62
|
+
const rangeResult = rangeRegex.exec(str);
|
63
|
+
|
64
|
+
if (!rangeResult) {
|
65
|
+
continue;
|
66
|
+
}
|
67
|
+
|
68
|
+
const from = rangeResult?.groups?.from;
|
69
|
+
const to = rangeResult?.groups?.to;
|
70
|
+
|
71
|
+
if (from && to) {
|
72
|
+
return (
|
73
|
+
"(" +
|
74
|
+
field +
|
75
|
+
">='" +
|
76
|
+
from +
|
77
|
+
" 00:00:00' AND " +
|
78
|
+
field +
|
79
|
+
"<='" +
|
80
|
+
to +
|
81
|
+
" 23:59:59')"
|
82
|
+
);
|
83
|
+
}
|
84
|
+
|
85
|
+
if (from) {
|
86
|
+
return "(" + field + ">='" + from + " 00:00:00')";
|
87
|
+
} else if (to) {
|
88
|
+
return "(" + field + "<='" + to + "' 23:59:59')";
|
89
|
+
}
|
90
|
+
|
91
|
+
return "false";
|
92
|
+
}
|
93
|
+
|
94
|
+
const prefix = str.substring(0, 1) === "-";
|
95
|
+
const suffix = str.substring(str.length - 1, str.length) === "-";
|
96
|
+
|
97
|
+
if (prefix) {
|
98
|
+
str = str.substring(1, str.length);
|
99
|
+
} else if (suffix) {
|
100
|
+
str = str.substring(0, str.length - 1);
|
101
|
+
}
|
102
|
+
|
103
|
+
const regex = new RegExp("^(?<date>" + pattern + ")$", "g");
|
104
|
+
if (regex.test(str)) {
|
105
|
+
regex.lastIndex = 0;
|
106
|
+
const result = regex.exec(str);
|
107
|
+
|
108
|
+
if (!result) {
|
109
|
+
continue;
|
110
|
+
}
|
111
|
+
|
112
|
+
const date = result?.groups?.date;
|
113
|
+
if (date) {
|
114
|
+
if (prefix) {
|
115
|
+
return "(" + field + "<='" + date + " 23:59:59')";
|
116
|
+
} else if (suffix) {
|
117
|
+
return "(" + field + ">='" + date + "' 00:00:00')";
|
118
|
+
}
|
119
|
+
return (
|
120
|
+
"(" +
|
121
|
+
field +
|
122
|
+
">='" +
|
123
|
+
date +
|
124
|
+
" 00:00:00' AND " +
|
125
|
+
field +
|
126
|
+
"<='" +
|
127
|
+
date +
|
128
|
+
" 23:59:59')"
|
129
|
+
);
|
130
|
+
} else {
|
131
|
+
return "false";
|
132
|
+
}
|
133
|
+
}
|
134
|
+
} catch (e) {}
|
135
|
+
}
|
136
|
+
|
137
|
+
return "false";
|
138
|
+
}
|