Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement boolean filters correctly #2402

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading