Skip to content

Commit

Permalink
#1283 | Select lower address levels implicitly on selection of addres…
Browse files Browse the repository at this point in the history
…s filter in custom dashboard
  • Loading branch information
1t5j0y committed Feb 15, 2024
1 parent bdc6a40 commit 420ee81
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/openchs-android/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
}
}
2 changes: 1 addition & 1 deletion packages/openchs-android/translations/gu_IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,6 @@
"trackLocation": "ટ્રૅક સ્થાન",
"disableAutoSync": "સ્વતઃ સમન્વયન અક્ષમ કરો",
"autoSync": "સ્વતઃ સમન્વયન",
"addressFilterBehaviorHint": "(યોગ્ય સ્તર પસંદ કરો કે જેમાં વિષય નોંધાયેલ છે)"
"addressFilterBehaviorHint": "(પસંદગીમાં નિમ્ન સ્તરનો ગર્ભિત સમાવેશ થાય છે)"
}
}
2 changes: 1 addition & 1 deletion packages/openchs-android/translations/hi_IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,6 @@
"disableAutoSync": "ऑटो सिंक अक्षम करें",
"autoSync": "ऑटो सिंक",
"backgroundSyncInProgress": "ऑटो सिंक प्रगति पर है| कृपया कुछ देर बाद प्रयास करें।",
"addressFilterBehaviorHint": "(वही लोकेशन जहाँ सब्जेक्ट रजिस्टर्ड है)"
"addressFilterBehaviorHint": "(चयन में निचले स्तर परोक्ष रूप से शामिल हैं)"
}
}
2 changes: 1 addition & 1 deletion packages/openchs-android/translations/ka_IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,6 @@
"autoRefresh": "ಡ್ಯಾಶ್ಬೋರ್ಡ್ ಸ್ವಯಂ ರಿಫ್ರೆಶ್",
"disableAutoSync": "ಸ್ವಯಂ ಸಿಂಕ್ ಅನ್ನು ನಿಷ್ಕ್ರಿಯಗೊಳಿಸಿ",
"autoSync": "ಸ್ವಯಂ ಸಿಂಕ್",
"addressFilterBehaviorHint": "(ಯಾವ ವಿಷಯವನ್ನು ನೋಂದಾಯಿಸಲಾಗಿದೆ ಎಂಬುದನ್ನು ನಿಖರವಾದ ಮಟ್ಟವನ್ನು ಆರಿಸಿ)"
"addressFilterBehaviorHint": "(ಆಯ್ಕೆಯು ಕೆಳ ಹಂತಗಳನ್ನು ಸೂಚ್ಯವಾಗಿ ಒಳಗೊಂಡಿರುತ್ತದೆ)"
}
}
2 changes: 1 addition & 1 deletion packages/openchs-android/translations/mr_IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,6 @@
"autoRefresh": "डॅशबोर्ड ऑटो रिफ्रेश",
"disableAutoSync": "ऑटो सिंक अक्षम करा",
"autoSync": "ऑटो सिंक",
"addressFilterBehaviorHint": "(कोणत्या विषयावर नोंदणी केली आहे ते अचूक स्तर निवडा)"
"addressFilterBehaviorHint": "(निवडीत खालच्या स्तरांचा समावेश होतो)"
}
}
2 changes: 1 addition & 1 deletion packages/openchs-android/translations/ta_IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,6 @@
"autoRefresh": "டாஷ்போர்டு தானியங்கு புதுப்பிப்பு",
"disableAutoSync": "தானியங்கு ஒத்திசைவை முடக்கு",
"autoSync": "தானியங்கு ஒத்திசைவு",
"addressFilterBehaviorHint": "(எந்த பாடத்தில் பதிவு செய்யப்பட்டுள்ளது என்பதை சரியான அளவில் தேர்வு செய்யவும்)"
"addressFilterBehaviorHint": "(தேர்வு என்பது கீழ்நிலைகளை மறைமுகமாக உள்ளடக்கியது)"
}
}

0 comments on commit 420ee81

Please sign in to comment.