65717: Remove object updates on page url (only bundles now) and added support for tracking custom order changes, discard and reinstate

This commit is contained in:
Kristof De Langhe
2019-10-23 14:28:19 +02:00
parent 9113a08796
commit 7adb50a9b8
5 changed files with 60 additions and 23 deletions

View File

@@ -20,7 +20,6 @@ import { Item } from '../../../core/shared/item.model';
import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list';
import { Bundle } from '../../../core/shared/bundle.model';
import { CdkDragDrop } from '@angular/cdk/drag-drop';
@Component({
selector: 'ds-item-bitstreams',
@@ -85,13 +84,6 @@ export class ItemBitstreamsComponent extends AbstractItemUpdateComponent impleme
this.notificationsPrefix = 'item.edit.bitstreams.notifications.';
}
/**
* Initialize the original fields for the object-updates-service
*/
initializeOriginalFields(): void {
this.objectUpdatesService.initialize(this.url, [], this.item.lastModified);
}
/**
* Update the item (and view) when it's removed in the request cache
* Also re-initialize the original fields and updates
@@ -166,7 +158,6 @@ export class ItemBitstreamsComponent extends AbstractItemUpdateComponent impleme
* Request the object updates service to undo discarding all changes to this item
*/
reinstate() {
super.reinstate();
this.bundles$.pipe(take(1)).subscribe((bundles: Bundle[]) => {
bundles.forEach((bundle: Bundle) => {
this.objectUpdatesService.reinstateFieldUpdates(bundle.self);
@@ -174,6 +165,26 @@ export class ItemBitstreamsComponent extends AbstractItemUpdateComponent impleme
});
}
/**
* Checks whether or not the object is currently reinstatable
*/
isReinstatable(): Observable<boolean> {
return this.bundles$.pipe(
switchMap((bundles: Bundle[]) => observableZip(...bundles.map((bundle: Bundle) => this.objectUpdatesService.isReinstatable(bundle.self)))),
map((reinstatable: boolean[]) => reinstatable.includes(true))
);
}
/**
* Checks whether or not there are currently updates for this object
*/
hasChanges(): Observable<boolean> {
return this.bundles$.pipe(
switchMap((bundles: Bundle[]) => observableZip(...bundles.map((bundle: Bundle) => this.objectUpdatesService.hasUpdates(bundle.self)))),
map((hasChanges: boolean[]) => hasChanges.includes(true))
);
}
/**
* De-cache the current item (it should automatically reload due to itemUpdateSubscription)
*/