RXNT / react-jsonschema-form-conditionals

react-jsonschema-form-conditionals

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

paging merge

zboldyga opened this issue · comments

Sandeep expressed a need for us to be able to show/hide tabs based on conditions. In order to accomplish this we might want your conditional module to have the ability to act on the ui:tabID property I've added in the pagination project (e.g. have a condition effect all fields with a specific ui:tabID value.

I see currently that your rules are defined on a per-field basis. Maybe we can add a mechanism for defining a rule for a ui:tabID?

We're also going to run into a similar situation with having to show/hide groups of fields - in the healthcare context it seems that it's usually going to be whole sections of a form that show/hide based on the input of some field. In this situation we'll have a similar issue - we can explicitly define a rule for every component in the group, but it might make more sense to have a concise handle that acts on a whole group of components.

I think the groups will just be Widgets, as defined in the Mozilla project. So we may want conditional rules to apply to Widgets as well... We may want to defer thinking about the Widgets until we get a little further though.

What do you think?

I've opened an #15, to support group of fields in actions.

I was thinking that group of fields will be something like field of type address that will be displayed as city, state, zip, e t.c.,

That way by defining action on per-field basis you can support group of fields as well, but this is if they are combined in a field of some type.

After fixing #15 & #8 , we can safely close this issue, since now an action does not have to be per-field basis and can have any side effect, we need.

For example we can define actions: "closeTab", and write it down like this:

{
   closeTab: ({ tab }, schema, uiSchema) => {
      Object.keys(uiSchema).map((key) => {
          if (uiSchema[key]["ui:TabId"] === tab) {
               delete schema.properties[key];
          }
   }
}

which can be triggered like this:

let rules = [{
   conditions: { firstName: "empty" },
   events: { type: "closeTab",  params: { tab: 1 }}
}]