mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
add a custom FindDataImpl for browsedefinitions
This commit is contained in:
@@ -6,6 +6,7 @@ import { RemoteDataBuildService } from '../cache/builders/remote-data-build.serv
|
||||
import { PaginatedList } from '../data/paginated-list.model';
|
||||
import { RemoteData } from '../data/remote-data';
|
||||
import { RequestService } from '../data/request.service';
|
||||
import { BrowseDefinition } from '../shared/browse-definition.model';
|
||||
import { FlatBrowseDefinition } from '../shared/flat-browse-definition.model';
|
||||
import { BrowseEntry } from '../shared/browse-entry.model';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
@@ -60,7 +61,7 @@ export class BrowseService {
|
||||
/**
|
||||
* Get all BrowseDefinitions
|
||||
*/
|
||||
getBrowseDefinitions(): Observable<RemoteData<PaginatedList<FlatBrowseDefinition>>> {
|
||||
getBrowseDefinitions(): Observable<RemoteData<PaginatedList<BrowseDefinition>>> {
|
||||
// TODO properly support pagination
|
||||
return this.browseDefinitionDataService.findAll({ elementsPerPage: 9999 }).pipe(
|
||||
getFirstSucceededRemoteData(),
|
||||
@@ -233,13 +234,18 @@ export class BrowseService {
|
||||
return this.getBrowseDefinitions().pipe(
|
||||
getRemoteDataPayload(),
|
||||
getPaginatedListPayload(),
|
||||
map((browseDefinitions: FlatBrowseDefinition[]) => browseDefinitions
|
||||
.find((def: FlatBrowseDefinition) => {
|
||||
const matchingKeys = def.metadataKeys.find((key: string) => searchKeyArray.indexOf(key) >= 0);
|
||||
map((browseDefinitions: BrowseDefinition[]) => browseDefinitions
|
||||
.find((def: BrowseDefinition) => {
|
||||
let matchingKeys = '';
|
||||
|
||||
if (Array.isArray((def as FlatBrowseDefinition).metadataKeys)) {
|
||||
matchingKeys = (def as FlatBrowseDefinition).metadataKeys.find((key: string) => searchKeyArray.indexOf(key) >= 0);
|
||||
}
|
||||
|
||||
return isNotEmpty(matchingKeys);
|
||||
})
|
||||
),
|
||||
map((def: FlatBrowseDefinition) => {
|
||||
map((def: BrowseDefinition) => {
|
||||
if (isEmpty(def) || isEmpty(def._links) || isEmpty(def._links[linkPath])) {
|
||||
throw new Error(`A browse endpoint for ${linkPath} on ${metadataKey} isn't configured`);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user