aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-05-09 18:02:19 -0300
committerSebastian <sebasjm@gmail.com>2024-05-09 18:02:19 -0300
commit2375c1c1c8095b4d38dd2afa878705ad3bb216e1 (patch)
tree0580af464796aee06b90b76b864af3aa5e293c33
parent5ec065a90be3a0bd4a85ca4fdb949fb5f643db96 (diff)
downloadwallet-core-2375c1c1c8095b4d38dd2afa878705ad3bb216e1.tar.xz
documentation updated: change some types
-rw-r--r--packages/aml-backoffice-ui/src/forms.json903
-rw-r--r--packages/aml-backoffice-ui/src/forms/simplest.ts60
-rw-r--r--packages/aml-backoffice-ui/src/hooks/form.ts28
-rw-r--r--packages/aml-backoffice-ui/src/pages/CaseUpdate.tsx1
-rw-r--r--packages/aml-backoffice-ui/src/pages/ShowConsolidated.tsx75
-rw-r--r--packages/web-util/src/forms/forms.ts78
-rw-r--r--packages/web-util/src/forms/ui-form.ts376
7 files changed, 706 insertions, 815 deletions
diff --git a/packages/aml-backoffice-ui/src/forms.json b/packages/aml-backoffice-ui/src/forms.json
index ed556307b..ef8001f91 100644
--- a/packages/aml-backoffice-ui/src/forms.json
+++ b/packages/aml-backoffice-ui/src/forms.json
@@ -13,222 +13,199 @@
"fields": [
{
"type": "choiceStacked",
- "properties": {
- "name": "customerType",
- "id": ".customerType",
- "label": "Type of customer",
- "help": "Select one and complete the next form",
- "required": true,
- "choices": [
- {
- "label": "Natural person",
- "value": "natural"
- },
- {
- "label": "Legal entity",
- "value": "legal"
- }
- ]
- }
+
+ "name": "customerType",
+ "id": ".customerType",
+ "label": "Type of customer",
+ "help": "Select one and complete the next form",
+ "required": true,
+ "choices": [
+ {
+ "label": "Natural person",
+ "value": "natural"
+ },
+ {
+ "label": "Legal entity",
+ "value": "legal"
+ }
+ ]
},
{
"type": "group",
- "properties": {
- "label": "Natural customer form",
- "name": "algo",
- "id": "algo",
- "before": "a) Country risk (nationality)",
- "after": "a) Country risk (nationality)",
- "fields": [
- {
- "type": "text",
- "properties": {
- "name": "naturalCustomer.fullName",
- "id": ".naturalCustomer.fullName",
- "label": "Full name",
- "required": true
- }
- },
- {
- "type": "text",
- "properties": {
- "name": "naturalCustomer.address",
- "id": ".naturalCustomer.address",
- "label": "Residential address",
- "required": true
- }
- },
- {
- "type": "integer",
- "properties": {
- "name": "naturalCustomer.telephone",
- "id": ".naturalCustomer.telephone",
- "label": "Telephone"
- }
- },
- {
- "type": "text",
- "properties": {
- "name": "naturalCustomer.email",
- "id": ".naturalCustomer.email",
- "label": "E-mail"
- }
- },
- {
- "type": "absoluteTime",
- "properties": {
- "pattern": "dd/MM/yyyy",
- "name": "naturalCustomer.dateOfBirth",
- "id": ".naturalCustomer.dateOfBirth",
- "label": "Date of birth",
- "required": true
- }
- },
- {
- "type": "text",
- "properties": {
- "name": "naturalCustomer.nationality",
- "id": ".naturalCustomer.nationality",
- "label": "Nationality",
- "required": true
- }
- },
- {
- "type": "text",
- "properties": {
- "name": "naturalCustomer.document",
- "id": ".naturalCustomer.document",
- "label": "Identification document",
- "required": true
- }
- },
- {
- "type": "file",
- "properties": {
- "name": "naturalCustomer.documentAttachment",
- "id": ".naturalCustomer.documentAttachment",
- "label": "Document attachment",
- "required": true,
- "maxBites": 2097152,
- "accept": ".pdf",
- "help": "PDF file with max size of 2 mega bytes"
- }
- },
- {
- "type": "text",
- "properties": {
- "name": "naturalCustomer.companyName",
- "id": ".naturalCustomer.companyName",
- "label": "Company name"
- }
- },
- {
- "type": "text",
- "properties": {
- "name": "naturalCustomer.office",
- "id": ".naturalCustomer.office",
- "label": "Registered office"
- }
- },
- {
- "type": "text",
- "properties": {
- "name": "naturalCustomer.companyDocument",
- "id": ".naturalCustomer.companyDocument",
- "label": "Company identification document"
- }
- },
- {
- "type": "file",
- "properties": {
- "name": "naturalCustomer.companyDocumentAttachment",
- "id": ".naturalCustomer.companyDocumentAttachment",
- "label": "Document attachment",
- "required": true,
- "maxBites": 2097152,
- "accept": ".png",
- "help": "PNG file with max size of 2 mega bytes"
- }
- }
- ]
- }
+
+ "label": "Natural customer form",
+ "name": "algo",
+ "id": "algo",
+ "before": "a) Country risk (nationality)",
+ "after": "a) Country risk (nationality)",
+ "fields": [
+ {
+ "type": "text",
+
+ "name": "naturalCustomer.fullName",
+ "id": ".naturalCustomer.fullName",
+ "label": "Full name",
+ "required": true
+ },
+ {
+ "type": "text",
+
+ "name": "naturalCustomer.address",
+ "id": ".naturalCustomer.address",
+ "label": "Residential address",
+ "required": true
+ },
+ {
+ "type": "integer",
+
+ "name": "naturalCustomer.telephone",
+ "id": ".naturalCustomer.telephone",
+ "label": "Telephone"
+ },
+ {
+ "type": "text",
+
+ "name": "naturalCustomer.email",
+ "id": ".naturalCustomer.email",
+ "label": "E-mail"
+ },
+ {
+ "type": "absoluteTime",
+
+ "pattern": "dd/MM/yyyy",
+ "name": "naturalCustomer.dateOfBirth",
+ "id": ".naturalCustomer.dateOfBirth",
+ "label": "Date of birth",
+ "required": true
+ },
+ {
+ "type": "text",
+
+ "name": "naturalCustomer.nationality",
+ "id": ".naturalCustomer.nationality",
+ "label": "Nationality",
+ "required": true
+ },
+ {
+ "type": "text",
+
+ "name": "naturalCustomer.document",
+ "id": ".naturalCustomer.document",
+ "label": "Identification document",
+ "required": true
+ },
+ {
+ "type": "file",
+
+ "name": "naturalCustomer.documentAttachment",
+ "id": ".naturalCustomer.documentAttachment",
+ "label": "Document attachment",
+ "required": true,
+ "maxBites": 2097152,
+ "accept": ".pdf",
+ "help": "PDF file with max size of 2 mega bytes"
+ },
+ {
+ "type": "text",
+
+ "name": "naturalCustomer.companyName",
+ "id": ".naturalCustomer.companyName",
+ "label": "Company name"
+ },
+ {
+ "type": "text",
+
+ "name": "naturalCustomer.office",
+ "id": ".naturalCustomer.office",
+ "label": "Registered office"
+ },
+ {
+ "type": "text",
+
+ "name": "naturalCustomer.companyDocument",
+ "id": ".naturalCustomer.companyDocument",
+ "label": "Company identification document"
+ },
+ {
+ "type": "file",
+
+ "name": "naturalCustomer.companyDocumentAttachment",
+ "id": ".naturalCustomer.companyDocumentAttachment",
+ "label": "Document attachment",
+ "required": true,
+ "maxBites": 2097152,
+ "accept": ".png",
+ "help": "PNG file with max size of 2 mega bytes"
+ }
+ ]
},
-
-
+
{
"type": "group",
- "properties": {
- "label": "Natural customer form",
- "name": "algo",
- "id": "algo",
- "before": "a) Country risk (nationality)",
- "after": "a) Country risk (nationality)",
- "fields": [
- {
- "type": "text",
- "properties": {
- "name": "legalCustomer.companyName",
- "id": ".legalCustomer.companyName",
- "label": "Company name",
- "required": true
- }
- },
- {
- "type": "text",
- "properties": {
- "name": "legalCustomer.domicile",
- "id": ".legalCustomer.domicile",
- "label": "Domicile",
- "required": true
- }
- },
- {
- "type": "text",
- "properties": {
- "name": "legalCustomer.contactPerson",
- "id": ".legalCustomer.contactPerson",
- "label": "Contact person"
- }
- },
- {
- "type": "text",
- "properties": {
- "name": "legalCustomer.telephone",
- "id": ".legalCustomer.telephone",
- "label": "Telephone"
- }
- },
- {
- "type": "text",
- "properties": {
- "name": "legalCustomer.email",
- "id": ".legalCustomer.email",
- "label": "E-mail"
- }
- },
- {
- "type": "text",
- "properties": {
- "name": "legalCustomer.document",
- "id": ".legalCustomer.document",
- "label": "Identification document",
- "help": "Not older than 12 month"
- }
- },
- {
- "type": "file",
- "properties": {
- "name": "legalCustomer.documentAttachment",
- "id": ".legalCustomer.documentAttachment",
- "label": "Document attachment",
- "required": true,
- "maxBites": 2097152,
- "accept": ".png",
- "help": "PNG file with max size of 2 mega bytes"
- }
- }
- ]
- }
+
+ "label": "Natural customer form",
+ "name": "algo",
+ "id": "algo",
+ "before": "a) Country risk (nationality)",
+ "after": "a) Country risk (nationality)",
+ "fields": [
+ {
+ "type": "text",
+
+ "name": "legalCustomer.companyName",
+ "id": ".legalCustomer.companyName",
+ "label": "Company name",
+ "required": true
+ },
+ {
+ "type": "text",
+
+ "name": "legalCustomer.domicile",
+ "id": ".legalCustomer.domicile",
+ "label": "Domicile",
+ "required": true
+ },
+ {
+ "type": "text",
+
+ "name": "legalCustomer.contactPerson",
+ "id": ".legalCustomer.contactPerson",
+ "label": "Contact person"
+ },
+ {
+ "type": "text",
+
+ "name": "legalCustomer.telephone",
+ "id": ".legalCustomer.telephone",
+ "label": "Telephone"
+ },
+ {
+ "type": "text",
+
+ "name": "legalCustomer.email",
+ "id": ".legalCustomer.email",
+ "label": "E-mail"
+ },
+ {
+ "type": "text",
+
+ "name": "legalCustomer.document",
+ "id": ".legalCustomer.document",
+ "label": "Identification document",
+ "help": "Not older than 12 month"
+ },
+ {
+ "type": "file",
+
+ "name": "legalCustomer.documentAttachment",
+ "id": ".legalCustomer.documentAttachment",
+ "label": "Document attachment",
+ "required": true,
+ "maxBites": 2097152,
+ "accept": ".png",
+ "help": "PNG file with max size of 2 mega bytes"
+ }
+ ]
}
]
},
@@ -238,108 +215,99 @@
"fields": [
{
"type": "array",
- "properties": {
- "name": "businessEstablisher",
- "id": ".businessEstablisher",
- "label": "Persons",
- "required": true,
- "labelFieldId": "fullName",
- "placeholder": "this is the placeholder",
- "fields": [
- {
- "type": "text",
- "properties": {
- "name": "fullName",
- "id": ".fullName",
- "label": "Full name",
- "required": true
- }
- },
- {
- "type": "text",
- "properties": {
- "name": "address",
- "id": ".address",
- "label": "Residential address",
- "required": true
- }
- },
- {
- "type": "absoluteTime",
- "properties": {
- "pattern": "dd/MM/yyyy",
- "name": "dateOfBirth",
- "id": ".dateOfBirth",
- "label": "Date of birth",
- "required": true
- }
- },
-
- {
- "type": "text",
- "properties": {
- "name": "nationality",
- "id": ".nationality",
- "label": "Nationality",
- "required": true
- }
- },
- {
- "type": "text",
- "properties": {
- "name": "typeOfAuthorization",
- "id": ".typeOfAuthorization",
- "label": "Type of authorization (signatory of representation)",
- "required": true
- }
- },
- {
- "type": "file",
- "properties": {
- "name": "documentAttachment",
- "id": ".documentAttachment",
- "label": "Identification document attachment",
- "required": true,
- "maxBites": 2097152,
- "accept": ".pdf",
- "help": "PDF file with max size of 2 mega bytes"
- }
- },
- {
- "type": "choiceStacked",
- "properties": {
- "name": "powerOfAttorneyArrangements",
- "id": ".powerOfAttorneyArrangements",
- "label": "Power of attorney arrangements",
- "required": true,
- "choices": [
- {
- "label": "CR extract",
- "value": "cr"
- },
- {
- "label": "Mandate",
- "value": "mandate"
- },
- {
- "label": "Other",
- "value": "other"
- }
- ]
- }
- },
- {
- "type": "text",
- "properties": {
- "name": "powerOfAttorneyArrangementsOther",
- "id": ".powerOfAttorneyArrangementsOther",
- "label": "Power of attorney arrangements",
- "required": true
+
+ "name": "businessEstablisher",
+ "id": ".businessEstablisher",
+ "label": "Persons",
+ "required": true,
+ "labelFieldId": "fullName",
+ "placeholder": "this is the placeholder",
+ "fields": [
+ {
+ "type": "text",
+
+ "name": "fullName",
+ "id": ".fullName",
+ "label": "Full name",
+ "required": true
+ },
+ {
+ "type": "text",
+
+ "name": "address",
+ "id": ".address",
+ "label": "Residential address",
+ "required": true
+ },
+ {
+ "type": "absoluteTime",
+
+ "pattern": "dd/MM/yyyy",
+ "name": "dateOfBirth",
+ "id": ".dateOfBirth",
+ "label": "Date of birth",
+ "required": true
+ },
+
+ {
+ "type": "text",
+
+ "name": "nationality",
+ "id": ".nationality",
+ "label": "Nationality",
+ "required": true
+ },
+ {
+ "type": "text",
+
+ "name": "typeOfAuthorization",
+ "id": ".typeOfAuthorization",
+ "label": "Type of authorization (signatory of representation)",
+ "required": true
+ },
+ {
+ "type": "file",
+
+ "name": "documentAttachment",
+ "id": ".documentAttachment",
+ "label": "Identification document attachment",
+ "required": true,
+ "maxBites": 2097152,
+ "accept": ".pdf",
+ "help": "PDF file with max size of 2 mega bytes"
+ },
+ {
+ "type": "choiceStacked",
+
+ "name": "powerOfAttorneyArrangements",
+ "id": ".powerOfAttorneyArrangements",
+ "label": "Power of attorney arrangements",
+ "required": true,
+ "choices": [
+ {
+ "label": "CR extract",
+ "value": "cr"
+ },
+ {
+ "label": "Mandate",
+ "value": "mandate"
+ },
+ {
+ "label": "Other",
+ "value": "other"
}
- }
- ],
- "labelField": "fullName"
- }
+ ]
+ },
+ {
+ "type": "text",
+
+ "name": "powerOfAttorneyArrangementsOther",
+ "id": ".powerOfAttorneyArrangementsOther",
+ "label": "Power of attorney arrangements",
+ "required": true
+ }
+ ],
+ "labelField": "fullName"
}
]
},
@@ -348,103 +316,96 @@
"fields": [
{
"type": "absoluteTime",
- "properties": {
- "name": "acceptance.when",
- "id": ".acceptance.when",
- "pattern": "dd/MM/yyyy",
- "converterId": "Taler.AbsoluteTime",
- "label": "Date (conclusion of contract)"
- }
+
+ "name": "acceptance.when",
+ "id": ".acceptance.when",
+ "pattern": "dd/MM/yyyy",
+ "converterId": "Taler.AbsoluteTime",
+ "label": "Date (conclusion of contract)"
},
{
"type": "choiceStacked",
- "properties": {
- "name": "acceptance.acceptedBy",
- "id": ".acceptance.acceptedBy",
- "label": "Accepted by",
- "required": true,
- "choices": [
- {
- "label": "Face-to-face meeting with customer",
- "value": "face-to-face"
- },
- {
- "label": "Correspondence: authenticated copy of identification document obtained",
- "value": "correspondence-document"
- },
- {
- "label": "Correspondence: residential address validated",
- "value": "correspondence-address"
- }
- ]
- }
+
+ "name": "acceptance.acceptedBy",
+ "id": ".acceptance.acceptedBy",
+ "label": "Accepted by",
+ "required": true,
+ "choices": [
+ {
+ "label": "Face-to-face meeting with customer",
+ "value": "face-to-face"
+ },
+ {
+ "label": "Correspondence: authenticated copy of identification document obtained",
+ "value": "correspondence-document"
+ },
+ {
+ "label": "Correspondence: residential address validated",
+ "value": "correspondence-address"
+ }
+ ]
},
{
"type": "choiceStacked",
- "properties": {
- "name": "acceptance.typeOfCorrespondence",
- "id": ".acceptance.typeOfCorrespondence",
- "label": "Type of correspondence service",
- "choices": [
- {
- "label": "to the customer",
- "value": "customer"
- },
- {
- "label": "hold at bank",
- "value": "bank"
- },
- {
- "label": "to the member",
- "value": "member"
- },
- {
- "label": "to a third party",
- "value": "third-party"
- }
- ]
- }
+
+ "name": "acceptance.typeOfCorrespondence",
+ "id": ".acceptance.typeOfCorrespondence",
+ "label": "Type of correspondence service",
+ "choices": [
+ {
+ "label": "to the customer",
+ "value": "customer"
+ },
+ {
+ "label": "hold at bank",
+ "value": "bank"
+ },
+ {
+ "label": "to the member",
+ "value": "member"
+ },
+ {
+ "label": "to a third party",
+ "value": "third-party"
+ }
+ ]
},
{
"type": "text",
- "properties": {
- "name": "acceptance.thirdPartyFullName",
- "id": ".acceptance.thirdPartyFullName",
- "label": "Third party full name",
- "required": true
- }
+
+ "name": "acceptance.thirdPartyFullName",
+ "id": ".acceptance.thirdPartyFullName",
+ "label": "Third party full name",
+ "required": true
},
{
"type": "text",
- "properties": {
- "name": "acceptance.thirdPartyAddress",
- "id": ".acceptance.thirdPartyAddress",
- "label": "Third party address",
- "required": true
- }
+
+ "name": "acceptance.thirdPartyAddress",
+ "id": ".acceptance.thirdPartyAddress",
+ "label": "Third party address",
+ "required": true
},
{
"type": "selectMultiple",
- "properties": {
- "name": "acceptance.language",
- "id": ".acceptance.language",
- "label": "Languages",
- "choices": [
- {
- "label": "Espanol",
- "value": "es"
- }
- ],
- "unique": true
- }
+
+ "name": "acceptance.language",
+ "id": ".acceptance.language",
+ "label": "Languages",
+ "choices": [
+ {
+ "label": "Espanol",
+ "value": "es"
+ }
+ ],
+ "unique": true
},
{
"type": "textArea",
- "properties": {
- "name": "acceptance.furtherInformation",
- "id": ".acceptance.furtherInformation",
- "label": "Further information"
- }
+
+ "name": "acceptance.furtherInformation",
+ "id": ".acceptance.furtherInformation",
+ "label": "Further information"
}
]
},
@@ -454,34 +415,33 @@
"fields": [
{
"type": "choiceStacked",
- "properties": {
- "name": "establishment",
- "id": ".establishment",
- "label": "The customer is",
- "required": true,
- "choices": [
- {
- "label": "a natural person and there are no doubts that this person is the sole beneficial owner of the assets",
- "value": "natural"
- },
- {
- "label": "a foundation (or a similar construct; incl. underlying companies)",
- "value": "foundation"
- },
- {
- "label": "a trust (incl. underlying companies)",
- "value": "trust"
- },
- {
- "label": "a life insurance policy with separately managed accounts/securities accounts",
- "value": "insurance-wrapper"
- },
- {
- "label": "all other cases",
- "value": "other"
- }
- ]
- }
+
+ "name": "establishment",
+ "id": ".establishment",
+ "label": "The customer is",
+ "required": true,
+ "choices": [
+ {
+ "label": "a natural person and there are no doubts that this person is the sole beneficial owner of the assets",
+ "value": "natural"
+ },
+ {
+ "label": "a foundation (or a similar construct; incl. underlying companies)",
+ "value": "foundation"
+ },
+ {
+ "label": "a trust (incl. underlying companies)",
+ "value": "trust"
+ },
+ {
+ "label": "a life insurance policy with separately managed accounts/securities accounts",
+ "value": "insurance-wrapper"
+ },
+ {
+ "label": "all other cases",
+ "value": "other"
+ }
+ ]
}
]
},
@@ -491,12 +451,11 @@
"fields": [
{
"type": "textArea",
- "properties": {
- "name": "embargoEvaluation",
- "id": ".embargoEvaluation",
- "help": "The evaluation must be made at the beginning of the business relationship and has to be repeated in the case of permanent business relationship every time the according lists are updated.",
- "label": "Evaluation"
- }
+
+ "name": "embargoEvaluation",
+ "id": ".embargoEvaluation",
+ "help": "The evaluation must be made at the beginning of the business relationship and has to be repeated in the case of permanent business relationship every time the according lists are updated.",
+ "label": "Evaluation"
}
]
},
@@ -506,42 +465,78 @@
"fields": [
{
"type": "choiceStacked",
- "properties": {
- "name": "cashTransactions.typeOfBusiness",
- "id": ".cashTransactions.typeOfBusiness",
- "label": "Type of business relationship",
- "choices": [
- {
- "label": "Money exchange",
- "value": "money-exchange"
- },
- {
- "label": "Money and asset transfer",
- "value": "money-and-asset-transfer"
- },
- {
- "label": "Other cash transactions. Specify below",
- "value": "other"
- }
- ]
- }
+
+ "name": "cashTransactions.typeOfBusiness",
+ "id": ".cashTransactions.typeOfBusiness",
+ "label": "Type of business relationship",
+ "choices": [
+ {
+ "label": "Money exchange",
+ "value": "money-exchange"
+ },
+ {
+ "label": "Money and asset transfer",
+ "value": "money-and-asset-transfer"
+ },
+ {
+ "label": "Other cash transactions. Specify below",
+ "value": "other"
+ }
+ ]
},
{
"type": "text",
- "properties": {
- "name": "cashTransactions.otherTypeOfBusiness",
- "id": ".cashTransactions.otherTypeOfBusiness",
- "required": true,
- "label": "Specify other cash transactions:"
- }
+
+ "name": "cashTransactions.otherTypeOfBusiness",
+ "id": ".cashTransactions.otherTypeOfBusiness",
+ "required": true,
+ "label": "Specify other cash transactions:"
},
{
"type": "textArea",
- "properties": {
- "name": "cashTransactions.purpose",
- "id": ".cashTransactions.purpose",
- "label": "Purpose of the business relationship (purpose of service requested)"
- }
+ "name": "cashTransactions.purpose",
+ "id": ".cashTransactions.purpose",
+ "label": "Purpose of the business relationship (purpose of service requested)"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "label": "Example form",
+ "id": "example",
+ "version": 1,
+ "config": {
+ "type": "double-column",
+ "design": [
+ {
+ "title": "Decorative elements",
+ "description": "This is an example UI of a form with decorative elements",
+ "fields": [
+ {
+ "type": "caption",
+ "name": "cap",
+ "label": "This is a caption"
+ },
+ {
+ "type": "group",
+ "name": "group",
+ "label": "The first name and last name are in a group",
+ "fields": [
+ {
+ "type": "text",
+ "name": "firstName",
+ "id": ".person.name",
+ "label": "First name"
+ },
+ {
+ "type": "text",
+ "name": "lastName",
+ "id": ".person.lastName",
+ "label": "Last name"
+ }
+ ]
}
]
}
diff --git a/packages/aml-backoffice-ui/src/forms/simplest.ts b/packages/aml-backoffice-ui/src/forms/simplest.ts
index 37ab0913d..4cd781b74 100644
--- a/packages/aml-backoffice-ui/src/forms/simplest.ts
+++ b/packages/aml-backoffice-ui/src/forms/simplest.ts
@@ -18,7 +18,7 @@ import type {
DoubleColumnForm,
DoubleColumnFormSection,
InternationalizationAPI,
- UIHandlerId
+ UIHandlerId,
} from "@gnu-taler/web-util/browser";
export const v1 = (i18n: InternationalizationAPI): DoubleColumnForm => ({
@@ -29,11 +29,9 @@ export const v1 = (i18n: InternationalizationAPI): DoubleColumnForm => ({
fields: [
{
type: "textArea",
- properties: {
- id: ".comment" as UIHandlerId,
- name: "comment",
- label: i18n.str`Comment`,
- },
+ id: ".comment" as UIHandlerId,
+ name: "comment",
+ label: i18n.str`Comment`,
},
],
},
@@ -61,36 +59,32 @@ export function resolutionSection(
fields: [
{
type: "choiceHorizontal",
- properties: {
- id: ".state" as UIHandlerId,
- name: "state",
- label: i18n.str`New state`,
- converterId: "TalerExchangeApi.AmlState",
- choices: [
- {
- value: "frozen",
- label: i18n.str`Frozen`,
- },
- {
- value: "pending",
- label: i18n.str`Pending`,
- },
- {
- value: "normal",
- label: i18n.str`Normal`,
- },
- ],
- },
+ id: ".state" as UIHandlerId,
+ name: "state",
+ label: i18n.str`New state`,
+ converterId: "TalerExchangeApi.AmlState",
+ choices: [
+ {
+ value: "frozen",
+ label: i18n.str`Frozen`,
+ },
+ {
+ value: "pending",
+ label: i18n.str`Pending`,
+ },
+ {
+ value: "normal",
+ label: i18n.str`Normal`,
+ },
+ ],
},
{
type: "amount",
- properties: {
- id: ".threshold" as UIHandlerId,
- currency: "NETZBON",
- name: "threshold",
- converterId: "Taler.Amount",
- label: i18n.str`New threshold`,
- },
+ id: ".threshold" as UIHandlerId,
+ currency: "NETZBON",
+ name: "threshold",
+ converterId: "Taler.Amount",
+ label: i18n.str`New threshold`,
},
],
};
diff --git a/packages/aml-backoffice-ui/src/hooks/form.ts b/packages/aml-backoffice-ui/src/hooks/form.ts
index e9194d86d..70b2db571 100644
--- a/packages/aml-backoffice-ui/src/hooks/form.ts
+++ b/packages/aml-backoffice-ui/src/hooks/form.ts
@@ -22,7 +22,7 @@ import {
} from "@gnu-taler/taler-util";
import {
UIFieldHandler,
- UIFormFieldConfig,
+ UIFormElementConfig,
UIHandlerId,
} from "@gnu-taler/web-util/browser";
import { useState } from "preact/hooks";
@@ -167,21 +167,21 @@ export function setValueDeeper(object: any, names: string[], value: any): any {
}
export function getShapeFromFields(
- fields: UIFormFieldConfig[],
+ fields: UIFormElementConfig[],
): Array<UIHandlerId> {
const shape: Array<UIHandlerId> = [];
fields.forEach((field) => {
- if ("id" in field.properties) {
+ if ("id" in field) {
// FIXME: this should be a validation when loading the form
// consistency check
- if (shape.indexOf(field.properties.id) !== -1) {
- throw Error(`already present: ${field.properties.id}`);
+ if (shape.indexOf(field.id) !== -1) {
+ throw Error(`already present: ${field.id}`);
}
- shape.push(field.properties.id);
+ shape.push(field.id);
} else if (field.type === "group") {
Array.prototype.push.apply(
shape,
- getShapeFromFields(field.properties.fields),
+ getShapeFromFields(field.fields),
);
}
});
@@ -189,24 +189,24 @@ export function getShapeFromFields(
}
export function getRequiredFields(
- fields: UIFormFieldConfig[],
+ fields: UIFormElementConfig[],
): Array<UIHandlerId> {
const shape: Array<UIHandlerId> = [];
fields.forEach((field) => {
- if ("id" in field.properties) {
+ if ("id" in field) {
// FIXME: this should be a validation when loading the form
// consistency check
- if (shape.indexOf(field.properties.id) !== -1) {
- throw Error(`already present: ${field.properties.id}`);
+ if (shape.indexOf(field.id) !== -1) {
+ throw Error(`already present: ${field.id}`);
}
- if (!field.properties.required) {
+ if (!field.required) {
return;
}
- shape.push(field.properties.id);
+ shape.push(field.id);
} else if (field.type === "group") {
Array.prototype.push.apply(
shape,
- getRequiredFields(field.properties.fields),
+ getRequiredFields(field.fields),
);
}
});
diff --git a/packages/aml-backoffice-ui/src/pages/CaseUpdate.tsx b/packages/aml-backoffice-ui/src/pages/CaseUpdate.tsx
index 712a1fed9..7801625d0 100644
--- a/packages/aml-backoffice-ui/src/pages/CaseUpdate.tsx
+++ b/packages/aml-backoffice-ui/src/pages/CaseUpdate.tsx
@@ -145,7 +145,6 @@ export function CaseUpdate({
const validatedForm = state.status !== "ok" ? undefined : state.result;
- console.log(state.errors);
const submitHandler =
validatedForm === undefined
? undefined
diff --git a/packages/aml-backoffice-ui/src/pages/ShowConsolidated.tsx b/packages/aml-backoffice-ui/src/pages/ShowConsolidated.tsx
index 3c0301e9f..cdc5d0bc1 100644
--- a/packages/aml-backoffice-ui/src/pages/ShowConsolidated.tsx
+++ b/packages/aml-backoffice-ui/src/pages/ShowConsolidated.tsx
@@ -21,11 +21,10 @@ import {
} from "@gnu-taler/taler-util";
import {
DefaultForm,
- FlexibleForm,
- UIFormField,
- UIFormFieldConfig,
+ FormConfiguration,
+ UIFormElementConfig,
UIHandlerId,
- useTranslationContext,
+ useTranslationContext
} from "@gnu-taler/web-util/browser";
import { format } from "date-fns";
import { Fragment, VNode, h } from "preact";
@@ -42,7 +41,7 @@ export function ShowConsolidated({
const cons = getConsolidated(history, until);
- const form: FlexibleForm = {
+ const form: FormConfiguration = {
type: "double-column",
design: [
{
@@ -50,34 +49,30 @@ export function ShowConsolidated({
fields: [
{
type: "amount",
- properties: {
- id: ".aml.threshold" as UIHandlerId,
- currency: "NETZBON",
- label: i18n.str`Threshold`,
- name: "aml.threshold",
- },
+ id: ".aml.threshold" as UIHandlerId,
+ currency: "NETZBON",
+ label: i18n.str`Threshold`,
+ name: "aml.threshold",
},
{
type: "choiceHorizontal",
- properties: {
- label: i18n.str`State`,
- name: "aml.state",
- id: ".aml.state" as UIHandlerId,
- choices: [
- {
- label: i18n.str`Frozen`,
- value: "frozen",
- },
- {
- label: i18n.str`Pending`,
- value: "pending",
- },
- {
- label: i18n.str`Normal`,
- value: "normal",
- },
- ],
- },
+ label: i18n.str`State`,
+ name: "aml.state",
+ id: ".aml.state" as UIHandlerId,
+ choices: [
+ {
+ label: i18n.str`Frozen`,
+ value: "frozen",
+ },
+ {
+ label: i18n.str`Pending`,
+ value: "pending",
+ },
+ {
+ label: i18n.str`Normal`,
+ value: "normal",
+ },
+ ],
},
],
},
@@ -85,18 +80,16 @@ export function ShowConsolidated({
? {
title: i18n.str`KYC`,
fields: Object.entries(cons.kyc).map(([key, field]) => {
- const result: UIFormFieldConfig = {
+ const result: UIFormElementConfig = {
type: "text",
- properties: {
- label: key as TranslatedString,
- id: `kyc.${key}.value` as UIHandlerId,
- name: `kyc.${key}.value`,
- help: `${field.provider} since ${
- field.since.t_ms === "never"
- ? "never"
- : format(field.since.t_ms, "dd/MM/yyyy")
- }` as TranslatedString,
- },
+ label: key as TranslatedString,
+ id: `kyc.${key}.value` as UIHandlerId,
+ name: `kyc.${key}.value`,
+ help: `${field.provider} since ${
+ field.since.t_ms === "never"
+ ? "never"
+ : format(field.since.t_ms, "dd/MM/yyyy")
+ }` as TranslatedString,
};
return result;
}),
diff --git a/packages/web-util/src/forms/forms.ts b/packages/web-util/src/forms/forms.ts
index 4bd6b4924..f2c00083c 100644
--- a/packages/web-util/src/forms/forms.ts
+++ b/packages/web-util/src/forms/forms.ts
@@ -14,9 +14,9 @@ import { InputText } from "./InputText.js";
import { InputTextArea } from "./InputTextArea.js";
import { InputToggle } from "./InputToggle.js";
import { Addon, StringConverter, UIFieldHandler } from "./FormProvider.js";
-import { InternationalizationAPI, UIFieldBaseDescription } from "../index.browser.js";
+import { InternationalizationAPI, UIFieldElementDescription } from "../index.browser.js";
import { assertUnreachable, TranslatedString } from "@gnu-taler/taler-util";
-import {UIFormFieldBaseConfig, UIFormFieldConfig} from "./ui-form.js";
+import {UIFormFieldBaseConfig, UIFormElementConfig} from "./ui-form.js";
/**
* Constrain the type with the ui props
*/
@@ -156,7 +156,7 @@ export function RenderAllFieldsByUiConfig({
*/
export function convertUiField(
i18n_: InternationalizationAPI,
- fieldConfig: UIFormFieldConfig[],
+ fieldConfig: UIFormElementConfig[],
form: object,
getConverterById: GetConverterById,
): UIFormField[] {
@@ -166,7 +166,7 @@ export function convertUiField(
case "caption": {
const resp: UIFormField = {
type: config.type,
- properties: converBaseFieldsProps(i18n_, config.properties),
+ properties: converBaseFieldsProps(i18n_, config),
};
return resp;
}
@@ -174,8 +174,8 @@ export function convertUiField(
const resp: UIFormField = {
type: config.type,
properties: {
- ...converBaseFieldsProps(i18n_, config.properties),
- fields: convertUiField(i18n_, config.properties.fields, form, getConverterById),
+ ...converBaseFieldsProps(i18n_, config),
+ fields: convertUiField(i18n_, config.fields, form, getConverterById),
},
};
return resp;
@@ -187,10 +187,10 @@ export function convertUiField(
return {
type: "array",
properties: {
- ...converBaseFieldsProps(i18n_, config.properties),
- ...converInputFieldsProps(form, config.properties, getConverterById),
- labelField: config.properties.labelFieldId,
- fields: convertUiField(i18n_, config.properties.fields, form, getConverterById),
+ ...converBaseFieldsProps(i18n_, config),
+ ...converInputFieldsProps(form, config, getConverterById),
+ labelField: config.labelFieldId,
+ fields: convertUiField(i18n_, config.fields, form, getConverterById),
},
} as UIFormField;
}
@@ -198,8 +198,8 @@ export function convertUiField(
return {
type: "absoluteTime",
properties: {
- ...converBaseFieldsProps(i18n_, config.properties),
- ...converInputFieldsProps(form, config.properties, getConverterById),
+ ...converBaseFieldsProps(i18n_, config),
+ ...converInputFieldsProps(form, config, getConverterById),
},
} as UIFormField;
}
@@ -207,8 +207,8 @@ export function convertUiField(
return {
type: "amount",
properties: {
- ...converBaseFieldsProps(i18n_, config.properties),
- ...converInputFieldsProps(form, config.properties, getConverterById),
+ ...converBaseFieldsProps(i18n_, config),
+ ...converInputFieldsProps(form, config, getConverterById),
},
} as UIFormField;
}
@@ -216,9 +216,9 @@ export function convertUiField(
return {
type: "choiceHorizontal",
properties: {
- ...converBaseFieldsProps(i18n_, config.properties),
- ...converInputFieldsProps(form, config.properties, getConverterById),
- choices: config.properties.choices,
+ ...converBaseFieldsProps(i18n_, config),
+ ...converInputFieldsProps(form, config, getConverterById),
+ choices: config.choices,
},
} as UIFormField;
}
@@ -226,9 +226,9 @@ export function convertUiField(
return {
type: "choiceStacked",
properties: {
- ...converBaseFieldsProps(i18n_, config.properties),
- ...converInputFieldsProps(form, config.properties, getConverterById),
- choices: config.properties.choices,
+ ...converBaseFieldsProps(i18n_, config),
+ ...converInputFieldsProps(form, config, getConverterById),
+ choices: config.choices,
},
}as UIFormField;
@@ -237,10 +237,10 @@ export function convertUiField(
return {
type: "file",
properties: {
- ...converBaseFieldsProps(i18n_, config.properties),
- ...converInputFieldsProps(form, config.properties, getConverterById),
- accept: config.properties.accept,
- maxBites: config.properties.maxBytes,
+ ...converBaseFieldsProps(i18n_, config),
+ ...converInputFieldsProps(form, config, getConverterById),
+ accept: config.accept,
+ maxBites: config.maxBytes,
},
} as UIFormField;
}
@@ -248,8 +248,8 @@ export function convertUiField(
return {
type: "integer",
properties: {
- ...converBaseFieldsProps(i18n_, config.properties),
- ...converInputFieldsProps(form, config.properties, getConverterById),
+ ...converBaseFieldsProps(i18n_, config),
+ ...converInputFieldsProps(form, config, getConverterById),
},
} as UIFormField;
}
@@ -257,9 +257,9 @@ export function convertUiField(
return {
type: "selectMultiple",
properties: {
- ...converBaseFieldsProps(i18n_, config.properties),
- ...converInputFieldsProps(form, config.properties, getConverterById),
- choices: config.properties.choices,
+ ...converBaseFieldsProps(i18n_, config),
+ ...converInputFieldsProps(form, config, getConverterById),
+ choices: config.choices,
},
} as UIFormField;
}
@@ -267,9 +267,9 @@ export function convertUiField(
return {
type: "selectOne",
properties: {
- ...converBaseFieldsProps(i18n_, config.properties),
- ...converInputFieldsProps(form, config.properties, getConverterById),
- choices: config.properties.choices,
+ ...converBaseFieldsProps(i18n_, config),
+ ...converInputFieldsProps(form, config, getConverterById),
+ choices: config.choices,
},
} as UIFormField;
}
@@ -277,8 +277,8 @@ export function convertUiField(
return {
type: "text",
properties: {
- ...converBaseFieldsProps(i18n_, config.properties),
- ...converInputFieldsProps(form, config.properties, getConverterById),
+ ...converBaseFieldsProps(i18n_, config),
+ ...converInputFieldsProps(form, config, getConverterById),
},
} as UIFormField;
}
@@ -286,8 +286,8 @@ export function convertUiField(
return {
type: "text",
properties: {
- ...converBaseFieldsProps(i18n_, config.properties),
- ...converInputFieldsProps(form, config.properties, getConverterById),
+ ...converBaseFieldsProps(i18n_, config),
+ ...converInputFieldsProps(form, config, getConverterById),
},
} as UIFormField;
}
@@ -295,8 +295,8 @@ export function convertUiField(
return {
type: "toggle",
properties: {
- ...converBaseFieldsProps(i18n_, config.properties),
- ...converInputFieldsProps(form, config.properties, getConverterById),
+ ...converBaseFieldsProps(i18n_, config),
+ ...converInputFieldsProps(form, config, getConverterById),
},
} as UIFormField;
}
@@ -340,7 +340,7 @@ function converInputFieldsProps(
function converBaseFieldsProps(
i18n_: InternationalizationAPI,
- p: UIFieldBaseDescription,
+ p: UIFieldElementDescription,
) {
return {
after: getAddonById(p.addonAfterId),
diff --git a/packages/web-util/src/forms/ui-form.ts b/packages/web-util/src/forms/ui-form.ts
index ef9ad96e1..d683b15de 100644
--- a/packages/web-util/src/forms/ui-form.ts
+++ b/packages/web-util/src/forms/ui-form.ts
@@ -14,18 +14,18 @@ import {
TalerProtocolTimestamp,
} from "@gnu-taler/taler-util";
-export type FlexibleForm = DoubleColumnForm;
+export type FormConfiguration = DoubleColumnForm;
-export interface DoubleColumnForm {
+export type DoubleColumnForm = {
type: "double-column";
- design: Array<DoubleColumnFormSection>;
+ design: DoubleColumnFormSection[];
// behavior?: (form: Partial<T>) => FormState<T>;
-}
+};
export type DoubleColumnFormSection = {
title: string;
description?: string;
- fields: UIFormFieldConfig[];
+ fields: UIFormElementConfig[];
};
// export interface BaseForm {
@@ -33,92 +33,74 @@ export type DoubleColumnFormSection = {
// threshold: AmountJson;
// }
-export type UIFormFieldConfig =
- | UIFormFieldConfigAbsoluteTime
- | UIFormFieldConfigAmount
- | UIFormFieldConfigArray
- | UIFormFieldConfigCaption
- | UIFormFieldConfigChoiseHorizontal
- | UIFormFieldConfigChoiseStacked
- | UIFormFieldConfigFile
- | UIFormFieldConfigGroup
- | UIFormFieldConfigInteger
- | UIFormFieldConfigSelectMultiple
- | UIFormFieldConfigSelectOne
- | UIFormFieldConfigText
- | UIFormFieldConfigTextArea
- | UIFormFieldConfigToggle;
-
-type UIFormFieldConfigAbsoluteTime = {
+export type UIFormElementConfig =
+ | UIFormElementGroup
+ | UIFormElementCaption
+ | UIFormFieldAbsoluteTime
+ | UIFormFieldAmount
+ | UIFormFieldArray
+ | UIFormFieldChoiseHorizontal
+ | UIFormFieldChoiseStacked
+ | UIFormFieldFile
+ | UIFormFieldInteger
+ | UIFormFieldSelectMultiple
+ | UIFormFieldSelectOne
+ | UIFormFieldText
+ | UIFormFieldTextArea
+ | UIFormFieldToggle;
+
+type UIFormFieldAbsoluteTime = {
type: "absoluteTime";
- properties: UIFormFieldBaseConfig & {
- max?: TalerProtocolTimestamp;
- min?: TalerProtocolTimestamp;
- pattern: string;
- };
-};
+ max?: TalerProtocolTimestamp;
+ min?: TalerProtocolTimestamp;
+ pattern: string;
+} & UIFormFieldBaseConfig;
-type UIFormFieldConfigAmount = {
+type UIFormFieldAmount = {
type: "amount";
- properties: UIFormFieldBaseConfig & {
- max?: Integer;
- min?: Integer;
- currency: string;
- };
-};
+ max?: Integer;
+ min?: Integer;
+ currency: string;
+} & UIFormFieldBaseConfig;
-type UIFormFieldConfigArray = {
+type UIFormFieldArray = {
type: "array";
- properties: UIFormFieldBaseConfig & {
- // id of the field shown when the array is collapsed
- labelFieldId: UIHandlerId;
- fields: UIFormFieldConfig[];
- };
-};
+ // id of the field shown when the array is collapsed
+ labelFieldId: UIHandlerId;
+ fields: UIFormElementConfig[];
+} & UIFormFieldBaseConfig;
-type UIFormFieldConfigCaption = {
- type: "caption";
- properties: UIFieldBaseDescription;
-};
+type UIFormElementCaption = { type: "caption" } & UIFieldElementDescription;
-type UIFormFieldConfigGroup = {
+type UIFormElementGroup = {
type: "group";
- properties: UIFieldBaseDescription & {
- fields: UIFormFieldConfig[];
- };
-};
+ fields: UIFormElementConfig[];
+} & UIFieldElementDescription;
-type UIFormFieldConfigChoiseHorizontal = {
+type UIFormFieldChoiseHorizontal = {
type: "choiceHorizontal";
- properties: UIFormFieldBaseConfig & {
- choices: Array<SelectUiChoice>;
- };
-};
+ choices: Array<SelectUiChoice>;
+} & UIFormFieldBaseConfig;
-type UIFormFieldConfigChoiseStacked = {
+type UIFormFieldChoiseStacked = {
type: "choiceStacked";
- properties: UIFormFieldBaseConfig & {
- choices: Array<SelectUiChoice>;
- };
-};
+ choices: Array<SelectUiChoice>;
+} & UIFormFieldBaseConfig;
-type UIFormFieldConfigFile = {
+type UIFormFieldFile = {
type: "file";
- properties: UIFormFieldBaseConfig & {
- maxBytes?: Integer;
- minBytes?: Integer;
- // comma-separated list of one or more file types
- // https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept#unique_file_type_specifiers
- accept?: string;
- };
-};
-type UIFormFieldConfigInteger = {
+ maxBytes?: Integer;
+ minBytes?: Integer;
+ // comma-separated list of one or more file types
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept#unique_file_type_specifiers
+ accept?: string;
+} & UIFormFieldBaseConfig;
+
+type UIFormFieldInteger = {
type: "integer";
- properties: UIFormFieldBaseConfig & {
- max?: Integer;
- min?: Integer;
- };
-};
+ max?: Integer;
+ min?: Integer;
+} & UIFormFieldBaseConfig;
interface SelectUiChoice {
label: string;
@@ -126,41 +108,30 @@ interface SelectUiChoice {
value: string;
}
-type UIFormFieldConfigSelectMultiple = {
+type UIFormFieldSelectMultiple = {
type: "selectMultiple";
- properties: UIFormFieldBaseConfig & {
- max?: Integer;
- min?: Integer;
- unique?: boolean;
- choices: Array<SelectUiChoice>;
- };
-};
-type UIFormFieldConfigSelectOne = {
+ max?: Integer;
+ min?: Integer;
+ unique?: boolean;
+ choices: Array<SelectUiChoice>;
+} & UIFormFieldBaseConfig;
+
+type UIFormFieldSelectOne = {
type: "selectOne";
- properties: UIFormFieldBaseConfig & {
- choices: Array<SelectUiChoice>;
- };
-};
-type UIFormFieldConfigText = {
- type: "text";
- properties: UIFormFieldBaseConfig;
-};
-type UIFormFieldConfigTextArea = {
- type: "textArea";
- properties: UIFormFieldBaseConfig;
-};
-type UIFormFieldConfigToggle = {
- type: "toggle";
- properties: UIFormFieldBaseConfig;
-};
+ choices: Array<SelectUiChoice>;
+} & UIFormFieldBaseConfig;
+type UIFormFieldText = { type: "text" } & UIFormFieldBaseConfig;
+type UIFormFieldTextArea = { type: "textArea" } & UIFormFieldBaseConfig;
+type UIFormFieldToggle = { type: "toggle" } & UIFormFieldBaseConfig;
-export type UIFieldBaseDescription = {
+export type UIFieldElementDescription = {
/* label if the field, visible for the user */
label: string;
+
/* long text to be shown on user demand */
tooltip?: string;
- /* short text to be shown close to the field */
+ /* short text to be shown close to the field, usually below and dimmer*/
help?: string;
/* name of the field, useful for a11y */
@@ -168,13 +139,15 @@ export type UIFieldBaseDescription = {
/* if the field should be initially hidden */
hidden?: boolean;
+
/* ui element to show before */
addonBeforeId?: string;
+
/* ui element to show after */
addonAfterId?: string;
};
-export type UIFormFieldBaseConfig = UIFieldBaseDescription & {
+export type UIFormFieldBaseConfig = UIFieldElementDescription & {
/* example to be shown inside the field */
placeholder?: string;
@@ -200,7 +173,7 @@ export type UIHandlerId = string & { [__handlerId]: true };
const codecForUiFieldId = codecForString as () => Codec<UIHandlerId>;
const codecForUIFormFieldBaseDescriptionTemplate = <
- T extends UIFieldBaseDescription,
+ T extends UIFieldElementDescription,
>() =>
buildCodecForObject<T>()
.property("addonAfterId", codecOptional(codecForString()))
@@ -221,62 +194,35 @@ const codecForUIFormFieldBaseConfigTemplate = <
.property("required", codecOptional(codecForBoolean()))
.property("placeholder", codecOptional(codecForString()));
-const codecForUIFormFieldBaseConfig = (): Codec<UIFormFieldBaseConfig> =>
- codecForUIFormFieldBaseConfigTemplate().build("UIFieldToggleProperties");
-
-const codecForUIFormFieldAbsoluteTimeConfig = (): Codec<
- UIFormFieldConfigAbsoluteTime["properties"]
-> =>
- codecForUIFormFieldBaseConfigTemplate<
- UIFormFieldConfigAbsoluteTime["properties"]
- >()
+const codecForUiFormFieldAbsoluteTime = (): Codec<UIFormFieldAbsoluteTime> =>
+ codecForUIFormFieldBaseConfigTemplate<UIFormFieldAbsoluteTime>()
+ .property("type", codecForConstString("absoluteTime"))
.property("pattern", codecForString())
.property("max", codecOptional(codecForTimestamp))
.property("min", codecOptional(codecForTimestamp))
- .build("UIFormFieldConfigAbsoluteTime.properties");
-
-const codecForUiFormFieldAbsoluteTime =
- (): Codec<UIFormFieldConfigAbsoluteTime> =>
- buildCodecForObject<UIFormFieldConfigAbsoluteTime>()
- .property("type", codecForConstString("absoluteTime"))
- .property("properties", codecForUIFormFieldAbsoluteTimeConfig())
- .build("UIFormFieldConfigAbsoluteTime");
-
-const codecForUIFormFieldAmountConfig = (): Codec<
- UIFormFieldConfigAmount["properties"]
-> =>
- codecForUIFormFieldBaseConfigTemplate<UIFormFieldConfigAmount["properties"]>()
+ .build("UIFormFieldAbsoluteTime");
+
+const codecForUiFormFieldAmount = (): Codec<UIFormFieldAmount> =>
+ codecForUIFormFieldBaseConfigTemplate<UIFormFieldAmount>()
+ .property("type", codecForConstString("amount"))
.property("currency", codecForString())
.property("max", codecOptional(codecForNumber()))
.property("min", codecOptional(codecForNumber()))
- .build("UIFormFieldConfigAmount.properties");
-
-const codecForUiFormFieldAmount = (): Codec<UIFormFieldConfigAmount> =>
- buildCodecForObject<UIFormFieldConfigAmount>()
- .property("type", codecForConstString("amount"))
- .property("properties", codecForUIFormFieldAmountConfig())
- .build("UIFormFieldConfigAmount");
+ .build("UIFormFieldAmount");
-const codecForUIFormFieldArrayConfig = (): Codec<
- UIFormFieldConfigArray["properties"]
-> =>
- codecForUIFormFieldBaseConfigTemplate<UIFormFieldConfigArray["properties"]>()
+const codecForUiFormFieldArray = (): Codec<UIFormFieldArray> =>
+ codecForUIFormFieldBaseConfigTemplate<UIFormFieldArray>()
+ .property("type", codecForConstString("array"))
.property("labelFieldId", codecForUiFieldId())
+ .property("tooltip", codecOptional(codecForString()))
// eslint-disable-next-line @typescript-eslint/no-use-before-define
.property("fields", codecForList(codecForUiFormField()))
- .build("UIFormFieldConfigArray.properties");
-
-const codecForUiFormFieldArray = (): Codec<UIFormFieldConfigArray> =>
- buildCodecForObject<UIFormFieldConfigArray>()
- .property("type", codecForConstString("array"))
- .property("properties", codecForUIFormFieldArrayConfig())
- .build("UIFormFieldConfigArray");
+ .build("UIFormFieldArray");
-const codecForUiFormFieldCaption = (): Codec<UIFormFieldConfigCaption> =>
- buildCodecForObject<UIFormFieldConfigCaption>()
+const codecForUiFormFieldCaption = (): Codec<UIFormElementCaption> =>
+ codecForUIFormFieldBaseDescriptionTemplate<UIFormElementCaption>()
.property("type", codecForConstString("caption"))
- .property("properties", codecForUIFormFieldBaseConfig())
- .build("UIFormFieldConfigCaption");
+ .build("UIFormFieldCaption");
const codecForUiFormSelectUiChoice = (): Codec<SelectUiChoice> =>
buildCodecForObject<SelectUiChoice>()
@@ -285,111 +231,75 @@ const codecForUiFormSelectUiChoice = (): Codec<SelectUiChoice> =>
.property("value", codecForString())
.build("SelectUiChoice");
-const codecForUIFormFieldWithChoiseConfig = (): Codec<
- UIFormFieldConfigChoiseHorizontal["properties"]
-> =>
- codecForUIFormFieldBaseConfigTemplate<
- UIFormFieldConfigChoiseHorizontal["properties"]
- >()
- .property("choices", codecForList(codecForUiFormSelectUiChoice()))
- .build("UIFormFieldConfigChoiseHorizontal.properties");
-
const codecForUiFormFieldChoiceHorizontal =
- (): Codec<UIFormFieldConfigChoiseHorizontal> =>
- buildCodecForObject<UIFormFieldConfigChoiseHorizontal>()
+ (): Codec<UIFormFieldChoiseHorizontal> =>
+ codecForUIFormFieldBaseConfigTemplate<UIFormFieldChoiseHorizontal>()
.property("type", codecForConstString("choiceHorizontal"))
- .property("properties", codecForUIFormFieldWithChoiseConfig())
- .build("UIFormFieldConfigChoiseHorizontal");
-
-const codecForUiFormFieldChoiceStacked =
- (): Codec<UIFormFieldConfigChoiseStacked> =>
- buildCodecForObject<UIFormFieldConfigChoiseStacked>()
- .property("type", codecForConstString("choiceStacked"))
- .property("properties", codecForUIFormFieldWithChoiseConfig())
- .build("UIFormFieldConfigChoiseStacked");
-
-const codecForUIFormFieldFileConfig = (): Codec<
- UIFormFieldConfigFile["properties"]
-> =>
- codecForUIFormFieldBaseConfigTemplate<UIFormFieldConfigFile["properties"]>()
+ .property("choices", codecForList(codecForUiFormSelectUiChoice()))
+ .build("UIFormFieldChoiseHorizontal");
+
+const codecForUiFormFieldChoiceStacked = (): Codec<UIFormFieldChoiseStacked> =>
+ codecForUIFormFieldBaseConfigTemplate<UIFormFieldChoiseStacked>()
+ .property("type", codecForConstString("choiceStacked"))
+ .property("choices", codecForList(codecForUiFormSelectUiChoice()))
+ .build("UIFormFieldChoiseStacked");
+
+const codecForUiFormFieldFile = (): Codec<UIFormFieldFile> =>
+ codecForUIFormFieldBaseConfigTemplate<UIFormFieldFile>()
+ .property("type", codecForConstString("file"))
.property("accept", codecOptional(codecForString()))
.property("maxBytes", codecOptional(codecForNumber()))
.property("minBytes", codecOptional(codecForNumber()))
- .build("UIFormFieldConfigFile.properties");
+ .build("UIFormFieldFile");
-const codecForUiFormFieldFile = (): Codec<UIFormFieldConfigFile> =>
- buildCodecForObject<UIFormFieldConfigFile>()
- .property("type", codecForConstString("file"))
- .property("properties", codecForUIFormFieldFileConfig())
- .build("UIFormFieldConfigFile");
-
-const codecForUIFormFieldWithFieldsConfig = (): Codec<
- UIFormFieldConfigGroup["properties"]
-> =>
- codecForUIFormFieldBaseDescriptionTemplate<
- UIFormFieldConfigGroup["properties"]
- >()
+const codecForUiFormFieldGroup = (): Codec<UIFormElementGroup> =>
+ codecForUIFormFieldBaseDescriptionTemplate<UIFormElementGroup>()
+ .property("type", codecForConstString("group"))
// eslint-disable-next-line @typescript-eslint/no-use-before-define
.property("fields", codecForList(codecForUiFormField()))
- .build("UIFormFieldConfigGroup.properties");
-
-const codecForUiFormFieldGroup = (): Codec<UIFormFieldConfigGroup> =>
- buildCodecForObject<UIFormFieldConfigGroup>()
- .property("type", codecForConstString("group"))
- .property("properties", codecForUIFormFieldWithFieldsConfig())
.build("UiFormFieldGroup");
-const codecForUiFormFieldInteger = (): Codec<UIFormFieldConfigInteger> =>
- buildCodecForObject<UIFormFieldConfigInteger>()
+const codecForUiFormFieldInteger = (): Codec<UIFormFieldInteger> =>
+ codecForUIFormFieldBaseConfigTemplate<UIFormFieldInteger>()
.property("type", codecForConstString("integer"))
- .property("properties", codecForUIFormFieldBaseConfig())
- .build("UIFormFieldConfigInteger");
-
-const codecForUIFormFieldSelectMultipleConfig = (): Codec<
- UIFormFieldConfigSelectMultiple["properties"]
-> =>
- codecForUIFormFieldBaseConfigTemplate<
- UIFormFieldConfigSelectMultiple["properties"]
- >()
+ // .property("properties", codecForUIFormFieldBaseConfig())
.property("max", codecOptional(codecForNumber()))
.property("min", codecOptional(codecForNumber()))
- .property("unique", codecOptional(codecForBoolean()))
- .property("choices", codecForList(codecForUiFormSelectUiChoice()))
- .build("UIFormFieldConfigSelectMultiple.properties");
+ .build("UIFormFieldInteger");
const codecForUiFormFieldSelectMultiple =
- (): Codec<UIFormFieldConfigSelectMultiple> =>
- buildCodecForObject<UIFormFieldConfigSelectMultiple>()
+ (): Codec<UIFormFieldSelectMultiple> =>
+ codecForUIFormFieldBaseConfigTemplate<UIFormFieldSelectMultiple>()
.property("type", codecForConstString("selectMultiple"))
- .property("properties", codecForUIFormFieldSelectMultipleConfig())
+ .property("max", codecOptional(codecForNumber()))
+ .property("min", codecOptional(codecForNumber()))
+ .property("unique", codecOptional(codecForBoolean()))
+ .property("choices", codecForList(codecForUiFormSelectUiChoice()))
.build("UiFormFieldSelectMultiple");
-const codecForUiFormFieldSelectOne = (): Codec<UIFormFieldConfigSelectOne> =>
- buildCodecForObject<UIFormFieldConfigSelectOne>()
+const codecForUiFormFieldSelectOne = (): Codec<UIFormFieldSelectOne> =>
+ codecForUIFormFieldBaseConfigTemplate<UIFormFieldSelectOne>()
.property("type", codecForConstString("selectOne"))
- .property("properties", codecForUIFormFieldWithChoiseConfig())
- .build("UIFormFieldConfigSelectOne");
+ .property("choices", codecForList(codecForUiFormSelectUiChoice()))
+ .build("UIFormFieldSelectOne");
-const codecForUiFormFieldText = (): Codec<UIFormFieldConfigText> =>
- buildCodecForObject<UIFormFieldConfigText>()
+const codecForUiFormFieldText = (): Codec<UIFormFieldText> =>
+ codecForUIFormFieldBaseConfigTemplate<UIFormFieldText>()
.property("type", codecForConstString("text"))
- .property("properties", codecForUIFormFieldBaseConfig())
- .build("UIFormFieldConfigText");
+ .build("UIFormFieldText");
-const codecForUiFormFieldTextArea = (): Codec<UIFormFieldConfigTextArea> =>
- buildCodecForObject<UIFormFieldConfigTextArea>()
+const codecForUiFormFieldTextArea = (): Codec<UIFormFieldTextArea> =>
+ codecForUIFormFieldBaseConfigTemplate<UIFormFieldTextArea>()
.property("type", codecForConstString("textArea"))
- .property("properties", codecForUIFormFieldBaseConfig())
- .build("UIFormFieldConfigTextArea");
+ .build("UIFormFieldTextArea");
-const codecForUiFormFieldToggle = (): Codec<UIFormFieldConfigToggle> =>
- buildCodecForObject<UIFormFieldConfigToggle>()
+const codecForUiFormFieldToggle = (): Codec<UIFormFieldToggle> =>
+ codecForUIFormFieldBaseConfigTemplate<UIFormFieldToggle>()
.property("type", codecForConstString("toggle"))
- .property("properties", codecForUIFormFieldBaseConfig())
- .build("UIFormFieldConfigToggle");
+ .build("UIFormFieldToggle");
-const codecForUiFormField = (): Codec<UIFormFieldConfig> =>
- buildCodecForUnion<UIFormFieldConfig>()
+const codecForUiFormField = (): Codec<UIFormElementConfig> =>
+ buildCodecForUnion<UIFormElementConfig>()
.discriminateOn("type")
.alternative("array", codecForLazy(codecForUiFormFieldArray))
.alternative("group", codecForLazy(codecForUiFormFieldGroup))
@@ -420,18 +330,18 @@ const codecForDoubleColumnForm = (): Codec<DoubleColumnForm> =>
.property("design", codecForList(codecForDoubleColumnFormSection()))
.build("DoubleColumnForm");
-const codecForFlexibleForm = (): Codec<FlexibleForm> =>
- buildCodecForUnion<FlexibleForm>()
+const codecForFormConfiguration = (): Codec<FormConfiguration> =>
+ buildCodecForUnion<FormConfiguration>()
.discriminateOn("type")
.alternative("double-column", codecForDoubleColumnForm())
- .build<FlexibleForm>("FlexibleForm");
+ .build<FormConfiguration>("FormConfiguration");
const codecForFormMetadata = (): Codec<FormMetadata> =>
buildCodecForObject<FormMetadata>()
.property("label", codecForString())
.property("id", codecForString())
.property("version", codecForNumber())
- .property("config", codecForFlexibleForm())
+ .property("config", codecForFormConfiguration())
.build("FormMetadata");
export const codecForUIForms = (): Codec<UiForms> =>
@@ -443,7 +353,7 @@ export type FormMetadata = {
label: string;
id: string;
version: number;
- config: FlexibleForm;
+ config: FormConfiguration;
};
export interface UiForms {