Skip to content

Commit

Permalink
list: do not save vueRef in DB
Browse files Browse the repository at this point in the history
  • Loading branch information
seballot committed Jun 18, 2024
1 parent bf20e02 commit 1c8ebad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions tools/bazar/presentation/javascripts/list-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ new Vue({
// vueRef is used to give a unique and fixed ID to each node
this.rootNode.children = (list.nodes || []).map((n) => ({ ...{ vueRef: n.id }, ...n }))
},
computed: {
jsonNodes() {
const data = this.rootNode.children.map((node) => this.removeVueRefProps(node))
return JSON.stringify(data)
}
},
methods: {
onSubmit(event) {
// check for id presence and uniquness
Expand All @@ -39,9 +45,10 @@ new Vue({
node.children.forEach((childNode) => this.collectIds(childNode))
},
removeVueRefProps(node) {
delete node.vueRef;
(node.children || []).forEach((child) => this.removeVueRefProps(child))
return node
const result = { ...node } // clone the object
delete result.vueRef
result.children = result.children.map((child) => this.removeVueRefProps(child))
return result
}
}
})
2 changes: 1 addition & 1 deletion tools/bazar/templates/lists/list_form.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<list-node :node="rootNode" :depth="0" :index="0"></list-node>
</div>
{# Hidden JSON Nodes #}
<input type="hidden" name="nodes" :value="JSON.stringify(rootNode.children)" />
<input type="hidden" name="nodes" :value="jsonNodes" />

{# Form Actions #}
<div class="form-actions form-group">
Expand Down

0 comments on commit 1c8ebad

Please sign in to comment.