Skip to content

Commit

Permalink
Merge pull request #35029 from dimagi/ml/location-gray-out
Browse files Browse the repository at this point in the history
Disable previously selected location from the location dropdown
  • Loading branch information
minhaminha authored Aug 28, 2024
2 parents 2a30604 + 574f505 commit f2cc281
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
15 changes: 14 additions & 1 deletion corehq/apps/locations/static/locations/js/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
hqDefine("locations/js/widgets", [
'jquery',
'underscore',
'hqwebapp/js/toggles',
'select2/dist/js/select2.full.min',
], function (
$,
_
_,
toggles
) {
// Update the options available to one select2 to be
// the selected values from another (multiselect) select2
Expand Down Expand Up @@ -89,6 +91,17 @@ hqDefine("locations/js/widgets", [
},
processResults: function (data, params) {
var more = (params.page || 1) * 10 < data.total;
if (toggles.toggleEnabled('LOCATION_FIELD_USER_PROVISIONING')) {
let selectedLocations = Array.from($select[0].selectedOptions);
if (selectedLocations.length > 0) {
let locIds = selectedLocations.map(option => option.value);
data.results.forEach(result => {
if (locIds.includes(result.id)) {
result.disabled = true;
}
});
}
}
return {
results: data.results,
pagination: { more: more },
Expand Down
8 changes: 8 additions & 0 deletions corehq/toggles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,14 @@ def _ensure_valid_randomness(randomness):
owner='Jenny Schweers',
)

LOCATION_FIELD_USER_PROVISIONING = FeatureRelease(
'location_field_user_provisioning',
'USH: Holding feature flag for various works relating to the location field',
TAG_RELEASE,
namespaces=[NAMESPACE_DOMAIN],
owner='Minha Lee',
)

WEB_APPS_ANCHORED_SUBMIT = StaticToggle(
'web_apps_anchored_submit',
'USH: Keep submit button anchored at the bottom of screen for forms in Web Apps',
Expand Down

0 comments on commit f2cc281

Please sign in to comment.