diff --git a/widgets/form/layout.go b/widgets/form/layout.go index 52bc4adb14..16450a993e 100644 --- a/widgets/form/layout.go +++ b/widgets/form/layout.go @@ -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{}{}, + }}, }, } } @@ -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{}{}, + }}, }, } } diff --git a/widgets/table/layout.go b/widgets/table/layout.go index e5a07043bc..5f8a2e1899 100644 --- a/widgets/table/layout.go +++ b/widgets/table/layout.go @@ -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}, + }}, + }}..., ) }