Refactor AXO module

This commit is contained in:
Pedro Silva 2024-03-14 10:54:15 +00:00
parent a9d2f97a80
commit 578a5426dc
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
7 changed files with 337 additions and 121 deletions

View file

@ -48,36 +48,40 @@ class MockData {
content.innerHTML = '';
if (!this.active) {
this.hideField(this.contentSelector);
} else {
this.showField(this.contentSelector);
}
Object.keys(this.fields).forEach((key) => {
const field = this.fields[key];
if (this.active) {
this.hideField(field.selector);
//this.showField(this.contentSelector);
} else {
this.showField(field.selector);
//this.hideField(this.contentSelector);
}
if (typeof this.template === 'function') {
content.innerHTML = this.template({
value: (valueKey) => {
return this.getDataValue(this.fields[valueKey].valuePath);
},
isEmpty: () => {
let isEmpty = true;
Object.values(this.fields).forEach((valueField) => {
if (this.getDataValue(valueField.valuePath)) {
isEmpty = false;
return false;
}
});
return isEmpty;
}
});
}
});
if (typeof this.template === 'function') {
content.innerHTML = this.template({
value: (valueKey) => {
return this.getDataValue(this.fields[valueKey].valuePath);
},
isEmpty: () => {
let isEmpty = true;
Object.values(this.fields).forEach((valueField) => {
if (this.getDataValue(valueField.valuePath)) {
isEmpty = false;
return false;
}
});
return isEmpty;
}
});
}
}
showField(selector) {