Skip to content
Snippets Groups Projects
Verified Commit b64b8ac3 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

feat: nullabel integer bind, add debug logging for save-button

parent 82840c03
No related branches found
No related tags found
No related merge requests found
...@@ -99,6 +99,8 @@ class SaveButton extends CustomElement { ...@@ -99,6 +99,8 @@ class SaveButton extends CustomElement {
* @property {string} classes.badge The badge class * @property {string} classes.badge The badge class
* @property {Array} ignoreChanges The ignore changes (regex) * @property {Array} ignoreChanges The ignore changes (regex)
* @property {Array} data The data * @property {Array} data The data
* @property {boolean} disabled The disabled state
* @property {string} logLevel The log level (off, debug)
* @return {Object} * @return {Object}
*/ */
get defaults() { get defaults() {
...@@ -125,6 +127,9 @@ class SaveButton extends CustomElement { ...@@ -125,6 +127,9 @@ class SaveButton extends CustomElement {
data: {}, data: {},
disabled: false, disabled: false,
logLevel: "off",
}); });
updateOptionsFromArguments.call(this, obj); updateOptionsFromArguments.call(this, obj);
...@@ -199,6 +204,27 @@ class SaveButton extends CustomElement { ...@@ -199,6 +204,27 @@ class SaveButton extends CustomElement {
const ignoreChanges = self.getOption("ignoreChanges"); const ignoreChanges = self.getOption("ignoreChanges");
const result = diff(self[originValuesSymbol], currentValues); const result = diff(self[originValuesSymbol], currentValues);
if(self.getOption("logLevel") === "debug") {
console.groupCollapsed("SaveButton");
console.log(result);
if(isArray(result)&&result.length>0) {
const formattedDiff = result.map(change => ({
Operator: change?.operator,
Path: change?.path?.join("."),
"First Value": change?.first?.value,
"First Type": change?.first?.type,
"Second Value": change?.second?.value,
"Second Type": change?.second?.type
}));
console.table(formattedDiff);
} else {
console.log("There are no changes to save");
}
console.groupEnd();
}
if (isArray(ignoreChanges) && ignoreChanges.length > 0) { if (isArray(ignoreChanges) && ignoreChanges.length > 0) {
const itemsToRemove = []; const itemsToRemove = [];
......
...@@ -404,6 +404,16 @@ function retrieveAndSetValue(element) { ...@@ -404,6 +404,16 @@ function retrieveAndSetValue(element) {
const type = element.getAttribute(ATTRIBUTE_UPDATER_BIND_TYPE); const type = element.getAttribute(ATTRIBUTE_UPDATER_BIND_TYPE);
switch (type) { switch (type) {
case "integer?":
case "int?":
case "number?":
value = Number(value);
if (isNaN(value)||0===value) {
value = undefined;
}
break;
case "number": case "number":
case "int": case "int":
case "float": case "float":
......
...@@ -238,6 +238,8 @@ function format(text) { ...@@ -238,6 +238,8 @@ function format(text) {
throw new Error("too deep nesting"); throw new Error("too deep nesting");
} }
validateString(text);
const openMarker = const openMarker =
this[internalSymbol]["marker"]["open"]?.[this[markerOpenIndexSymbol]]; this[internalSymbol]["marker"]["open"]?.[this[markerOpenIndexSymbol]];
const closeMarker = const closeMarker =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment