Skip to content

Commit

Permalink
Merge pull request YaoApp#411 from trheyi/main
Browse files Browse the repository at this point in the history
[update] table & form default actions
  • Loading branch information
trheyi authored May 13, 2023
2 parents bd9d6a0 + 1aa0fc4 commit 2d60eea
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 64 deletions.
88 changes: 66 additions & 22 deletions widgets/form/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,42 @@ func (layout *LayoutDSL) BindModel(m *model.Model, formID string, fields *Fields
if layout.Actions == nil {
layout.Actions = []component.ActionDSL{
{
Title: "::Save",
Icon: "icon-check",
Style: "primary",
ShowWhenAdd: true,
Action: component.ActionNodes{{
"name": "Submit",
"type": "Form.submit",
"payload": map[string]interface{}{},
}},
}, {
Title: "::Delete",
Icon: "icon-trash-2",
Style: "danger",
Action: component.ActionNodes{
{
"name": "Delete",
"type": "Form.delete",
"payload": map[string]interface{}{"model": formID},
},
},
Confirm: &component.ConfirmActionDSL{
Title: "::Confirm",
Desc: "::Please confirm, the data cannot be recovered",
},
Action: component.ActionNodes{{
"name": "Confirm",
"type": "Common.confirm",
"payload": map[string]interface{}{"title": "::Confirm", "content": "::Please confirm, the data cannot be recovered"},
}, {
"name": "Delete",
"type": "Form.delete",
"payload": map[string]interface{}{"model": formID},
}, {
"name": "Back",
"type": "Common.historyBack",
"payload": map[string]interface{}{},
}},
}, {
Title: "::Back",
Icon: "icon-arrow-left",
ShowWhenAdd: true,
ShowWhenView: true,
Action: component.ActionNodes{{
"name": "Back",
"type": "Common.historyBack",
"payload": map[string]interface{}{},
}},
},
}
}
Expand Down Expand Up @@ -95,20 +117,42 @@ func (layout *LayoutDSL) BindTable(tab *table.DSL, formID string, fields *Fields
if layout.Actions == nil {
layout.Actions = []component.ActionDSL{
{
Title: "::Save",
Icon: "icon-check",
Style: "primary",
ShowWhenAdd: true,
Action: component.ActionNodes{{
"name": "Submit",
"type": "Form.submit",
"payload": map[string]interface{}{},
}},
}, {
Title: "::Delete",
Icon: "icon-trash-2",
Style: "danger",
Action: component.ActionNodes{
{
"name": "Delete",
"type": "Form.delete",
"payload": map[string]interface{}{"model": formID},
},
},
Confirm: &component.ConfirmActionDSL{
Title: "::Confirm",
Desc: "::Please confirm, the data cannot be recovered",
},
Action: component.ActionNodes{{
"name": "Confirm",
"type": "Common.confirm",
"payload": map[string]interface{}{"title": "::Confirm", "content": "::Please confirm, the data cannot be recovered"},
}, {
"name": "Delete",
"type": "Form.delete",
"payload": map[string]interface{}{"model": formID},
}, {
"name": "Back",
"type": "Common.historyBack",
"payload": map[string]interface{}{},
}},
}, {
Title: "::Back",
Icon: "icon-arrow-left",
ShowWhenAdd: true,
ShowWhenView: true,
Action: component.ActionNodes{{
"name": "Back",
"type": "Common.historyBack",
"payload": map[string]interface{}{},
}},
},
}
}
Expand Down
67 changes: 25 additions & 42 deletions widgets/table/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,57 +79,40 @@ func (layout *LayoutDSL) BindModel(m *model.Model, fields *FieldsDSL, option map
layout.Table.Operation.Hide = false
layout.Table.Operation.Actions = append(
layout.Table.Operation.Actions,

component.ActionDSL{
[]component.ActionDSL{{
Title: "::View",
Icon: "icon-eye",
Action: component.ActionNodes{
{
"name": "OpenModal",
"type": "Common.openModal",
"payload": map[string]interface{}{
"Form": map[string]interface{}{
"type": "view",
"model": formName,
},
},
Action: component.ActionNodes{{
"name": "OpenModal",
"type": "Common.openModal",
"payload": map[string]interface{}{
"Form": map[string]interface{}{"type": "view", "model": formName},
},
},
},

component.ActionDSL{
}},
}, {
Title: "::Edit",
Icon: "icon-edit-2",
Action: component.ActionNodes{
{
"name": "OpenModal",
"type": "Common.openModal",
"payload": map[string]interface{}{
"Form": map[string]interface{}{
"type": "edit",
"model": formName,
},
},
Action: component.ActionNodes{{
"name": "OpenModal",
"type": "Common.openModal",
"payload": map[string]interface{}{
"Form": map[string]interface{}{"type": "edit", "model": formName},
},
},
},

component.ActionDSL{
}},
}, {
Title: "::Delete",
Icon: "icon-trash-2",
Style: "danger",
Action: component.ActionNodes{
{
"name": "Delete",
"type": "Table.delete",
"payload": map[string]interface{}{"model": formName},
},
},
Confirm: &component.ConfirmActionDSL{
Title: "::Confirm",
Desc: "::Please confirm, the data cannot be recovered",
},
},
Action: component.ActionNodes{{
"name": "Confirm",
"type": "Common.confirm",
"payload": map[string]interface{}{"title": "::Confirm", "content": "::Please confirm, the data cannot be recovered"},
}, {
"name": "Delete",
"type": "Table.delete",
"payload": map[string]interface{}{"model": formName},
}},
}}...,
)
}

Expand Down

0 comments on commit 2d60eea

Please sign in to comment.