Skip to content

Commit

Permalink
Change institution default filters by object type
Browse files Browse the repository at this point in the history
  • Loading branch information
futa-ikeda committed Oct 2, 2023
1 parent f99e17e commit fd6bed1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
14 changes: 13 additions & 1 deletion app/institutions/discover/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,20 @@ export default class InstitutionDiscoverController extends Controller {

get defaultQueryOptions() {
const identifiers = this.model.iris.join(',');
let key = 'affiliation';
const { resourceType } = this;
switch (resourceType) {
case ResourceTypeFilterValue.Preprints:
key = 'creator.affiliation';
break;
case ResourceTypeFilterValue.Files:
key = 'isContainedby.affiliation';
break;
default:
break;
}
return {
'affiliation,creator.affiliation,isContainedby.affiliation': identifiers,
[key]: identifiers,
};
}

Expand Down
6 changes: 3 additions & 3 deletions lib/osf-components/addon/components/search-page/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ export default class SearchPage extends Component<SearchArgs> {
try {
const cardSearchText = this.cardSearchText;
const { page, sort, activeFilters, resourceType } = this;
if (this.args.onSearch) {
this.args.onSearch({cardSearchText, sort, resourceType, activeFilters});
}
let filterQueryObject = activeFilters.reduce((acc, filter) => {
// boolean filters should look like cardSearchFilter[hasDataResource][is-present]
if (filter.suggestedFilterOperator === SuggestedFilterOperators.IsPresent) {
Expand Down Expand Up @@ -246,9 +249,6 @@ export default class SearchPage extends Component<SearchArgs> {
this.searchResults = searchResult.searchResultPage.toArray();
this.totalResultCount = searchResult.totalResultCount === ShareMoreThanTenThousand ? '10,000+' :
searchResult.totalResultCount;
if (this.args.onSearch) {
this.args.onSearch({cardSearchText, sort, resourceType, activeFilters});
}
} catch (e) {
this.toast.error(e);
}
Expand Down

0 comments on commit fd6bed1

Please sign in to comment.