Feat: add the conditions for ui schema spec (#3461)

Signed-off-by: barnettZQG <barnett.zqg@gmail.com>
This commit is contained in:
barnettZQG
2022-03-18 09:52:58 +08:00
committed by GitHub
parent 8f9908e723
commit 5209be6da9
2 changed files with 26 additions and 1 deletions
+3
View File
@@ -328,6 +328,9 @@ func patchSchema(defaultSchema, customSchema []*utils.UIParameter) []*utils.UIPa
if cusSchema.Style != nil {
dSchema.Style = cusSchema.Style
}
if cusSchema.Conditions != nil {
dSchema.Conditions = cusSchema.Conditions
}
}
}
sort.Slice(defaultSchema, func(i, j int) bool {
+23 -1
View File
@@ -34,13 +34,35 @@ type UIParameter struct {
UIType string `json:"uiType"`
Style *Style `json:"style,omitempty"`
// means disable parameter in ui
Disable *bool `json:"disable,omitempty"`
Disable *bool `json:"disable,omitempty"`
// Conditions: control whether fields are enabled or disabled by certain conditions.
// Rules:
// if all conditions are not matching, the parameter will be disabled
// if there are no conditions, and disable==false the parameter will be enabled.
// if one disable action condition is matched, the parameter will be disabled.
// if all enable actions conditions are matched, the parameter will be enabled.
// +optional
Conditions []Condition `json:"conditions,omitempty"`
SubParameterGroupOption []GroupOption `json:"subParameterGroupOption,omitempty"`
SubParameters []*UIParameter `json:"subParameters,omitempty"`
AdditionalParameter *UIParameter `json:"additionalParameter,omitempty"`
Additional *bool `json:"additional,omitempty"`
}
// Condition control whether fields are enabled or disabled by certain conditions.
type Condition struct {
// JSONKey specifies the path of the field, support the peer and subordinate fields.
JSONKey string `json:"jsonKey"`
// Op options includes `==` 、`!=` and `in`, default is `==`
// +optional
Op string `json:"op,omitempty"`
// Value specifies the prospective value.
Value interface{} `json:"value"`
// Action options includes `enable` or `disable`, default is `enable`
// +optional
Action string `json:"action,omitempty"`
}
// Style ui style
type Style struct {
// ColSpan the width of a responsive layout