1
0

Merge branch 'master' into w2p-68346_Bundles-in-edit-item-Updates

Conflicts:
	package.json
	src/app/+item-page/item-page-routing.module.ts
	src/app/core/cache/builders/remote-data-build.service.ts
	src/app/core/cache/server-sync-buffer.effects.ts
	src/app/core/core.module.ts
	src/app/core/data/bitstream-data.service.ts
	src/app/core/data/bundle-data.service.ts
	src/app/core/data/data.service.ts
	src/app/core/data/dso-change-analyzer.service.ts
	src/app/core/data/item-data.service.ts
	src/app/core/data/object-updates/object-updates.actions.ts
	src/app/core/shared/bitstream.model.ts
	src/app/core/shared/dspace-object.model.ts
	src/app/shared/mocks/mock-request.service.ts
	src/app/shared/shared.module.ts
	yarn.lock
This commit is contained in:
Kristof De Langhe
2020-03-05 17:21:38 +01:00
526 changed files with 11384 additions and 9370 deletions

View File

@@ -1,16 +1,16 @@
import { Router } from '@angular/router';
import { Observable } from 'rxjs';
import { filter, find, flatMap, map, take, tap } from 'rxjs/operators';
import { hasValue, hasValueOperator, isNotEmpty } from '../../shared/empty.util';
import { SearchResult } from '../../shared/search/search-result.model';
import { DSOSuccessResponse, RestResponse } from '../cache/response.models';
import { PaginatedList } from '../data/paginated-list';
import { RemoteData } from '../data/remote-data';
import { RestRequest } from '../data/request.models';
import { RequestEntry } from '../data/request.reducer';
import { RequestService } from '../data/request.service';
import { BrowseDefinition } from './browse-definition.model';
import { DSpaceObject } from './dspace-object.model';
import { PaginatedList } from '../data/paginated-list';
import { SearchResult } from '../../shared/search/search-result.model';
import { Router } from '@angular/router';
/**
* This file contains custom RxJS operators that can be used in multiple places
@@ -59,10 +59,92 @@ export const getRemoteDataPayload = () =>
<T>(source: Observable<RemoteData<T>>): Observable<T> =>
source.pipe(map((remoteData: RemoteData<T>) => remoteData.payload));
export const getPaginatedListPayload = () =>
<T>(source: Observable<PaginatedList<T>>): Observable<T[]> =>
source.pipe(map((list: PaginatedList<T>) => list.page));
export const getSucceededRemoteData = () =>
<T>(source: Observable<RemoteData<T>>): Observable<RemoteData<T>> =>
source.pipe(find((rd: RemoteData<T>) => rd.hasSucceeded));
/**
* Get the first successful remotely retrieved object
*
* You usually don't want to use this, it is a code smell.
* Work with the RemoteData object instead, that way you can
* handle loading and errors correctly.
*
* These operators were created as a first step in refactoring
* out all the instances where this is used incorrectly.
*/
export const getFirstSucceededRemoteDataPayload = () =>
<T>(source: Observable<RemoteData<T>>): Observable<T> =>
source.pipe(
getSucceededRemoteData(),
getRemoteDataPayload()
);
/**
* Get the all successful remotely retrieved objects
*
* You usually don't want to use this, it is a code smell.
* Work with the RemoteData object instead, that way you can
* handle loading and errors correctly.
*
* These operators were created as a first step in refactoring
* out all the instances where this is used incorrectly.
*/
export const getAllSucceededRemoteDataPayload = () =>
<T>(source: Observable<RemoteData<T>>): Observable<T> =>
source.pipe(
getAllSucceededRemoteData(),
getRemoteDataPayload()
);
/**
* Get the first successful remotely retrieved paginated list
* as an array
*
* You usually don't want to use this, it is a code smell.
* Work with the RemoteData object instead, that way you can
* handle loading and errors correctly.
*
* You also don't want to ignore pagination and simply use the
* page as an array.
*
* These operators were created as a first step in refactoring
* out all the instances where this is used incorrectly.
*/
export const getFirstSucceededRemoteListPayload = () =>
<T>(source: Observable<RemoteData<PaginatedList<T>>>): Observable<T[]> =>
source.pipe(
getSucceededRemoteData(),
getRemoteDataPayload(),
getPaginatedListPayload()
);
/**
* Get all successful remotely retrieved paginated lists
* as arrays
*
* You usually don't want to use this, it is a code smell.
* Work with the RemoteData object instead, that way you can
* handle loading and errors correctly.
*
* You also don't want to ignore pagination and simply use the
* page as an array.
*
* These operators were created as a first step in refactoring
* out all the instances where this is used incorrectly.
*/
export const getAllSucceededRemoteListPayload = () =>
<T>(source: Observable<RemoteData<PaginatedList<T>>>): Observable<T[]> =>
source.pipe(
getAllSucceededRemoteData(),
getRemoteDataPayload(),
getPaginatedListPayload()
);
/**
* Operator that checks if a remote data object contains a page not found error
* When it does contain such an error, it will redirect the user to a page not found, without altering the current URL
@@ -126,18 +208,6 @@ export const getFirstOccurrence = () =>
map((rd) => Object.assign(rd, { payload: rd.payload.page.length > 0 ? rd.payload.page[0] : undefined }))
);
/**
* Get the first succeeded RemoteData's payload
*/
export const getFirstSucceededRemoteDataPayload = () =>
<T>(source: Observable<RemoteData<T>>): Observable<T> =>
source.pipe(
getSucceededRemoteData(),
getRemoteDataPayload(),
hasValueOperator(),
take(1)
);
/**
* Operator for turning the current page of bitstreams into an array
*/