@opencrvs/toolkit 1.9.10 → 1.9.11-rc.0272b4e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -84,8 +84,8 @@ export declare function isPageVisible(page: PageConfig, formValues: ActionUpdate
|
|
|
84
84
|
* * @param validatorContext - custom validation context
|
|
85
85
|
* @returns {Partial<T>} A new object containing only the values for visible fields
|
|
86
86
|
*/
|
|
87
|
-
export declare function omitHiddenFields<T extends EventState | ActionUpdate>(fields: FieldConfig[], formValues: T, validatorContext: ValidatorContext): Partial<T>;
|
|
88
|
-
export declare function omitHiddenPaginatedFields<T extends EventState | ActionUpdate>(formConfig: FormConfig, values: T, validatorContext: ValidatorContext): Partial<Partial<T>>;
|
|
87
|
+
export declare function omitHiddenFields<T extends EventState | ActionUpdate>(fields: FieldConfig[], formValues: T, validatorContext: ValidatorContext, includeHiddenFieldsWithNullValues?: boolean): Partial<T>;
|
|
88
|
+
export declare function omitHiddenPaginatedFields<T extends EventState | ActionUpdate>(formConfig: FormConfig, values: T, validatorContext: ValidatorContext, includeHiddenFieldsWithNullValues?: boolean): Partial<Partial<T>>;
|
|
89
89
|
/**
|
|
90
90
|
*
|
|
91
91
|
* @returns a draft for the event that has been created since the last non-read action.
|
package/dist/events/index.js
CHANGED
|
@@ -3759,20 +3759,30 @@ function isPageVisible(page, formValues, context) {
|
|
|
3759
3759
|
}
|
|
3760
3760
|
return isConditionMet(page.conditional, formValues, context);
|
|
3761
3761
|
}
|
|
3762
|
-
function omitHiddenFields(fields, formValues, validatorContext) {
|
|
3762
|
+
function omitHiddenFields(fields, formValues, validatorContext, includeHiddenFieldsWithNullValues = false) {
|
|
3763
3763
|
const base = (0, import_lodash.cloneDeep)(formValues);
|
|
3764
3764
|
function fn(prevVisibilityContext) {
|
|
3765
|
-
const cleaned = (0, import_lodash.omitBy)(base, (
|
|
3765
|
+
const cleaned = (0, import_lodash.omitBy)(base, (value, fieldId) => {
|
|
3766
3766
|
const fieldConfig = fields.filter((f) => f.id === fieldId);
|
|
3767
|
-
|
|
3767
|
+
if (!fieldConfig.length) {
|
|
3768
|
+
return false;
|
|
3769
|
+
}
|
|
3770
|
+
const isHidden = fieldConfig.every(
|
|
3768
3771
|
(f) => !isFieldVisible(f, prevVisibilityContext, validatorContext)
|
|
3769
|
-
)
|
|
3772
|
+
);
|
|
3773
|
+
if (!isHidden) {
|
|
3774
|
+
return false;
|
|
3775
|
+
}
|
|
3776
|
+
if (includeHiddenFieldsWithNullValues && value === null) {
|
|
3777
|
+
return false;
|
|
3778
|
+
}
|
|
3779
|
+
return true;
|
|
3770
3780
|
});
|
|
3771
3781
|
return (0, import_lodash.isEqual)(cleaned, prevVisibilityContext) ? cleaned : fn(cleaned);
|
|
3772
3782
|
}
|
|
3773
3783
|
return fn(base);
|
|
3774
3784
|
}
|
|
3775
|
-
function omitHiddenPaginatedFields(formConfig, values, validatorContext) {
|
|
3785
|
+
function omitHiddenPaginatedFields(formConfig, values, validatorContext, includeHiddenFieldsWithNullValues = false) {
|
|
3776
3786
|
const visibleFields = formConfig.pages.filter((p) => isPageVisible(p, values, validatorContext)).flatMap((p) => p.fields);
|
|
3777
3787
|
const hiddenFields = formConfig.pages.filter((p) => !isPageVisible(p, values, validatorContext)).flatMap((p) => p.fields);
|
|
3778
3788
|
const valuesExceptHiddenPage = (0, import_lodash.omitBy)(values, (_2, fieldId) => {
|
|
@@ -3781,7 +3791,8 @@ function omitHiddenPaginatedFields(formConfig, values, validatorContext) {
|
|
|
3781
3791
|
return omitHiddenFields(
|
|
3782
3792
|
visibleFields,
|
|
3783
3793
|
valuesExceptHiddenPage,
|
|
3784
|
-
validatorContext
|
|
3794
|
+
validatorContext,
|
|
3795
|
+
includeHiddenFieldsWithNullValues
|
|
3785
3796
|
);
|
|
3786
3797
|
}
|
|
3787
3798
|
function findActiveDraftForEvent(event2, draft) {
|
|
@@ -8429,8 +8440,9 @@ function generateActionDeclarationInput(configuration, action, rng, overrides) {
|
|
|
8429
8440
|
...declaration,
|
|
8430
8441
|
...overrides
|
|
8431
8442
|
},
|
|
8432
|
-
{}
|
|
8443
|
+
{},
|
|
8433
8444
|
// Intentionally empty. Allow generating fields with custom conditionals.
|
|
8445
|
+
true
|
|
8434
8446
|
);
|
|
8435
8447
|
}
|
|
8436
8448
|
console.warn(`${action} is not a declaration action. Setting data as {}.`);
|