bugfix
This commit is contained in:
parent
145bf1c6ed
commit
b5f89a9a68
@ -241,24 +241,34 @@ body {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
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 {
|
.accordion-item {
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
}
|
}
|
||||||
.accordion-item-header {
|
.accordion-item-header {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
background-color: #eeeeee;
|
background-color: #f0f0f0;
|
||||||
width: auto;
|
|
||||||
}
|
}
|
||||||
.accordion-item-info {
|
.accordion-item-info {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
background-color: #f0f0f0;
|
background-color: #fbfbfb;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
width: auto;
|
height: 50px;
|
||||||
|
}
|
||||||
|
.accordion-item-info-selected {
|
||||||
|
background-color: #e6e6e6;
|
||||||
}
|
}
|
||||||
.accordion-item-content {
|
.accordion-item-content {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
background-color: #ffffff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.llm_msg {
|
.llm_msg {
|
||||||
|
@ -22,13 +22,19 @@ bricks.DataRow = class extends bricks.HBox {
|
|||||||
*/
|
*/
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
super(opts);
|
super(opts);
|
||||||
// this.set_style('flexShrink', '0');
|
this.record_w = null;
|
||||||
}
|
}
|
||||||
render_header(editable, checkable){
|
render_header(editable, checkable){
|
||||||
this.render(editable, checkable, true);
|
this.render(editable, checkable, true);
|
||||||
|
this.set_css('accordion-item-header');
|
||||||
|
this.editable = editable;
|
||||||
|
this.checkable = checkable;
|
||||||
}
|
}
|
||||||
render_data(editable, checkable){
|
render_data(editable, checkable){
|
||||||
this.render(editable, checkable, false);
|
this.render(editable, checkable, false);
|
||||||
|
this.set_css('accordion-item-info');
|
||||||
|
this.editable = editable;
|
||||||
|
this.checkable = checkable;
|
||||||
}
|
}
|
||||||
render(editable, checkable, header){
|
render(editable, checkable, header){
|
||||||
if (checkable){
|
if (checkable){
|
||||||
@ -39,6 +45,11 @@ bricks.DataRow = class extends bricks.HBox {
|
|||||||
this.build_toolbar(editable, header);
|
this.build_toolbar(editable, header);
|
||||||
this.build_fields(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){
|
get_check_state(e){
|
||||||
d = e.target.getValue()
|
d = e.target.getValue()
|
||||||
this.dispatch('checked', d.c)
|
this.dispatch('checked', d.c)
|
||||||
@ -102,7 +113,12 @@ bricks.DataRow = class extends bricks.HBox {
|
|||||||
my_dispatch(e){
|
my_dispatch(e){
|
||||||
this.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 exclouded = [];
|
||||||
var cwidths = {};
|
var cwidths = {};
|
||||||
if (this.browserfields && this.browserfields.exclouded){
|
if (this.browserfields && this.browserfields.exclouded){
|
||||||
@ -113,7 +129,7 @@ bricks.DataRow = class extends bricks.HBox {
|
|||||||
}
|
}
|
||||||
for (var i=0;i<this.fields.length;i++){
|
for (var i=0;i<this.fields.length;i++){
|
||||||
var f = this.fields[i]
|
var f = this.fields[i]
|
||||||
if (this.exclouded.includes(f.name)){
|
if (exclouded.includes(f.name)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var opts = bricks.extend({
|
var opts = bricks.extend({
|
||||||
@ -121,6 +137,8 @@ bricks.DataRow = class extends bricks.HBox {
|
|||||||
}, f);
|
}, f);
|
||||||
if (header){
|
if (header){
|
||||||
opts.value = f.label || f.name;
|
opts.value = f.label || f.name;
|
||||||
|
} else {
|
||||||
|
opts.value = this.user_data[f.name];
|
||||||
}
|
}
|
||||||
var cwidth = cwidths[f.name];
|
var cwidth = cwidths[f.name];
|
||||||
if (cwidth){
|
if (cwidth){
|
||||||
@ -129,7 +147,7 @@ bricks.DataRow = class extends bricks.HBox {
|
|||||||
var f = bricks.get_ViewBuilder(f.uitype);
|
var f = bricks.get_ViewBuilder(f.uitype);
|
||||||
if (!f) f = bricks.get_ViewBuilder('str');
|
if (!f) f = bricks.get_ViewBuilder('str');
|
||||||
var w = f(opts);
|
var w = f(opts);
|
||||||
this.add_widget(w)
|
cw.add_widget(w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel {
|
|||||||
"data_method",
|
"data_method",
|
||||||
"cache_limit",
|
"cache_limit",
|
||||||
"page_rows",
|
"page_rows",
|
||||||
|
"row_cheight":1.5
|
||||||
"record_view"
|
"record_view"
|
||||||
"content_rely_on"
|
"content_rely_on"
|
||||||
"content_rely_value"
|
"content_rely_value"
|
||||||
@ -33,7 +34,7 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel {
|
|||||||
*/
|
*/
|
||||||
constructor(opts){
|
constructor(opts){
|
||||||
super(opts);
|
super(opts);
|
||||||
this.element = this.dom_element;
|
this.row_cheight = opts.row_cheight || 1.5;
|
||||||
// this.set_style('overflow', 'auto');
|
// this.set_style('overflow', 'auto');
|
||||||
this.loader = new bricks.PageDataLoader({
|
this.loader = new bricks.PageDataLoader({
|
||||||
url:this.opts.data_url,
|
url:this.opts.data_url,
|
||||||
@ -115,9 +116,7 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel {
|
|||||||
}
|
}
|
||||||
content.set_css('accordion-item-content');
|
content.set_css('accordion-item-content');
|
||||||
content.hide();
|
content.hide();
|
||||||
if ( build_content ){
|
info.bind('click', this.line_clicked.bind(this, info, content, record));
|
||||||
info.bind('click', this.toggle_content.bind(this, info, content, record));
|
|
||||||
}
|
|
||||||
item.add_widget(content);
|
item.add_widget(content);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
@ -128,8 +127,8 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel {
|
|||||||
}
|
}
|
||||||
var w;
|
var w;
|
||||||
var tb = null;
|
var tb = null;
|
||||||
var info = new bricks.AccordionInfo({});
|
var info = new bricks.AccordionInfo({cheight:this.cheight});
|
||||||
info.data = record;
|
info.user_data = record;
|
||||||
item.add_widget(info);
|
item.add_widget(info);
|
||||||
tb = this.build_record_toolbar(info, record);
|
tb = this.build_record_toolbar(info, record);
|
||||||
if (! record){
|
if (! record){
|
||||||
@ -214,16 +213,19 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel {
|
|||||||
var desc = await resp.json();
|
var desc = await resp.json();
|
||||||
var w = await bricks.widgetBuild(desc);
|
var w = await bricks.widgetBuild(desc);
|
||||||
if (desc.widgettype == 'Message'){
|
if (desc.widgettype == 'Message'){
|
||||||
var d = form.getValue();
|
await this.renew_record_view(form, info);
|
||||||
var record = bricks.extend(info.data, d);
|
|
||||||
var w = info.children[0];
|
|
||||||
info.clear_widgets();
|
|
||||||
var rtb = w.children[0];
|
|
||||||
var w = await bricks.widgetBuild(this.record_view, info, record);
|
|
||||||
w.add_widget(rtb, 0);
|
|
||||||
info.add_widget(w);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
async renew_record_view(form, info){
|
||||||
|
var d = form.getValue();
|
||||||
|
var record = bricks.extend(info.user_data, d);
|
||||||
|
var w = info.children[0];
|
||||||
|
info.clear_widgets();
|
||||||
|
var rtb = w.children[0];
|
||||||
|
var w = await bricks.widgetBuild(this.record_view, info, record);
|
||||||
|
w.add_widget(rtb, 0);
|
||||||
|
info.add_widget(w);
|
||||||
|
}
|
||||||
delete_record(info, record){
|
delete_record(info, record){
|
||||||
var conform_w = new bricks.Conform({
|
var conform_w = new bricks.Conform({
|
||||||
target:this,
|
target:this,
|
||||||
@ -399,6 +401,21 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel {
|
|||||||
this.container.remove_widget(w);
|
this.container.remove_widget(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
select_line(info){
|
||||||
|
if (this.select_row){
|
||||||
|
this.select_row.unset_css('accordion-item-info-selected');
|
||||||
|
}
|
||||||
|
this.select_row = info;
|
||||||
|
this.select_row.set_css('accordion-item-info-selected');
|
||||||
|
this.dispatch('row_selected', info);
|
||||||
|
}
|
||||||
|
async line_clicked(info, content, record, event){
|
||||||
|
this.select_line(info);
|
||||||
|
if(! this.content_view){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.toggle_content(info, content, record, event);
|
||||||
|
}
|
||||||
async toggle_content(info, content, record, event){
|
async toggle_content(info, content, record, event){
|
||||||
if(! this.content_view){
|
if(! this.content_view){
|
||||||
return;
|
return;
|
||||||
|
@ -6,7 +6,7 @@ bricks.Tabular = class extends bricks.DynamicAccordion {
|
|||||||
this.get_edit_fields();
|
this.get_edit_fields();
|
||||||
}
|
}
|
||||||
get_edit_fields(){
|
get_edit_fields(){
|
||||||
var fs = this.record_view_.optiosn.fields;
|
var fs = this.record_view.options.fields;
|
||||||
this.fields = [];
|
this.fields = [];
|
||||||
var exclouded = [];
|
var exclouded = [];
|
||||||
if (this.record_view.options.editexcloded){
|
if (this.record_view.options.editexcloded){
|
||||||
@ -27,15 +27,8 @@ bricks.Tabular = class extends bricks.DynamicAccordion {
|
|||||||
if (record){
|
if (record){
|
||||||
/* data row
|
/* data row
|
||||||
*/
|
*/
|
||||||
var options = bricks.extend({}, this.record_view.options);
|
var options = bricks.extend({cheight:this.cheight}, this.record_view.options);
|
||||||
var fields = [];
|
|
||||||
options.fields.forEach(f => {
|
|
||||||
var newf = bricks.extend({}, f);
|
|
||||||
newf.value = record[f.name];
|
|
||||||
fields.push(newf);
|
|
||||||
});
|
|
||||||
var desc = bricks.extend({}, this.record_view);
|
var desc = bricks.extend({}, this.record_view);
|
||||||
options.fields = fields;
|
|
||||||
options.user_data = record;
|
options.user_data = record;
|
||||||
desc.options = options
|
desc.options = options
|
||||||
var dr = await bricks.widgetBuild(desc, this);
|
var dr = await bricks.widgetBuild(desc, this);
|
||||||
@ -53,6 +46,11 @@ bricks.Tabular = class extends bricks.DynamicAccordion {
|
|||||||
item.add_widget(dr);
|
item.add_widget(dr);
|
||||||
return 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){
|
record_event_handle(event_name, record, row, item){
|
||||||
console.log('event_name=', event_name, 'record=', record);
|
console.log('event_name=', event_name, 'record=', record);
|
||||||
switch(event_name){
|
switch(event_name){
|
||||||
|
@ -171,6 +171,9 @@ bricks.JsWidget = class {
|
|||||||
this.set_css(c, remove_flg);
|
this.set_css(c, remove_flg);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
unset_css(css){
|
||||||
|
this.dom_element.classList.remove(css);
|
||||||
|
}
|
||||||
set_css(css, remove_flg){
|
set_css(css, remove_flg){
|
||||||
if (!remove_flg){
|
if (!remove_flg){
|
||||||
this.dom_element.classList.add(css);
|
this.dom_element.classList.add(css);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"widgettype":"DomElement",
|
"widgettype":"Html",
|
||||||
"options":{
|
"options":{
|
||||||
"html":"<p>Test domelement</p>"
|
"html":"<p>Test domelement</p>"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user