Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#104299 - Updated snowdog-menu block id #309

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions view/adminhtml/templates/menu/nodes.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ $blockHtmlId = $block->getBlockHtmlId();
"imageDeleteUrl" : "<?= $block->getImageDeleteUrl() ?>",
"imageUploadFileId": "<?= $block->getImageUploadFileId() ?>",
"lazyMinItemsCount": "1000",
"serializedNodesElementName": "serialized_nodes",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: pass the correct value from backend (either "serialized_nodes" or "snowmenu_staging_serialized_nodes")

"translation": {
"nodes" : "<?= __('Nodes') ?>",
"click" : "<?= __('Click') ?>",
Expand Down
21 changes: 4 additions & 17 deletions view/adminhtml/web/vue/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@
},
watch: {
jsonList: function (newValue) {
this.updateSerializedNodes(newValue)
this.updateMenuStagingSerializedNodes(newValue);
this.updateSerializedNodes(newValue);
}
},
mounted () {
Expand All @@ -110,14 +109,10 @@
};

// while loaded set JSON list as a value
checkElement('[name="serialized_nodes"]').then(() => {
this.list = this.nodes.map(item => setUuidRecursive(item))
checkElement(`[name='${this.config.serializedNodesElementName}']`).then(() => {
this.list = this.nodes.map(item => setUuidRecursive(item));
this.updateSerializedNodes(this.jsonList);
});
checkElement('[name="snowmenu_staging_serialized_nodes"]').then(() => {
this.list = this.nodes.map(item => setUuidRecursive(item))
this.updateMenuStagingSerializedNodes(this.jsonList);
});
},
methods: {
uuid,
Expand Down Expand Up @@ -148,20 +143,12 @@
},
updateSerializedNodes(value) {
const updateEvent = new Event('change');
const serializedNodeInput = document.querySelector('[name="serialized_nodes"]');
const serializedNodeInput = document.querySelector(`[name='${this.config.serializedNodesElementName}']`);
// update serialized_nodes input value
serializedNodeInput.value = value;
// trigger change event to set value
serializedNodeInput.dispatchEvent(updateEvent);
},
updateMenuStagingSerializedNodes(value) {
const updateEvent = new Event('change');
const serializedNodeInput = document.querySelector('[name="snowmenu_staging_serialized_nodes"]');
// update serialized_nodes input value
serializedNodeInput.value = value;
// trigger change event to set value
serializedNodeInput.dispatchEvent(updateEvent);
}
},
template: template
});
Expand Down