65717: Edit-bitstreams move + delete request fix

This commit is contained in:
Kristof De Langhe
2019-10-31 14:07:03 +01:00
parent dd5f40858d
commit e762ed4d9e
4 changed files with 4 additions and 31 deletions

View File

@@ -4,7 +4,7 @@ import { ObjectUpdatesService } from '../../../../core/data/object-updates/objec
import { Observable } from 'rxjs/internal/Observable';
import { FieldUpdates } from '../../../../core/data/object-updates/object-updates.reducer';
import { toBitstreamsArray } from '../../../../core/shared/item-bitstreams-utils';
import { map, switchMap, tap } from 'rxjs/operators';
import { map, switchMap, take, tap } from 'rxjs/operators';
import { Bitstream } from '../../../../core/shared/bitstream.model';
import { Item } from '../../../../core/shared/item.model';
import { CdkDragDrop } from '@angular/cdk/drag-drop';
@@ -89,6 +89,7 @@ export class ItemEditBitstreamBundleComponent implements OnInit {
this.updates$ = this.bitstreamsRD$.pipe(
toBitstreamsArray(),
tap((bitstreams: Bitstream[]) => this.objectUpdatesService.initialize(this.bundle.self, bitstreams, new Date(), true)),
take(1),
switchMap((bitstreams: Bitstream[]) => this.objectUpdatesService.getFieldUpdatesByCustomOrder(this.bundle.self, bitstreams))
);
this.isLoadingMore$ = observableCombineLatest(this.currentSize$, this.bitstreamsRD$).pipe(

View File

@@ -46,22 +46,6 @@ describe('BitstreamDataService', () => {
service = new BitstreamDataService(requestService, null, null, null, null, objectCache, halService, null, null, null, bitstreamFormatService);
});
describe('when deleting a bitstream', () => {
let response$: Observable<RestResponse>;
beforeEach(() => {
response$ = service.deleteAndReturnResponse(bitstream);
});
it('should de-cache the bitstream\'s object cache', () => {
expect(objectCache.remove).toHaveBeenCalledWith(bitstream.self);
});
it('should de-cache the bitstream\'s request cache', () => {
expect(requestService.removeByHrefSubstring).toHaveBeenCalledWith(bitstream.self);
});
});
describe('when updating the bitstream\'s format', () => {
beforeEach(() => {
service.updateFormat(bitstream, format);

View File

@@ -61,19 +61,6 @@ export class BitstreamDataService extends DataService<Bitstream> {
return this.halService.getEndpoint(linkPath);
}
/**
* Delete an existing DSpace Object on the server
* @param bitstream The Bitstream to be removed
* De-cache the removed bitstream from Object and Request cache
* Return an observable of the completed response
*/
deleteAndReturnResponse(bitstream: Bitstream): Observable<RestResponse> {
const response$ = super.deleteAndReturnResponse(bitstream);
this.objectCache.remove(bitstream.self);
this.requestService.removeByHrefSubstring(bitstream.self);
return response$;
}
/**
* Set the format of a bitstream
* @param bitstream

View File

@@ -4,7 +4,7 @@ import { Observable } from 'rxjs';
import { distinctUntilChanged, filter, find, first, map, mergeMap, switchMap, take } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { hasValue, isNotEmpty, isNotEmptyOperator } from '../../shared/empty.util';
import { hasValue, hasValueOperator, isNotEmpty, isNotEmptyOperator } from '../../shared/empty.util';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { CoreState } from '../core.reducers';
import { HALEndpointService } from '../shared/hal-endpoint.service';
@@ -327,6 +327,7 @@ export abstract class DataService<T extends CacheableObject> {
const requestId = this.deleteAndReturnRequestId(dso);
return this.requestService.getByUUID(requestId).pipe(
hasValueOperator(),
find((request: RequestEntry) => request.completed),
map((request: RequestEntry) => request.response)
);