fix(AgentIO): 模型下拉尊重服务端 selected 标记,不再每次重建回退首项
- UiCode.build_options: 未显式指定 value 时,扫描数据项 selected:true 标记作为初始选中 (此前每次重建控件都把用户已持久化的选择重置成列表第一项) - AgentIO 透传 model_params 给 AgentInput(多 tab 会话按 session_id 解析项目模型)
This commit is contained in:
parent
406ed6f17a
commit
5227a4d491
@ -323,7 +323,7 @@ bricks.AgentIO = class extends bricks.VBox {
|
|||||||
width: '100%',
|
width: '100%',
|
||||||
css: 'filler'
|
css: 'filler'
|
||||||
});
|
});
|
||||||
this.inputw = new bricks.AgentInput({model_dataurl:this.opts.model_dataurl,model_cwidth:this.opts.model_cwidth,placeholder:this.opts.placeholder});
|
this.inputw = new bricks.AgentInput({model_dataurl:this.opts.model_dataurl,model_cwidth:this.opts.model_cwidth,model_params:this.opts.model_params,placeholder:this.opts.placeholder});
|
||||||
this.inputw.bind('inputed', this.user_inputed.bind(this));
|
this.inputw.bind('inputed', this.user_inputed.bind(this));
|
||||||
this.add_widget(this.msg_box);
|
this.add_widget(this.msg_box);
|
||||||
this.add_widget(this.inputw);
|
this.add_widget(this.inputw);
|
||||||
|
|||||||
@ -1198,6 +1198,14 @@ bricks.UiCode =class extends bricks.UiType {
|
|||||||
var vf = this.opts.valueField || 'value';
|
var vf = this.opts.valueField || 'value';
|
||||||
var tf = this.opts.textField || 'text';
|
var tf = this.opts.textField || 'text';
|
||||||
var v = this.opts.value || this.opts.defaultvalue || null;
|
var v = this.opts.value || this.opts.defaultvalue || null;
|
||||||
|
// 服务端数据可用 selected:true 标记当前项(如:项目已选的模型)。
|
||||||
|
// 未显式指定 value 时尊重该标记,而不是永远回退第一项——
|
||||||
|
// 否则每次重建控件都会把用户已持久化的选择重置成列表首项。
|
||||||
|
if (!v) {
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
if (data[i] && data[i].selected) { v = data[i][vf]; break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!v && ! this.opts.nullable && data.length > 0){
|
if (!v && ! this.opts.nullable && data.length > 0){
|
||||||
v = data[0][vf]
|
v = data[0][vf]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user