From b6f67f465e514d0c58acf365570188d735c3d940 Mon Sep 17 00:00:00 2001 From: himeshr Date: Wed, 27 Nov 2024 12:36:13 +0530 Subject: [PATCH 1/3] #1530 | Display Custom Dashboard Filters only for the selected subject types --- packages/openchs-android/package-lock.json | 14 +++++++------- .../src/service/CustomFilterService.js | 10 ++++++++++ .../src/service/reports/DashboardFilterService.js | 1 + .../src/views/filter/FiltersViewV2.js | 6 ++++++ 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/packages/openchs-android/package-lock.json b/packages/openchs-android/package-lock.json index c5e95e116..35c5cce5a 100644 --- a/packages/openchs-android/package-lock.json +++ b/packages/openchs-android/package-lock.json @@ -36,7 +36,7 @@ "lodash": "4.17.21", "moment": "2.29.4", "native-base": "3.4.9", - "openchs-models": "1.32.16", + "openchs-models": "1.32.19", "prop-types": "15.8.1", "react": "18.2.0", "react-native": "0.72.8", @@ -16554,9 +16554,9 @@ } }, "node_modules/openchs-models": { - "version": "1.32.16", - "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.32.16.tgz", - "integrity": "sha512-VVePwjyvepiDZMyVALAOxILyZ+ezBmE4NXHejFa+EnMe545+VB++kYfJ2+IMB4bzNF0OpELnz6LyWg1VmUDQAA==", + "version": "1.32.19", + "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.32.19.tgz", + "integrity": "sha512-lU0mb1Rjk9gNLVZP72LNoLIxJ+3QMW8GCEbBkMv5RvO3J1h+LRaSsklxKxaLfoOkAc8wZ6oYoNgr9uKiPcEblw==", "dependencies": { "uuid": "^9.0.1" }, @@ -35354,9 +35354,9 @@ } }, "openchs-models": { - "version": "1.32.16", - "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.32.16.tgz", - "integrity": "sha512-VVePwjyvepiDZMyVALAOxILyZ+ezBmE4NXHejFa+EnMe545+VB++kYfJ2+IMB4bzNF0OpELnz6LyWg1VmUDQAA==", + "version": "1.32.19", + "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.32.19.tgz", + "integrity": "sha512-lU0mb1Rjk9gNLVZP72LNoLIxJ+3QMW8GCEbBkMv5RvO3J1h+LRaSsklxKxaLfoOkAc8wZ6oYoNgr9uKiPcEblw==", "requires": { "uuid": "^9.0.1" } diff --git a/packages/openchs-android/src/service/CustomFilterService.js b/packages/openchs-android/src/service/CustomFilterService.js index 0ead5dc06..6003d5f4b 100644 --- a/packages/openchs-android/src/service/CustomFilterService.js +++ b/packages/openchs-android/src/service/CustomFilterService.js @@ -120,6 +120,16 @@ class CustomFilterService extends BaseService { && filter.subjectTypeUUID === subjectTypeUUID); } + shouldFilterBeHidden(filterConfigs, selectedValues, filterConfig) { + const subjectTypeFilterUUID = Object.keys(filterConfigs).find(key => filterConfigs[key].type === CustomFilter.type.SubjectType); + const subjectTypeFilterValue = selectedValues[subjectTypeFilterUUID]; + const subjectTypeUUIDs = subjectTypeFilterValue ? subjectTypeFilterValue.subjectTypes.map(st => st.uuid) : []; + const type = filterConfig.type; + return (type !== CustomFilter.type.SubjectType && type !== CustomFilter.type.AsOnDate) && + !!filterConfig.subjectType && + !_.includes(subjectTypeUUIDs, filterConfig.subjectType.uuid); + } + queryEntity(schemaName, selectedAnswerQueryFunction, otherFilters, indFunc, includeVoided) { const query = selectedAnswerQueryFunction(); diff --git a/packages/openchs-android/src/service/reports/DashboardFilterService.js b/packages/openchs-android/src/service/reports/DashboardFilterService.js index ec28e7613..006b356b8 100644 --- a/packages/openchs-android/src/service/reports/DashboardFilterService.js +++ b/packages/openchs-android/src/service/reports/DashboardFilterService.js @@ -45,6 +45,7 @@ class DashboardFilterService extends BaseService { const filterConfig = new DashboardFilterConfig(); filterConfig.widget = obj.widget; filterConfig.type = obj.type; + filterConfig.subjectType = this.findByUUID(obj.subjectTypeUUID, SubjectType.schema.name); if (obj.type === CustomFilter.type.GroupSubject) { filterConfig.groupSubjectTypeFilter = new GroupSubjectTypeFilter(); filterConfig.groupSubjectTypeFilter.subjectType = this.findByUUID(obj.groupSubjectTypeFilter.subjectTypeUUID, SubjectType.schema.name); diff --git a/packages/openchs-android/src/views/filter/FiltersViewV2.js b/packages/openchs-android/src/views/filter/FiltersViewV2.js index 677ec1fc6..adbbc7d22 100644 --- a/packages/openchs-android/src/views/filter/FiltersViewV2.js +++ b/packages/openchs-android/src/views/filter/FiltersViewV2.js @@ -29,6 +29,7 @@ import AddressLevelState from '../../action/common/AddressLevelsState'; import FormMetaDataSelect from "../common/formMetaData/FormMetaDataSelect"; import AddressLevelService from "../../service/AddressLevelService"; import NamedSelectableEntities from "../../model/NamedSelectableEntities"; +import CustomFilterService from '../../service/CustomFilterService'; class GroupSubjectFilter extends AbstractComponent { constructor(props, context) { @@ -108,6 +109,7 @@ class FiltersViewV2 extends AbstractComponent { constructor(props, context) { super(props, context, Reducers.reducerKeys.filterActionV2); + this.customFilterService = context.getService(CustomFilterService); } viewName() { @@ -164,6 +166,10 @@ class FiltersViewV2 extends AbstractComponent { const filterValue = selectedValues[filter.uuid]; const filterError = filterErrors[filter.uuid]; + if(this.customFilterService.shouldFilterBeHidden(filterConfigs, selectedValues, filterConfig)) { + return null; + } + switch (filterConfig.type) { case CustomFilter.type.Gender: return Date: Wed, 27 Nov 2024 13:14:04 +0530 Subject: [PATCH 2/3] #1530 | Use only non-voided dashboard filters during hash computation --- .../openchs-android/src/service/CustomDashboardCacheService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/openchs-android/src/service/CustomDashboardCacheService.js b/packages/openchs-android/src/service/CustomDashboardCacheService.js index 75e7b060e..fab622b83 100644 --- a/packages/openchs-android/src/service/CustomDashboardCacheService.js +++ b/packages/openchs-android/src/service/CustomDashboardCacheService.js @@ -24,7 +24,7 @@ function getDashboardCache(service, dashboardUUID) { } function getDashboardFiltersHash(dashboard) { - const str = JSON.stringify(dashboard.filters.map((x) => x.filterConfig)); + const str = JSON.stringify(dashboard.filters.filter(x => !x.voided).map((x) => x.filterConfig)); return new Hashes.MD5().hex(str); } From f917ae812855dff1a2c1a80db78d262bcbe21eb6 Mon Sep 17 00:00:00 2001 From: Vivek Singh Date: Wed, 27 Nov 2024 17:03:22 +0530 Subject: [PATCH 3/3] #0 - put-db-custom target --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 401adc3b7..fe1d104d3 100644 --- a/Makefile +++ b/Makefile @@ -312,6 +312,14 @@ appdb:=$(if $(appdb),$(appdb),../db/default.realm) put_db: ## Apply realmdb from ../default.realm adb push $(appdb) /data/data/${app_android_package_name}/files/default.realm +put-db: put_db + +put-db-custom: +ifndef dbPath + @echo "Provde the variable dbPath" + exit 1 +endif + adb push $(dbPath) /data/data/${app_android_package_name}/files/default.realm put_db_force: adb push $(appdb) /product/default.realm