mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +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;
|
@Input() fixedFilterQuery: string;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to show the scope selection dropdown
|
||||||
|
*/
|
||||||
|
@Input() scopeSelectable = true;
|
||||||
|
|
||||||
constructor(protected service: SearchService,
|
constructor(protected service: SearchService,
|
||||||
protected sidebarService: SidebarService,
|
protected sidebarService: SidebarService,
|
||||||
protected windowService: HostWindowService,
|
protected windowService: HostWindowService,
|
||||||
|
@@ -45,6 +45,7 @@
|
|||||||
<ng-template #searchForm>
|
<ng-template #searchForm>
|
||||||
<ds-search-form *ngIf="searchEnabled" id="search-form"
|
<ds-search-form *ngIf="searchEnabled" id="search-form"
|
||||||
[query]="(searchOptions$ | async)?.query"
|
[query]="(searchOptions$ | async)?.query"
|
||||||
|
[scopeSelectable]="scopeSelectable"
|
||||||
[scope]="(searchOptions$ | async)?.scope"
|
[scope]="(searchOptions$ | async)?.scope"
|
||||||
[currentUrl]="searchLink"
|
[currentUrl]="searchLink"
|
||||||
[scopes]="(scopeListRD$ | async)"
|
[scopes]="(scopeListRD$ | async)"
|
||||||
|
@@ -99,6 +99,11 @@ export class SearchComponent implements OnInit {
|
|||||||
@Input()
|
@Input()
|
||||||
context: Context;
|
context: Context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to show the scope selection dropdown
|
||||||
|
*/
|
||||||
|
@Input() scopeSelectable = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Link to the search page
|
* Link to the search page
|
||||||
*/
|
*/
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
<form #form="ngForm" (ngSubmit)="onSubmit(form.value)" class="row" action="/search">
|
<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">
|
<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 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>
|
<option *ngFor="let scopeOption of scopes" [value]="scopeOption.id">{{scopeOption?.name ? scopeOption.name : 'search.form.search_dspace' | translate}}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</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">
|
<div class="form-group input-group">
|
||||||
<input type="text" [(ngModel)]="query" name="query" class="form-control" attr.aria-label="{{ searchPlaceholder }}"
|
<input type="text" [(ngModel)]="query" name="query" class="form-control" attr.aria-label="{{ searchPlaceholder }}"
|
||||||
[placeholder]="searchPlaceholder">
|
[placeholder]="searchPlaceholder">
|
||||||
|
@@ -72,6 +72,16 @@ describe('SearchFormComponent', () => {
|
|||||||
expect(select).toBeNull();
|
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(() => {
|
it('should display set query value in input field', fakeAsync(() => {
|
||||||
const testString = 'This is a test query';
|
const testString = 'This is a test query';
|
||||||
comp.query = testString;
|
comp.query = testString;
|
||||||
|
@@ -66,6 +66,11 @@ export class SearchFormComponent {
|
|||||||
*/
|
*/
|
||||||
@Output() submitSearch = new EventEmitter<any>();
|
@Output() submitSearch = new EventEmitter<any>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to show the scope selection dropdown
|
||||||
|
*/
|
||||||
|
@Input() scopeSelectable = true;
|
||||||
|
|
||||||
constructor(private router: Router, private searchService: SearchService,
|
constructor(private router: Router, private searchService: SearchService,
|
||||||
private paginationService: PaginationService,
|
private paginationService: PaginationService,
|
||||||
private searchConfig: SearchConfigurationService
|
private searchConfig: SearchConfigurationService
|
||||||
|
Reference in New Issue
Block a user