This commit is contained in:
yumoqing 2025-01-16 23:38:51 +08:00
parent b0061cd6f5
commit f5d692a192
2 changed files with 20 additions and 7 deletions

View File

@ -133,9 +133,8 @@ bricks.TreeNode = class extends bricks.VBox {
if (this.view_w){ if (this.view_w){
widget.add_widget(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 jc = new bricks.HttpJson()
var desc = await jc.post(this.editable.update_url, {params:d}); var desc = await jc.post(this.editable.update_url, {params:d});
if (desc.widgettype == 'Message'){ 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); var w = await bricks.widgetBuild(desc, this);
w.open(); w.open();
} else { } 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){ async update_node_data(node, data){
for (var name in Object.keys(data)){ var data_keys = Object.keys(node.user_data);
node.user_data[name] = data[name]; 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(); await node.update_content();
} }

View File

@ -1,5 +1,13 @@
var bricks = window.bricks || {}; var bricks = window.bricks || {};
bricks.bug = false; bricks.bug = false;
var formdata2object = function(formdata){
let result = {};
formdata.forEach((value, key) => {
result[key] = value;
});
return result;
}
var inputdata2dic = function(data){ var inputdata2dic = function(data){
try { try {
var d = {} var d = {}