Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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