commit
041253aeed
7 changed files with 84 additions and 79 deletions
|
|
@ -23,7 +23,8 @@ func (actions Actions) Hash() Actions {
|
|||
h := md4.New()
|
||||
for i := range actions {
|
||||
keys := []string{}
|
||||
for key, value := range actions[i].Action {
|
||||
for i, value := range actions[i].Action {
|
||||
key := fmt.Sprintf("%d", i)
|
||||
for k, v := range value {
|
||||
data, _ := jsoniter.Marshal(v)
|
||||
key = fmt.Sprintf("%s%s%s", key, k, data)
|
||||
|
|
|
|||
|
|
@ -30,15 +30,15 @@ type ActionsExport struct {
|
|||
|
||||
// ActionDSL the component action DSL
|
||||
type ActionDSL struct {
|
||||
Title string `json:"title,omitempty"`
|
||||
Width int `json:"width,omitempty"`
|
||||
Icon string `json:"icon,omitempty"`
|
||||
Style string `json:"style,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Xpath string `json:"xpath,omitempty"`
|
||||
Props PropsDSL `json:"props,omitempty"`
|
||||
Confirm *ConfirmActionDSL `json:"confirm,omitempty"`
|
||||
Action map[string]ParamsDSL `json:"action,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Width int `json:"width,omitempty"`
|
||||
Icon string `json:"icon,omitempty"`
|
||||
Style string `json:"style,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Xpath string `json:"xpath,omitempty"`
|
||||
Props PropsDSL `json:"props,omitempty"`
|
||||
Confirm *ConfirmActionDSL `json:"confirm,omitempty"`
|
||||
Action []ParamsDSL `json:"action,omitempty"`
|
||||
}
|
||||
|
||||
// ConfirmActionDSL action.confirm
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ func TestReadFile(t *testing.T) {
|
|||
assert.Equal(t, "::PET ADMIN", res.Get("name"))
|
||||
assert.Equal(t, "20", res.Get("action.search.default.2"))
|
||||
assert.Equal(t, "https://yaoapps.com", res.Get("layout.header.preset.import.operation.0.link"))
|
||||
assert.Equal(t, "cured", res.Get("layout.table.operation.actions[2].action.Table.save.status"))
|
||||
assert.Equal(t, "cured", res.Get("layout.table.operation.actions[2].action[0].payload.status"))
|
||||
assert.Equal(t, "提示", res["layout.table.operation.actions[5].confirm.title"])
|
||||
assert.Equal(t, "icon-trash", res["layout.table.operation.actions[5].icon"])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -280,14 +280,12 @@ func (dsl *DSL) Actions() []component.ActionsExport {
|
|||
|
||||
// layout.operation.actions
|
||||
if dsl.Layout != nil &&
|
||||
dsl.Layout.Operation != nil &&
|
||||
dsl.Layout.Operation.Actions != nil &&
|
||||
len(dsl.Layout.Operation.Actions) > 0 {
|
||||
|
||||
dsl.Layout.Actions != nil &&
|
||||
len(dsl.Layout.Actions) > 0 {
|
||||
res = append(res, component.ActionsExport{
|
||||
Type: "operation",
|
||||
Xpath: "layout.operation.actions",
|
||||
Actions: dsl.Layout.Operation.Actions.Hash(),
|
||||
Actions: dsl.Layout.Actions.Hash(),
|
||||
})
|
||||
}
|
||||
return res
|
||||
|
|
|
|||
|
|
@ -15,22 +15,23 @@ func (layout *LayoutDSL) BindModel(m *gou.Model, formID string, fields *FieldsDS
|
|||
layout.Primary = m.PrimaryKey
|
||||
}
|
||||
|
||||
if layout.Operation == nil {
|
||||
layout.Operation = &OperationLayoutDSL{
|
||||
Preset: map[string]map[string]interface{}{"save": {}, "back": {}},
|
||||
Actions: []component.ActionDSL{
|
||||
{
|
||||
Title: "::Delete",
|
||||
Icon: "icon-trash-2",
|
||||
Style: "danger",
|
||||
Action: map[string]component.ParamsDSL{
|
||||
"Form.delete": {"model": formID},
|
||||
},
|
||||
Confirm: &component.ConfirmActionDSL{
|
||||
Title: "::Confirm",
|
||||
Desc: "::Please confirm, the data cannot be recovered",
|
||||
if layout.Actions == nil {
|
||||
layout.Actions = []component.ActionDSL{
|
||||
{
|
||||
Title: "::Delete",
|
||||
Icon: "icon-trash-2",
|
||||
Style: "danger",
|
||||
Action: []component.ParamsDSL{
|
||||
{
|
||||
"name": "Delete",
|
||||
"type": "Form.delete",
|
||||
"payload": map[string]interface{}{"model": formID},
|
||||
},
|
||||
},
|
||||
Confirm: &component.ConfirmActionDSL{
|
||||
Title: "::Confirm",
|
||||
Desc: "::Please confirm, the data cannot be recovered",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -71,21 +72,9 @@ func (layout *LayoutDSL) BindForm(form *DSL, fields *FieldsDSL) error {
|
|||
layout.Primary = form.Layout.Primary
|
||||
}
|
||||
|
||||
if layout.Operation == nil && form.Layout.Operation != nil {
|
||||
layout.Operation = &OperationLayoutDSL{
|
||||
Actions: []component.ActionDSL{},
|
||||
Preset: map[string]map[string]interface{}{},
|
||||
}
|
||||
}
|
||||
|
||||
if (layout.Operation.Actions == nil || len(layout.Operation.Actions) == 0) &&
|
||||
form.Layout.Operation.Actions != nil {
|
||||
layout.Operation.Actions = form.Layout.Operation.Actions
|
||||
}
|
||||
|
||||
if layout.Operation.Preset == nil || len(layout.Operation.Preset) == 0 &&
|
||||
form.Layout.Operation.Preset != nil {
|
||||
layout.Operation.Preset = form.Layout.Operation.Preset
|
||||
if (layout.Actions == nil || len(layout.Actions) == 0) &&
|
||||
form.Layout.Actions != nil {
|
||||
layout.Actions = form.Layout.Actions
|
||||
}
|
||||
|
||||
if layout.Form == nil && form.Layout.Form != nil {
|
||||
|
|
@ -102,22 +91,23 @@ func (layout *LayoutDSL) BindTable(tab *table.DSL, formID string, fields *Fields
|
|||
layout.Primary = tab.Layout.Primary
|
||||
}
|
||||
|
||||
if layout.Operation == nil {
|
||||
layout.Operation = &OperationLayoutDSL{
|
||||
Preset: map[string]map[string]interface{}{"save": {}, "back": {}},
|
||||
Actions: []component.ActionDSL{
|
||||
{
|
||||
Title: "::Delete",
|
||||
Icon: "icon-trash-2",
|
||||
Style: "danger",
|
||||
Action: map[string]component.ParamsDSL{
|
||||
"Form.delete": {"model": formID},
|
||||
},
|
||||
Confirm: &component.ConfirmActionDSL{
|
||||
Title: "::Confirm",
|
||||
Desc: "::Please confirm, the data cannot be recovered",
|
||||
if layout.Actions == nil {
|
||||
layout.Actions = []component.ActionDSL{
|
||||
{
|
||||
Title: "::Delete",
|
||||
Icon: "icon-trash-2",
|
||||
Style: "danger",
|
||||
Action: []component.ParamsDSL{
|
||||
{
|
||||
"name": "Delete",
|
||||
"type": "Form.delete",
|
||||
"payload": map[string]interface{}{"model": formID},
|
||||
},
|
||||
},
|
||||
Confirm: &component.ConfirmActionDSL{
|
||||
Title: "::Confirm",
|
||||
Desc: "::Please confirm, the data cannot be recovered",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,16 +56,10 @@ type BindActionDSL struct {
|
|||
|
||||
// LayoutDSL the form layout DSL
|
||||
type LayoutDSL struct {
|
||||
Primary string `json:"primary,omitempty"`
|
||||
Operation *OperationLayoutDSL `json:"operation,omitempty"`
|
||||
Form *ViewLayoutDSL `json:"form,omitempty"`
|
||||
Config map[string]interface{} `json:"config,omitempty"`
|
||||
}
|
||||
|
||||
// OperationLayoutDSL layout.operation
|
||||
type OperationLayoutDSL struct {
|
||||
Preset map[string]map[string]interface{} `json:"preset,omitempty"`
|
||||
Actions component.Actions `json:"actions,omitempty"`
|
||||
Primary string `json:"primary,omitempty"`
|
||||
Actions component.Actions `json:"actions,omitempty"`
|
||||
Form *ViewLayoutDSL `json:"form,omitempty"`
|
||||
Config map[string]interface{} `json:"config,omitempty"`
|
||||
}
|
||||
|
||||
// FieldsDSL the form fields DSL
|
||||
|
|
|
|||
|
|
@ -31,8 +31,12 @@ func (layout *LayoutDSL) BindModel(m *gou.Model, fields *FieldsDSL, option map[s
|
|||
Title: "::Create",
|
||||
Icon: "icon-plus",
|
||||
Width: 3,
|
||||
Action: map[string]component.ParamsDSL{
|
||||
"Common.historyPush": {"pathname": fmt.Sprintf("/x/Form/%s/0/edit", formName)},
|
||||
Action: []component.ParamsDSL{
|
||||
{
|
||||
"name": "HistoryPush",
|
||||
"type": "Common.historyPush",
|
||||
"payload": map[string]interface{}{"pathname": fmt.Sprintf("/x/Form/%s/0/edit", formName)},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -78,9 +82,16 @@ func (layout *LayoutDSL) BindModel(m *gou.Model, fields *FieldsDSL, option map[s
|
|||
component.ActionDSL{
|
||||
Title: "::View",
|
||||
Icon: "icon-eye",
|
||||
Action: map[string]component.ParamsDSL{
|
||||
"Common.openModal": {
|
||||
"Form": map[string]interface{}{"type": "view", "model": formName},
|
||||
Action: []component.ParamsDSL{
|
||||
{
|
||||
"name": "OpenModal",
|
||||
"type": "Common.openModal",
|
||||
"payload": map[string]interface{}{
|
||||
"Form": map[string]interface{}{
|
||||
"type": "view",
|
||||
"model": formName,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -88,9 +99,16 @@ func (layout *LayoutDSL) BindModel(m *gou.Model, fields *FieldsDSL, option map[s
|
|||
component.ActionDSL{
|
||||
Title: "::Edit",
|
||||
Icon: "icon-edit-2",
|
||||
Action: map[string]component.ParamsDSL{
|
||||
"Common.openModal": {
|
||||
"Form": map[string]interface{}{"type": "edit", "model": formName},
|
||||
Action: []component.ParamsDSL{
|
||||
{
|
||||
"name": "OpenModal",
|
||||
"type": "Common.openModal",
|
||||
"payload": map[string]interface{}{
|
||||
"Form": map[string]interface{}{
|
||||
"type": "edit",
|
||||
"model": formName,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -99,8 +117,12 @@ func (layout *LayoutDSL) BindModel(m *gou.Model, fields *FieldsDSL, option map[s
|
|||
Title: "::Delete",
|
||||
Icon: "icon-trash-2",
|
||||
Style: "danger",
|
||||
Action: map[string]component.ParamsDSL{
|
||||
"Table.delete": {"model": formName},
|
||||
Action: []component.ParamsDSL{
|
||||
{
|
||||
"name": "Delete",
|
||||
"type": "Table.delete",
|
||||
"payload": map[string]interface{}{"model": formName},
|
||||
},
|
||||
},
|
||||
Confirm: &component.ConfirmActionDSL{
|
||||
Title: "::Confirm",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue