Merge pull request #765 from trheyi/main
Add default value for Upload API if not provided in props
This commit is contained in:
commit
2a070f6bc6
2 changed files with 17 additions and 0 deletions
|
|
@ -28,6 +28,11 @@ func (dsl DSL) Map() map[string]interface{} {
|
|||
"props": map[string]interface{}(dsl.Props),
|
||||
}
|
||||
|
||||
// Add Default Value for Upload api
|
||||
if dsl.Type == "Upload" && dsl.Props != nil && !dsl.Props.Has("api") {
|
||||
res["props"].(map[string]interface{})["$api"] = map[string]interface{}{"process": "fs.data.Upload"}
|
||||
}
|
||||
|
||||
if dsl.HideLabel {
|
||||
res["hideLabel"] = true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,6 +179,18 @@ func (p PropsDSL) parseCloudProps(xpath string, component string, props map[stri
|
|||
return res, nil
|
||||
}
|
||||
|
||||
// Has check if the prop exists in the props
|
||||
func (p PropsDSL) Has(name string) bool {
|
||||
_, has := p[name]
|
||||
if has {
|
||||
return has
|
||||
}
|
||||
|
||||
// check if the prop is a cloud prop
|
||||
_, has = p[fmt.Sprintf("$%s", name)]
|
||||
return has
|
||||
}
|
||||
|
||||
// Parse parse cloud props
|
||||
func (cProp *CloudPropsDSL) Parse(v interface{}) error {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue