Skip to content

Commit

Permalink
[change] form layout
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Oct 22, 2022
1 parent 901a44b commit ca777d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion widgets/form/form.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ func New(id string) *DSL {
return &DSL{
ID: id,
Fields: &FieldsDSL{Form: field.Columns{}},
Layout: &LayoutDSL{},
CProps: field.CloudProps{},
Config: map[string]interface{}{},
}
}

Expand Down Expand Up @@ -182,6 +184,14 @@ func (dsl *DSL) Parse() error {
// Xgen trans to xgen setting
func (dsl *DSL) Xgen() (map[string]interface{}, error) {

if dsl.Layout == nil {
dsl.Layout = &LayoutDSL{Form: &ViewLayoutDSL{}}
}

if dsl.Layout.Form == nil {
dsl.Layout.Form = &ViewLayoutDSL{}
}

setting, err := dsl.Layout.Xgen()
if err != nil {
return nil, err
Expand All @@ -192,6 +202,11 @@ func (dsl *DSL) Xgen() (map[string]interface{}, error) {
return nil, err
}

// full width default value
if _, has := dsl.Config["full"]; !has {
dsl.Config["full"] = true
}

setting["fields"] = fields
setting["config"] = dsl.Config
for _, cProp := range dsl.CProps {
Expand All @@ -201,7 +216,6 @@ func (dsl *DSL) Xgen() (map[string]interface{}, error) {
"params": cProp.Query,
}
})

if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion widgets/form/form_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestLoad(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assert.Equal(t, 2, len(Forms))
assert.Equal(t, 8, len(Forms))
}

func prepare(t *testing.T, language ...string) {
Expand Down

0 comments on commit ca777d7

Please sign in to comment.