[add] widgets config

This commit is contained in:
Max 2022-10-20 05:00:16 +08:00
parent 7c0070ad3b
commit f5fbef9e39
9 changed files with 35 additions and 28 deletions

View file

@ -80,8 +80,8 @@ func adminRoot() (string, int) {
} }
adminRoot := "/yao/" adminRoot := "/yao/"
if root, ok := share.App.Optional["adminRoot"].(string); ok && root != "" { if share.App.AdminRoot != "" {
root = strings.TrimPrefix(root, "/") root := strings.TrimPrefix(share.App.AdminRoot, "/")
root = strings.TrimSuffix(root, "/") root = strings.TrimSuffix(root, "/")
adminRoot = fmt.Sprintf("/%s/", root) adminRoot = fmt.Sprintf("/%s/", root)
} }

View file

@ -80,6 +80,7 @@ type AppInfo struct {
Storage AppStorage `json:"storage,omitempty"` Storage AppStorage `json:"storage,omitempty"`
Option map[string]interface{} `json:"option,omitempty"` Option map[string]interface{} `json:"option,omitempty"`
XGen string `json:"xgen,omitempty"` XGen string `json:"xgen,omitempty"`
AdminRoot string `json:"adminRoot,omitempty"`
Optional map[string]interface{} `json:"optional,omitempty"` Optional map[string]interface{} `json:"optional,omitempty"`
} }

View file

@ -174,6 +174,7 @@ func (dsl *DSL) Xgen() (map[string]interface{}, error) {
} }
setting["fields"] = fields setting["fields"] = fields
setting["config"] = dsl.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{} {
return map[string]interface{}{ return map[string]interface{}{

View file

@ -9,14 +9,15 @@ import (
// DSL the chart DSL // DSL the chart DSL
type DSL struct { type DSL struct {
ID string `json:"id,omitempty"` ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Action *ActionDSL `json:"action"` Action *ActionDSL `json:"action"`
Layout *LayoutDSL `json:"layout"` Layout *LayoutDSL `json:"layout"`
Fields *FieldsDSL `json:"fields"` Fields *FieldsDSL `json:"fields"`
ComputesIn field.ComputeFields `json:"-"` Config map[string]interface{} `json:"config,omitempty"`
ComputesOut field.ComputeFields `json:"-"` ComputesIn field.ComputeFields `json:"-"`
CProps field.CloudProps `json:"-"` ComputesOut field.ComputeFields `json:"-"`
CProps field.CloudProps `json:"-"`
} }
// ActionDSL the chart action DSL // ActionDSL the chart action DSL

View file

@ -192,6 +192,7 @@ func (dsl *DSL) Xgen() (map[string]interface{}, error) {
} }
setting["fields"] = fields setting["fields"] = fields
setting["config"] = dsl.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{} {
return map[string]interface{}{ return map[string]interface{}{

View file

@ -9,14 +9,15 @@ import (
// DSL the form DSL // DSL the form DSL
type DSL struct { type DSL struct {
ID string `json:"id,omitempty"` ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Action *ActionDSL `json:"action"` Action *ActionDSL `json:"action"`
Layout *LayoutDSL `json:"layout"` Layout *LayoutDSL `json:"layout"`
Fields *FieldsDSL `json:"fields"` Fields *FieldsDSL `json:"fields"`
ComputesIn field.ComputeFields `json:"-"` Config map[string]interface{} `json:"config,omitempty"`
ComputesOut field.ComputeFields `json:"-"` ComputesIn field.ComputeFields `json:"-"`
CProps field.CloudProps `json:"-"` ComputesOut field.ComputeFields `json:"-"`
CProps field.CloudProps `json:"-"`
} }
// ActionDSL the form action DSL // ActionDSL the form action DSL

View file

@ -261,6 +261,7 @@ func (dsl *DSL) Xgen() (map[string]interface{}, error) {
} }
setting["fields"] = fields setting["fields"] = fields
setting["config"] = dsl.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{} {
return map[string]interface{}{ return map[string]interface{}{

View file

@ -22,7 +22,7 @@ func TestLoad(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
assert.Equal(t, 6, len(Tables)) assert.Equal(t, 9, len(Tables))
} }
func TestLoadID(t *testing.T) { func TestLoadID(t *testing.T) {

View file

@ -9,15 +9,16 @@ import (
// DSL the table DSL // DSL the table DSL
type DSL struct { type DSL struct {
Root string `json:"-"` Root string `json:"-"`
ID string `json:"id,omitempty"` ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Action *ActionDSL `json:"action"` Action *ActionDSL `json:"action"`
Layout *LayoutDSL `json:"layout"` Layout *LayoutDSL `json:"layout"`
Fields *FieldsDSL `json:"fields"` Fields *FieldsDSL `json:"fields"`
ComputesIn field.ComputeFields `json:"-"` Config map[string]interface{} `json:"config,omitempty"`
ComputesOut field.ComputeFields `json:"-"` ComputesIn field.ComputeFields `json:"-"`
CProps field.CloudProps `json:"-"` ComputesOut field.ComputeFields `json:"-"`
CProps field.CloudProps `json:"-"`
} }
// ActionDSL the table action DSL // ActionDSL the table action DSL