diff --git a/bricks/tree.js b/bricks/tree.js index 38a414c..2c96838 100644 --- a/bricks/tree.js +++ b/bricks/tree.js @@ -133,9 +133,8 @@ bricks.TreeNode = class extends bricks.VBox { if (this.view_w){ widget.add_widget(this.view_w); } - } else { - this.str_w.set_text(this.user_data[this.tree.opts.textField]); } + this.str_w.set_text(this.user_data[this.tree.opts.textField]); } } @@ -398,19 +397,25 @@ bricks.Tree = class extends bricks.VScrollPanel { var jc = new bricks.HttpJson() var desc = await jc.post(this.editable.update_url, {params:d}); if (desc.widgettype == 'Message'){ - await this.update_node_data(node, d); + var o = formdata2object(d); + await this.update_node_data(node, o); } var w = await bricks.widgetBuild(desc, this); w.open(); } else { - await this.update_node_data(node, d); + var o = formdata2object(d); + await this.update_node_data(node, o); } } async update_node_data(node, data){ - for (var name in Object.keys(data)){ - node.user_data[name] = data[name]; - } + var data_keys = Object.keys(node.user_data); + Object.keys(data).forEach(k => { + if (data_keys.includes(k)){ + console.log(node.user_data[k], ':', k, ':', data[k]); + node.user_data[k] = data[k]; + } + }); await node.update_content(); } diff --git a/bricks/utils.js b/bricks/utils.js index b05a4d5..e52b0c1 100644 --- a/bricks/utils.js +++ b/bricks/utils.js @@ -1,5 +1,13 @@ var bricks = window.bricks || {}; bricks.bug = false; +var formdata2object = function(formdata){ + let result = {}; + formdata.forEach((value, key) => { + result[key] = value; + }); + return result; +} + var inputdata2dic = function(data){ try { var d = {}