17.6. Elements

You can list one or more elements from a medini analyze project and prompt the user to select one or more of them.

17.6.1. Element Input

promptElement()

Input to this service is an element type, such as SafetyRequirement or SafetyGoal. All elements of this type found in the selected project are listed in a tree structure and the user can select one.

In the following example, the output is the name of the element the user selects.

Example 17.6: Example

{ m:'Select an element:'.promptElement(safetygoals::SafetyRequirement).name }


17.6.2. Selecting Multiple Elements

promptElements()

The promptElements() service is similar to the promptElement() service but is customizable. You can:

  • use root to assign one or more structure roots, such as a requirements package, from which to display the elements. This is a variable you assign in medini analyze.

  • use preselect to select one or more elements to be pre-selected. This is a variable you assign in medini analyze.

  • configure whether the user can select one or more options

  • configure whether the elements are displayed flat (root-level only) or structured (in the tree below the selected root), by setting flat to true or false, respectively.

In the following example, the input is a collection of (two) metaclasses. In medini analyze, the root and pre-selected elements are specified. With true, the user can make multiple selections instead of just one (false). A flat list is selected, so only the root-level packages are available for the user to select. The output is a comma-separated list of names of the packages that are selected by the user at the prompt.

Example 17.7: Example

{ m:'Select one or more elements:'.promptElements(OrderedSet{safetygoals::SafetyRequirement, safetygoals::SafetyGoal}, root, preselect, true, flat = 'true').name->sep(', ') }