Skip to content

Commit

Permalink
Move boolean filters into group (#2399)
Browse files Browse the repository at this point in the history
  • Loading branch information
futa-ikeda authored Nov 18, 2024
1 parent 46ea031 commit fe98821
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@ as |list|>
@toggleFilter={{queue this.toggleFilter (perform list.searchObjectsTask)}}
/>
{{/each}}
{{#if list.booleanFilters.length}}
<SearchPage::BooleanFilters
@cardSearchText={{this.cardSearchText}}
@cardSearchFilter={{this.valueSearchQueryOptions}}
@properties={{list.booleanFilters}}
@toggleFilter={{queue this.toggleFilter (perform list.searchObjectsTask)}}
/>
{{/if}}
</wrapper.right>
{{/if}}
</Institutions::Dashboard::-Components::InstitutionalDashboardWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Toast from 'ember-toastr/services/toast';

import SearchResultModel from 'ember-osf-web/models/search-result';
import { taskFor } from 'ember-concurrency-ts';
import RelatedPropertyPathModel from 'ember-osf-web/models/related-property-path';
import RelatedPropertyPathModel, { SuggestedFilterOperators } from 'ember-osf-web/models/related-property-path';

interface IndexCardSearcherArgs {
queryOptions: Record<string, any>;
Expand All @@ -25,6 +25,7 @@ export default class IndexCardSearcher extends Component<IndexCardSearcherArgs>
@tracked totalResultCount = 0;

@tracked relatedProperties?: RelatedPropertyPathModel[] = [];
@tracked booleanFilters?: RelatedPropertyPathModel[] = [];

@tracked firstPageCursor?: string;
@tracked nextPageCursor?: string;
Expand Down Expand Up @@ -57,7 +58,12 @@ export default class IndexCardSearcher extends Component<IndexCardSearcherArgs>
try {
const searchResult = await this.store.queryRecord('index-card-search', this.args.queryOptions);

this.relatedProperties = await searchResult.relatedProperties;
this.booleanFilters = searchResult.relatedProperties
.filterBy('suggestedFilterOperator', SuggestedFilterOperators.IsPresent);
this.relatedProperties = searchResult.relatedProperties.filter(
(property: RelatedPropertyPathModel) =>
property.suggestedFilterOperator !== SuggestedFilterOperators.IsPresent, // AnyOf or AtDate
);
this.firstPageCursor = searchResult.firstPageCursor;
this.nextPageCursor = searchResult.nextPageCursor;
this.prevPageCursor = searchResult.prevPageCursor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{yield (hash
searchResults=this.searchResults
relatedProperties=this.relatedProperties
booleanFilters=this.booleanFilters
totalResultCount=this.totalResultCount

debouceSearchObjectsTask=this.debouceSearchObjectsTask
Expand Down

0 comments on commit fe98821

Please sign in to comment.