mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
84367: SearchForm/SearchComponent: add option to hide scope selection dropdown
This commit is contained in:
@@ -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,
|
||||
|
@@ -45,6 +45,7 @@
|
||||
<ng-template #searchForm>
|
||||
<ds-search-form *ngIf="searchEnabled" id="search-form"
|
||||
[query]="(searchOptions$ | async)?.query"
|
||||
[scopeSelectable]="scopeSelectable"
|
||||
[scope]="(searchOptions$ | async)?.scope"
|
||||
[currentUrl]="searchLink"
|
||||
[scopes]="(scopeListRD$ | async)"
|
||||
|
@@ -99,6 +99,11 @@ export class SearchComponent implements OnInit {
|
||||
@Input()
|
||||
context: Context;
|
||||
|
||||
/**
|
||||
* Whether to show the scope selection dropdown
|
||||
*/
|
||||
@Input() scopeSelectable = true;
|
||||
|
||||
/**
|
||||
* Link to the search page
|
||||
*/
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<form #form="ngForm" (ngSubmit)="onSubmit(form.value)" class="row" action="/search">
|
||||
<div *ngIf="isNotEmpty(scopes)" class="col-12 col-sm-3">
|
||||
<div *ngIf="scopeSelectable && isNotEmpty(scopes)" class="col-12 col-sm-3">
|
||||
<select [(ngModel)]="scope" name="scope" class="form-control" aria-label="Search scope" (change)="onScopeChange($event.target.value)" tabindex="0">
|
||||
<option value>{{'search.form.search_dspace' | translate}}</option>
|
||||
<option *ngFor="let scopeOption of scopes" [value]="scopeOption.id">{{scopeOption?.name ? scopeOption.name : 'search.form.search_dspace' | translate}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div [ngClass]="{'col-sm-9': isNotEmpty(scopes)}" class="col-12">
|
||||
<div [ngClass]="{'col-sm-9': (scopeSelectable && isNotEmpty(scopes))}" class="col-12">
|
||||
<div class="form-group input-group">
|
||||
<input type="text" [(ngModel)]="query" name="query" class="form-control" attr.aria-label="{{ searchPlaceholder }}"
|
||||
[placeholder]="searchPlaceholder">
|
||||
|
@@ -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;
|
||||
|
@@ -66,6 +66,11 @@ export class SearchFormComponent {
|
||||
*/
|
||||
@Output() submitSearch = new EventEmitter<any>();
|
||||
|
||||
/**
|
||||
* Whether to show the scope selection dropdown
|
||||
*/
|
||||
@Input() scopeSelectable = true;
|
||||
|
||||
constructor(private router: Router, private searchService: SearchService,
|
||||
private paginationService: PaginationService,
|
||||
private searchConfig: SearchConfigurationService
|
||||
|
Reference in New Issue
Block a user