59695: Starts-with implementation for browse-by date

This commit is contained in:
Kristof De Langhe
2019-02-12 10:40:47 +01:00
parent d80233074f
commit cdcacedfae
11 changed files with 190 additions and 34 deletions

View File

@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { Observable, of as observableOf } from 'rxjs';
import { distinctUntilChanged, map, startWith, take } from 'rxjs/operators';
import {
ensureArrayHasValue,
ensureArrayHasValue, hasValue,
hasValueOperator,
isEmpty,
isNotEmpty,
@@ -162,6 +162,28 @@ export class BrowseService {
);
}
getFirstItemFor(definition: string, scope?: string): Observable<RemoteData<PaginatedList<Item>>> {
return this.getBrowseDefinitions().pipe(
getBrowseDefinitionLinks(definition),
hasValueOperator(),
map((_links: any) => _links.items),
hasValueOperator(),
map((href: string) => {
const args = [];
if (hasValue(scope)) {
args.push(`scope=${scope}`);
}
args.push('page=0');
args.push('size=1');
if (isNotEmpty(args)) {
href = new URLCombiner(href, `?${args.join('&')}`).toString();
}
return href;
}),
getBrowseItemsFor(this.requestService, this.responseCache, this.rdb)
);
}
getPrevBrowseItems(items: RemoteData<PaginatedList<Item>>): Observable<RemoteData<PaginatedList<Item>>> {
return observableOf(items.payload.prev).pipe(
getBrowseItemsFor(this.requestService, this.responseCache, this.rdb)