Skip to content

Commit

Permalink
#1109 - fixed cloning
Browse files Browse the repository at this point in the history
  • Loading branch information
petmongrels committed Sep 27, 2023
1 parent 73b02bf commit 40614de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ import { ArrayUtil, CustomFilter } from "openchs-models";
export class IndividualSearchActions {
static clone(state) {
return {
...state,
searchCriteria: state.searchCriteria.clone(),
subjectTypes: state.subjectTypes.map((subjectType => subjectType.clone())),
selectedCustomFilters: {...state.selectedCustomFilters},
genders: {...state.genders},
addressLevelState: state.addressLevelState.clone(),
addressLevelState: state.addressLevelState.clone()
};
}

static resetFilters(state) {
return {
...state,
searchCriteria: IndividualSearchCriteria.empty(),
subjectTypes: state.subjectTypes.map((subjectType => subjectType.clone())),
selectedCustomFilters: {},
Expand Down Expand Up @@ -176,9 +178,9 @@ export class IndividualSearchActions {
}

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

static loadIndicator(state, action) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class IndividualSearchView extends AbstractComponent {
const allowedSubjectTypes = _.sortBy(_.filter(this.state.subjectTypes, subjectType => !privilegeService.hasEverSyncedGroupPrivileges() || privilegeService.hasAllPrivileges() || _.includes(allowedSubjectTypeUuidsForView, subjectType.uuid)), ({name}) => this.I18n.t(name));
let subjectTypeSelectFilter = SingleSelectFilterModel.forSubjectTypes(allowedSubjectTypes, this.state.searchCriteria.subjectType);
const locale = this.getService(UserInfoService).getUserSettings().locale;

const genderFilterPresent = this.customFilterService.filterTypePresent(filterScreenName, CustomFilter.type.Gender, subjectTypeUUID);
return (
<CHSContainer>
<AppHeader title={this.I18n.t('search')} hideBackButton={this.props.hideBackButton}
Expand Down Expand Up @@ -127,7 +127,7 @@ class IndividualSearchView extends AbstractComponent {
selectedCustomFilters={this.state.selectedCustomFilters}
onSelect={(selectedCustomFilters) => this.dispatchAction(Actions.CUSTOM_FILTER_CHANGE, {selectedCustomFilters})}
/> : null}
{this.customFilterService.filterTypePresent(filterScreenName, CustomFilter.type.Gender, subjectTypeUUID) &&
{genderFilterPresent &&
<GenderFilter
selectedGenders={this.state.selectedGenders || []}
onSelect={(selectedGender) => this.dispatchAction(Actions.GENDER_CHANGE, {selectedGender})}
Expand Down

0 comments on commit 40614de

Please sign in to comment.