Daml-ui-template: multiple parameter choices, dialog generation
- gaborhOP 8
DAML UI Template got support for creation of dialogs for multi-parameter choices. One just needs to use the
Contractscomponent and itsdialogsparameter.For example, given a template
Assetwith parametersname(text),owner(party),value(number) anddateOfIssuance(date), one can just write the following:<Contracts contracts={queryResult.contracts} columns={[ { name: "ContractId", path: "contractId" }, { name: "Owner", path: "payload.roleOwner" }, ]} actions={[]} dialogs={ [{ name: "Create new asset", dialogFields: [ field("Name", text), field("Value", number), field("Owner", menu(["Alice", "Bob"])), field("Date of issuance", date) ], action: doCreate }]} />The
dialogspart is a list of dialog specifications. Each specification consists of:- A name which is displayed as a dialog header and is the label of the corresponding action button in the contract list
- Fields, a list of field specification
- An action, a function with two parameters: the contract for the contract list’s corresponding row and the actual values from the dialog
Field specifications can be created using the
fieldfunction. Field type has to be given, either text, number, date or menu with a list of choices.The action can be used to exercise the appropriate choice and validate/transform user input if needed.
See the following full examples:
- ManishGrover 1
This is great and much needed. thank you!