mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
Merge remote-tracking branch 'remotes/origin/master' into submission
# Conflicts: # src/app/+search-page/search-service/search.service.spec.ts # src/app/app.component.spec.ts # src/app/app.component.ts # src/app/core/auth/auth-response-parsing.service.ts # src/app/core/cache/models/normalized-object-factory.ts # src/app/core/cache/models/normalized-resource-policy.model.ts # src/app/core/core.module.ts # src/app/core/data/base-response-parsing.service.ts # src/app/core/data/config-response-parsing.service.spec.ts # src/app/core/data/config-response-parsing.service.ts # src/app/core/data/dso-response-parsing.service.ts # src/app/core/data/request.models.ts # src/app/core/data/search-response-parsing.service.ts # src/app/core/integration/integration-response-parsing.service.spec.ts # src/app/core/integration/integration-response-parsing.service.ts # src/app/core/shared/item.model.ts # src/app/core/shared/resource-policy.model.ts # src/app/core/shared/resource-type.ts # src/app/shared/shared.module.ts # src/app/thumbnail/thumbnail.component.html
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { filter, take } from 'rxjs/operators';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { hasValue, isNotEmpty } from '../../shared/empty.util';
|
||||
@@ -23,17 +24,13 @@ export abstract class DataService<TNormalized extends NormalizedObject, TDomain>
|
||||
protected abstract halService: HALEndpointService;
|
||||
protected abstract forceBypassCache = false;
|
||||
|
||||
public abstract getScopedEndpoint(scope: string): Observable<string>
|
||||
public abstract getBrowseEndpoint(options: FindAllOptions): Observable<string>
|
||||
|
||||
protected getFindAllHref(endpoint, options: FindAllOptions = {}): Observable<string> {
|
||||
protected getFindAllHref(options: FindAllOptions = {}): Observable<string> {
|
||||
let result: Observable<string>;
|
||||
const args = [];
|
||||
|
||||
if (hasValue(options.scopeID)) {
|
||||
result = this.getScopedEndpoint(options.scopeID).distinctUntilChanged();
|
||||
} else {
|
||||
result = Observable.of(endpoint);
|
||||
}
|
||||
result = this.getBrowseEndpoint(options).distinctUntilChanged();
|
||||
|
||||
if (hasValue(options.currentPage) && typeof options.currentPage === 'number') {
|
||||
/* TODO: this is a temporary fix for the pagination start index (0 or 1) discrepancy between the rest and the frontend respectively */
|
||||
@@ -48,6 +45,10 @@ export abstract class DataService<TNormalized extends NormalizedObject, TDomain>
|
||||
args.push(`sort=${options.sort.field},${options.sort.direction}`);
|
||||
}
|
||||
|
||||
if (hasValue(options.startsWith)) {
|
||||
args.push(`startsWith=${options.startsWith}`);
|
||||
}
|
||||
|
||||
if (isNotEmpty(args)) {
|
||||
return result.map((href: string) => new URLCombiner(href, `?${args.join('&')}`).toString());
|
||||
} else {
|
||||
@@ -92,12 +93,11 @@ export abstract class DataService<TNormalized extends NormalizedObject, TDomain>
|
||||
}
|
||||
|
||||
findAll(options: FindAllOptions = {}): Observable<RemoteData<PaginatedList<TDomain>>> {
|
||||
const hrefObs = this.halService.getEndpoint(this.linkPath).filter((href: string) => isNotEmpty(href))
|
||||
.flatMap((endpoint: string) => this.getFindAllHref(endpoint, options));
|
||||
const hrefObs = this.getFindAllHref(options);
|
||||
|
||||
hrefObs
|
||||
.filter((href: string) => hasValue(href))
|
||||
.take(1)
|
||||
hrefObs.pipe(
|
||||
filter((href: string) => hasValue(href)),
|
||||
take(1))
|
||||
.subscribe((href: string) => {
|
||||
const request = new FindAllRequest(this.requestService.generateRequestId(), href, options);
|
||||
this.requestService.configure(request, this.forceBypassCache);
|
||||
@@ -115,8 +115,7 @@ export abstract class DataService<TNormalized extends NormalizedObject, TDomain>
|
||||
.map((endpoint: string) => this.getFindByIDHref(endpoint, id));
|
||||
|
||||
hrefObs
|
||||
.filter((href: string) => hasValue(href))
|
||||
.take(1)
|
||||
.first((href: string) => hasValue(href))
|
||||
.subscribe((href: string) => {
|
||||
const request = new FindByIDRequest(this.requestService.generateRequestId(), href, id);
|
||||
this.requestService.configure(request, this.forceBypassCache);
|
||||
|
Reference in New Issue
Block a user