mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
65717: Edit-bitstreams move + delete request fix
This commit is contained in:
@@ -4,7 +4,7 @@ import { ObjectUpdatesService } from '../../../../core/data/object-updates/objec
|
|||||||
import { Observable } from 'rxjs/internal/Observable';
|
import { Observable } from 'rxjs/internal/Observable';
|
||||||
import { FieldUpdates } from '../../../../core/data/object-updates/object-updates.reducer';
|
import { FieldUpdates } from '../../../../core/data/object-updates/object-updates.reducer';
|
||||||
import { toBitstreamsArray } from '../../../../core/shared/item-bitstreams-utils';
|
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 { Bitstream } from '../../../../core/shared/bitstream.model';
|
||||||
import { Item } from '../../../../core/shared/item.model';
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
import { CdkDragDrop } from '@angular/cdk/drag-drop';
|
import { CdkDragDrop } from '@angular/cdk/drag-drop';
|
||||||
@@ -89,6 +89,7 @@ export class ItemEditBitstreamBundleComponent implements OnInit {
|
|||||||
this.updates$ = this.bitstreamsRD$.pipe(
|
this.updates$ = this.bitstreamsRD$.pipe(
|
||||||
toBitstreamsArray(),
|
toBitstreamsArray(),
|
||||||
tap((bitstreams: Bitstream[]) => this.objectUpdatesService.initialize(this.bundle.self, bitstreams, new Date(), true)),
|
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))
|
switchMap((bitstreams: Bitstream[]) => this.objectUpdatesService.getFieldUpdatesByCustomOrder(this.bundle.self, bitstreams))
|
||||||
);
|
);
|
||||||
this.isLoadingMore$ = observableCombineLatest(this.currentSize$, this.bitstreamsRD$).pipe(
|
this.isLoadingMore$ = observableCombineLatest(this.currentSize$, this.bitstreamsRD$).pipe(
|
||||||
|
@@ -46,22 +46,6 @@ describe('BitstreamDataService', () => {
|
|||||||
service = new BitstreamDataService(requestService, null, null, null, null, objectCache, halService, null, null, null, bitstreamFormatService);
|
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', () => {
|
describe('when updating the bitstream\'s format', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
service.updateFormat(bitstream, format);
|
service.updateFormat(bitstream, format);
|
||||||
|
@@ -61,19 +61,6 @@ export class BitstreamDataService extends DataService<Bitstream> {
|
|||||||
return this.halService.getEndpoint(linkPath);
|
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
|
* Set the format of a bitstream
|
||||||
* @param bitstream
|
* @param bitstream
|
||||||
|
@@ -4,7 +4,7 @@ import { Observable } from 'rxjs';
|
|||||||
import { distinctUntilChanged, filter, find, first, map, mergeMap, switchMap, take } from 'rxjs/operators';
|
import { distinctUntilChanged, filter, find, first, map, mergeMap, switchMap, take } from 'rxjs/operators';
|
||||||
import { Store } from '@ngrx/store';
|
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 { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||||
import { CoreState } from '../core.reducers';
|
import { CoreState } from '../core.reducers';
|
||||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||||
@@ -327,6 +327,7 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
const requestId = this.deleteAndReturnRequestId(dso);
|
const requestId = this.deleteAndReturnRequestId(dso);
|
||||||
|
|
||||||
return this.requestService.getByUUID(requestId).pipe(
|
return this.requestService.getByUUID(requestId).pipe(
|
||||||
|
hasValueOperator(),
|
||||||
find((request: RequestEntry) => request.completed),
|
find((request: RequestEntry) => request.completed),
|
||||||
map((request: RequestEntry) => request.response)
|
map((request: RequestEntry) => request.response)
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user