diff --git a/packages/openchs-android/src/service/reports/DashboardFilterService.js b/packages/openchs-android/src/service/reports/DashboardFilterService.js index 3759f9988..71ba32643 100644 --- a/packages/openchs-android/src/service/reports/DashboardFilterService.js +++ b/packages/openchs-android/src/service/reports/DashboardFilterService.js @@ -13,6 +13,10 @@ import { } from 'openchs-models'; import {DashboardReportFilter} from "../../model/DashboardReportFilters"; import _ from "lodash"; +import General from "../../utility/General"; +import AddressLevelService from "../AddressLevelService"; +import GlobalContext from "../../GlobalContext"; + @Service("dashboardFilterService") class DashboardFilterService extends BaseService { @@ -71,7 +75,16 @@ class DashboardFilterService extends BaseService { }; } if (filterConfig.type === CustomFilter.type.Address) { - ruleInput.filterValue = filterValue.selectedAddresses; + if (_.isEmpty(filterValue.selectedAddresses)) { + ruleInput.filterValue = filterValue.selectedAddresses; + } else { + const addressLevelService = GlobalContext.getInstance().beanRegistry.getService(AddressLevelService); + const allChildrenOfLowestSelectedLocations = filterValue.selectedAddresses + .filter(location => location.level === _.get(_.minBy(filterValue.selectedAddresses, 'level'), 'level')) + .reduce((acc, parent) => acc.concat(addressLevelService.getChildrenOfNode(parent, false)), []); + ruleInput.filterValue = allChildrenOfLowestSelectedLocations + .map(addressLevel => _.pick(addressLevel, ['uuid', 'name', 'level', 'type', 'parentUuid', 'typeUuid'])); + } } else ruleInput.filterValue = filterValue; diff --git a/packages/openchs-android/translations/en.json b/packages/openchs-android/translations/en.json index d94cefa57..87e92743e 100644 --- a/packages/openchs-android/translations/en.json +++ b/packages/openchs-android/translations/en.json @@ -493,6 +493,6 @@ "enterNewPasswordFor" : "Enter new password for {{userName}}", "enterOTP" : "Enter OTP", "backgroundSyncInProgress" : "Auto sync is in progress. Please try again after sometime.", - "addressFilterBehaviorHint": "(Choose exact level at which subject is registered)" + "addressFilterBehaviorHint": "(Selection includes lower levels implicitly)" } } diff --git a/packages/openchs-android/translations/gu_IN.json b/packages/openchs-android/translations/gu_IN.json index 2445a583b..af4853c28 100644 --- a/packages/openchs-android/translations/gu_IN.json +++ b/packages/openchs-android/translations/gu_IN.json @@ -299,6 +299,6 @@ "trackLocation": "ટ્રૅક સ્થાન", "disableAutoSync": "સ્વતઃ સમન્વયન અક્ષમ કરો", "autoSync": "સ્વતઃ સમન્વયન", - "addressFilterBehaviorHint": "(યોગ્ય સ્તર પસંદ કરો કે જેમાં વિષય નોંધાયેલ છે)" + "addressFilterBehaviorHint": "(પસંદગીમાં નિમ્ન સ્તરનો ગર્ભિત સમાવેશ થાય છે)" } } diff --git a/packages/openchs-android/translations/hi_IN.json b/packages/openchs-android/translations/hi_IN.json index 950600911..f73c32daf 100644 --- a/packages/openchs-android/translations/hi_IN.json +++ b/packages/openchs-android/translations/hi_IN.json @@ -366,6 +366,6 @@ "disableAutoSync": "ऑटो सिंक अक्षम करें", "autoSync": "ऑटो सिंक", "backgroundSyncInProgress": "ऑटो सिंक प्रगति पर है| कृपया कुछ देर बाद प्रयास करें।", - "addressFilterBehaviorHint": "(वही लोकेशन जहाँ सब्जेक्ट रजिस्टर्ड है)" + "addressFilterBehaviorHint": "(चयन में निचले स्तर परोक्ष रूप से शामिल हैं)" } } diff --git a/packages/openchs-android/translations/ka_IN.json b/packages/openchs-android/translations/ka_IN.json index 08ec813b4..3e6b18d46 100644 --- a/packages/openchs-android/translations/ka_IN.json +++ b/packages/openchs-android/translations/ka_IN.json @@ -307,6 +307,6 @@ "autoRefresh": "ಡ್ಯಾಶ್ಬೋರ್ಡ್ ಸ್ವಯಂ ರಿಫ್ರೆಶ್", "disableAutoSync": "ಸ್ವಯಂ ಸಿಂಕ್ ಅನ್ನು ನಿಷ್ಕ್ರಿಯಗೊಳಿಸಿ", "autoSync": "ಸ್ವಯಂ ಸಿಂಕ್", - "addressFilterBehaviorHint": "(ಯಾವ ವಿಷಯವನ್ನು ನೋಂದಾಯಿಸಲಾಗಿದೆ ಎಂಬುದನ್ನು ನಿಖರವಾದ ಮಟ್ಟವನ್ನು ಆರಿಸಿ)" + "addressFilterBehaviorHint": "(ಆಯ್ಕೆಯು ಕೆಳ ಹಂತಗಳನ್ನು ಸೂಚ್ಯವಾಗಿ ಒಳಗೊಂಡಿರುತ್ತದೆ)" } } diff --git a/packages/openchs-android/translations/mr_IN.json b/packages/openchs-android/translations/mr_IN.json index 1a55a9d2f..4553e5a13 100644 --- a/packages/openchs-android/translations/mr_IN.json +++ b/packages/openchs-android/translations/mr_IN.json @@ -296,6 +296,6 @@ "autoRefresh": "डॅशबोर्ड ऑटो रिफ्रेश", "disableAutoSync": "ऑटो सिंक अक्षम करा", "autoSync": "ऑटो सिंक", - "addressFilterBehaviorHint": "(कोणत्या विषयावर नोंदणी केली आहे ते अचूक स्तर निवडा)" + "addressFilterBehaviorHint": "(निवडीत खालच्या स्तरांचा समावेश होतो)" } } diff --git a/packages/openchs-android/translations/ta_IN.json b/packages/openchs-android/translations/ta_IN.json index 4e6d69214..aa81fa68f 100755 --- a/packages/openchs-android/translations/ta_IN.json +++ b/packages/openchs-android/translations/ta_IN.json @@ -307,6 +307,6 @@ "autoRefresh": "டாஷ்போர்டு தானியங்கு புதுப்பிப்பு", "disableAutoSync": "தானியங்கு ஒத்திசைவை முடக்கு", "autoSync": "தானியங்கு ஒத்திசைவு", - "addressFilterBehaviorHint": "(எந்த பாடத்தில் பதிவு செய்யப்பட்டுள்ளது என்பதை சரியான அளவில் தேர்வு செய்யவும்)" + "addressFilterBehaviorHint": "(தேர்வு என்பது கீழ்நிலைகளை மறைமுகமாக உள்ளடக்கியது)" } }