Skip to content

Commit

Permalink
#1020 | Fix selected gender toggle
Browse files Browse the repository at this point in the history
(cherry picked from commit b41810d)
  • Loading branch information
Suhas Vishwanath authored and himeshr committed Jul 24, 2023
1 parent a00015e commit 64d224d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import _ from "lodash";
import PrivilegeService from "../../service/PrivilegeService";
import {firebaseEvents, logEvent} from "../../utility/Analytics";
import AddressLevelState from "../common/AddressLevelsState";
import { CustomFilter } from "openchs-models";
import {ArrayUtil, CustomFilter} from "openchs-models";

export class IndividualSearchActions {
static clone(state) {
Expand Down Expand Up @@ -176,7 +176,9 @@ export class IndividualSearchActions {
}

static genderChange(state, action) {
return {...state, selectedGenders: action.selectedGenders};
let selectedGenders = state.selectedGenders || [];
ArrayUtil.toggle(selectedGenders, action.selectedGender, (l,r) => l.uuid === r.uuid)
return {...state, selectedGenders};
}

static loadIndicator(state, action) {
Expand Down
2 changes: 1 addition & 1 deletion packages/openchs-android/src/views/filter/FiltersViewV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class FiltersViewV2 extends AbstractComponent {

switch (filterConfig.type) {
case CustomFilter.type.Gender:
return <GenderFilter selectedGenders={filterValue}
return <GenderFilter selectedGenders={filterValue || []}
filterLabel={this.I18n.t(filter.name)}
key={index}
deprecatedUsage={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ class IndividualSearchView extends AbstractComponent {
/> : null}
{this.customFilterService.filterTypePresent(filterScreenName, CustomFilter.type.Gender, subjectTypeUUID) &&
<GenderFilter
selectedGenders={this.state.selectedGenders}
onSelect={(selectedGenders) => this.dispatchAction(Actions.GENDER_CHANGE, {selectedGenders})}
selectedGenders={this.state.selectedGenders || []}
onSelect={(selectedGender) => this.dispatchAction(Actions.GENDER_CHANGE, {selectedGender})}
/>}
{this.customFilterService.filterTypePresent(filterScreenName, CustomFilter.type.Address, subjectTypeUUID) &&
<AddressLevels
Expand Down

0 comments on commit 64d224d

Please sign in to comment.