feat: Add hideLabel option to component and column DSL

Add the hideLabel option to the component and column DSLs. This allows hiding the label for the respective widgets. The hideLabel option is set to true in the component and column DSLs when necessary.
This commit is contained in:
Max 2024-05-23 06:48:12 +08:00
parent f38a2e4eb4
commit 1a1ffabbd8
6 changed files with 37 additions and 17 deletions

View file

@ -27,6 +27,11 @@ func (dsl DSL) Map() map[string]interface{} {
"type": dsl.Type, "type": dsl.Type,
"props": map[string]interface{}(dsl.Props), "props": map[string]interface{}(dsl.Props),
} }
if dsl.HideLabel {
res["hideLabel"] = true
}
if dsl.Bind != "" { if dsl.Bind != "" {
res["bind"] = dsl.Bind res["bind"] = dsl.Bind
} }

View file

@ -2,10 +2,11 @@ package component
// DSL the component DSL // DSL the component DSL
type DSL struct { type DSL struct {
Bind string `json:"bind,omitempty"` Bind string `json:"bind,omitempty"`
Type string `json:"type,omitempty"` HideLabel bool `json:"hideLabel,omitempty"`
Compute *Compute `json:"compute,omitempty"` Type string `json:"type,omitempty"`
Props PropsDSL `json:"props,omitempty"` Compute *Compute `json:"compute,omitempty"`
Props PropsDSL `json:"props,omitempty"`
} }
// Actions the actions // Actions the actions

View file

@ -112,6 +112,10 @@ func (column ColumnDSL) Map() map[string]interface{} {
"bind": column.Bind, "bind": column.Bind,
} }
if column.HideLabel {
res["hideLabel"] = true
}
if column.Data != nil { if column.Data != nil {
res["data"] = map[string]interface{}{"process": column.Data.Process, "query": column.Data.Query} res["data"] = map[string]interface{}{"process": column.Data.Process, "query": column.Data.Query}
} }

View file

@ -18,13 +18,14 @@ type CloudProps map[string]component.CloudPropsDSL
// ColumnDSL the field column dsl // ColumnDSL the field column dsl
type ColumnDSL struct { type ColumnDSL struct {
ID string `json:"id,omitempty"` ID string `json:"id,omitempty"`
Data *component.CloudPropsDSL `json:"$data,omitempty"` Data *component.CloudPropsDSL `json:"$data,omitempty"`
Key string `json:"key,omitempty"` Key string `json:"key,omitempty"`
Bind string `json:"bind,omitempty"` Bind string `json:"bind,omitempty"`
Link string `json:"link,omitempty"` Link string `json:"link,omitempty"`
View *component.DSL `json:"view,omitempty"` HideLabel bool `json:"hideLabel,omitempty"`
Edit *component.DSL `json:"edit,omitempty"` View *component.DSL `json:"view,omitempty"`
Edit *component.DSL `json:"edit,omitempty"`
} }
type aliasColumnDSL ColumnDSL type aliasColumnDSL ColumnDSL

View file

@ -264,15 +264,24 @@ func (dsl *DSL) Xgen(data map[string]interface{}, excludes map[string]bool) (map
return nil, err return nil, err
} }
// full width default value // ** WARNING **
if _, has := dsl.Config["full"]; !has { // set the full configuration by default
dsl.Config["full"] = true // Temporary solution, Will be removed in the future
// should be set when the list is created
config := map[string]interface{}{}
if dsl.Config != nil {
for key, value := range dsl.Config {
config[key] = value
}
}
if _, has := config["full"]; !has {
config["full"] = true
} }
// Merge the layout config // Merge the layout config
if layout.Config != nil { if layout.Config != nil {
for key, value := range layout.Config { for key, value := range layout.Config {
dsl.Config[key] = value config[key] = value
} }
} }
@ -289,7 +298,7 @@ func (dsl *DSL) Xgen(data map[string]interface{}, excludes map[string]bool) (map
onChange := map[string]interface{}{} // Hooks onChange := map[string]interface{}{} // Hooks
setting["fields"] = fields setting["fields"] = fields
setting["config"] = dsl.Config setting["config"] = config
for _, cProp := range dsl.CProps { for _, cProp := range dsl.CProps {
err := cProp.Replace(setting, func(cProp component.CloudPropsDSL) interface{} { err := cProp.Replace(setting, func(cProp component.CloudPropsDSL) interface{} {

View file

@ -230,7 +230,7 @@ func (dsl *DSL) Xgen(data map[string]interface{}, excludes map[string]bool, quer
} }
} }
if _, has := config["full"]; !has { if _, has := config["full"]; !has {
dsl.Config["full"] = true config["full"] = true
} }
setting := map[string]interface{}{} setting := map[string]interface{}{}