Merge pull request #411 from trheyi/main

[update] table & form default actions
This commit is contained in:
Max 2023-05-13 18:11:44 +08:00 committed by GitHub
commit 2d60eeac85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 91 additions and 64 deletions

View file

@ -19,20 +19,42 @@ func (layout *LayoutDSL) BindModel(m *model.Model, formID string, fields *Fields
if layout.Actions == nil { if layout.Actions == nil {
layout.Actions = []component.ActionDSL{ 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", Title: "::Delete",
Icon: "icon-trash-2", Icon: "icon-trash-2",
Style: "danger", Style: "danger",
Action: component.ActionNodes{ Action: component.ActionNodes{{
{ "name": "Confirm",
"type": "Common.confirm",
"payload": map[string]interface{}{"title": "::Confirm", "content": "::Please confirm, the data cannot be recovered"},
}, {
"name": "Delete", "name": "Delete",
"type": "Form.delete", "type": "Form.delete",
"payload": map[string]interface{}{"model": formID}, "payload": map[string]interface{}{"model": formID},
}, }, {
}, "name": "Back",
Confirm: &component.ConfirmActionDSL{ "type": "Common.historyBack",
Title: "::Confirm", "payload": map[string]interface{}{},
Desc: "::Please confirm, the data cannot be recovered", }},
}, }, {
Title: "::Back",
Icon: "icon-arrow-left",
ShowWhenAdd: true,
ShowWhenView: true,
Action: component.ActionNodes{{
"name": "Back",
"type": "Common.historyBack",
"payload": map[string]interface{}{},
}},
}, },
} }
} }
@ -95,20 +117,42 @@ func (layout *LayoutDSL) BindTable(tab *table.DSL, formID string, fields *Fields
if layout.Actions == nil { if layout.Actions == nil {
layout.Actions = []component.ActionDSL{ 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", Title: "::Delete",
Icon: "icon-trash-2", Icon: "icon-trash-2",
Style: "danger", Style: "danger",
Action: component.ActionNodes{ Action: component.ActionNodes{{
{ "name": "Confirm",
"type": "Common.confirm",
"payload": map[string]interface{}{"title": "::Confirm", "content": "::Please confirm, the data cannot be recovered"},
}, {
"name": "Delete", "name": "Delete",
"type": "Form.delete", "type": "Form.delete",
"payload": map[string]interface{}{"model": formID}, "payload": map[string]interface{}{"model": formID},
}, }, {
}, "name": "Back",
Confirm: &component.ConfirmActionDSL{ "type": "Common.historyBack",
Title: "::Confirm", "payload": map[string]interface{}{},
Desc: "::Please confirm, the data cannot be recovered", }},
}, }, {
Title: "::Back",
Icon: "icon-arrow-left",
ShowWhenAdd: true,
ShowWhenView: true,
Action: component.ActionNodes{{
"name": "Back",
"type": "Common.historyBack",
"payload": map[string]interface{}{},
}},
}, },
} }
} }

View file

@ -79,57 +79,40 @@ func (layout *LayoutDSL) BindModel(m *model.Model, fields *FieldsDSL, option map
layout.Table.Operation.Hide = false layout.Table.Operation.Hide = false
layout.Table.Operation.Actions = append( layout.Table.Operation.Actions = append(
layout.Table.Operation.Actions, layout.Table.Operation.Actions,
[]component.ActionDSL{{
component.ActionDSL{
Title: "::View", Title: "::View",
Icon: "icon-eye", Icon: "icon-eye",
Action: component.ActionNodes{ Action: component.ActionNodes{{
{
"name": "OpenModal", "name": "OpenModal",
"type": "Common.openModal", "type": "Common.openModal",
"payload": map[string]interface{}{ "payload": map[string]interface{}{
"Form": map[string]interface{}{ "Form": map[string]interface{}{"type": "view", "model": formName},
"type": "view",
"model": formName,
}, },
}, }},
}, }, {
},
},
component.ActionDSL{
Title: "::Edit", Title: "::Edit",
Icon: "icon-edit-2", Icon: "icon-edit-2",
Action: component.ActionNodes{ Action: component.ActionNodes{{
{
"name": "OpenModal", "name": "OpenModal",
"type": "Common.openModal", "type": "Common.openModal",
"payload": map[string]interface{}{ "payload": map[string]interface{}{
"Form": map[string]interface{}{ "Form": map[string]interface{}{"type": "edit", "model": formName},
"type": "edit",
"model": formName,
}, },
}, }},
}, }, {
},
},
component.ActionDSL{
Title: "::Delete", Title: "::Delete",
Icon: "icon-trash-2", Icon: "icon-trash-2",
Style: "danger", Style: "danger",
Action: component.ActionNodes{ Action: component.ActionNodes{{
{ "name": "Confirm",
"type": "Common.confirm",
"payload": map[string]interface{}{"title": "::Confirm", "content": "::Please confirm, the data cannot be recovered"},
}, {
"name": "Delete", "name": "Delete",
"type": "Table.delete", "type": "Table.delete",
"payload": map[string]interface{}{"model": formName}, "payload": map[string]interface{}{"model": formName},
}, }},
}, }}...,
Confirm: &component.ConfirmActionDSL{
Title: "::Confirm",
Desc: "::Please confirm, the data cannot be recovered",
},
},
) )
} }