@schukai/monster 4.88.0 → 4.90.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/CHANGELOG.md +16 -0
- package/package.json +1 -1
- package/source/components/datatable/save-button.mjs +85 -20
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
## [4.90.0] - 2026-01-11
|
|
6
|
+
|
|
7
|
+
### Add Features
|
|
8
|
+
|
|
9
|
+
- Enhance origin values management in SaveButton component
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## [4.89.0] - 2026-01-11
|
|
14
|
+
|
|
15
|
+
### Add Features
|
|
16
|
+
|
|
17
|
+
- Enhance root node retrieval for linked forms
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
5
21
|
## [4.88.0] - 2026-01-11
|
|
6
22
|
|
|
7
23
|
### Add Features
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.
|
|
1
|
+
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.90.0"}
|
|
@@ -62,7 +62,9 @@ const stateButtonElementSymbol = Symbol("stateButtonElement");
|
|
|
62
62
|
* @private
|
|
63
63
|
* @type {symbol}
|
|
64
64
|
*/
|
|
65
|
-
const originValuesSymbol = Symbol(
|
|
65
|
+
const originValuesSymbol = Symbol.for(
|
|
66
|
+
"@schukai/monster/components/datatable/save-button@@originValues",
|
|
67
|
+
);
|
|
66
68
|
|
|
67
69
|
/**
|
|
68
70
|
* @private
|
|
@@ -192,19 +194,20 @@ class SaveButton extends CustomElement {
|
|
|
192
194
|
}
|
|
193
195
|
|
|
194
196
|
if (element instanceof RestDatasource) {
|
|
195
|
-
element.addEventListener("monster-datasource-fetch", (
|
|
197
|
+
element.addEventListener("monster-datasource-fetch", () => {
|
|
196
198
|
if (self[saveInFlightSymbol]) {
|
|
197
199
|
self[pendingResetSymbol] = true;
|
|
198
200
|
return;
|
|
199
201
|
}
|
|
200
202
|
self[fetchInFlightSymbol] = true;
|
|
201
|
-
self
|
|
203
|
+
clearOriginValues.call(self);
|
|
202
204
|
});
|
|
203
205
|
element.addEventListener("monster-datasource-fetched", () => {
|
|
204
206
|
self[fetchInFlightSymbol] = false;
|
|
205
|
-
if (!self
|
|
206
|
-
|
|
207
|
-
self
|
|
207
|
+
if (!getOriginValues.call(self)) {
|
|
208
|
+
setOriginValues.call(
|
|
209
|
+
self,
|
|
210
|
+
clone(self[datasourceLinkedElementSymbol].data),
|
|
208
211
|
);
|
|
209
212
|
updateChangesState.call(self);
|
|
210
213
|
}
|
|
@@ -219,22 +222,25 @@ class SaveButton extends CustomElement {
|
|
|
219
222
|
new Observer(handleDataSourceChanges.bind(this)),
|
|
220
223
|
);
|
|
221
224
|
|
|
222
|
-
self
|
|
225
|
+
clearOriginValues.call(self);
|
|
223
226
|
|
|
224
227
|
element.datasource.attachObserver(
|
|
225
228
|
new Observer(function () {
|
|
226
229
|
if (self[fetchInFlightSymbol] === true) {
|
|
227
230
|
return;
|
|
228
231
|
}
|
|
229
|
-
if (!self
|
|
230
|
-
|
|
231
|
-
self
|
|
232
|
+
if (!getOriginValues.call(self)) {
|
|
233
|
+
setOriginValues.call(
|
|
234
|
+
self,
|
|
235
|
+
clone(self[datasourceLinkedElementSymbol].data),
|
|
232
236
|
);
|
|
233
237
|
}
|
|
234
238
|
|
|
235
239
|
updateChangesState.call(self);
|
|
236
240
|
}),
|
|
237
241
|
);
|
|
242
|
+
|
|
243
|
+
syncOriginValues.call(self);
|
|
238
244
|
}
|
|
239
245
|
|
|
240
246
|
this.attachObserver(
|
|
@@ -253,6 +259,53 @@ class SaveButton extends CustomElement {
|
|
|
253
259
|
}
|
|
254
260
|
}
|
|
255
261
|
|
|
262
|
+
/**
|
|
263
|
+
* @private
|
|
264
|
+
*/
|
|
265
|
+
function syncOriginValues() {
|
|
266
|
+
if (getOriginValues.call(this)) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const data = this[datasourceLinkedElementSymbol]?.data;
|
|
270
|
+
if (!data) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
setOriginValues.call(this, clone(data));
|
|
274
|
+
updateChangesState.call(this);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* @private
|
|
279
|
+
* @return {*}
|
|
280
|
+
*/
|
|
281
|
+
function getOriginValues() {
|
|
282
|
+
const datasource = this[datasourceLinkedElementSymbol];
|
|
283
|
+
return datasource ? datasource[originValuesSymbol] : null;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* @private
|
|
288
|
+
* @param {*} value
|
|
289
|
+
* @return {void}
|
|
290
|
+
*/
|
|
291
|
+
function setOriginValues(value) {
|
|
292
|
+
const datasource = this[datasourceLinkedElementSymbol];
|
|
293
|
+
if (datasource) {
|
|
294
|
+
datasource[originValuesSymbol] = value;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* @private
|
|
300
|
+
* @return {void}
|
|
301
|
+
*/
|
|
302
|
+
function clearOriginValues() {
|
|
303
|
+
const datasource = this[datasourceLinkedElementSymbol];
|
|
304
|
+
if (datasource) {
|
|
305
|
+
datasource[originValuesSymbol] = null;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
256
309
|
function getTranslations() {
|
|
257
310
|
const locale = getLocaleOfDocument();
|
|
258
311
|
switch (locale.language) {
|
|
@@ -359,9 +412,10 @@ function initEventHandler() {
|
|
|
359
412
|
flushLinkedForms.call(this)
|
|
360
413
|
.then(() => this[datasourceLinkedElementSymbol].write())
|
|
361
414
|
.then(() => {
|
|
362
|
-
this
|
|
363
|
-
|
|
364
|
-
this
|
|
415
|
+
clearOriginValues.call(this);
|
|
416
|
+
setOriginValues.call(
|
|
417
|
+
this,
|
|
418
|
+
clone(this[datasourceLinkedElementSymbol].data),
|
|
365
419
|
);
|
|
366
420
|
this[stateButtonElementSymbol].removeState();
|
|
367
421
|
this[stateButtonElementSymbol].setOption("disabled", true);
|
|
@@ -381,7 +435,7 @@ function initEventHandler() {
|
|
|
381
435
|
this[saveInFlightSymbol] = false;
|
|
382
436
|
if (this[pendingResetSymbol]) {
|
|
383
437
|
this[pendingResetSymbol] = false;
|
|
384
|
-
this
|
|
438
|
+
clearOriginValues.call(this);
|
|
385
439
|
}
|
|
386
440
|
});
|
|
387
441
|
});
|
|
@@ -399,12 +453,22 @@ function flushLinkedForms() {
|
|
|
399
453
|
}
|
|
400
454
|
|
|
401
455
|
const roots = new Set();
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
456
|
+
let current = this;
|
|
457
|
+
while (current) {
|
|
458
|
+
const root = current.getRootNode?.();
|
|
459
|
+
if (root && typeof root.querySelectorAll === "function") {
|
|
460
|
+
roots.add(root);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
if (root instanceof ShadowRoot) {
|
|
464
|
+
current = root.host;
|
|
465
|
+
} else {
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
405
468
|
}
|
|
469
|
+
|
|
406
470
|
const doc = getDocument();
|
|
407
|
-
if (doc
|
|
471
|
+
if (doc) {
|
|
408
472
|
roots.add(doc);
|
|
409
473
|
}
|
|
410
474
|
|
|
@@ -453,7 +517,8 @@ function flushLinkedForms() {
|
|
|
453
517
|
function updateChangesState() {
|
|
454
518
|
const currentValues = this[datasourceLinkedElementSymbol]?.datasource?.get();
|
|
455
519
|
const ignoreChanges = this.getOption("ignoreChanges");
|
|
456
|
-
|
|
520
|
+
const originValues = getOriginValues.call(this);
|
|
521
|
+
let result = diff(originValues, currentValues);
|
|
457
522
|
|
|
458
523
|
if (
|
|
459
524
|
this.getOption("logLevel") === "debug" ||
|
|
@@ -462,7 +527,7 @@ function updateChangesState() {
|
|
|
462
527
|
console.groupCollapsed("SaveButton");
|
|
463
528
|
console.log(
|
|
464
529
|
"originValues",
|
|
465
|
-
JSON.parse(JSON.stringify(
|
|
530
|
+
JSON.parse(JSON.stringify(originValues)),
|
|
466
531
|
);
|
|
467
532
|
console.log("currentValues", JSON.parse(JSON.stringify(currentValues)));
|
|
468
533
|
console.log("result of diff", result);
|