Skip to content

Commit

Permalink
Merge pull request #479 from trheyi/main
Browse files Browse the repository at this point in the history
[fix] table & form layout.confg
  • Loading branch information
trheyi authored Oct 17, 2023
2 parents 680a8c1 + e984481 commit df2a473
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
11 changes: 7 additions & 4 deletions widgets/form/form.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,6 @@ func MustGet(form interface{}) *DSL {
// Xgen trans to xgen setting
func (dsl *DSL) Xgen(data map[string]interface{}, excludes map[string]bool) (map[string]interface{}, error) {

if dsl.Config == nil {
dsl.Config = map[string]interface{}{}
}

if dsl.Layout == nil {
dsl.Layout = &LayoutDSL{Form: &ViewLayoutDSL{}}
}
Expand All @@ -245,6 +241,13 @@ func (dsl *DSL) Xgen(data map[string]interface{}, excludes map[string]bool) (map
dsl.Config["full"] = true
}

// Merge the layout config
if layout.Config != nil {
for key, value := range layout.Config {
dsl.Config[key] = value
}
}

setting := map[string]interface{}{}
bytes, err := jsoniter.Marshal(layout)
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions widgets/table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,13 @@ func (dsl *DSL) Xgen(data map[string]interface{}, excludes map[string]bool) (map
dsl.Config["full"] = true
}

// Merge the layout config
if layout.Config != nil {
for key, value := range layout.Config {
dsl.Config[key] = value
}
}

setting := map[string]interface{}{}
bytes, err := jsoniter.Marshal(layout)
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions widgets/table/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ type BindActionDSL struct {

// LayoutDSL the table layout
type LayoutDSL struct {
Primary string `json:"primary,omitempty"`
Header *HeaderLayoutDSL `json:"header,omitempty"`
Filter *FilterLayoutDSL `json:"filter,omitempty"`
Table *ViewLayoutDSL `json:"table,omitempty"`
Primary string `json:"primary,omitempty"`
Header *HeaderLayoutDSL `json:"header,omitempty"`
Filter *FilterLayoutDSL `json:"filter,omitempty"`
Table *ViewLayoutDSL `json:"table,omitempty"`
Config map[string]interface{} `json:"config,omitempty"`
}

// HeaderLayoutDSL layout.header
Expand Down

0 comments on commit df2a473

Please sign in to comment.