Add color field support to QueryProp and Option structures
This commit is contained in:
parent
b9aaff7afb
commit
35f16e107d
2 changed files with 22 additions and 0 deletions
|
|
@ -21,6 +21,13 @@ var BackendOnlyProps = map[string]map[string]map[string]interface{}{
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"tag": {
|
||||||
|
"query": {
|
||||||
|
"xProps": map[string]interface{}{
|
||||||
|
"$remote": map[string]interface{}{"process": "yao.component.GetOptions"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"autocomplete": {"query": {
|
"autocomplete": {"query": {
|
||||||
"xProps": map[string]interface{}{
|
"xProps": map[string]interface{}{
|
||||||
"$remote": map[string]interface{}{"process": "yao.component.GetOptions"},
|
"$remote": map[string]interface{}{"process": "yao.component.GetOptions"},
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,11 @@ type QueryProp struct {
|
||||||
LabelField string `json:"labelField,omitempty"`
|
LabelField string `json:"labelField,omitempty"`
|
||||||
ValueField string `json:"valueField,omitempty"`
|
ValueField string `json:"valueField,omitempty"`
|
||||||
IconField string `json:"iconField,omitempty"`
|
IconField string `json:"iconField,omitempty"`
|
||||||
|
ColorField string `json:"colorField,omitempty"`
|
||||||
LabelFormat string `json:"labelFormat,omitempty"`
|
LabelFormat string `json:"labelFormat,omitempty"`
|
||||||
ValueFormat string `json:"valueFormat,omitempty"`
|
ValueFormat string `json:"valueFormat,omitempty"`
|
||||||
IconFormat string `json:"iconFormat,omitempty"`
|
IconFormat string `json:"iconFormat,omitempty"`
|
||||||
|
ColorFormat string `json:"colorFormat,omitempty"`
|
||||||
Wheres []map[string]interface{} `json:"wheres,omitempty"`
|
Wheres []map[string]interface{} `json:"wheres,omitempty"`
|
||||||
param model.QueryParam
|
param model.QueryParam
|
||||||
dsl map[string]interface{}
|
dsl map[string]interface{}
|
||||||
|
|
@ -37,6 +39,7 @@ type Option struct {
|
||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
Value interface{} `json:"value"`
|
Value interface{} `json:"value"`
|
||||||
Icon string `json:"icon,omitempty"`
|
Icon string `json:"icon,omitempty"`
|
||||||
|
Color string `json:"color,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Export process
|
// Export process
|
||||||
|
|
@ -177,6 +180,10 @@ func (q *QueryProp) format(options *[]Option, row map[string]interface{}) {
|
||||||
option.Icon = fmt.Sprintf("%v", row[q.IconField])
|
option.Icon = fmt.Sprintf("%v", row[q.IconField])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if q.ColorField != "" {
|
||||||
|
option.Color = fmt.Sprintf("%v", row[q.ColorField])
|
||||||
|
}
|
||||||
|
|
||||||
if q.LabelFormat != "" {
|
if q.LabelFormat != "" {
|
||||||
option.Label = q.replaceString(q.LabelFormat, row)
|
option.Label = q.replaceString(q.LabelFormat, row)
|
||||||
}
|
}
|
||||||
|
|
@ -189,6 +196,10 @@ func (q *QueryProp) format(options *[]Option, row map[string]interface{}) {
|
||||||
option.Icon = q.replaceString(q.IconFormat, row)
|
option.Icon = q.replaceString(q.IconFormat, row)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if q.ColorField != "" && q.ColorFormat != "" {
|
||||||
|
option.Color = q.replaceString(q.ColorFormat, row)
|
||||||
|
}
|
||||||
|
|
||||||
// Update the option
|
// Update the option
|
||||||
*options = append(*options, option)
|
*options = append(*options, option)
|
||||||
}
|
}
|
||||||
|
|
@ -259,6 +270,10 @@ func (q *QueryProp) parse(query map[string]interface{}) error {
|
||||||
q.param.Select = append(q.param.Select, q.IconField)
|
q.param.Select = append(q.param.Select, q.IconField)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if q.ColorField != "" {
|
||||||
|
q.param.Select = append(q.param.Select, q.ColorField)
|
||||||
|
}
|
||||||
|
|
||||||
raw, err := jsoniter.Marshal(props)
|
raw, err := jsoniter.Marshal(props)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue