Skip to content

Commit

Permalink
Optimize saveElement code
Browse files Browse the repository at this point in the history
  • Loading branch information
sonvnn committed Nov 8, 2024
1 parent 83f9975 commit c9e64a1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 49 deletions.
46 changes: 23 additions & 23 deletions assets/vendor/manager/dist/index.js

Large diffs are not rendered by default.

41 changes: 15 additions & 26 deletions assets/vendor/manager/src/components/helpers/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,37 +130,26 @@ function editElement(el) {
_showModal.value = true;
}
function saveElement(param) {
layout.value.sections.every(section => {
if (element.value.type === section.type && element.value.id === section.id) {
section.params = param;
const updateParams = (el) => {
if (element.value.type === el.type && element.value.id === el.id) {
el.params = param;
element.value = {};
return false;
return true;
}
section.rows.every(row => {
if (element.value.type === row.type && element.value.id === row.id) {
row.params = param;
element.value = {};
return false;
}
row.cols.every(column => {
if (element.value.type === column.type && element.value.id === column.id) {
column.params = param;
element.value = {};
return false;
}
column.elements.every(el => {
if (element.value.type === el.type && element.value.id === el.id) {
el.params = param;
element.value = {};
return false;
}
return true;
return false;
};
layout.value.sections.forEach(section => {
if (updateParams(section)) return;
section.rows.forEach(row => {
if (updateParams(row)) return;
row.cols.forEach(column => {
if (updateParams(column)) return;
column.elements.forEach(el => {
if (updateParams(el)) return;
});
return true;
});
return true;
});
return true;
});
}
Expand Down

0 comments on commit c9e64a1

Please sign in to comment.