fixed a few sorting, rpp and view persistence issues with grid view

This commit is contained in:
Art Lowel
2018-04-26 10:57:12 +02:00
parent 545145a759
commit 994c089925
23 changed files with 208 additions and 96 deletions

View File

@@ -4,5 +4,6 @@
"config", "config",
"src/index.html" "src/index.html"
], ],
"ext": "js ts json html" "ext": "js ts json html",
"delay": "500"
} }

View File

@@ -28,14 +28,13 @@ export class SearchFilterComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
const sub = this.filterService.isFilterActive(this.filter.paramName).first().subscribe((isActive) => { this.filterService.isFilterActive(this.filter.paramName).first().subscribe((isActive) => {
if (this.filter.isOpenByDefault || isActive) { if (this.filter.isOpenByDefault || isActive) {
this.initialExpand(); this.initialExpand();
} else { } else {
this.initialCollapse(); this.initialCollapse();
} }
}); });
sub.unsubscribe();
} }
toggle() { toggle() {

View File

@@ -1,4 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { debounceTime, distinctUntilChanged, map } from 'rxjs/operators';
import { SearchFiltersState, SearchFilterState } from './search-filter.reducer'; import { SearchFiltersState, SearchFilterState } from './search-filter.reducer';
import { createSelector, MemoizedSelector, Store } from '@ngrx/store'; import { createSelector, MemoizedSelector, Store } from '@ngrx/store';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
@@ -79,8 +80,9 @@ export class SearchFilterService {
this.getCurrentView(), this.getCurrentView(),
this.getCurrentScope(), this.getCurrentScope(),
this.getCurrentQuery(), this.getCurrentQuery(),
this.getCurrentFilters(), this.getCurrentFilters()).pipe(
(pagination, sort, view, scope, query, filters) => { distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)),
map(([pagination, sort, view, scope, query, filters]) => {
return Object.assign(new PaginatedSearchOptions(), return Object.assign(new PaginatedSearchOptions(),
defaults, defaults,
{ {
@@ -91,7 +93,7 @@ export class SearchFilterService {
query: query, query: query,
filters: filters filters: filters
}) })
} })
) )
} }

View File

@@ -23,6 +23,8 @@ export class SearchFiltersComponent {
constructor(private searchService: SearchService, private filterService: SearchFilterService) { constructor(private searchService: SearchService, private filterService: SearchFilterService) {
this.filters = searchService.getConfig(); this.filters = searchService.getConfig();
this.clearParams = filterService.getCurrentFilters().map((filters) => {Object.keys(filters).forEach((f) => filters[f] = null); return filters;}); this.clearParams = filterService.getCurrentFilters().map((filters) => {Object.keys(filters).forEach((f) => filters[f] = null); return filters;});
this.filters.subscribe((v) => console.log('this.filters', v));
} }
getSearchLink() { getSearchLink() {

View File

@@ -7,7 +7,7 @@
<ds-search-form id="search-form" <ds-search-form id="search-form"
[query]="(searchOptions$ | async)?.query" [query]="(searchOptions$ | async)?.query"
[scope]="(searchOptions$ | async)?.scope" [scope]="(searchOptions$ | async)?.scope"
[currentParams]="currentParams" [currentUrl]="service.getSearchLink()"
[scopes]="(scopeListRD$ | async)?.payload?.page"> [scopes]="(scopeListRD$ | async)?.payload?.page">
</ds-search-form> </ds-search-form>
<div class="row"> <div class="row">

View File

@@ -38,7 +38,8 @@ describe('SearchPageComponent', () => {
const sort: SortOptions = new SortOptions(); const sort: SortOptions = new SortOptions();
const mockResults = Observable.of(['test', 'data']); const mockResults = Observable.of(['test', 'data']);
const searchServiceStub = jasmine.createSpyObj('SearchService', { const searchServiceStub = jasmine.createSpyObj('SearchService', {
search: mockResults search: mockResults,
getSearchLink: '/search'
}); });
const queryParam = 'test query'; const queryParam = 'test query';
const scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f'; const scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f';

View File

@@ -31,7 +31,6 @@ import { SearchSidebarService } from './search-sidebar/search-sidebar.service';
export class SearchPageComponent implements OnInit { export class SearchPageComponent implements OnInit {
resultsRD$: Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>>; resultsRD$: Observable<RemoteData<PaginatedList<SearchResult<DSpaceObject>>>>;
currentParams = {};
searchOptions$: Observable<PaginatedSearchOptions>; searchOptions$: Observable<PaginatedSearchOptions>;
sortConfig: SortOptions; sortConfig: SortOptions;
scopeListRD$: Observable<RemoteData<PaginatedList<Community>>>; scopeListRD$: Observable<RemoteData<PaginatedList<Community>>>;

View File

@@ -1,5 +1,6 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { CoreModule } from '../core/core.module';
import { SharedModule } from '../shared/shared.module'; import { SharedModule } from '../shared/shared.module';
import { SearchPageRoutingModule } from './search-page-routing.module'; import { SearchPageRoutingModule } from './search-page-routing.module';
import { SearchPageComponent } from './search-page.component'; import { SearchPageComponent } from './search-page.component';
@@ -31,6 +32,7 @@ const effects = [
CommonModule, CommonModule,
SharedModule, SharedModule,
EffectsModule.forFeature(effects), EffectsModule.forFeature(effects),
CoreModule.forRoot()
], ],
declarations: [ declarations: [
SearchPageComponent, SearchPageComponent,

View File

@@ -1,5 +1,5 @@
<h2>{{ 'search.results.head' | translate }}</h2> <h2>{{ 'search.results.head' | translate }}</h2>
<div *ngIf="searchResults?.hasSucceeded && !searchResults?.isLoading" @fadeIn> <div *ngIf="searchResults?.hasSucceeded && !searchResults?.isLoading && searchResults?.payload?.page.length > 0" @fadeIn>
<ds-viewable-collection <ds-viewable-collection
[config]="searchConfig.pagination" [config]="searchConfig.pagination"
[sortConfig]="searchConfig.sort" [sortConfig]="searchConfig.sort"

View File

@@ -167,7 +167,8 @@ export class SearchService implements OnDestroy {
// get search results from response cache // get search results from response cache
const facetConfigObs: Observable<SearchFilterConfig[]> = responseCacheObs.pipe( const facetConfigObs: Observable<SearchFilterConfig[]> = responseCacheObs.pipe(
map((entry: ResponseCacheEntry) => entry.response), map((entry: ResponseCacheEntry) => entry.response),
map((response: FacetConfigSuccessResponse) => response.results) map((response: FacetConfigSuccessResponse) =>
response.results.map((result: any) => Object.assign(new SearchFilterConfig(), result)))
); );
return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, facetConfigObs); return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, facetConfigObs);

View File

@@ -22,8 +22,6 @@ export class SearchSettingsComponent implements OnInit {
*/ */
public pageSize; public pageSize;
@Input() public pageSizeOptions; @Input() public pageSizeOptions;
public listPageSizeOptions: number[] = [5, 10, 20, 40, 60, 80, 100];
public gridPageSizeOptions: number[] = [12, 24, 36, 48 , 50, 62, 74, 84];
private sub; private sub;
private scope: string; private scope: string;
@@ -51,9 +49,9 @@ export class SearchSettingsComponent implements OnInit {
this.pageSize = +params.pageSize || this.searchOptions.pagination.pageSize; this.pageSize = +params.pageSize || this.searchOptions.pagination.pageSize;
this.direction = params.sortDirection || this.searchOptions.sort.direction; this.direction = params.sortDirection || this.searchOptions.sort.direction;
if (params.view === ViewMode.Grid) { if (params.view === ViewMode.Grid) {
this.pageSizeOptions = this.gridPageSizeOptions; this.pageSizeOptions = this.pageSizeOptions;
} else { } else {
this.pageSizeOptions = this.listPageSizeOptions; this.pageSizeOptions = this.pageSizeOptions;
} }
}); });
} }

View File

@@ -1,3 +1,4 @@
import { distinctUntilChanged, map } from 'rxjs/operators';
import { HostWindowState } from './host-window.reducer'; import { HostWindowState } from './host-window.reducer';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { createSelector, Store } from '@ngrx/store'; import { createSelector, Store } from '@ngrx/store';
@@ -8,11 +9,18 @@ import { AppState } from '../app.reducer';
// TODO: ideally we should get these from sass somehow // TODO: ideally we should get these from sass somehow
export enum GridBreakpoint { export enum GridBreakpoint {
XS = 0, SM_MIN = 576,
SM = 576, MD_MIN = 768,
MD = 768, LG_MIN = 992,
LG = 992, XL_MIN = 1200
XL = 1200 }
export enum WidthCategory {
XS,
SM,
MD,
LG,
XL
} }
const hostWindowStateSelector = (state: AppState) => state.hostWindow; const hostWindowStateSelector = (state: AppState) => state.hostWindow;
@@ -31,33 +39,57 @@ export class HostWindowService {
.filter((width) => hasValue(width)); .filter((width) => hasValue(width));
} }
get widthCategory(): Observable<WidthCategory> {
return this.getWidthObs().pipe(
map((width: number) => {
if (width < GridBreakpoint.SM_MIN) {
return WidthCategory.XS
} else if (width >= GridBreakpoint.SM_MIN && width < GridBreakpoint.MD_MIN) {
return WidthCategory.SM
} else if (width >= GridBreakpoint.MD_MIN && width < GridBreakpoint.LG_MIN) {
return WidthCategory.MD
} else if (width >= GridBreakpoint.LG_MIN && width < GridBreakpoint.XL_MIN) {
return WidthCategory.LG
} else {
return WidthCategory.XL
}
}),
distinctUntilChanged()
);
}
isXs(): Observable<boolean> { isXs(): Observable<boolean> {
return this.getWidthObs() return this.widthCategory.pipe(
.map((width) => width < GridBreakpoint.SM) map((widthCat: WidthCategory) => widthCat === WidthCategory.XS),
.distinctUntilChanged(); distinctUntilChanged()
);
} }
isSm(): Observable<boolean> { isSm(): Observable<boolean> {
return this.getWidthObs() return this.widthCategory.pipe(
.map((width) => width >= GridBreakpoint.SM && width < GridBreakpoint.MD) map((widthCat: WidthCategory) => widthCat === WidthCategory.SM),
.distinctUntilChanged(); distinctUntilChanged()
);
} }
isMd(): Observable<boolean> { isMd(): Observable<boolean> {
return this.getWidthObs() return this.widthCategory.pipe(
.map((width) => width >= GridBreakpoint.MD && width < GridBreakpoint.LG) map((widthCat: WidthCategory) => widthCat === WidthCategory.MD),
.distinctUntilChanged(); distinctUntilChanged()
);
} }
isLg(): Observable<boolean> { isLg(): Observable<boolean> {
return this.getWidthObs() return this.widthCategory.pipe(
.map((width) => width >= GridBreakpoint.LG && width < GridBreakpoint.XL) map((widthCat: WidthCategory) => widthCat === WidthCategory.LG),
.distinctUntilChanged(); distinctUntilChanged()
);
} }
isXl(): Observable<boolean> { isXl(): Observable<boolean> {
return this.getWidthObs() return this.widthCategory.pipe(
.map((width) => width >= GridBreakpoint.XL) map((widthCat: WidthCategory) => widthCat === WidthCategory.XL),
.distinctUntilChanged(); distinctUntilChanged()
);
} }
} }

View File

@@ -1,13 +1,13 @@
<div class="card"> <div class="card">
<a [routerLink]="['/collections/' + object.id]"class="card-img-top"> <a [routerLink]="['/collections/', object.id]" class="card-img-top">
<ds-comcol-page-logo [logo]="object.logo"> <ds-grid-thumbnail [thumbnail]="object.logo">
</ds-comcol-page-logo> </ds-grid-thumbnail>
</a> </a>
<div class="card-body"> <div class="card-body">
<h4 class="card-title">{{object.name}}</h4> <h4 class="card-title">{{object.name}}</h4>
<p *ngIf="object.shortDescription" class="card-text">{{object.shortDescription}}</p> <p *ngIf="object.shortDescription" class="card-text">{{object.shortDescription}}</p>
<div class="text-center"> <div class="text-center">
<a [routerLink]="['/collections/' + object.id]" class="lead btn btn-primary viewButton">View</a> <a [routerLink]="['/collections/', object.id]" class="lead btn btn-primary viewButton">View</a>
</div> </div>
</div> </div>

View File

@@ -1,14 +1,14 @@
<div class="card"> <div class="card">
<a [routerLink]="['/communities/' + object.id]"class="card-img-top"> <a [routerLink]="['/communities/', object.id]" class="card-img-top">
<ds-comcol-page-logo [logo]="object.logo"> <ds-grid-thumbnail [thumbnail]="object.logo">
</ds-comcol-page-logo> </ds-grid-thumbnail>
</a> </a>
<div class="card-body"> <div class="card-body">
<h4 class="card-title">{{object.name}}</h4> <h4 class="card-title">{{object.name}}</h4>
<p *ngIf="object.shortDescription" class="card-text">{{object.shortDescription}}</p> <p *ngIf="object.shortDescription" class="card-text">{{object.shortDescription}}</p>
<div class="text-center"> <div class="text-center">
<a [routerLink]="['/communities/' + object.id]" class="lead btn btn-primary viewButton">View</a> <a [routerLink]="['/communities/', object.id]" class="lead btn btn-primary viewButton">View</a>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -1,6 +1,6 @@
<div class="card"> <div class="card">
<a [routerLink]="['/items/' + object.id]" class="card-img-top"> <a [routerLink]="['/items/', object.id]" class="card-img-top">
<ds-grid-thumbnail [thumbnail]="object.getThumbnail()"> <ds-grid-thumbnail [thumbnail]="object.getThumbnail()">
</ds-grid-thumbnail> </ds-grid-thumbnail>
</a> </a>
@@ -16,7 +16,7 @@
<p *ngIf="object.findMetadata('dc.description.abstract')" class="item-abstract card-text">{{object.findMetadata("dc.description.abstract") | dsTruncate:[200] }}</p> <p *ngIf="object.findMetadata('dc.description.abstract')" class="item-abstract card-text">{{object.findMetadata("dc.description.abstract") | dsTruncate:[200] }}</p>
<div class="text-center"> <div class="text-center">
<a [routerLink]="['/items/' + object.id]" class="lead btn btn-primary viewButton">View</a> <a [routerLink]="['/items/', object.id]" class="lead btn btn-primary viewButton">View</a>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -10,12 +10,14 @@
(sortDirectionChange)="onSortDirectionChange($event)" (sortDirectionChange)="onSortDirectionChange($event)"
(sortFieldChange)="onSortFieldChange($event)" (sortFieldChange)="onSortFieldChange($event)"
(paginationChange)="onPaginationChange($event)"> (paginationChange)="onPaginationChange($event)">
<div class="card-columns" *ngIf="objects?.hasSucceeded" @fadeIn> <div class="card-columns" *ngIf="objects?.hasSucceeded">
<div <div class="card-column" *ngFor="let column of (columns$ | async)" @fadeIn>
*ngFor="let object of objects?.payload?.page"> <div class="card-element" *ngFor="let object of column">
<ds-wrapper-grid-element [object]="object"></ds-wrapper-grid-element> <ds-wrapper-grid-element [object]="object"></ds-wrapper-grid-element>
</div> </div>
</div> </div>
</div>
<ds-error *ngIf="objects.hasFailed | async" message="{{'error.objects' | translate}}"></ds-error> <ds-error *ngIf="objects.hasFailed | async" message="{{'error.objects' | translate}}"></ds-error>
<ds-loading *ngIf="objects.isLoading | async" message="{{'loading.objects' | translate}}"></ds-loading> <ds-loading *ngIf="objects.isLoading | async" message="{{'loading.objects' | translate}}"></ds-loading>
</ds-pagination> </ds-pagination>

View File

@@ -11,14 +11,33 @@ ds-wrapper-grid-element ::ng-deep {
} }
} }
$gutter: ($grid-gutter-width / 2);
$min-width: 300px;
$max-cols: 3;
.card-columns { .card-columns {
@include media-breakpoint-only(lg) { display: flex;
column-count: 3; flex-wrap: wrap;
margin-left: -$gutter;
margin-top: -$gutter;
.card-column {
flex: 1 0 $min-width;
margin-left: $gutter;
margin-top: $gutter;
@for $i from 2 through $max-cols {
$screen-width: ($min-width*$i)+($gutter*$i);
$column-width: (100%/$i);
@media (min-width: $screen-width) {
max-width: calc(#{$column-width} - #{$gutter});
} }
@include media-breakpoint-only(sm) {
column-count: 2;
} }
@include media-breakpoint-only(xs) {
column-count: 1; $column-width: (100%/$max-cols);
@media (min-width: $min-width*$max-cols) {
min-width: calc(#{$column-width} - #{$gutter});
}
} }
} }

View File

@@ -2,16 +2,21 @@ import {
ChangeDetectionStrategy, ChangeDetectionStrategy,
Component, Component,
EventEmitter, EventEmitter,
Input, Input, OnInit,
Output, Output,
ViewEncapsulation ViewEncapsulation
} from '@angular/core'; } from '@angular/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Observable } from 'rxjs/Observable';
import { map } from 'rxjs/operators';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model'; import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { PaginatedList } from '../../core/data/paginated-list'; import { PaginatedList } from '../../core/data/paginated-list';
import { RemoteData } from '../../core/data/remote-data'; import { RemoteData } from '../../core/data/remote-data';
import { fadeIn } from '../animations/fade'; import { fadeIn } from '../animations/fade';
import { hasNoValue, hasValue } from '../empty.util';
import { HostWindowService, WidthCategory } from '../host-window.service';
import { ListableObject } from '../object-collection/shared/listable-object.model'; import { ListableObject } from '../object-collection/shared/listable-object.model';
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model'; import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
@@ -25,18 +30,18 @@ import { PaginationComponentOptions } from '../pagination/pagination-component-o
animations: [fadeIn] animations: [fadeIn]
}) })
export class ObjectGridComponent { export class ObjectGridComponent implements OnInit {
@Input() config: PaginationComponentOptions; @Input() config: PaginationComponentOptions;
@Input() sortConfig: SortOptions; @Input() sortConfig: SortOptions;
@Input() hideGear = false; @Input() hideGear = false;
@Input() hidePagerWhenSinglePage = true; @Input() hidePagerWhenSinglePage = true;
private _objects: RemoteData<PaginatedList<ListableObject>>; private _objects$: BehaviorSubject<RemoteData<PaginatedList<ListableObject>>>;
@Input() set objects(objects: RemoteData<PaginatedList<ListableObject>>) { @Input() set objects(objects: RemoteData<PaginatedList<ListableObject>>) {
this._objects = objects; this._objects$.next(objects);
} }
get objects() { get objects() {
return this._objects; return this._objects$.getValue();
} }
/** /**
@@ -77,6 +82,55 @@ export class ObjectGridComponent {
*/ */
@Output() sortFieldChange: EventEmitter<string> = new EventEmitter<string>(); @Output() sortFieldChange: EventEmitter<string> = new EventEmitter<string>();
data: any = {}; data: any = {};
columns$: Observable<ListableObject[]>
constructor(private hostWindow: HostWindowService) {
this._objects$ = new BehaviorSubject(undefined);
}
ngOnInit(): void {
const nbColumns$ = this.hostWindow.widthCategory.pipe(
map((widthCat: WidthCategory) => {
switch (widthCat) {
case WidthCategory.XL:
case WidthCategory.LG: {
return 3;
}
case WidthCategory.MD:
case WidthCategory.SM: {
return 2;
}
default: {
return 1;
}
}
})
).startWith(3);
this.columns$ = Observable.combineLatest(
nbColumns$,
this._objects$,
(nbColumns, objects) => {
if (hasValue(objects) && hasValue(objects.payload) && hasValue(objects.payload.page)) {
const page = objects.payload.page;
const result = [];
page.forEach((obj: ListableObject, i: number) => {
const colNb = i % nbColumns;
let col = result[colNb];
if (hasNoValue(col)) {
col = [];
}
result[colNb] = [...col, obj];
});
return result;
} else {
return [];
}
});
}
onPageChange(event) { onPageChange(event) {
this.pageChange.emit(event); this.pageChange.emit(event);
} }

View File

@@ -1,13 +1,13 @@
<div class="card"> <div class="card">
<a [routerLink]="['/collections/' + dso.id]"class="card-img-top"> <a [routerLink]="['/collections/', dso.id]" class="card-img-top">
<ds-comcol-page-logo [logo]="dso.logo"> <ds-grid-thumbnail [thumbnail]="dso.logo">
</ds-comcol-page-logo> </ds-grid-thumbnail>
</a> </a>
<div class="card-body"> <div class="card-body">
<h4 class="card-title">{{dso.name}}</h4> <h4 class="card-title">{{dso.name}}</h4>
<p *ngIf="dso.shortDescription" class="card-text">{{dso.shortDescription}}</p> <p *ngIf="dso.shortDescription" class="card-text">{{dso.shortDescription}}</p>
<div class="text-center"> <div class="text-center">
<a [routerLink]="['/collections/' + dso.id]" class="lead btn btn-primary viewButton">View</a> <a [routerLink]="['/collections/', dso.id]" class="lead btn btn-primary viewButton">View</a>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -1,14 +1,14 @@
<div class="card"> <div class="card">
<a [routerLink]="['/communities/' + dso.id]"class="card-img-top"> <a [routerLink]="['/communities/', dso.id]" class="card-img-top">
<ds-comcol-page-logo [logo]="dso.logo"> <ds-grid-thumbnail [thumbnail]="dso.logo">
</ds-comcol-page-logo> </ds-grid-thumbnail>
</a> </a>
<div class="card-body"> <div class="card-body">
<h4 class="card-title">{{dso.name}}</h4> <h4 class="card-title">{{dso.name}}</h4>
<p *ngIf="dso.shortDescription" class="card-text">{{dso.shortDescription}}</p> <p *ngIf="dso.shortDescription" class="card-text">{{dso.shortDescription}}</p>
<div class="text-center"> <div class="text-center">
<a [routerLink]="['/communities/' + dso.id]" class="lead btn btn-primary viewButton">View</a> <a [routerLink]="['/communities/', dso.id]" class="lead btn btn-primary viewButton">View</a>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -2,7 +2,6 @@ import { ComponentFixture, TestBed, async, tick, fakeAsync } from '@angular/core
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core'; import { DebugElement } from '@angular/core';
import { SearchFormComponent } from './search-form.component'; import { SearchFormComponent } from './search-form.component';
import { Observable } from 'rxjs/Observable';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { ResourceType } from '../../core/shared/resource-type'; import { ResourceType } from '../../core/shared/resource-type';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';

View File

@@ -1,4 +1,5 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { SearchService } from '../../+search-page/search-service/search.service';
import { DSpaceObject } from '../../core/shared/dspace-object.model'; import { DSpaceObject } from '../../core/shared/dspace-object.model';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { isNotEmpty, hasValue, isEmpty } from '../empty.util'; import { isNotEmpty, hasValue, isEmpty } from '../empty.util';
@@ -17,8 +18,7 @@ import { isNotEmpty, hasValue, isEmpty } from '../empty.util';
export class SearchFormComponent { export class SearchFormComponent {
@Input() query: string; @Input() query: string;
selectedId = ''; selectedId = '';
// Optional existing search parameters @Input() currentUrl: string;
@Input() currentParams: {};
@Input() scopes: DSpaceObject[]; @Input() scopes: DSpaceObject[];
@Input() @Input()
@@ -34,16 +34,14 @@ export class SearchFormComponent {
} }
updateSearch(data: any) { updateSearch(data: any) {
this.router.navigate(['/search'], { this.router.navigate([this.currentUrl], {
queryParams: Object.assign({}, this.currentParams, queryParams: {
{
query: data.query, query: data.query,
scope: data.scope || undefined, scope: data.scope || undefined,
page: data.page || 1 page: data.page || 1
} },
) queryParamsHandling: 'merge'
}) });
;
} }
isNotEmpty(object: any) { isNotEmpty(object: any) {

View File

@@ -13,6 +13,9 @@ module.exports = {
output: { output: {
path: root('dist') path: root('dist')
}, },
watchOptions: {
aggregateTimeout: 500,
},
module: { module: {
rules: [{ rules: [{
test: /\.ts$/, test: /\.ts$/,