Service Dialogs: Conditional Visibility


#1

-Is there a way to make items in a service dialog visible conditionally?
Example: if i have a drop down with “Yes” and “No” as choices. To have a text box be visible only when the dropdown selection is “Yes”


#2

Indeed, you can. You have to make the text field dynamic and activate auto
refresh. Then in the method you call for this field, you can set the dialog
item (in)visible with :

$evm.object[‘visible’] = true|false

To make it conditional, you can test the value of your checkbox :

if $evm.root[‘dialog_option_my_checkbox’] == ‘t’
$evm.object[‘visible’] = true
else
$evm.object[‘visible’] = false
end

The checkbox also has to be configured to refresh other fields.

However, you will experience overhead when loading the dialog, as the field
will trigger the method. And if you build a complex dialog with many
dynamically visible fields, the overhead will grow.


#3

Awesome!!

Thanks for your help and your reply. If we can get this working it will be a really big win.
It’s the end of the day here, but I plan on testing this tomorrow.

Thanks again.


#4

Tell me how it goes for you once you’ve run your tests.


#5

I work with midacts, tried out using one dialog element’s output to make another dialog element visible. But not able to get it working.

Started with creating dialog element one with type dynamic dropdown and possible values Yes/No. Then created dialog element two with test field dynamic and checked auto refresh. Declared method as following

$evm.object[‘visible’] = true|false

if $evm.root[‘dialog_element1’] == ‘Yes’
$evm.object[‘visible’] = true
else
$evm.object[‘visible’] = false
end


#6

Element one does not have to be dynamic, only to be configured to refresh other fields, as shown one the following picture:

Then element two is a dynamic text field configured to be auto refreshed, as show on the following picture:

The method called by element two is the following:

if $evm.root['dialog_element1'] == 'Yes'
  $evm.object['visible'] = true
else
  $evm.object['false'] = false
end

In your method the line $evm.object['visible'] = true|false is useless. It was just to show you the syntax, e.g. that $evm.object['visible'] is a boolean.

The method can also be reduced to:

$evm.object['visible'] = $evm.root['dialog_element1'] == 'Yes'

When the value of element one is Yes, it looks like this:

And when the value is No it looks like this:


#7

Great explaination.
tkopuru had been telling me that we did not have the visibility checkbox on our dropdown options. It looks like we will have to upgrade from version 4.1 to version 4.2?

We will give that a shot and go from there.
THanks for your help on this! (This is an important feature that we are really looking forward to being able to use).


#8

Yes, visibility is a new feature of CloudForms 4.2, so upgrade is the way to go.


#9

Excellent.
We will perform the upgrade and go from there.

Is it easy to do an in place upgrade? or should we stand up a new environment?


#10

The upgrade is pretty straight forward: https://access.
redhat.com/documentation/en/red-hat-cloudforms/4.2/paged/
migrating-to-red-hat-cloudforms-42.

Be careful to logout, then login again, after the yum update. It
reloads the Ruby environment.

If you have more than one appliance, be sure you follow the upgrade order.

If you have overriden code from ManageIQ or RedHat domains, do a code
review as the upgrade resets these domains to the latest version, thus
potentially modifying the behaviour.


#11

Thanks a lot for detailed explanation and confirmation on Upgrade for visibility feature.

Upgraded our Clouforms servers to 4.2 and able to get element visibility work on condition based in web console.

But it doesn’t work as expected in self-service portal. One of our WebUI appliance server seems to be dead recently. Can this be a reason?

Thanks again.


#12

I have seen the same behavior on my instance. I don’t use SSUI, so I never tested it. I have opened an issue: https://github.com/ManageIQ/manageiq-ui-service/issues/497.


#13

Thanks for doing that. We are still new to the who process and what to expect.
We are getting closer now though ; )