Refactor bind logic in DSL
This commit is contained in:
parent
dff977590b
commit
edad2e76f3
2 changed files with 27 additions and 21 deletions
|
|
@ -10,23 +10,27 @@ import (
|
|||
// Bind model / store / table / ...
|
||||
func (dsl *DSL) Bind() error {
|
||||
|
||||
if dsl.Action.Bind == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if dsl.Action.Bind.Model != "" {
|
||||
return dsl.bindModel()
|
||||
}
|
||||
|
||||
if dsl.Action.Bind.Store != "" {
|
||||
return dsl.bindStore()
|
||||
}
|
||||
|
||||
if dsl.Action.Bind.Table != "" {
|
||||
return dsl.bindTable()
|
||||
}
|
||||
// Support bind in future version
|
||||
|
||||
return nil
|
||||
|
||||
// if dsl.Action.Bind == nil {
|
||||
// return nil
|
||||
// }
|
||||
|
||||
// if dsl.Action.Bind.Model != "" {
|
||||
// return dsl.bindModel()
|
||||
// }
|
||||
|
||||
// if dsl.Action.Bind.Store != "" {
|
||||
// return dsl.bindStore()
|
||||
// }
|
||||
|
||||
// if dsl.Action.Bind.Table != "" {
|
||||
// return dsl.bindTable()
|
||||
// }
|
||||
|
||||
// return nil
|
||||
}
|
||||
|
||||
func (dsl *DSL) bindModel() error {
|
||||
|
|
|
|||
|
|
@ -104,13 +104,15 @@ func (dsl *DSL) translate(name string, process *gouProcess.Process, data interfa
|
|||
}
|
||||
|
||||
widgets := []string{}
|
||||
if dsl.Action.Bind.Model != "" {
|
||||
m := model.Select(dsl.Action.Bind.Model)
|
||||
widgets = append(widgets, fmt.Sprintf("model.%s", m.ID))
|
||||
}
|
||||
if dsl.Action.Bind != nil {
|
||||
if dsl.Action.Bind.Model != "" {
|
||||
m := model.Select(dsl.Action.Bind.Model)
|
||||
widgets = append(widgets, fmt.Sprintf("model.%s", m.ID))
|
||||
}
|
||||
|
||||
if dsl.Action.Bind.Table != "" {
|
||||
widgets = append(widgets, fmt.Sprintf("table.%s", dsl.Action.Bind.Table))
|
||||
if dsl.Action.Bind.Table != "" {
|
||||
widgets = append(widgets, fmt.Sprintf("table.%s", dsl.Action.Bind.Table))
|
||||
}
|
||||
}
|
||||
|
||||
widgets = append(widgets, fmt.Sprintf("list.%s", dsl.ID))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue