Skip to content
Martin Hradil edited this page Jul 11, 2019 · 8 revisions

This page is meant to describe various details of the service dialog data formats, implementation, etc. The UI part is currently implemented as 2 components - dialog editor and dialog user.


(TODO describe formats)


value vs default_value

(from https://github.com/ManageIQ/ui-components/pull/392#discussion_r296871830)

On the automate side, you want to set the 'value' key like you're doing above: $evm.object['value'] = something

However, on the ui-components side, for most of the field types, default_value is the value that is getting passed back from the refresh API call that we should be looking at to determine what to show to the user after a refresh happens. We changed it in 7dcb1f7. For sorted items, values is the key we use since it needs to be a list, and default_value is simply the one that is selected from that list.

On the ui-components side, because of the way datetime controls work, there's special logic for the date and time parts because the default_value comes in as a string (cause it's just a JSON response), and then it gets parsed and separated into a dateField and a timeField since the controls are separate.

Also.. default_value always comes as a string from the API. Even when the automate method just does .default_value = 5.


howto - run dynamic dialog during service order

define an automate method

go to Automation > Automate > Explorer

add a new method anywhere, type inline

dialog_hash = {'A' => 'A', 'B' => 'B' ,'C' => 'C'}
$evm.root['values'] = dialog_hash
$evm.root['default_value'] = dialog_hash.keys
exit MIQ_OK

add a new instance in the same place,
value = name of the new method

add a new dialog

go to Automation > Automate > Customization,
accordion Service Dialogs

toolbar Configuration > Add a New Dialog

add a dropdown, edit details
tab Field Information
enable Dynamic
tab Options
set entry point to the newly created instance
enable Show Refresh Button
enable Load values on init
enable Multiselect

add a catalog item

go to Service > Catalogs > Catalog Items

add a new catalog item,
select the newly created Dialog,
enable Display in Catalog,
select a Catalog

order the catalog item

go to Service > Catalogs > Service Catalogs

order the new catalog item


dialog-user tidbits

  • setDefaultValue should be the only place to manipulate default_value
  • dialogField should not transform data, just push default_value as is (validations from dialog-user and from dialog-field need to work with the same values)
  • dateField & timeField should be local only (ideally hidden in a component), any validation needs to work with the default_value generated by dateTimeFieldChanged

validation

Validation is implemented entirely in dialogData#validateField,
exposed on DialogField controller as .validation.{isValid,message},
exposed to DialogUser onUpdate(data) (setDialogData) as data.validations.{isValid,messages[]}, called from DialogField on change, from changesHappened, before updating DialogUser data, and from DialogUser from validateFields when saving.

field data lifetime...

load & user change:

(...magic)
<dialogField field="data">
$onInit calls DialogData.setupField,
on changes does DialogUser.updateDialogField
(magic...)

dynamic update TODO