1

I'm using Rappid to diagram relationship between objects. I need to customize the inspector. I want to use select2 plugin to replace select-box when the values are too many. To do that i used an example that appear in the documentation that use renderFieldContent to render the special fields I define in the inspector.js my function and the object appear correctly, but in addition i need that another field appear when i had selected any value in mi select2, to do that I define the following "when"

when: {
       and: [
             { ne: { 'attrs/attributes/to_eval': '' } },
             { ne: { 'attrs/attributes/to_eval': null } },
            ]
      },

The problem is the following: When I change the selected option for the select2 the conditions is not validated.

How can i run the validation? I need to declare an event for select2, trigger an inspector event or i need to run the validation manually?

Matias Medina
  • 133
  • 1
  • 8

1 Answers1

1

I know this is an old question, but for those that may also be confused, I had to solve a similar problem with a field that needed to show up/hide when a toggle field was changed. This is what I did:

  • added only one ne expression to the field that was supposed to show up/hide (textOnToggle);
  • the ne expression path needed to point to the triggering field (toggleText);
  • set a defaultValue on the triggering field.

Therefore, it is as simple as this:

textOnToggle: {
  type: 'content-editable',
  label: 'Text',
  index: 1,
  when: { ne: {'attrs/mypath/toggleText': true} },
},
toggleText: {
  defaultValue: false,
  type: 'toggle',
  label: 'Hide the text',
  index: 2,
},

So clicking the toggleText field in the inspector would, in this case, hide the textOnTogle field. You can change the boolean values to have the opposite action.

JointJS expressions definition table is a good reference to know which conditions can be added.

CPHPython
  • 12,379
  • 5
  • 59
  • 71