This commit is contained in:
yumoqing 2024-07-03 18:04:19 +08:00
parent 76a6511fbd
commit e2ddd8c775
5 changed files with 29 additions and 11 deletions

View File

@ -41,6 +41,7 @@ bricks.Accordion = class extends bricks.VBox {
this.content.set_css('filler');
}
async change_content(event){
var refresh = false;
var b = event.target.bricks_widget;
var name = b.opts.name;
bricks.debug('accordion: button=', b, 'name=', name);
@ -48,6 +49,7 @@ bricks.Accordion = class extends bricks.VBox {
for (var i=0; i< this.opts.items.length; i++){
if (name == this.opts.items[i].name){
pos = i;
if (this.opts.items[i].refresh) refresh = true;
break
}
}
@ -55,7 +57,7 @@ bricks.Accordion = class extends bricks.VBox {
debug('Accordion():name=',name, 'not found in items',this.opts.items);
}
var c = objget(this.subcontents,name);
if (! c){
if (refresh || ! c ){
c = await bricks.widgetBuild(this.opts.items[pos].content);
this.subcontents[name] = c;
}

View File

@ -708,7 +708,9 @@ bricks.UiCode =class extends bricks.UiType {
}
build_options(data){
var e = this.dom_element;
e.replaceChildren();
while(e.firstChild){
e.removeChild(e.firstChild);
}
var v = this.opts.value || this.opts.defaultvalue || null;
if (!v && ! this.opts.nullable){
v = data[0][this.opts.valueField]

View File

@ -75,12 +75,9 @@ bricks.LlmModel = class extends bricks.JsWidget {
var d = data;
if (this.messages){
this.messages.push(umsg);
d = {
messages:this.messages,
mapi:this.mapi,
prompt:prompt,
model:this.opts.model
}
d = bricks.extend({}, data);
d.messages = this.messages;
d.model = this.opts.model;
} else {
d = bricks.extend({}, data);
d.model = this.opts.model;
@ -132,6 +129,7 @@ bricks.LlmModel = class extends bricks.JsWidget {
if (! d.content || d.content == ''){
return;
}
d.content = bricks.escapeSpecialChars(d.content);
this.set_stream_data(d);
mout.update_data(this.stream_data);
}

View File

@ -87,7 +87,7 @@ bricks.BaseModal = class extends bricks.Layout {
this.timeout_task = null;
}
try {
this.target_w.remove_widget(this);
this.parent.remove_widget(this);
} catch(e){
console.log(e, 'remove modal error');
}

View File

@ -123,12 +123,28 @@ bricks.Tabular = class extends bricks.DynamicAccordion {
console.log('event_name=', event_name, 'record=', record);
this.dispatch(event_name, record);
}
get_hidefields(){
var fs = [];
var params = this.data_params || {};
for (var k in params){
fs.push({name:k, value:params[k], uitype:'hide'});
}
return fs;
}
add_record(info){
var hidefields = [];
if (!this.data_params){
this.data_params = {}
}
var fs = this.get_hidefields();
for (var i=0;i<this.fields.length;i++){
fs.push(this.fields[i]);
}
var f = new bricks.ModalForm({
"width":"90%",
"height":"70%",
"submit_url":this.editable.new_data_url,
"fields":this.fields
"fields":fs
});
f.open();
f.bind('submited', this.add_record_finish.bind(this, f));
@ -142,7 +158,7 @@ bricks.Tabular = class extends bricks.DynamicAccordion {
}
update_record(){
var record = this.select_row.user_data;
var fields = [];
var fields = this.get_hidefields();
for (var i=0; i< this.fields.length; i++){
var f = bricks.extend({}, this.fields[i]);
f.value = record[f.name];