mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
59695: Starts-with implementation for browse-by date
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user