@schukai/monster 4.57.0 → 4.59.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 +20 -0
- package/package.json +1 -1
- package/source/components/data/stylesheet/metric-graph.mjs +1 -1
- package/source/components/data/stylesheet/metric.mjs +1 -1
- package/source/components/datatable/datasource/rest.mjs +141 -14
- package/source/components/datatable/datatable.mjs +3 -7
- package/source/components/datatable/save-button.mjs +348 -334
- package/source/components/datatable/status.mjs +7 -0
- package/source/components/datatable/util.mjs +7 -0
- package/source/components/form/button-bar.mjs +193 -95
- package/source/components/form/field-set.mjs +283 -283
- package/source/components/form/form.mjs +407 -169
- package/source/components/form/login.mjs +1571 -1571
- package/source/components/form/quantity.mjs +233 -233
- package/source/components/form/select.mjs +3106 -3101
- package/source/components/form/style/field-set.pcss +6 -2
- package/source/components/form/style/form.pcss +8 -0
- package/source/components/form/stylesheet/field-set.mjs +1 -1
- package/source/components/form/stylesheet/form.mjs +1 -1
- package/source/components/form/stylesheet/select.mjs +13 -6
- package/source/components/style/typography.css +2 -2
- package/source/components/tree-menu/stylesheet/tree-menu.mjs +1 -1
- package/source/constraints/abstract.mjs +17 -17
- package/source/dom/customelement.mjs +962 -963
- package/source/dom/updater.mjs +886 -863
- package/source/dom/util/init-options-from-attributes.mjs +56 -56
- package/source/monster.mjs +0 -1
- package/source/net/webconnect.mjs +325 -325
- package/source/types/is.mjs +66 -66
- package/test/web/tests.js +8 -0
|
@@ -17,9 +17,9 @@ import { diff } from "../../data/diff.mjs";
|
|
|
17
17
|
import { addAttributeToken } from "../../dom/attributes.mjs";
|
|
18
18
|
import { ATTRIBUTE_ERRORMESSAGE } from "../../dom/constants.mjs";
|
|
19
19
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
assembleMethodSymbol,
|
|
21
|
+
CustomElement,
|
|
22
|
+
registerCustomElement,
|
|
23
23
|
} from "../../dom/customelement.mjs";
|
|
24
24
|
import { findElementWithSelectorUpwards } from "../../dom/util.mjs";
|
|
25
25
|
import { isString, isArray } from "../../types/is.mjs";
|
|
@@ -35,8 +35,8 @@ import { SaveButtonStyleSheet } from "./stylesheet/save-button.mjs";
|
|
|
35
35
|
import "../form/state-button.mjs";
|
|
36
36
|
|
|
37
37
|
import {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
handleDataSourceChanges,
|
|
39
|
+
datasourceLinkedElementSymbol,
|
|
40
40
|
} from "./util.mjs";
|
|
41
41
|
import { getLocaleOfDocument } from "../../dom/locale.mjs";
|
|
42
42
|
|
|
@@ -59,6 +59,7 @@ const originValuesSymbol = Symbol("originValues");
|
|
|
59
59
|
* @type {symbol}
|
|
60
60
|
*/
|
|
61
61
|
const badgeElementSymbol = Symbol("badgeElement");
|
|
62
|
+
const saveInFlightSymbol = Symbol("saveInFlight");
|
|
62
63
|
|
|
63
64
|
/**
|
|
64
65
|
* A save button component
|
|
@@ -73,273 +74,276 @@ const badgeElementSymbol = Symbol("badgeElement");
|
|
|
73
74
|
* @summary This is a save button component that can be used to save changes to a datasource.
|
|
74
75
|
*/
|
|
75
76
|
class SaveButton extends CustomElement {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
77
|
+
/**
|
|
78
|
+
* This method is called by the `instanceof` operator.
|
|
79
|
+
* @return {symbol}
|
|
80
|
+
*/
|
|
81
|
+
static get [instanceSymbol]() {
|
|
82
|
+
return Symbol.for(
|
|
83
|
+
"@schukai/monster/components/datatable/save-button@@instance",
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* To set the options via the HTML tag, the attribute `data-monster-options` must be used.
|
|
89
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
|
90
|
+
*
|
|
91
|
+
* The individual configuration values can be found in the table.
|
|
92
|
+
*
|
|
93
|
+
* @property {Object} templates Template definitions
|
|
94
|
+
* @property {string} templates.main Main template
|
|
95
|
+
* @property {object} datasource The datasource
|
|
96
|
+
* @property {string} datasource.selector The selector of the datasource
|
|
97
|
+
* @property {string} labels.button The button label
|
|
98
|
+
* @property {Object} classes The classes
|
|
99
|
+
* @property {string} classes.bar The bar class
|
|
100
|
+
* @property {string} classes.badge The badge class
|
|
101
|
+
* @property {Array} ignoreChanges The ignore changes (regex)
|
|
102
|
+
* @property {Array} data The data
|
|
103
|
+
* @property {boolean} disabled The disabled state
|
|
104
|
+
* @property {string} logLevel The log level (off, debug)
|
|
105
|
+
* @return {Object}
|
|
106
|
+
*/
|
|
107
|
+
get defaults() {
|
|
108
|
+
const obj = Object.assign({}, super.defaults, {
|
|
109
|
+
templates: {
|
|
110
|
+
main: getTemplate(),
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
labels: getTranslations(),
|
|
114
|
+
|
|
115
|
+
classes: {
|
|
116
|
+
bar: "monster-button-primary",
|
|
117
|
+
badge: "monster-badge-secondary hidden",
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
datasource: {
|
|
121
|
+
selector: null,
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
changes: "0",
|
|
125
|
+
|
|
126
|
+
ignoreChanges: [],
|
|
127
|
+
|
|
128
|
+
data: {},
|
|
129
|
+
|
|
130
|
+
disabled: false,
|
|
131
|
+
|
|
132
|
+
logLevel: "off",
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
updateOptionsFromArguments.call(this, obj);
|
|
136
|
+
return obj;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
*
|
|
141
|
+
* @return {string}
|
|
142
|
+
*/
|
|
143
|
+
static getTag() {
|
|
144
|
+
return "monster-datasource-save-button";
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* This method is responsible for assembling the component.
|
|
149
|
+
*
|
|
150
|
+
* It calls the parent's assemble method first, then initializes control references and event handlers.
|
|
151
|
+
* If the `datasource.selector` option is provided and is a string, it searches for the corresponding
|
|
152
|
+
* element in the DOM using that selector.
|
|
153
|
+
*
|
|
154
|
+
* If the selector matches exactly one element, it checks if the element is an instance of the `Datasource` class.
|
|
155
|
+
*
|
|
156
|
+
* If it is, the component's `datasourceLinkedElementSymbol` property is set to the element, and the component
|
|
157
|
+
* attaches an observer to the datasource's changes.
|
|
158
|
+
*
|
|
159
|
+
* The observer is a function that calls the `handleDataSourceChanges` method in the context of the component.
|
|
160
|
+
* Additionally, the component attaches an observer to itself, which also calls the `handleDataSourceChanges`
|
|
161
|
+
* method in the component's context.
|
|
162
|
+
*/
|
|
163
|
+
[assembleMethodSymbol]() {
|
|
164
|
+
super[assembleMethodSymbol]();
|
|
165
|
+
const self = this;
|
|
166
|
+
|
|
167
|
+
initControlReferences.call(this);
|
|
168
|
+
initEventHandler.call(this);
|
|
169
|
+
|
|
170
|
+
const selector = this.getOption("datasource.selector");
|
|
171
|
+
|
|
172
|
+
if (isString(selector)) {
|
|
173
|
+
const element = findElementWithSelectorUpwards(this, selector);
|
|
174
|
+
if (element === null) {
|
|
175
|
+
throw new Error("the selector must match exactly one element");
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (!(element instanceof Datasource)) {
|
|
179
|
+
throw new TypeError("the element must be a datasource");
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (element instanceof RestDatasource) {
|
|
183
|
+
element.addEventListener("monster-datasource-fetch", (event) => {
|
|
184
|
+
if (self[saveInFlightSymbol]) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
self[originValuesSymbol] = null;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
this[datasourceLinkedElementSymbol] = element;
|
|
192
|
+
element.datasource.attachObserver(
|
|
193
|
+
new Observer(handleDataSourceChanges.bind(this)),
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
self[originValuesSymbol] = null;
|
|
197
|
+
|
|
198
|
+
element.datasource.attachObserver(
|
|
199
|
+
new Observer(function () {
|
|
200
|
+
if (!self[originValuesSymbol]) {
|
|
201
|
+
self[originValuesSymbol] = clone(
|
|
202
|
+
self[datasourceLinkedElementSymbol].data,
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const currentValues = this.getRealSubject();
|
|
207
|
+
const ignoreChanges = self.getOption("ignoreChanges");
|
|
208
|
+
|
|
209
|
+
const result = diff(self[originValuesSymbol], currentValues);
|
|
210
|
+
if (
|
|
211
|
+
self.getOption("logLevel") === "debug" ||
|
|
212
|
+
location.search.includes("logLevel=debug")
|
|
213
|
+
) {
|
|
214
|
+
console.groupCollapsed("SaveButton");
|
|
215
|
+
console.log(
|
|
216
|
+
"originValues",
|
|
217
|
+
JSON.parse(JSON.stringify(currentValues)),
|
|
218
|
+
);
|
|
219
|
+
console.log("result of diff", result);
|
|
220
|
+
console.log("ignoreChanges", ignoreChanges);
|
|
221
|
+
|
|
222
|
+
if (isArray(result) && result.length > 0) {
|
|
223
|
+
const formattedDiff = result.map((change) => ({
|
|
224
|
+
Operator: change?.operator,
|
|
225
|
+
Path: change?.path?.join("."),
|
|
226
|
+
"First Value": change?.first?.value,
|
|
227
|
+
"First Type": change?.first?.type,
|
|
228
|
+
"Second Value": change?.second?.value,
|
|
229
|
+
"Second Type": change?.second?.type,
|
|
230
|
+
}));
|
|
231
|
+
|
|
232
|
+
console.table(formattedDiff);
|
|
233
|
+
} else {
|
|
234
|
+
console.log("There are no changes to save");
|
|
235
|
+
}
|
|
236
|
+
console.groupEnd();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (isArray(ignoreChanges) && ignoreChanges.length > 0) {
|
|
240
|
+
const itemsToRemove = [];
|
|
241
|
+
for (const item of result) {
|
|
242
|
+
for (const ignorePattern of ignoreChanges) {
|
|
243
|
+
const p = new RegExp(ignorePattern);
|
|
244
|
+
|
|
245
|
+
let matchPath = item.path;
|
|
246
|
+
if (isArray(item.path)) {
|
|
247
|
+
matchPath = item.path.join(".");
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (p.test(matchPath)) {
|
|
251
|
+
itemsToRemove.push(item);
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
for (const itemToRemove of itemsToRemove) {
|
|
258
|
+
const index = result.indexOf(itemToRemove);
|
|
259
|
+
if (index > -1) {
|
|
260
|
+
result.splice(index, 1);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (isArray(result) && result.length > 0) {
|
|
266
|
+
self[stateButtonElementSymbol].setState("changed");
|
|
267
|
+
self[stateButtonElementSymbol].setOption("disabled", false);
|
|
268
|
+
self.setOption("changes", result.length);
|
|
269
|
+
self.setOption(
|
|
270
|
+
"classes.badge",
|
|
271
|
+
new TokenList(self.getOption("classes.badge"))
|
|
272
|
+
.remove("hidden")
|
|
273
|
+
.toString(),
|
|
274
|
+
);
|
|
275
|
+
} else {
|
|
276
|
+
self[stateButtonElementSymbol].removeState();
|
|
277
|
+
self[stateButtonElementSymbol].setOption("disabled", true);
|
|
278
|
+
self.setOption("changes", 0);
|
|
279
|
+
self.setOption(
|
|
280
|
+
"classes.badge",
|
|
281
|
+
new TokenList(self.getOption("classes.badge"))
|
|
282
|
+
.add("hidden")
|
|
283
|
+
.toString(),
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
}),
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
this.attachObserver(
|
|
291
|
+
new Observer(() => {
|
|
292
|
+
handleDataSourceChanges.call(this);
|
|
293
|
+
}),
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
*
|
|
299
|
+
* @return [CSSStyleSheet]
|
|
300
|
+
*/
|
|
301
|
+
static getCSSStyleSheet() {
|
|
302
|
+
return [SaveButtonStyleSheet, BadgeStyleSheet];
|
|
303
|
+
}
|
|
300
304
|
}
|
|
301
305
|
|
|
302
306
|
function getTranslations() {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
307
|
+
const locale = getLocaleOfDocument();
|
|
308
|
+
switch (locale.language) {
|
|
309
|
+
case "de":
|
|
310
|
+
return {
|
|
311
|
+
button: "Speichern",
|
|
312
|
+
};
|
|
313
|
+
case "fr":
|
|
314
|
+
return {
|
|
315
|
+
button: "Enregistrer",
|
|
316
|
+
};
|
|
317
|
+
case "sp":
|
|
318
|
+
return {
|
|
319
|
+
button: "Guardar",
|
|
320
|
+
};
|
|
321
|
+
case "it":
|
|
322
|
+
return {
|
|
323
|
+
button: "Salva",
|
|
324
|
+
};
|
|
325
|
+
case "pl":
|
|
326
|
+
return {
|
|
327
|
+
button: "Zapisz",
|
|
328
|
+
};
|
|
329
|
+
case "no":
|
|
330
|
+
return {
|
|
331
|
+
button: "Lagre",
|
|
332
|
+
};
|
|
333
|
+
case "dk":
|
|
334
|
+
return {
|
|
335
|
+
button: "Gem",
|
|
336
|
+
};
|
|
337
|
+
case "sw":
|
|
338
|
+
return {
|
|
339
|
+
button: "Spara",
|
|
340
|
+
};
|
|
341
|
+
default:
|
|
342
|
+
case "en":
|
|
343
|
+
return {
|
|
344
|
+
button: "Save",
|
|
345
|
+
};
|
|
346
|
+
}
|
|
343
347
|
}
|
|
344
348
|
|
|
345
349
|
/**
|
|
@@ -353,71 +357,81 @@ function getTranslations() {
|
|
|
353
357
|
* @throws {Error} the selector must match exactly one element
|
|
354
358
|
*/
|
|
355
359
|
function initControlReferences() {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
360
|
+
if (!this.shadowRoot) {
|
|
361
|
+
throw new Error("no shadow-root is defined");
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
this[stateButtonElementSymbol] = this.shadowRoot.querySelector(
|
|
365
|
+
"[data-monster-role=state-button]",
|
|
366
|
+
);
|
|
367
|
+
|
|
368
|
+
this[badgeElementSymbol] = this.shadowRoot.querySelector(
|
|
369
|
+
"[data-monster-role=badge]",
|
|
370
|
+
);
|
|
371
|
+
|
|
372
|
+
if (this[stateButtonElementSymbol]) {
|
|
373
|
+
queueMicrotask(() => {
|
|
374
|
+
const states = {
|
|
375
|
+
changed: new State(
|
|
376
|
+
"changed",
|
|
377
|
+
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cloud-arrow-up" viewBox="0 0 16 16">' +
|
|
378
|
+
'<path fill-rule="evenodd" d="M7.646 5.146a.5.5 0 0 1 .708 0l2 2a.5.5 0 0 1-.708.708L8.5 6.707V10.5a.5.5 0 0 1-1 0V6.707L6.354 7.854a.5.5 0 1 1-.708-.708z"/>' +
|
|
379
|
+
'<path d="M4.406 3.342A5.53 5.53 0 0 1 8 2c2.69 0 4.923 2 5.166 4.579C14.758 6.804 16 8.137 16 9.773 16 11.569 14.502 13 12.687 13H3.781C1.708 13 0 11.366 0 9.318c0-1.763 1.266-3.223 2.942-3.593.143-.863.698-1.723 1.464-2.383m.653.757c-.757.653-1.153 1.44-1.153 2.056v.448l-.445.049C2.064 6.805 1 7.952 1 9.318 1 10.785 2.23 12 3.781 12h8.906C13.98 12 15 10.988 15 9.773c0-1.216-1.02-2.228-2.313-2.228h-.5v-.5C12.188 4.825 10.328 3 8 3a4.53 4.53 0 0 0-2.941 1.1z"/>' +
|
|
380
|
+
"</svg>",
|
|
381
|
+
),
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
this[stateButtonElementSymbol].removeState();
|
|
385
|
+
this[stateButtonElementSymbol].setOption("disabled", "disabled");
|
|
386
|
+
this[stateButtonElementSymbol].setOption("states", states);
|
|
387
|
+
this[stateButtonElementSymbol].setOption(
|
|
388
|
+
"labels.button",
|
|
389
|
+
this.getOption("labels.button"),
|
|
390
|
+
);
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
return this;
|
|
391
395
|
}
|
|
392
396
|
|
|
393
397
|
/**
|
|
394
398
|
* @private
|
|
395
399
|
*/
|
|
396
400
|
function initEventHandler() {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
401
|
+
queueMicrotask(() => {
|
|
402
|
+
this[stateButtonElementSymbol].setOption("actions.click", () => {
|
|
403
|
+
if (this[saveInFlightSymbol]) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
this[saveInFlightSymbol] = true;
|
|
407
|
+
this[stateButtonElementSymbol].setOption("disabled", true);
|
|
408
|
+
|
|
409
|
+
this[datasourceLinkedElementSymbol]
|
|
410
|
+
.write()
|
|
411
|
+
.then(() => {
|
|
412
|
+
this[originValuesSymbol] = null;
|
|
413
|
+
this[originValuesSymbol] = clone(
|
|
414
|
+
this[datasourceLinkedElementSymbol].data,
|
|
415
|
+
);
|
|
416
|
+
this[stateButtonElementSymbol].removeState();
|
|
417
|
+
this[stateButtonElementSymbol].setOption("disabled", true);
|
|
418
|
+
this.setOption("changes", 0);
|
|
419
|
+
this.setOption(
|
|
420
|
+
"classes.badge",
|
|
421
|
+
new TokenList(this.getOption("classes.badge"))
|
|
422
|
+
.add("hidden")
|
|
423
|
+
.toString(),
|
|
424
|
+
);
|
|
425
|
+
})
|
|
426
|
+
.catch((error) => {
|
|
427
|
+
addAttributeToken(this, ATTRIBUTE_ERRORMESSAGE, error.toString());
|
|
428
|
+
this[stateButtonElementSymbol].setOption("disabled", false);
|
|
429
|
+
})
|
|
430
|
+
.finally(() => {
|
|
431
|
+
this[saveInFlightSymbol] = false;
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
});
|
|
421
435
|
}
|
|
422
436
|
|
|
423
437
|
/**
|
|
@@ -425,10 +439,10 @@ function initEventHandler() {
|
|
|
425
439
|
* @deprecated 2024-12-31
|
|
426
440
|
*/
|
|
427
441
|
function updateOptionsFromArguments(options) {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
442
|
+
const selector = this.getAttribute(ATTRIBUTE_DATASOURCE_SELECTOR);
|
|
443
|
+
if (selector) {
|
|
444
|
+
options.datasource.selector = selector;
|
|
445
|
+
}
|
|
432
446
|
}
|
|
433
447
|
|
|
434
448
|
/**
|
|
@@ -436,8 +450,8 @@ function updateOptionsFromArguments(options) {
|
|
|
436
450
|
* @return {string}
|
|
437
451
|
*/
|
|
438
452
|
function getTemplate() {
|
|
439
|
-
|
|
440
|
-
|
|
453
|
+
// language=HTML
|
|
454
|
+
return `
|
|
441
455
|
<div data-monster-role="control" part="control"
|
|
442
456
|
data-monster-attributes="disabled path:disabled | if:true">
|
|
443
457
|
<monster-state-button data-monster-role="state-button"></monster-state-button>
|