Skip to content

Commit 41d71ee

Browse files
authored
Merge pull request #335 from opencrvs/auto-pr-release-v1.6.1-334-243
fix(v1.6.1): use form data to check if details exist
2 parents 96c15f9 + 6a1108e commit 41d71ee

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
- You can now configure the home screen application’s name and icons in your country configuration package as manifest.json and app icon files are moved from core to country config (check `src/client-static` folder)
4949
- Updated `allowedFileFormats` in signature fields to use MIME types (`image/png`, `image/jpg`, `image/jpeg`, `image/svg`) instead of simple file extensions. If you are already using the `allowedFileFormats` field in your implementation, please ensure to update the format accordingly.
5050
- Remove unnecessary UI dividers that add in various sections of the declaration forms(e.g the Death, Birth and Marriage forms) [#244](https://github.com/opencrvs/opencrvs-countryconfig/pull/244)
51+
- The details exists conditionals for the various sections i.e. father, mother, spouse has to use the `values.detailsExist` property instead of accessing it from `draftData.[sectionName].detailsExists`. This is due to the fact that the draftData is not populated until any changes have been made to any of the fields in the current section.
5152

5253
### Bug fixes
5354

src/form/addresses/index.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
*/
1111

1212
import {
13-
FATHER_DETAILS_DONT_EXIST,
14-
MOTHER_DETAILS_DONT_EXIST,
15-
SPOUSE_DETAILS_DONT_EXIST,
1613
detailsDontExist,
1714
expressionToConditional,
1815
hideIfInformantBrideOrGroom,
@@ -99,11 +96,11 @@ export const defaultAddressConfiguration: IAddressConfiguration[] = [
9996
{
10097
config: AddressSubsections.PRIMARY_ADDRESS_SUBSECTION,
10198
label: formMessageDescriptors.primaryAddress,
102-
conditionalCase: MOTHER_DETAILS_DONT_EXIST
99+
conditionalCase: detailsDontExist
103100
},
104101
{
105102
config: AddressCases.PRIMARY_ADDRESS,
106-
conditionalCase: MOTHER_DETAILS_DONT_EXIST
103+
conditionalCase: detailsDontExist
107104
} /*,
108105
{
109106
config: AddressSubsections.SECONDARY_ADDRESS_SUBSECTION,
@@ -125,9 +122,9 @@ export const defaultAddressConfiguration: IAddressConfiguration[] = [
125122
config: AddressSubsections.PRIMARY_ADDRESS_SUBSECTION,
126123
label: formMessageDescriptors.primaryAddress,
127124
conditionalCase: [
128-
expressionToConditional(FATHER_DETAILS_DONT_EXIST),
125+
expressionToConditional(detailsDontExist),
129126
expressionToConditional(
130-
`${FATHER_DETAILS_DONT_EXIST} || ${primaryAddressSameAsOtherPrimaryAddress}`,
127+
`${detailsDontExist} || ${primaryAddressSameAsOtherPrimaryAddress}`,
131128
'hideInPreview'
132129
)
133130
]
@@ -149,7 +146,7 @@ export const defaultAddressConfiguration: IAddressConfiguration[] = [
149146
},
150147
{
151148
config: AddressCases.PRIMARY_ADDRESS,
152-
conditionalCase: `((${FATHER_DETAILS_DONT_EXIST} || ${primaryAddressSameAsOtherPrimaryAddress}) && !(${mothersDetailsDontExistOnOtherPage}) || ((${detailsDontExist}) && (${mothersDetailsDontExistOnOtherPage})))`
149+
conditionalCase: `((${detailsDontExist} || ${primaryAddressSameAsOtherPrimaryAddress}) && !(${mothersDetailsDontExistOnOtherPage}) || ((${detailsDontExist}) && (${mothersDetailsDontExistOnOtherPage})))`
153150
} /*,
154151
{
155152
config: AddressSubsections.SECONDARY_ADDRESS_SUBSECTION,
@@ -275,9 +272,9 @@ export const defaultAddressConfiguration: IAddressConfiguration[] = [
275272
config: AddressSubsections.PRIMARY_ADDRESS_SUBSECTION,
276273
label: formMessageDescriptors.primaryAddress,
277274
conditionalCase: [
278-
expressionToConditional(SPOUSE_DETAILS_DONT_EXIST),
275+
expressionToConditional(detailsDontExist),
279276
expressionToConditional(
280-
`${SPOUSE_DETAILS_DONT_EXIST} || ${primaryAddressSameAsOtherPrimaryAddress}`,
277+
`${detailsDontExist} || ${primaryAddressSameAsOtherPrimaryAddress}`,
281278
'hideInPreview'
282279
)
283280
]
@@ -297,7 +294,7 @@ export const defaultAddressConfiguration: IAddressConfiguration[] = [
297294
},
298295
{
299296
config: AddressCases.PRIMARY_ADDRESS,
300-
conditionalCase: `((${SPOUSE_DETAILS_DONT_EXIST} || ${primaryAddressSameAsOtherPrimaryAddress}) || (${detailsDontExist}))`
297+
conditionalCase: `(${detailsDontExist} || ${primaryAddressSameAsOtherPrimaryAddress})`
301298
}
302299
]
303300
},

src/form/common/default-validation-conditionals.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
*
99
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
1010
*/
11-
import { Conditional } from '../types/types'
12-
import { IntegratingSystemType } from '../types/types'
11+
import { Conditional, IntegratingSystemType } from '../types/types'
1312
import { Validator } from '../types/validators'
1413

1514
/**
@@ -470,18 +469,11 @@ export const spouseFamilyNameConditionals = [
470469
}
471470
]
472471

473-
export const FATHER_DETAILS_DONT_EXIST =
474-
'(draftData?.father && !draftData?.father.detailsExist) || !values.detailsExist'
475-
export const MOTHER_DETAILS_DONT_EXIST =
476-
'(draftData?.mother && !draftData?.mother.detailsExist) || !values.detailsExist'
477-
export const SPOUSE_DETAILS_DONT_EXIST =
478-
'(draftData?.spouse && !draftData?.spouse.detailsExist) || !values.detailsExist'
479-
480472
// if mothers details do not exist on other page
481473
export const mothersDetailsDontExistOnOtherPage =
482474
'draftData && draftData.mother && !draftData.mother.detailsExist'
483475

484-
// if fathers details do not exist
476+
// if details don't exist for the current section
485477
export const detailsDontExist = '!values.detailsExist'
486478

487479
// primary address same as other primary

0 commit comments

Comments
 (0)