This commit is contained in:
yumoqing 2024-07-26 18:29:02 +08:00
parent 72721b93dc
commit a81bbd456b

View File

@ -7,10 +7,9 @@ bricks.show_resp_message_or_error = async function(resp){
await bricks.widgetBuild(desc, bricks.Body);
}
bricks.FieldGroup = class extends bricks.VBox {
bricks.FieldGroup = class {
constructor(opts){
opts.leftMargin = '10px';
super(opts);
this.opts = opts
}
build_fields(form, parent, fields){
var dc = new bricks.DynamicColumn({mobile_cols:2});
@ -88,48 +87,10 @@ bricks.FormBody = class extends bricks.VScrollPanel {
}
}
bricks.Form = class extends bricks.VBox {
/*
{
title:
description:
notoolbar:False,
input_layout:"VBox" or "HBox", default is "VBox",
cols:
dataurl:
toolbar:
submit_url:
method:
fields
}
*/
bricks.FormBase = class extends bricks.Layout {
constructor(opts){
opts.height = "100%";
opts.width = "100%";
opts.overflow = "auto";
super(opts);
this.name_inputs = {};
this.need_formdata = false;
if (this.opts.title){
var t = new bricks.Title3({
otext:this.opts.title,
height:'auto',
i18n:true});
this.add_widget(t, 0);
}
if (this.opts.description){
var d = new bricks.Text({
otext:this.opts.description,
height:'auto',
i18n:true});
this.add_widget(d);
}
var filler = new bricks.Filler({});
this.add_widget(filler);
this.body = new bricks.FormBody(this, opts);
filler.add_widget(this.body);
if (! opts.notoolbar)
this.build_toolbar(this);
}
build_toolbar(widget){
var box = new bricks.HBox({height:'auto', width:'100%'});
@ -284,4 +245,61 @@ bricks.Form = class extends bricks.VBox {
}
}
bricks.InlineForm = class extends bricks.FormBase {
constructor(opts){
opts.height = "100%";
opts.width = "100%";
opts.overflow = "auto";
super(opts);
this.fg = new bricks.FieldGroup({});
this.fg.build_fields(this, this, this.opts.fields)
this.build_toolbar(this.children[0]);
}
}
bricks.Form = class extends bricks.FormBase {
/*
{
title:
description:
notoolbar:False,
input_layout:"VBox" or "HBox", default is "VBox",
cols:
dataurl:
toolbar:
submit_url:
method:
fields
}
*/
constructor(opts){
opts.height = "100%";
opts.width = "100%";
opts.overflow = "auto";
super(opts);
this.need_formdata = false;
if (this.opts.title){
var t = new bricks.Title3({
otext:this.opts.title,
height:'auto',
i18n:true});
this.add_widget(t, 0);
}
if (this.opts.description){
var d = new bricks.Text({
otext:this.opts.description,
height:'auto',
i18n:true});
this.add_widget(d);
}
var filler = new bricks.Filler({});
this.add_widget(filler);
this.body = new bricks.FormBody(this, opts);
filler.add_widget(this.body);
if (! opts.notoolbar)
this.build_toolbar(this);
}
}
bricks.Factory.register('InlineForm', bricks.InlineForm);
bricks.Factory.register('Form', bricks.Form);