From b5f89a9a68a95b74856e43a7f38073ddfdc35576 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 8 May 2024 16:01:23 +0800 Subject: [PATCH] bugfix --- bricks/css/bricks.css | 20 ++++++++++++----- bricks/datarow.js | 28 +++++++++++++++++++----- bricks/dynamicaccordion.js | 45 ++++++++++++++++++++++++++------------ bricks/tabular.js | 16 ++++++-------- bricks/widget.js | 3 +++ examples/html.ui | 2 +- 6 files changed, 80 insertions(+), 34 deletions(-) diff --git a/bricks/css/bricks.css b/bricks/css/bricks.css index 3c1d4ec..79d08c1 100755 --- a/bricks/css/bricks.css +++ b/bricks/css/bricks.css @@ -241,24 +241,34 @@ body { display: flex; flex-direction: column; } +.accordion-item:nth-child(odd) { + background-color: #fdfdfd; +} +.accordion-item:nth-child(even) { + background-color: #f9f9f9; +} +.accordion-item-selected { + background-color: #efefef; +} .accordion-item { border: 1px solid #ccc; margin-bottom: 5px; } .accordion-item-header { padding: 10px; - background-color: #eeeeee; - width: auto; + background-color: #f0f0f0; } .accordion-item-info { padding: 10px; - background-color: #f0f0f0; + background-color: #fbfbfb; cursor: pointer; - width: auto; + height: 50px; +} +.accordion-item-info-selected { + background-color: #e6e6e6; } .accordion-item-content { padding: 10px; - background-color: #ffffff; } .llm_msg { diff --git a/bricks/datarow.js b/bricks/datarow.js index 197ac47..4fa8dde 100644 --- a/bricks/datarow.js +++ b/bricks/datarow.js @@ -22,13 +22,19 @@ bricks.DataRow = class extends bricks.HBox { */ constructor(opts){ super(opts); - // this.set_style('flexShrink', '0'); + this.record_w = null; } render_header(editable, checkable){ this.render(editable, checkable, true); + this.set_css('accordion-item-header'); + this.editable = editable; + this.checkable = checkable; } render_data(editable, checkable){ this.render(editable, checkable, false); + this.set_css('accordion-item-info'); + this.editable = editable; + this.checkable = checkable; } render(editable, checkable, header){ if (checkable){ @@ -39,6 +45,11 @@ bricks.DataRow = class extends bricks.HBox { this.build_toolbar(editable, header); this.build_fields(header); } + renew(record){ + this.user_data = record; + this.record_w.clear_widgets(); + this._build_fields(false, this.record_w); + } get_check_state(e){ d = e.target.getValue() this.dispatch('checked', d.c) @@ -102,7 +113,12 @@ bricks.DataRow = class extends bricks.HBox { my_dispatch(e){ this.dispatch(e); } - build_fields(header){ + build_fields(header, cw){ + this.record_w = new bricks.HBox({height:'auto'}); + this.add_widget(this.record_w); + this._build_fields(header, this.record_w); + } + _build_fields(header, cw){ var exclouded = []; var cwidths = {}; if (this.browserfields && this.browserfields.exclouded){ @@ -113,7 +129,7 @@ bricks.DataRow = class extends bricks.HBox { } for (var i=0;i { - var newf = bricks.extend({}, f); - newf.value = record[f.name]; - fields.push(newf); - }); + var options = bricks.extend({cheight:this.cheight}, this.record_view.options); var desc = bricks.extend({}, this.record_view); - options.fields = fields; options.user_data = record; desc.options = options var dr = await bricks.widgetBuild(desc, this); @@ -53,6 +46,11 @@ bricks.Tabular = class extends bricks.DynamicAccordion { item.add_widget(dr); return dr; } + async renew_record_view(form, info){ + var d = form.getValue(); + var record = bricks.extend(info.user_data, d); + info.renew(record); + } record_event_handle(event_name, record, row, item){ console.log('event_name=', event_name, 'record=', record); switch(event_name){ diff --git a/bricks/widget.js b/bricks/widget.js index c24a2c9..df04c58 100755 --- a/bricks/widget.js +++ b/bricks/widget.js @@ -171,6 +171,9 @@ bricks.JsWidget = class { this.set_css(c, remove_flg); }) } + unset_css(css){ + this.dom_element.classList.remove(css); + } set_css(css, remove_flg){ if (!remove_flg){ this.dom_element.classList.add(css); diff --git a/examples/html.ui b/examples/html.ui index de99b0b..3aa0342 100644 --- a/examples/html.ui +++ b/examples/html.ui @@ -1,5 +1,5 @@ { - "widgettype":"DomElement", + "widgettype":"Html", "options":{ "html":"

Test domelement

" }