[change] widget table filter.actions
This commit is contained in:
parent
104acc89c1
commit
9797f1f31f
4 changed files with 34 additions and 7 deletions
|
|
@ -24,6 +24,7 @@ type InstanceDSL struct {
|
||||||
// ActionDSL the component action DSL
|
// ActionDSL the component action DSL
|
||||||
type ActionDSL struct {
|
type ActionDSL struct {
|
||||||
Title string `json:"title,omitempty"`
|
Title string `json:"title,omitempty"`
|
||||||
|
Width int `json:"width,omitempty"`
|
||||||
Icon string `json:"icon,omitempty"`
|
Icon string `json:"icon,omitempty"`
|
||||||
Style string `json:"style,omitempty"`
|
Style string `json:"style,omitempty"`
|
||||||
Props PropsDSL `json:"props,omitempty"`
|
Props PropsDSL `json:"props,omitempty"`
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package table
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/yaoapp/gou"
|
"github.com/yaoapp/gou"
|
||||||
"github.com/yaoapp/yao/widgets/field"
|
"github.com/yaoapp/yao/widgets/field"
|
||||||
|
|
@ -84,21 +85,37 @@ func (fields *FieldsDSL) Xgen(layout *LayoutDSL) (map[string]interface{}, error)
|
||||||
tables := map[string]interface{}{}
|
tables := map[string]interface{}{}
|
||||||
if layout.Filter != nil {
|
if layout.Filter != nil {
|
||||||
for i, f := range layout.Filter.Columns {
|
for i, f := range layout.Filter.Columns {
|
||||||
field, has := fields.Filter[f.Name]
|
name := f.Name
|
||||||
|
field, has := fields.Filter[name]
|
||||||
if !has {
|
if !has {
|
||||||
|
if strings.HasPrefix(f.Name, "::") {
|
||||||
|
name = fmt.Sprintf("$L(%s)", strings.TrimPrefix(f.Name, "::"))
|
||||||
|
if field, has = fields.Filter[name]; has {
|
||||||
|
filters[name] = field.Map()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil, fmt.Errorf("fields.filter.%s not found, checking layout.filter.columns.%d.name", f.Name, i)
|
return nil, fmt.Errorf("fields.filter.%s not found, checking layout.filter.columns.%d.name", f.Name, i)
|
||||||
}
|
}
|
||||||
filters[f.Name] = field.Map()
|
filters[name] = field.Map()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if layout.Table != nil {
|
if layout.Table != nil {
|
||||||
for i, f := range layout.Table.Columns {
|
for i, f := range layout.Table.Columns {
|
||||||
field, has := fields.Table[f.Name]
|
name := f.Name
|
||||||
|
field, has := fields.Table[name]
|
||||||
if !has {
|
if !has {
|
||||||
|
if strings.HasPrefix(f.Name, "::") {
|
||||||
|
name = fmt.Sprintf("$L(%s)", strings.TrimPrefix(f.Name, "::"))
|
||||||
|
if field, has = fields.Table[name]; has {
|
||||||
|
tables[name] = field.Map()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil, fmt.Errorf("fields.table.%s not found, checking layout.table.columns.%d.name", f.Name, i)
|
return nil, fmt.Errorf("fields.table.%s not found, checking layout.table.columns.%d.name", f.Name, i)
|
||||||
}
|
}
|
||||||
tables[f.Name] = field.Map()
|
tables[name] = field.Map()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,16 @@ func (layout *LayoutDSL) BindModel(m *gou.Model, fields *FieldsDSL, option map[s
|
||||||
|
|
||||||
layout.Filter = &FilterLayoutDSL{Columns: component.Instances{}}
|
layout.Filter = &FilterLayoutDSL{Columns: component.Instances{}}
|
||||||
if hasForm {
|
if hasForm {
|
||||||
layout.Filter.BtnAddText = "创建"
|
layout.Filter.Actions = component.Actions{
|
||||||
|
{
|
||||||
|
Title: "::Create",
|
||||||
|
Icon: "icon-plus",
|
||||||
|
Width: 3,
|
||||||
|
Action: map[string]component.ParamsDSL{
|
||||||
|
"Common.historyPush": {"pathname": fmt.Sprintf("/x/Form/%s/0/edit", formName)},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
max := 3
|
max := 3
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,8 @@ type OperationImportDSL struct {
|
||||||
|
|
||||||
// FilterLayoutDSL layout.filter
|
// FilterLayoutDSL layout.filter
|
||||||
type FilterLayoutDSL struct {
|
type FilterLayoutDSL struct {
|
||||||
BtnAddText string `json:"btnAddText,omitempty"`
|
Actions component.Actions `json:"actions,omitempty"`
|
||||||
Columns component.Instances `json:"columns,omitempty"`
|
Columns component.Instances `json:"columns,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ViewLayoutDSL layout.table
|
// ViewLayoutDSL layout.table
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue