110889: Remove the scope query parameter from the search on comcol pages

This commit is contained in:
Alexandre Vryghem
2024-02-15 23:18:47 +01:00
parent 0e2630d729
commit 0bee02a501
6 changed files with 30 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
<ds-themed-search
[showScopeSelector]="false"
[hideScopeInUrl]="true"
[scope]="(comcol$ | async)?.id">
</ds-themed-search>

View File

@@ -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<DSpaceObject> = new BehaviorSubject<DSpaceObject>(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,

View File

@@ -18,6 +18,8 @@ export class ThemedSearchFormComponent extends ThemedComponent<SearchFormCompone
@Input() scope: string;
@Input() hideScopeInUrl: boolean;
@Input() currentUrl: string;
@Input() large: boolean;
@@ -31,7 +33,15 @@ export class ThemedSearchFormComponent extends ThemedComponent<SearchFormCompone
@Output() submitSearch: EventEmitter<any> = 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',
];

View File

@@ -84,6 +84,7 @@
<ds-themed-search-form *ngIf="searchEnabled" id="search-form"
[query]="(searchOptions$ | async)?.query"
[scope]="(searchOptions$ | async)?.scope"
[hideScopeInUrl]="hideScopeInUrl"
[currentUrl]="searchLink"
[showScopeSelector]="showScopeSelector"
[inPlaceSearch]="inPlaceSearch"

View File

@@ -171,6 +171,11 @@ export class SearchComponent implements OnDestroy, OnInit {
*/
@Input() scope: string;
/**
* Hides the scope in the url, this can be useful when you hardcode the scope in another way
*/
@Input() hideScopeInUrl: boolean;
/**
* The current configuration used during the search
*/

View File

@@ -42,6 +42,7 @@ export class ThemedSearchComponent extends ThemedComponent<SearchComponent> {
'trackStatistics',
'query',
'scope',
'hideScopeInUrl',
'resultFound',
'deselectObject',
'selectObject',
@@ -93,6 +94,8 @@ export class ThemedSearchComponent extends ThemedComponent<SearchComponent> {
@Input() scope: string;
@Input() hideScopeInUrl: boolean;
@Output() resultFound: EventEmitter<SearchObjects<DSpaceObject>> = new EventEmitter();
@Output() deselectObject: EventEmitter<ListableObject> = new EventEmitter();