From 9a615bd256680e049103c1e0f60a946b21cf8ba1 Mon Sep 17 00:00:00 2001 From: tahmidrahman-dsi Date: Tue, 5 Dec 2023 12:28:34 +0600 Subject: [PATCH 1/9] Add custom field in death form deceased section: Number of dependants --- src/api/content/client/client.json | 4 +++- src/form/addresses/index.ts | 2 +- src/form/death/custom-fields.ts | 37 ++++++++++++++++++++++++++++++ src/form/death/index.ts | 4 +++- 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/form/death/custom-fields.ts diff --git a/src/api/content/client/client.json b/src/api/content/client/client.json index c21bcb68b..3f020b099 100644 --- a/src/api/content/client/client.json +++ b/src/api/content/client/client.json @@ -848,6 +848,7 @@ "fieldAgentHome.requireUpdatesCountLoading": "Checking your declarations", "fieldAgentHome.sentForReviewCount": "Sent for review ({total})", "fieldAgentHome.zeroUpdatesText": "No declarations require updates", + "form.customField.label.numberOfDependants": "No. of dependants", "form.field.label.addFile": "Upload", "form.field.showLabel": "Show", "form.field.hideLabel": "Hide", @@ -2960,6 +2961,7 @@ "fieldAgentHome.requireUpdatesCountLoading": "Vérification de vos déclarations", "fieldAgentHome.sentForReviewCount": "Envoyées pour révision ({total})", "fieldAgentHome.zeroUpdatesText": "Aucune déclaration ne nécessite de mise à jour", + "form.customField.label.numberOfDependants": "Nombre de personnes à charge", "form.field.showLabel": "Afficher", "form.field.hideLabel": "Cacher", "form.field.nidNotVerified": "Authentifier", @@ -4233,4 +4235,4 @@ } } ] -} +} \ No newline at end of file diff --git a/src/form/addresses/index.ts b/src/form/addresses/index.ts index ca63ae060..28a0a3a15 100644 --- a/src/form/addresses/index.ts +++ b/src/form/addresses/index.ts @@ -149,7 +149,7 @@ export const defaultAddressConfiguration: IAddressConfiguration[] = [ }, { // DECEASED ADDRESS FIELDS - precedingFieldId: 'death.deceased.deceased-view-group.maritalStatus', + precedingFieldId: 'death.deceased.deceased-view-group.numberOfDependants', configurations: [ { config: AddressSubsections.PRIMARY_ADDRESS_SUBSECTION, diff --git a/src/form/death/custom-fields.ts b/src/form/death/custom-fields.ts new file mode 100644 index 000000000..2b3add283 --- /dev/null +++ b/src/form/death/custom-fields.ts @@ -0,0 +1,37 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * OpenCRVS is also distributed under the terms of the Civil Registration + * & Healthcare Disclaimer located at http://opencrvs.org/license. + * + * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. + */ + +import { SerializedFormField } from '../types/types' +import { getCustomFieldMapping } from '@countryconfig/utils/mapping/field-mapping-utils' + +export function getNumberOfDependants(): SerializedFormField { + const fieldName: string = 'numberOfDependants' + const fieldId: string = `death.deceased.deceased-view-group.${fieldName}` + + return { + name: fieldName, + customQuestionMappingId: fieldId, + custom: true, + required: false, + type: 'NUMBER', + label: { + id: 'form.customField.label.numberOfDependants', + description: + 'A form field that asks for the persons number of dependants.', + defaultMessage: 'No. of dependants' + }, + initialValue: '', + validator: [], + mapping: getCustomFieldMapping(fieldId), + conditionals: [], + inputFieldWidth: '64px' + } +} diff --git a/src/form/death/index.ts b/src/form/death/index.ts index 2c7ac49af..808af5853 100644 --- a/src/form/death/index.ts +++ b/src/form/death/index.ts @@ -75,6 +75,7 @@ import { } from '../common/preview-groups' import { certificateHandlebars } from './certficate-handlebars' import { getCommonSectionMapping } from '@countryconfig/utils/mapping/field-mapping-utils' +import { getNumberOfDependants } from './custom-fields' //import { getSectionMapping } from '@countryconfig/utils/mapping/section/death/mapping-utils' // import { createCustomFieldExample } from '../custom-fields' @@ -205,7 +206,8 @@ export const deathForm = { getNationalIDValidators('deceased'), certificateHandlebars.deceasedNID ), - getMaritalStatus(certificateHandlebars.deceasedMaritalStatus, []) + getMaritalStatus(certificateHandlebars.deceasedMaritalStatus, []), + getNumberOfDependants() ], previewGroups: [deceasedNameInEnglish] } From a0ce8b321add2cc4473ea2de59d2ba37207b8e4b Mon Sep 17 00:00:00 2001 From: tahmidrahman-dsi Date: Tue, 5 Dec 2023 17:02:52 +0600 Subject: [PATCH 2/9] Replace national id input with type of id select and id number input --- src/form/birth/index.ts | 42 +++++++---- src/form/custom-fields.ts | 138 ++++++++++++++++++++++++++++++++++++- src/form/death/index.ts | 22 ++---- src/form/marriage/index.ts | 33 ++++----- 4 files changed, 187 insertions(+), 48 deletions(-) diff --git a/src/form/birth/index.ts b/src/form/birth/index.ts index 0f02e1c13..a8f964c36 100644 --- a/src/form/birth/index.ts +++ b/src/form/birth/index.ts @@ -75,6 +75,7 @@ import { documentsSection, registrationSection } from './required-sections' import { certificateHandlebars } from './certificate-handlebars' import { getSectionMapping } from '@countryconfig/utils/mapping/section/birth/mapping-utils' import { getCommonSectionMapping } from '@countryconfig/utils/mapping/field-mapping-utils' +import { getIDNumberFields, getIDType } from '../custom-fields' // import { createCustomFieldExample } from '../custom-fields' // ======================= FORM CONFIGURATION ======================= @@ -257,11 +258,16 @@ export const birthForm: ISerializedForm = { certificateHandlebars.informantNationality, hideIfInformantMotherOrFather ), // Required field. - getNationalID( - 'informantID', - hideIfNidIntegrationEnabled.concat(hideIfInformantMotherOrFather), - getNationalIDValidators('informant'), - certificateHandlebars.informantNID + getIDType( + 'birth', + 'informant', + hideIfNidIntegrationEnabled.concat(detailsExist), + true + ), + ...getIDNumberFields( + 'informant', + hideIfNidIntegrationEnabled.concat(detailsExist), + true ), // preceding field of address fields divider('informant-nid-seperator', [ @@ -331,11 +337,16 @@ export const birthForm: ISerializedForm = { certificateHandlebars.motherNationality, detailsExist ), // Required field. - getNationalID( - 'iD', + getIDType( + 'birth', + 'mother', hideIfNidIntegrationEnabled.concat(detailsExist), - getNationalIDValidators('mother'), - certificateHandlebars.motherNID + true + ), + ...getIDNumberFields( + 'mother', + hideIfNidIntegrationEnabled.concat(detailsExist), + true ), // preceding field of address fields divider('mother-nid-seperator', detailsExist), @@ -415,11 +426,16 @@ export const birthForm: ISerializedForm = { certificateHandlebars.fatherNationality, detailsExist ), // Required field. - getNationalID( - 'iD', + getIDType( + 'birth', + 'father', + hideIfNidIntegrationEnabled.concat(detailsExist), + true + ), + ...getIDNumberFields( + 'father', hideIfNidIntegrationEnabled.concat(detailsExist), - getNationalIDValidators('father'), - certificateHandlebars.fatherNID + true ), // preceding field of address fields divider('father-nid-seperator', detailsExist), diff --git a/src/form/custom-fields.ts b/src/form/custom-fields.ts index b6f8e6d23..09c7703a5 100644 --- a/src/form/custom-fields.ts +++ b/src/form/custom-fields.ts @@ -9,8 +9,11 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { SerializedFormField } from './types/types' +import { sentenceCase } from '@countryconfig/utils/address-utils' +import { formMessageDescriptors } from './common/messages' +import { Conditional, SerializedFormField } from './types/types' import { getCustomFieldMapping } from '@countryconfig/utils/mapping/field-mapping-utils' +import { getNationalIDValidators } from './common/default-validation-conditionals' // ======================= CUSTOM FIELD CONFIGURATION ======================= @@ -45,3 +48,136 @@ export function createCustomFieldExample(): SerializedFormField { maxLength: 250 } } + +type ArrayElement = ArrayType extends readonly (infer ElementType)[] + ? ElementType + : never + +const idTypeOptions = [ + { + value: 'NATIONAL_ID' as const, + label: { + defaultMessage: 'National ID', + description: 'Option for form field: Type of ID', + id: 'form.field.label.iDTypeNationalID' + } + }, + { + value: 'PASSPORT' as const, + label: { + defaultMessage: 'Passport', + description: 'Option for form field: Type of ID', + id: 'form.field.label.iDTypePassport' + } + }, + { + value: 'BIRTH_REGISTRATION_NUMBER' as const, + label: { + defaultMessage: 'Birth Registration Number', + description: 'Option for form field: Type of ID', + id: 'form.field.label.iDTypeBRN' + } + }, + { + value: 'NONE' as const, + label: { + defaultMessage: 'None', + description: 'Option for form field: Type of ID', + id: 'form.field.label.iDTypeNone' + } + } +] + +type IDType = ArrayElement['value'] + +export function getIDType( + event: string, + sectionId: string, + conditionals: Conditional[] = [], + required: boolean +): SerializedFormField { + const fieldName: string = `${sectionId}IdType` + const fieldId: string = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}` + return { + name: fieldName, + customQuestionMappingId: fieldId, + custom: true, + required, + type: 'SELECT_WITH_OPTIONS', + label: { + id: 'form.field.label.iDType', + description: 'A form field that asks for the type of ID.', + defaultMessage: 'Type of ID' + }, + initialValue: '', + validator: [], + mapping: getCustomFieldMapping(fieldId), + placeholder: formMessageDescriptors.formSelectPlaceholder, + conditionals, + options: idTypeOptions + } +} + +function getValidators(configCase: string, idValue: IDType) { + if (idValue === 'NATIONAL_ID') { + return getNationalIDValidators(configCase) + } + return [] +} + +export function getIDNumber( + sectionId: string, + idValue: IDType, + conditionals: Conditional[] = [], + required: boolean +): SerializedFormField { + const fieldName: string = `${sectionId}IdNumber${sentenceCase(idValue)}` + const validators = getValidators(sectionId, idValue) + // eslint-disable-next-line no-console + console.log('Custom field addded with handlebar: ', fieldName) + return { + name: fieldName, + required, + custom: true, + type: 'TEXT', + label: { + id: 'form.field.label.iD', + description: 'A form field that asks for the id number.', + defaultMessage: 'ID number' + }, + initialValue: '', + validator: validators, + mapping: { + template: { + fieldName: fieldName, + operation: 'identityToFieldTransformer', + parameters: ['id', idValue] + }, + mutation: { + operation: 'fieldToIdentityTransformer', + parameters: ['id', idValue] + }, + query: { + operation: 'identityToFieldTransformer', + parameters: ['id', idValue] + } + }, + conditionals: [ + { + action: 'hide', + expression: `(values.${sectionId}IdType!=="${idValue}") || (values.${sectionId}IdType==="NONE")` + } + ].concat(conditionals), + maxLength: 250 + } +} + +export function getIDNumberFields( + section: string, + conditionals: Conditional[] = [], + required: boolean +) { + return idTypeOptions + .filter((opt) => opt.value !== 'NONE') + .map((opt) => getIDNumber(section, opt.value, conditionals, required)) +} diff --git a/src/form/death/index.ts b/src/form/death/index.ts index 808af5853..299d6caaa 100644 --- a/src/form/death/index.ts +++ b/src/form/death/index.ts @@ -24,8 +24,7 @@ import { getFamilyNameField, getFirstNameField, getNationality, - otherInformantType, - getNationalID /*, + otherInformantType /*, getDetailsExist, getReasonNotExisting*/ } from '../common/common-required-fields' @@ -40,8 +39,6 @@ import { import { formMessageDescriptors } from '../common/messages' import { Event, ISerializedForm } from '../types/types' import { - getNationalIDValidators, - hideIfNidIntegrationEnabled, informantBirthDateConditionals, informantFamilyNameConditionals, ageOfIndividualConditionals, @@ -76,6 +73,7 @@ import { import { certificateHandlebars } from './certficate-handlebars' import { getCommonSectionMapping } from '@countryconfig/utils/mapping/field-mapping-utils' import { getNumberOfDependants } from './custom-fields' +import { getIDNumberFields, getIDType } from '../custom-fields' //import { getSectionMapping } from '@countryconfig/utils/mapping/section/death/mapping-utils' // import { createCustomFieldExample } from '../custom-fields' @@ -200,12 +198,8 @@ export const deathForm = { ageOfDeceasedConditionals ), getNationality(certificateHandlebars.deceasedNationality, []), - getNationalID( - 'deceasedID', - [], - getNationalIDValidators('deceased'), - certificateHandlebars.deceasedNID - ), + getIDType('death', 'deceased', [], true), + ...getIDNumberFields('deceased', [], true), getMaritalStatus(certificateHandlebars.deceasedMaritalStatus, []), getNumberOfDependants() ], @@ -283,12 +277,8 @@ export const deathForm = { ageOfIndividualConditionals ), getNationality(certificateHandlebars.informantNationality, []), - getNationalID( - 'informantID', - hideIfNidIntegrationEnabled, - getNationalIDValidators('informant'), - certificateHandlebars.informantNID - ), + getIDType('death', 'informant', [], true), + ...getIDNumberFields('informant', [], true), // ADDRESS FIELDS WILL RENDER HERE divider('informant-address-separator'), registrationPhone, diff --git a/src/form/marriage/index.ts b/src/form/marriage/index.ts index ff9b820b6..0cde411a7 100644 --- a/src/form/marriage/index.ts +++ b/src/form/marriage/index.ts @@ -21,8 +21,7 @@ import { getFamilyNameField, getFirstNameField, getNationality, - otherInformantType, - getNationalID + otherInformantType } from '../common/common-required-fields' import { formMessageDescriptors, @@ -60,6 +59,7 @@ import { } from '../common/preview-groups' import { certificateHandlebars } from './certificate-handlebars' import { getCommonSectionMapping } from '@countryconfig/utils/mapping/field-mapping-utils' +import { getIDNumberFields, getIDType } from '../custom-fields' // import { createCustomFieldExample } from '../custom-fields' @@ -137,11 +137,16 @@ export const marriageForm: ISerializedForm = { certificateHandlebars.informantNationality, hideIfInformantBrideOrGroom ), // Required field - getNationalID( - 'informantID', + getIDType( + 'marriage', + 'informant', hideIfInformantBrideOrGroom, - getNationalIDValidators('informant'), - certificateHandlebars.informantNID + true + ), + ...getIDNumberFields( + 'informant', + hideIfInformantBrideOrGroom, + true ), // ADDRESS FIELDS WILL RENDER HERE registrationPhone, @@ -190,12 +195,8 @@ export const marriageForm: ISerializedForm = { brideOrGroomAgeValidators ), getNationality(certificateHandlebars.groomNationality, []), // Required field - getNationalID( - 'iD', - [], - getNationalIDValidators('groom'), - certificateHandlebars.groomNID - ), + getIDType('marriage', 'groom', [], true), + ...getIDNumberFields('groom', [], true), getMarriedLastName(certificateHandlebars.groomMarriedLastNameEng) ], previewGroups: [groomNameInEnglish] @@ -240,12 +241,8 @@ export const marriageForm: ISerializedForm = { brideOrGroomAgeValidators ), getNationality(certificateHandlebars.brideNationality, []), // Required field - getNationalID( - 'iD', - [], - getNationalIDValidators('bride'), - certificateHandlebars.brideNID - ), + getIDType('marriage', 'bride', [], true), + ...getIDNumberFields('bride', [], true), getMarriedLastName(certificateHandlebars.brideMarriedLastNameEng) ], previewGroups: [brideNameInEnglish] From 5918b833b1fa7c5bdaad90d7ce07bf7093b04318 Mon Sep 17 00:00:00 2001 From: tahmidrahman-dsi Date: Wed, 6 Dec 2023 13:54:54 +0600 Subject: [PATCH 3/9] Uncomment spouse section in death form --- src/form/addresses/index.ts | 5 +++-- src/form/death/index.ts | 28 +++++++++++++++------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/form/addresses/index.ts b/src/form/addresses/index.ts index 28a0a3a15..a3e28a3cb 100644 --- a/src/form/addresses/index.ts +++ b/src/form/addresses/index.ts @@ -12,6 +12,7 @@ import { FATHER_DETAILS_DONT_EXIST, MOTHER_DETAILS_DONT_EXIST, + SPOUSE_DETAILS_DONT_EXIST, detailsDontExist, hideIfInformantBrideOrGroom, informantNotMotherOrFather, @@ -229,7 +230,7 @@ export const defaultAddressConfiguration: IAddressConfiguration[] = [ conditionalCase: `((${FATHER_DETAILS_DONT_EXIST} || ${primaryAddressSameAsOtherPrimaryAddress}) && !(${mothersDetailsDontExistOnOtherPage}) || ((${detailsDontExist}) && (${mothersDetailsDontExistOnOtherPage})))` } ] - }, + },*/ { // SPOUSE ADDRESS FIELDS precedingFieldId: 'death.spouse.spouse-view-group.spouse-nid-seperator', @@ -251,7 +252,7 @@ export const defaultAddressConfiguration: IAddressConfiguration[] = [ conditionalCase: `((${SPOUSE_DETAILS_DONT_EXIST} || ${primaryAddressSameAsOtherPrimaryAddress}) || (${detailsDontExist}))` } ] - },*/ + }, { // PLACE OF MARRIAGE ADDRESS FIELDS precedingFieldId: diff --git a/src/form/death/index.ts b/src/form/death/index.ts index 299d6caaa..d058a7ba1 100644 --- a/src/form/death/index.ts +++ b/src/form/death/index.ts @@ -24,9 +24,9 @@ import { getFamilyNameField, getFirstNameField, getNationality, - otherInformantType /*, + otherInformantType, getDetailsExist, - getReasonNotExisting*/ + getReasonNotExisting } from '../common/common-required-fields' import { deathInformantType, @@ -60,7 +60,12 @@ import { motherFamilyNameConditionals, mothersBirthDateConditionals, mothersDetailsExistConditionals, - spouseDetailsExistConditionals*/ + spouseDetailsExistConditionals*/, + spouseDetailsExistConditionals, + detailsExist, + spouseBirthDateConditionals, + spouseFamilyNameConditionals, + spouseFirstNameConditionals } from '../common/default-validation-conditionals' import { documentsSection, registrationSection } from './required-sections' import { @@ -68,12 +73,14 @@ import { informantNameInEnglish /*, fatherNameInEnglish, motherNameInEnglish, - spouseNameInEnglish*/ + spouseNameInEnglish*/, + spouseNameInEnglish } from '../common/preview-groups' import { certificateHandlebars } from './certficate-handlebars' import { getCommonSectionMapping } from '@countryconfig/utils/mapping/field-mapping-utils' import { getNumberOfDependants } from './custom-fields' import { getIDNumberFields, getIDType } from '../custom-fields' +import { getSectionMapping } from '@countryconfig/utils/mapping/section/death/mapping-utils' //import { getSectionMapping } from '@countryconfig/utils/mapping/section/death/mapping-utils' // import { createCustomFieldExample } from '../custom-fields' @@ -289,9 +296,6 @@ export const deathForm = { ], mapping: getCommonSectionMapping('informant') }, - /* - OTHER POSSIBLE SECTIONS FOR DEATH INCLUDE: - { id: 'spouse', viewType: 'form', @@ -341,12 +345,8 @@ export const deathForm = { certificateHandlebars.spouseNationality, detailsExist ), - getNationalID( - 'iD', - hideIfNidIntegrationEnabled.concat(detailsExist), - getNationalIDValidators('spouse'), - certificateHandlebars.spouseNID - ), + getIDType('death', 'spouse', detailsExist, true), + ...getIDNumberFields('spouse', detailsExist, true), // preceding field of address fields divider('spouse-nid-seperator', detailsExist), // ADDRESS FIELDS WILL RENDER HERE @@ -357,6 +357,8 @@ export const deathForm = { ], mapping: getSectionMapping('spouse') }, + /* + OTHER POSSIBLE SECTIONS FOR DEATH INCLUDE: { id: 'mother', viewType: 'form', From bd560878c61c5bf87259cc395d2466e0b78b26be Mon Sep 17 00:00:00 2001 From: tahmidrahman-dsi Date: Wed, 13 Dec 2023 18:48:56 +0600 Subject: [PATCH 4/9] Feedback amends --- src/form/birth/index.ts | 4 ++-- src/form/custom-fields.ts | 8 +++++--- src/form/death/index.ts | 10 ++++------ src/utils/index.ts | 4 ++++ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/form/birth/index.ts b/src/form/birth/index.ts index a8f964c36..a813a2330 100644 --- a/src/form/birth/index.ts +++ b/src/form/birth/index.ts @@ -261,12 +261,12 @@ export const birthForm: ISerializedForm = { getIDType( 'birth', 'informant', - hideIfNidIntegrationEnabled.concat(detailsExist), + hideIfNidIntegrationEnabled.concat(hideIfInformantMotherOrFather), true ), ...getIDNumberFields( 'informant', - hideIfNidIntegrationEnabled.concat(detailsExist), + hideIfNidIntegrationEnabled.concat(hideIfInformantMotherOrFather), true ), // preceding field of address fields diff --git a/src/form/custom-fields.ts b/src/form/custom-fields.ts index 09c7703a5..49d5fb628 100644 --- a/src/form/custom-fields.ts +++ b/src/form/custom-fields.ts @@ -9,11 +9,12 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { sentenceCase } from '@countryconfig/utils/address-utils' import { formMessageDescriptors } from './common/messages' import { Conditional, SerializedFormField } from './types/types' import { getCustomFieldMapping } from '@countryconfig/utils/mapping/field-mapping-utils' import { getNationalIDValidators } from './common/default-validation-conditionals' +import { camelCase } from 'lodash' +import { uppercaseFirstLetter } from '@countryconfig/utils' // ======================= CUSTOM FIELD CONFIGURATION ======================= @@ -131,14 +132,15 @@ export function getIDNumber( conditionals: Conditional[] = [], required: boolean ): SerializedFormField { - const fieldName: string = `${sectionId}IdNumber${sentenceCase(idValue)}` + const fieldName: string = `${sectionId}${uppercaseFirstLetter( + camelCase(idValue) + )}` const validators = getValidators(sectionId, idValue) // eslint-disable-next-line no-console console.log('Custom field addded with handlebar: ', fieldName) return { name: fieldName, required, - custom: true, type: 'TEXT', label: { id: 'form.field.label.iD', diff --git a/src/form/death/index.ts b/src/form/death/index.ts index d058a7ba1..12148cad5 100644 --- a/src/form/death/index.ts +++ b/src/form/death/index.ts @@ -59,8 +59,7 @@ import { motherFirstNameConditionals, motherFamilyNameConditionals, mothersBirthDateConditionals, - mothersDetailsExistConditionals, - spouseDetailsExistConditionals*/, + mothersDetailsExistConditionals,*/, spouseDetailsExistConditionals, detailsExist, spouseBirthDateConditionals, @@ -72,14 +71,13 @@ import { deceasedNameInEnglish, informantNameInEnglish /*, fatherNameInEnglish, - motherNameInEnglish, - spouseNameInEnglish*/, + motherNameInEnglish,*/, spouseNameInEnglish } from '../common/preview-groups' import { certificateHandlebars } from './certficate-handlebars' import { getCommonSectionMapping } from '@countryconfig/utils/mapping/field-mapping-utils' -import { getNumberOfDependants } from './custom-fields' -import { getIDNumberFields, getIDType } from '../custom-fields' +import { getNumberOfDependants } from '@countryconfig/form/death/custom-fields' +import { getIDNumberFields, getIDType } from '@countryconfig/form/custom-fields' import { getSectionMapping } from '@countryconfig/utils/mapping/section/death/mapping-utils' //import { getSectionMapping } from '@countryconfig/utils/mapping/section/death/mapping-utils' diff --git a/src/utils/index.ts b/src/utils/index.ts index 338342596..aea539610 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -272,3 +272,7 @@ export function createCustomFieldHandlebarName(fieldId: string) { fieldIdNameArray[fieldIdNameArray.length - 1] }` } + +export function uppercaseFirstLetter(str: string) { + return str.charAt(0).toUpperCase() + str.slice(1) +} From 3c6e2bfeba92dbc9cb07bc54c4fc3020fae4febf Mon Sep 17 00:00:00 2001 From: tahmidrahman-dsi Date: Tue, 13 Feb 2024 15:57:52 +0600 Subject: [PATCH 5/9] Make id field custom --- src/form/custom-fields.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/form/custom-fields.ts b/src/form/custom-fields.ts index 49d5fb628..0d1ced5f2 100644 --- a/src/form/custom-fields.ts +++ b/src/form/custom-fields.ts @@ -142,6 +142,7 @@ export function getIDNumber( name: fieldName, required, type: 'TEXT', + custom: true, label: { id: 'form.field.label.iD', description: 'A form field that asks for the id number.', From 19237856f268267a3f0f31903ef775dedf044d19 Mon Sep 17 00:00:00 2001 From: tahmidrahman-dsi Date: Tue, 13 Feb 2024 17:04:12 +0600 Subject: [PATCH 6/9] Informant section amends --- src/form/addresses/index.ts | 5 +++- .../common/default-validation-conditionals.ts | 10 ++++++++ src/form/death/index.ts | 25 +++++++++++-------- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/form/addresses/index.ts b/src/form/addresses/index.ts index a3e28a3cb..62af44b9a 100644 --- a/src/form/addresses/index.ts +++ b/src/form/addresses/index.ts @@ -16,6 +16,7 @@ import { detailsDontExist, hideIfInformantBrideOrGroom, informantNotMotherOrFather, + isInformantSpouse, mothersDetailsDontExistOnOtherPage, primaryAddressSameAsOtherPrimaryAddress /*, SPOUSE_DETAILS_DONT_EXIST*/ @@ -168,11 +169,13 @@ export const defaultAddressConfiguration: IAddressConfiguration[] = [ }, { // INFORMANT ADDRESS FIELDS - precedingFieldId: 'death.informant.informant-view-group.informantID', + precedingFieldId: + 'death.informant.informant-view-group.informantBirthRegistrationNumber', configurations: [ { config: AddressCopyConfigCases.PRIMARY_ADDRESS_SAME_AS_OTHER_PRIMARY, label: formMessageDescriptors.primaryAddressSameAsDeceasedsPrimary, + conditionalCase: `${isInformantSpouse}`, xComparisonSection: 'informant', yComparisonSection: 'deceased' }, diff --git a/src/form/common/default-validation-conditionals.ts b/src/form/common/default-validation-conditionals.ts index ebd96232f..30b706b3e 100644 --- a/src/form/common/default-validation-conditionals.ts +++ b/src/form/common/default-validation-conditionals.ts @@ -109,6 +109,16 @@ export const hideIfInformantMotherOrFather = [ } ] +export const isInformantSpouse = + '!values.informantType || values.informantType==="SPOUSE"' + +export const hideIfInformantSpouse = [ + { + action: 'hide', + expression: isInformantSpouse + } +] + export const mothersDetailsExistConditionals = [ { action: 'hide', diff --git a/src/form/death/index.ts b/src/form/death/index.ts index 12148cad5..6c635ee21 100644 --- a/src/form/death/index.ts +++ b/src/form/death/index.ts @@ -64,7 +64,8 @@ import { detailsExist, spouseBirthDateConditionals, spouseFamilyNameConditionals, - spouseFirstNameConditionals + spouseFirstNameConditionals, + hideIfInformantSpouse } from '../common/default-validation-conditionals' import { documentsSection, registrationSection } from './required-sections' import { @@ -252,17 +253,17 @@ export const deathForm = { otherInformantType(Event.Death), getFirstNameField( 'informantNameInEnglish', - informantFirstNameConditionals, + informantFirstNameConditionals.concat(hideIfInformantSpouse), certificateHandlebars.informantFirstName ), // Required field. In Farajaland, we have built the option to integrate with MOSIP. So we have different conditionals for each name to check MOSIP responses. You could always refactor firstNamesEng for a basic setup getFamilyNameField( 'informantNameInEnglish', - informantFamilyNameConditionals, + informantFamilyNameConditionals.concat(hideIfInformantSpouse), certificateHandlebars.informantFamilyName ), // Required field. getBirthDate( 'informantBirthDate', - informantBirthDateConditionals, + informantBirthDateConditionals.concat(hideIfInformantSpouse), [ { operation: 'dateFormatIsCorrect', @@ -278,14 +279,17 @@ export const deathForm = { exactDateOfBirthUnknown([]), getAgeOfIndividualInYears( formMessageDescriptors.ageOfInformant, - exactDateOfBirthUnknownConditional, + exactDateOfBirthUnknownConditional.concat(hideIfInformantSpouse), ageOfIndividualConditionals ), - getNationality(certificateHandlebars.informantNationality, []), - getIDType('death', 'informant', [], true), - ...getIDNumberFields('informant', [], true), + getNationality( + certificateHandlebars.informantNationality, + hideIfInformantSpouse + ), + getIDType('death', 'informant', hideIfInformantSpouse, true), + ...getIDNumberFields('informant', hideIfInformantSpouse, true), // ADDRESS FIELDS WILL RENDER HERE - divider('informant-address-separator'), + divider('informant-address-separator', hideIfInformantSpouse), registrationPhone, registrationEmail ], @@ -337,7 +341,8 @@ export const deathForm = { exactDateOfBirthUnknown([]), getAgeOfIndividualInYears( formMessageDescriptors.ageOfSpouse, - exactDateOfBirthUnknownConditional + exactDateOfBirthUnknownConditional, + ageOfIndividualConditionals ), getNationality( certificateHandlebars.spouseNationality, From 6189d43eed68341f5edc9b16fdc277d29ce7f134 Mon Sep 17 00:00:00 2001 From: tahmidrahman-dsi Date: Tue, 13 Feb 2024 17:22:14 +0600 Subject: [PATCH 7/9] Fix typo --- src/form/birth/index.ts | 5 ++--- src/form/common/default-validation-conditionals.ts | 4 ++-- src/form/death/index.ts | 6 +++--- src/form/marriage/index.ts | 7 +++---- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/form/birth/index.ts b/src/form/birth/index.ts index a813a2330..525bdf3ec 100644 --- a/src/form/birth/index.ts +++ b/src/form/birth/index.ts @@ -60,11 +60,10 @@ import { fatherFamilyNameConditionals, informantNotMotherOrFather, detailsExistConditional, - ageOfIndividualConditionals, + ageOfIndividualValidators, ageOfParentsConditionals } from '../common/default-validation-conditionals' import { - getNationalIDValidators, informantFirstNameConditionals, informantFamilyNameConditionals, informantBirthDateConditionals, @@ -252,7 +251,7 @@ export const birthForm: ISerializedForm = { exactDateOfBirthUnknownConditional.concat( hideIfInformantMotherOrFather ), - ageOfIndividualConditionals + ageOfIndividualValidators ), getNationality( certificateHandlebars.informantNationality, diff --git a/src/form/common/default-validation-conditionals.ts b/src/form/common/default-validation-conditionals.ts index 30b706b3e..093c2b7a8 100644 --- a/src/form/common/default-validation-conditionals.ts +++ b/src/form/common/default-validation-conditionals.ts @@ -251,7 +251,7 @@ export const brideOrGroomAgeValidators = [ } ] satisfies Validator[] -export const ageOfIndividualConditionals: Validator[] = [ +export const ageOfIndividualValidators: Validator[] = [ { operation: 'range', parameters: [12, 120] @@ -263,7 +263,7 @@ export const ageOfIndividualConditionals: Validator[] = [ ] export const ageOfParentsConditionals = [ - ...ageOfIndividualConditionals, + ...ageOfIndividualValidators, { operation: 'isValidParentsBirthDate', parameters: [10, true] diff --git a/src/form/death/index.ts b/src/form/death/index.ts index 6c635ee21..610cde321 100644 --- a/src/form/death/index.ts +++ b/src/form/death/index.ts @@ -41,7 +41,7 @@ import { Event, ISerializedForm } from '../types/types' import { informantBirthDateConditionals, informantFamilyNameConditionals, - ageOfIndividualConditionals, + ageOfIndividualValidators, ageOfDeceasedConditionals, informantFirstNameConditionals, exactDateOfBirthUnknownConditional, @@ -280,7 +280,7 @@ export const deathForm = { getAgeOfIndividualInYears( formMessageDescriptors.ageOfInformant, exactDateOfBirthUnknownConditional.concat(hideIfInformantSpouse), - ageOfIndividualConditionals + ageOfIndividualValidators ), getNationality( certificateHandlebars.informantNationality, @@ -342,7 +342,7 @@ export const deathForm = { getAgeOfIndividualInYears( formMessageDescriptors.ageOfSpouse, exactDateOfBirthUnknownConditional, - ageOfIndividualConditionals + ageOfIndividualValidators ), getNationality( certificateHandlebars.spouseNationality, diff --git a/src/form/marriage/index.ts b/src/form/marriage/index.ts index 0cde411a7..c88cab80b 100644 --- a/src/form/marriage/index.ts +++ b/src/form/marriage/index.ts @@ -40,10 +40,9 @@ import { } from './required-fields' import { Event, ISerializedForm } from '../types/types' import { - ageOfIndividualConditionals, + ageOfIndividualValidators, brideOrGroomAgeValidators, - exactDateOfBirthUnknownConditional, - getNationalIDValidators + exactDateOfBirthUnknownConditional } from '../common/default-validation-conditionals' import { hideIfInformantBrideOrGroom, @@ -131,7 +130,7 @@ export const marriageForm: ISerializedForm = { exactDateOfBirthUnknownConditional.concat( hideIfInformantBrideOrGroom ), - ageOfIndividualConditionals + ageOfIndividualValidators ), getNationality( certificateHandlebars.informantNationality, From 24608c3165fd47a43ca340ef6ea054e466d0296c Mon Sep 17 00:00:00 2001 From: tahmidrahman-dsi Date: Tue, 13 Feb 2024 17:23:34 +0600 Subject: [PATCH 8/9] Remove unused import --- src/form/birth/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/form/birth/index.ts b/src/form/birth/index.ts index 525bdf3ec..67064374a 100644 --- a/src/form/birth/index.ts +++ b/src/form/birth/index.ts @@ -19,7 +19,6 @@ import { getFirstNameField, getNationality, otherInformantType, - getNationalID, getDetailsExist, getReasonNotExisting } from '../common/common-required-fields' From e9399f4b472990c078944afa7e43fcda0c334e95 Mon Sep 17 00:00:00 2001 From: tahmidrahman-dsi Date: Tue, 13 Feb 2024 19:16:32 +0600 Subject: [PATCH 9/9] Update death informant id fields conditionals to support nid integration --- src/form/death/index.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/form/death/index.ts b/src/form/death/index.ts index 610cde321..d78a21e99 100644 --- a/src/form/death/index.ts +++ b/src/form/death/index.ts @@ -65,7 +65,8 @@ import { spouseBirthDateConditionals, spouseFamilyNameConditionals, spouseFirstNameConditionals, - hideIfInformantSpouse + hideIfInformantSpouse, + hideIfNidIntegrationEnabled } from '../common/default-validation-conditionals' import { documentsSection, registrationSection } from './required-sections' import { @@ -286,8 +287,17 @@ export const deathForm = { certificateHandlebars.informantNationality, hideIfInformantSpouse ), - getIDType('death', 'informant', hideIfInformantSpouse, true), - ...getIDNumberFields('informant', hideIfInformantSpouse, true), + getIDType( + 'death', + 'informant', + hideIfNidIntegrationEnabled.concat(hideIfInformantSpouse), + true + ), + ...getIDNumberFields( + 'informant', + hideIfNidIntegrationEnabled.concat(hideIfInformantSpouse), + true + ), // ADDRESS FIELDS WILL RENDER HERE divider('informant-address-separator', hideIfInformantSpouse), registrationPhone,