Skip to content

Commit

Permalink
Implement boolean filters correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
futa-ikeda committed Nov 19, 2024
1 parent fbc17d9 commit b97d535
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

import InstitutionModel from 'ember-osf-web/models/institution';
import { SuggestedFilterOperators } from 'ember-osf-web/models/related-property-path';
import SearchResultModel from 'ember-osf-web/models/search-result';
import { Filter } from 'osf-components/components/search-page/component';

Expand All @@ -29,7 +30,7 @@ export type ObjectListColumn = ValueColumn | LinkColumn | ComponentColumn;

interface InstitutionalObjectListArgs {
institution: InstitutionModel;
defaultQueryOptions: Record<'cardSearchFilter', Record<string, string[]>>;
defaultQueryOptions: Record<'cardSearchFilter', Record<string, string[] | any>>;
columns: ObjectListColumn[];
objectType: string;
}
Expand All @@ -53,6 +54,11 @@ export default class InstitutionalObjectList extends Component<InstitutionalObje
sort: this.sortParam ? { [this.sortParam]: this.sort } : this.sort,
};
const fullQueryOptions = this.activeFilters.reduce((acc, filter: Filter) => {
if (filter.suggestedFilterOperator === SuggestedFilterOperators.IsPresent) {
acc.cardSearchFilter[filter.propertyPathKey] = {};
acc.cardSearchFilter[filter.propertyPathKey][filter.value] = true;
return acc;
}
const currentValue = acc.cardSearchFilter[filter.propertyPathKey];
acc.cardSearchFilter[filter.propertyPathKey] =
currentValue ? currentValue.concat(filter.value) : [filter.value];
Expand Down

0 comments on commit b97d535

Please sign in to comment.