This commit is contained in:
yumoqing 2024-05-24 16:07:34 +08:00
parent 72173bef6a
commit a1213867ed
4 changed files with 24 additions and 9 deletions

View File

@ -35,12 +35,17 @@ bricks.DataRow = class extends bricks.HBox {
this.checkable = checkable; this.checkable = checkable;
} }
render(editable, checkable, header){ render(editable, checkable, header){
if (checkable){ this.build_toolbar(editable, header);
var w = new bricks.UiCheck({name:'c',value:false}) if (this.checkField){
this.add_widget(w); var w;
if (header){
w = new bricks.BlankIcon({});
} else {
w = new bricks.UiCheck({name:this.checkField,value:this.user_data[this.checkField]});
w.bind(changed, this.get_check_state.bind(this)); w.bind(changed, this.get_check_state.bind(this));
} }
this.build_toolbar(editable, header); this.add_widget(w);
}
this.build_fields(header); this.build_fields(header);
} }
renew(record){ renew(record){
@ -50,7 +55,8 @@ bricks.DataRow = class extends bricks.HBox {
} }
get_check_state(e){ get_check_state(e){
d = e.target.getValue() d = e.target.getValue()
this.dispatch('checked', d.c) this.user_data[this.checkField] = d[this.checkField];
this.dispatch('check_changed', this);
} }
build_toolbar(editable, header){ build_toolbar(editable, header){
var tools = []; var tools = [];
@ -136,6 +142,7 @@ bricks.DataRow = class extends bricks.HBox {
if (header || ! this.user_data){ if (header || ! this.user_data){
opts.value = f.label || f.name; opts.value = f.label || f.name;
} else { } else {
opts.user_data = this.user_data;
opts.value = this.user_data[f.name]; opts.value = this.user_data[f.name];
} }
var cwidth = cwidths[f.name]; var cwidth = cwidths[f.name];

View File

@ -10,9 +10,7 @@ bricks.Menu = class extends bricks.VBox {
constructor(options){ constructor(options){
super(options); super(options);
this.dom_element.style.display = ""; this.dom_element.style.display = "";
this.dom_element.style.position = "absolute";
this.dom_element.style.backgroundColor = options.bgcolor || "white"; this.dom_element.style.backgroundColor = options.bgcolor || "white";
this.dom_element.style.zIndex = "1000";
this.create_children(this, this.opts.items); this.create_children(this, this.opts.items);
this.bind('click', this.menu_clicked); this.bind('click', this.menu_clicked);
} }

View File

@ -30,9 +30,14 @@ bricks.Tabular = class extends bricks.DynamicAccordion {
dr.event_names.forEach(e => { dr.event_names.forEach(e => {
dr.toolbar_w.bind(e, this.record_event_handle.bind(this, e, record, dr, item)); dr.toolbar_w.bind(e, this.record_event_handle.bind(this, e, record, dr, item));
}); });
dr.bind('check_changed', this.record_check_changed.bind(this));
item.add_widget(dr); item.add_widget(dr);
return dr; return dr;
} }
record_check_changed(event){
var data = event.params.user_data;
this.dispatch('row_check_changed', data);
}
async renew_record_view(form, info){ async renew_record_view(form, info){
var d = form.getValue(); var d = form.getValue();
var record = bricks.extend(info.user_data, d); var record = bricks.extend(info.user_data, d);

View File

@ -21,7 +21,12 @@ bricks.add_ViewBuilder('icon', function(opts){
bricks.add_ViewBuilder('code', function(opts){ bricks.add_ViewBuilder('code', function(opts){
var textField = opts.textField || 'text'; var textField = opts.textField || 'text';
var valueField = opts.name; var valueField = opts.name;
var txt = opts.useer_data[textField] || opts.user_data[valueField]||''; var txt;
if (opts.user_data) {
txt = opts.user_data[textField] || opts.user_data[valueField]||'';
} else {
txt = opts.value || '';
}
var options = bricks.extend({}, opts); var options = bricks.extend({}, opts);
options.otext = txt; options.otext = txt;
options.i18n = true; options.i18n = true;