Skip to content

Commit

Permalink
#1381 | Fix break in applying customDashboardFilters apply
Browse files Browse the repository at this point in the history
  • Loading branch information
himeshr committed Jun 6, 2024
1 parent 3aec19e commit cef558e
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions packages/openchs-android/src/service/CustomDashboardCacheService.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,22 @@ class CustomDashboardCacheService extends BaseService {
const dashboardFilter = dashboardFilterService.findByUUID(filterUuid);
const dashboardFilterConfig = dashboardFilterService.getDashboardFilterConfig(dashboardFilter);

if (dashboardFilterConfig.type === CustomFilter.type.SubjectType) {
serialisedSelectedValues[filterUuid] = {
subjectTypes: selectedFilterValues[filterUuid].subjectTypes.map(x => x.uuid),
programs: selectedFilterValues[filterUuid].programs.map(x => x.uuid),
encounterTypes: selectedFilterValues[filterUuid].encounterTypes.map(x => x.uuid)
};
} else if (dataTypeDetails.has(dashboardFilterConfig.getInputDataType()) &&
if (!_.isNil(selectedFilterValues[filterUuid])) {
if (dashboardFilterConfig.type === CustomFilter.type.SubjectType) {
serialisedSelectedValues[filterUuid] = {
subjectTypes: selectedFilterValues[filterUuid].subjectTypes.map(x => x.uuid),
programs: selectedFilterValues[filterUuid].programs.map(x => x.uuid),
encounterTypes: selectedFilterValues[filterUuid].encounterTypes.map(x => x.uuid)
};
} else if (dataTypeDetails.has(dashboardFilterConfig.getInputDataType()) &&
dataTypeDetails.get(dashboardFilterConfig.getInputDataType()).isArray &&
!_.isEmpty(selectedFilterValues[filterUuid])) {
serialisedSelectedValues[filterUuid] = selectedFilterValues[filterUuid].map(x => x.uuid);
} else if (dataTypeDetails.has(dashboardFilterConfig.getInputDataType()) && !_.isNil(selectedFilterValues[filterUuid])) {
serialisedSelectedValues[filterUuid] = _.get(selectedFilterValues[filterUuid], "uuid");
} else if (!_.isNil(selectedFilterValues[filterUuid])) {
serialisedSelectedValues[filterUuid] = selectedFilterValues[filterUuid];
serialisedSelectedValues[filterUuid] = selectedFilterValues[filterUuid].map(x => x.uuid);
} else if (dataTypeDetails.has(dashboardFilterConfig.getInputDataType())) {
serialisedSelectedValues[filterUuid] = _.get(selectedFilterValues[filterUuid], "uuid");
} else {
serialisedSelectedValues[filterUuid] = selectedFilterValues[filterUuid];
}
}
});

Expand Down

0 comments on commit cef558e

Please sign in to comment.