mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 05:23:06 +00:00
54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
import { Component, Input } from '@angular/core';
|
|
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
|
import { Router } from '@angular/router';
|
|
import { isNotEmpty, hasValue, isEmpty } from '../empty.util';
|
|
|
|
/**
|
|
* This component renders a simple item page.
|
|
* The route parameter 'id' is used to request the item it represents.
|
|
* All fields of the item that should be displayed, are defined in its template.
|
|
*/
|
|
|
|
@Component({
|
|
selector: 'ds-search-form',
|
|
styleUrls: ['./search-form.component.scss'],
|
|
templateUrl: './search-form.component.html'
|
|
})
|
|
export class SearchFormComponent {
|
|
@Input() query: string;
|
|
selectedId = '';
|
|
// Optional existing search parameters
|
|
@Input() currentParams: {};
|
|
@Input() scopes: DSpaceObject[];
|
|
|
|
@Input()
|
|
set scope(id: string) {
|
|
this.selectedId = id;
|
|
}
|
|
|
|
constructor(private router: Router) {
|
|
}
|
|
|
|
onSubmit(data: any) {
|
|
this.updateSearch(data);
|
|
}
|
|
|
|
updateSearch(data: any) {
|
|
this.router.navigate(['/search'], {
|
|
queryParams: Object.assign({}, this.currentParams,
|
|
{
|
|
query: data.query,
|
|
scope: data.scope || undefined,
|
|
page: data.page || 1
|
|
}
|
|
)
|
|
})
|
|
;
|
|
}
|
|
|
|
isNotEmpty(object: any) {
|
|
return isNotEmpty(object);
|
|
}
|
|
|
|
}
|