DAML UI Template got support for creation of dialogs for multi-parameter choices. One just needs to use the Contracts
component and its dialogs
parameter.
For example, given a template Asset
with parameters name
(text), owner
(party), value
(number) and dateOfIssuance
(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 dialogs
part 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 field
function. 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: