diff --git a/src/app/shared/comcol/sections/comcol-search-section/comcol-search-section.component.html b/src/app/shared/comcol/sections/comcol-search-section/comcol-search-section.component.html index 6cbae34616..9922857eee 100644 --- a/src/app/shared/comcol/sections/comcol-search-section/comcol-search-section.component.html +++ b/src/app/shared/comcol/sections/comcol-search-section/comcol-search-section.component.html @@ -1,4 +1,5 @@ diff --git a/src/app/shared/search-form/search-form.component.ts b/src/app/shared/search-form/search-form.component.ts index 151ded6f9e..c9aa003486 100644 --- a/src/app/shared/search-form/search-form.component.ts +++ b/src/app/shared/search-form/search-form.component.ts @@ -1,7 +1,7 @@ import { Component, EventEmitter, Input, Output, OnChanges } from '@angular/core'; import { DSpaceObject } from '../../core/shared/dspace-object.model'; import { Router } from '@angular/router'; -import { isNotEmpty } from '../empty.util'; +import { isNotEmpty, hasValue } from '../empty.util'; import { SearchService } from '../../core/shared/search/search.service'; import { currentPath } from '../utils/route.utils'; import { PaginationService } from '../../core/pagination/pagination.service'; @@ -39,6 +39,11 @@ export class SearchFormComponent implements OnChanges { @Input() scope = ''; + /** + * Hides the scope in the url, this can be useful when you hardcode the scope in another way + */ + @Input() hideScopeInUrl = false; + selectedScope: BehaviorSubject = new BehaviorSubject(undefined); @Input() currentUrl: string; @@ -115,6 +120,9 @@ export class SearchFormComponent implements OnChanges { */ updateSearch(data: any) { const queryParams = Object.assign({}, data); + if (hasValue(data.scope) && this.hideScopeInUrl) { + delete queryParams.scope; + } void this.router.navigate(this.getSearchLinkParts(), { queryParams: queryParams, diff --git a/src/app/shared/search-form/themed-search-form.component.ts b/src/app/shared/search-form/themed-search-form.component.ts index 50b3751b06..83c396b2f9 100644 --- a/src/app/shared/search-form/themed-search-form.component.ts +++ b/src/app/shared/search-form/themed-search-form.component.ts @@ -18,6 +18,8 @@ export class ThemedSearchFormComponent extends ThemedComponent = new EventEmitter(); protected inAndOutputNames: (keyof SearchFormComponent & keyof this)[] = [ - 'query', 'inPlaceSearch', 'scope', 'currentUrl', 'large', 'brandColor', 'searchPlaceholder', 'showScopeSelector', + 'query', + 'inPlaceSearch', + 'scope', + 'hideScopeInUrl', + 'currentUrl', + 'large', + 'brandColor', + 'searchPlaceholder', + 'showScopeSelector', 'submitSearch', ]; diff --git a/src/app/shared/search/search.component.html b/src/app/shared/search/search.component.html index d43f506866..9c94b9e4c9 100644 --- a/src/app/shared/search/search.component.html +++ b/src/app/shared/search/search.component.html @@ -84,6 +84,7 @@ { 'trackStatistics', 'query', 'scope', + 'hideScopeInUrl', 'resultFound', 'deselectObject', 'selectObject', @@ -93,6 +94,8 @@ export class ThemedSearchComponent extends ThemedComponent { @Input() scope: string; + @Input() hideScopeInUrl: boolean; + @Output() resultFound: EventEmitter> = new EventEmitter(); @Output() deselectObject: EventEmitter = new EventEmitter();