Skip to content

Commit

Permalink
add 'myself' to one of the options in informant dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
rikukissa committed Nov 6, 2024
1 parent 9e390de commit 3ec801a
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 4 deletions.
44 changes: 43 additions & 1 deletion src/form/birth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ import {
} 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 {
getCommonSectionMapping,
getCustomFieldMapping
} from '@countryconfig/utils/mapping/field-mapping-utils'
import { getReasonForLateRegistration } from '../custom-fields'
import { getIDNumberFields, getIDType } from '../custom-fields'
// import { createCustomFieldExample } from '../custom-fields'
Expand Down Expand Up @@ -308,6 +311,45 @@ export const birthForm: ISerializedForm = {
mothersDetailsExistConditionals
),
getReasonNotExisting(certificateHandlebars.motherReasonNotApplying), // Strongly recommend is required if you want to register abandoned / orphaned children!
{
name: 'reasonNotAvailable',
type: 'SELECT_WITH_OPTIONS',
customQuestionMappingId: `birth.mother.mother-view-group.reasonNotAvailable`,
label: {
defaultMessage: 'Reason why details are unavailable ',
description: 'Label for Relationship to child',
id: 'form.field.label.asdf'
},
required: true,
custom: true,
hideInPreview: false,
initialValue: '',
validator: [],
conditionals: [
{
action: 'hide',
expression: `$draft?.informant?.informantType !== 'MYSELF'`
},
{
action: 'hide',
expression: 'values.detailsExist'
}
],
placeholder: formMessageDescriptors.formSelectPlaceholder,
mapping: getCustomFieldMapping(
`birth.mother.mother-view-group.reasonNotAvailable`
),
options: [
{
value: 'DECEASED',
label: {
defaultMessage: 'Deceased',
description: 'Label for option Spouse',
id: 'form.field.label.informantRelation.dfgdgfgfd'
}
}
]
},
getFirstNameField(
'motherNameInEnglish',
motherFirstNameConditionals,
Expand Down
4 changes: 4 additions & 0 deletions src/form/common/common-required-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ export const getReasonNotExisting = (certificateHandlebar: string) =>
{
action: 'hide',
expression: 'values.detailsExist'
},
{
action: 'hide',
expression: `$draft?.informant?.informantType === 'MYSELF'`
}
],
type: 'TEXT',
Expand Down
8 changes: 5 additions & 3 deletions src/form/common/default-validation-conditionals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const detailsExist = [

// if informant is not mother or father
export const informantNotMotherOrFather =
'((values.informantType==="MOTHER") || (values.informantType==="FATHER") || (!values.informantType))'
'((values.informantType==="MOTHER") || (values.informantType==="MYSELF") || (values.informantType==="FATHER") || (!values.informantType))'

export const hideIfInformantMotherOrFather = [
{
Expand Down Expand Up @@ -196,7 +196,8 @@ export const fathersBirthDateConditionals = [
export const motherFirstNameConditionals = [
{
action: 'hide',
expression: '!values.detailsExist'
expression:
'!values.detailsExist && $draft?.informant?.informantType !== "MYSELF"'
},
{
action: 'disable',
Expand All @@ -207,7 +208,8 @@ export const motherFirstNameConditionals = [
export const motherFamilyNameConditionals = [
{
action: 'hide',
expression: '!values.detailsExist'
expression:
'!values.detailsExist && $draft?.informant?.informantType !== "MYSELF"'
},
{
action: 'disable',
Expand Down
9 changes: 9 additions & 0 deletions src/form/common/select-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
// THIS FILE ALLOWS YOU TO CUSTOMISE EVERY DEFAULT SELECT OPTION IN OPENCRVS WHETHER OR NOT THE FIELD IS REQUIRED OR CUSTOM

export const informantTypes = {
MYSELF: 'MYSELF',
SPOUSE: 'SPOUSE',
SON: 'SON',
DAUGHTER: 'DAUGHTER',
Expand Down Expand Up @@ -166,6 +167,14 @@ export const birthInformantTypeOptions: ISelectOption[] = [
value: informantTypes.GRANDMOTHER,
label: informantMessageDescriptors.GRANDMOTHER
},
{
value: informantTypes.MYSELF,
label: {
defaultMessage: 'Self',
description: 'Label for option Spouse',
id: 'form.field.label.informantRelation.myself'
}
},
{
value: informantTypes.BROTHER,
label: informantMessageDescriptors.BROTHER
Expand Down

0 comments on commit 3ec801a

Please sign in to comment.