Hi Folks,
In my schema I have two arrays, “things” and “profiles”
Each profile has a name and a kind (enum of “Type1” or “Type2”)
Each thing has a “profile” property which is the name value of one of the profiles (an enum generated from the profile list), and two other properties (“key1” and “key2”)
I want add a rule to key2 so that it is hidden when the profile selected by its profile property has a kind of “Type2”.
I can see from the examples how I can add a rule based on the profile name, but in this case I need a level of indirection into the profile data values, and I can;t find any pointers on how to express that within the rule schema.
Here is my schema, uischema, and some initial data
The uischema has a rule for “key2” based on the name of the profile, what I need to do is replace that with something that uses the value of the “kind” property of the selected profile. (so something like Hide if profiles[#profile].kind == “Type2”
schema
{
"type": "object",
"properties": {
"things": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"dead": {
"type": "boolean"
},
"profile": {
"type": "string",
"enum": ["Profile#1", "Profile#2", "Profile#3"]
},
"key1": {
"type": "string"
},
"key2": {
"type": "string"
}
}
}
},
"profiles": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"kind": {
"type": "string",
"enum": ["Type1", "Type2"]
}
}
}
}
}
}
uischema
"type": "VerticalLayout",
"elements": [
{
"type": "Control",
"scope": "#/properties/things",
"options": {
"detail": {
"type": "HorizontalLayout",
"elements": [
{
"type": "Control",
"scope": "#/properties/name"
},
{
"type": "Control",
"scope": "#/properties/profile"
},
{
"type": "Control",
"scope": "#/properties/key1"
},
{
"type": "Control",
"scope": "#/properties/key2",
"rule": {
"effect": "HIDE",
"condition": {
"scope": "#/properties/profile",
"schema": {
"const": "Profile#2"
}
}
}
}
]
}
}
},
{
"type": "Control",
"scope": "#/properties/profiles"
}
]
}
initialData
const initialData = {
things: [
{name: "Thing1", dead: true, profile: "Profile#1", key1: "xxxx", key2: "yyyy"},
{name: "Thing2", dead: false, profile: "Profile#2", key1: "xxxx", key2: "yyyy"}
],
profiles: [
{name: "Profile#1", kind: "Type1"},
{name: "Profile#2", kind: "Type2"},
{name: "Profile#3", kind: "Type1"},
]
};