From 14b1fd463dd6930586d0fc5f5dad321afe0c8f49 Mon Sep 17 00:00:00 2001 From: Yura Date: Wed, 20 Oct 2021 11:27:55 +0200 Subject: [PATCH] 84367: SearchForm/SearchComponent: add option to hide scope selection dropdown --- .../search-page/configuration-search-page.component.ts | 6 ++++++ src/app/search-page/search.component.html | 1 + src/app/search-page/search.component.ts | 5 +++++ src/app/shared/search-form/search-form.component.html | 4 ++-- .../shared/search-form/search-form.component.spec.ts | 10 ++++++++++ src/app/shared/search-form/search-form.component.ts | 5 +++++ 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/app/search-page/configuration-search-page.component.ts b/src/app/search-page/configuration-search-page.component.ts index 1eefeeb569..5ba318b850 100644 --- a/src/app/search-page/configuration-search-page.component.ts +++ b/src/app/search-page/configuration-search-page.component.ts @@ -47,6 +47,12 @@ export class ConfigurationSearchPageComponent extends SearchComponent implements */ @Input() fixedFilterQuery: string; + + /** + * Whether to show the scope selection dropdown + */ + @Input() scopeSelectable = true; + constructor(protected service: SearchService, protected sidebarService: SidebarService, protected windowService: HostWindowService, diff --git a/src/app/search-page/search.component.html b/src/app/search-page/search.component.html index d8aa25e4a3..499f652200 100644 --- a/src/app/search-page/search.component.html +++ b/src/app/search-page/search.component.html @@ -45,6 +45,7 @@ -
+
-
+
diff --git a/src/app/shared/search-form/search-form.component.spec.ts b/src/app/shared/search-form/search-form.component.spec.ts index 1469eac566..bbaee5709d 100644 --- a/src/app/shared/search-form/search-form.component.spec.ts +++ b/src/app/shared/search-form/search-form.component.spec.ts @@ -72,6 +72,16 @@ describe('SearchFormComponent', () => { expect(select).toBeNull(); }); + it('should not display scopes when scopeSelectable is false', () => { + comp.scopeSelectable = false; + comp.scopes = objects; + comp.scope = objects[1].id; + + fixture.detectChanges(); + const select = de.query(By.css('select')); + expect(select).toBeNull(); + }); + it('should display set query value in input field', fakeAsync(() => { const testString = 'This is a test query'; comp.query = testString; diff --git a/src/app/shared/search-form/search-form.component.ts b/src/app/shared/search-form/search-form.component.ts index 2791aee378..1cf3c11913 100644 --- a/src/app/shared/search-form/search-form.component.ts +++ b/src/app/shared/search-form/search-form.component.ts @@ -66,6 +66,11 @@ export class SearchFormComponent { */ @Output() submitSearch = new EventEmitter(); + /** + * Whether to show the scope selection dropdown + */ + @Input() scopeSelectable = true; + constructor(private router: Router, private searchService: SearchService, private paginationService: PaginationService, private searchConfig: SearchConfigurationService