Nested menus for app submission forms

Hi all,

I’m trying to design a customized VNC application based on the bc_desktop that has two features:

  1. A user selects a queue from a drop-down
  2. Based on the queue selected, the user can then select a specific node name to launch a VNC session on.

I’ve modified my form.yml as follows, but I’m wondering if there are any examples that are similar or if this is even possible. The challenge is that if we let the user pick the queue and node name it is likely that they would pick an incompatible combination.

attributes:
  desktop: xfce
  bc_vnc_idle: 0
  ...
  bc_queue:
    label: Queue
    help: Please select a queue from the drop-down.
    widget: select
    options:
      - [ "devel", "devel" ]
      - [ "production", "prod" ]
  custom_node:
    label: Node
    help: Please select a node from the drop-down.
    widget: select
    options:
      - [ "hawksbill1", "hawksbill1" ]
      - [ "hawksbill2", "hawksbill2" ]
submit: "submit/submit.yml.erb"

form:
  - bc_vnc_idle
  - desktop
  ...
  - bc_queue
  - custom_node
  ...
  - bc_email_on_started

You can add data- attributes. One allows you to hide custom_nodeentirely (data-hide-) and another allows you to hide some of custom_node’s options (data-option-for-)

https://osc.github.io/ood-documentation/latest/how-tos/app-development/interactive/dynamic-form-widgets.html#hiding-select-options

Thanks, Jeff - that’s very helpful! Just one quick clarification from my example above. If I want to do an attribute for a specific node to only be available in the “devel” queue, do I need to specify both the true and false states as I’ve done here for hawksbill1?

 custom_queue:
    label: Queue
    help: Please select a queue from the drop-down.
    widget: select
    options:
      - [ "devel", "devel" ]
      - [ "production", "prod" ]
  custom_node:
    label: Node
    help: Please select a node from the drop-down.
    widget: select
    options:
      - [ "hawksbill1", "hawksbill1", data-option-for-custom-queue-devel: true, data-option-for-custom-queue-prod: false ]
      - [ "hawksbill2", "hawksbill2", data-option-for-custom-queue-prod: true ]
submit: "submit/submit.yml.erb"

Setting data-option-for- to true doesn’t do anything, so no. By default, everything is an option for everything else (true) so there’s no need to set it.

Hi @jeff.ohrstrom - apologies for the late reply. I did implement this but I’m not seeing the switching behavior, as I might expect. Is there any log I can check to see what is happening behind the scenes? The updated form.yml looks as follows:

 desktop: xfce
  bc_vnc_idle: 0
  bc_vnc_resolution:
  required: true
  node_type: null
  custom_queue:
    label: Queue
    help: Please select a queue from the drop-down.
    widget: select
    options:
      - [ 'dev', 'development' ]
      - [ 'prod', 'production' ]
  custom_node:
    label: Node
    help: Please select a node from the drop-down.
    widget: select
    options:
      - [ 'flubber3', 'flubber3', data-option-for-custom-queue-prod: false]
      - [ 'quorra1', 'quorra1', data-option-for-custom-queue-dev: false ]

submit: "submit/submit.yml.erb"

I realized my error here! I was using the display name rather than the actual queue name. The correct syntax should be as follows.

 custom_queue:
    label: Queue
    help: Please select a queue from the drop-down.
    widget: select
    options:
      - [ 'dev', 'development' ]
      - [ 'prod', 'production' ]
  custom_node:
    label: Node
    help: Please select a node from the drop-down.
    widget: select
    options:
      - [ 'flubber3', 'flubber3', data-option-for-custom-queue-development: false]
      - [ 'quorra1', 'quorra1', data-option-for-custom-queue-production: false ]

I was able to add a submit.yml.erb as follows and now my app works as expected!

Example of my submit.yml.erb to use this specific setup for a bc_desktop/VNC app.

---
batch_connect:
  template: vnc
script:
  queue_name: "<%= custom_queue %>"
  native:
    <%- unless custom_node.blank? -%>
      - "-w <%= custom_node %>"
    <%- end -%>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.