diff --git a/app/institutions/discover/controller.ts b/app/institutions/discover/controller.ts index 477f7a36e51..7f52f572a19 100644 --- a/app/institutions/discover/controller.ts +++ b/app/institutions/discover/controller.ts @@ -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, }; } diff --git a/lib/osf-components/addon/components/search-page/component.ts b/lib/osf-components/addon/components/search-page/component.ts index 87e0baf87b6..59e37fa09ed 100644 --- a/lib/osf-components/addon/components/search-page/component.ts +++ b/lib/osf-components/addon/components/search-page/component.ts @@ -206,6 +206,9 @@ export default class SearchPage extends Component { 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) { @@ -246,9 +249,6 @@ export default class SearchPage extends Component { 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); }