changed the scope to activate on change instead of on form submit

This commit is contained in:
Art Lowel
2018-07-19 11:49:32 +02:00
parent 6deac6b021
commit d845a7e902
3 changed files with 9 additions and 7 deletions

View File

@@ -63,7 +63,9 @@ export class SearchPageComponent implements OnInit {
);
this.scopeListRD$ = this.filterService.getCurrentScope().pipe(
flatMap((scopeId) => this.service.getScopes(scopeId))
)
);
this.resultsRD$.subscribe((v) => console.log('this.resultsRD$', v.state));
}
public closeSidebar(): void {

View File

@@ -1,6 +1,6 @@
<form #form="ngForm" (ngSubmit)="onSubmit(form.value)" class="row" action="/search">
<div *ngIf="isNotEmpty(scopes)" class="col-12 col-sm-3">
<select [(ngModel)]="selectedId" name="scope" class="form-control" aria-label="Search scope">
<select [(ngModel)]="selectedId" name="scope" class="form-control" aria-label="Search scope" (change)="onScopeChange($event.target.value)">
<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>

View File

@@ -33,14 +33,14 @@ export class SearchFormComponent {
this.updateSearch(data);
}
onScopeChange(scope: string) {
this.updateSearch({ scope });
}
updateSearch(data: any) {
const newUrl = hasValue(this.currentUrl) ? this.currentUrl : 'search';
this.router.navigate([newUrl], {
queryParams: {
query: data.query,
scope: data.scope || undefined,
page: data.page || 1
},
queryParams: Object.assign({}, { page: 1 }, data),
queryParamsHandling: 'merge'
});
}