From a81bbd456b4bf603559a3c18be36680ed77f0088 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 26 Jul 2024 18:29:02 +0800 Subject: [PATCH] bugfix --- bricks/form.js | 102 +++++++++++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 42 deletions(-) diff --git a/bricks/form.js b/bricks/form.js index c0142d3..757b6f6 100644 --- a/bricks/form.js +++ b/bricks/form.js @@ -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);