63945: Allow bitstreams from other pages to be deleted

This commit is contained in:
Kristof De Langhe
2019-07-30 10:28:46 +02:00
parent e187778dbc
commit 3807a16f9a
2 changed files with 5 additions and 3 deletions

View File

@@ -150,7 +150,7 @@ export class ItemBitstreamsComponent extends AbstractItemUpdateComponent impleme
submit() {
const removedBitstreams$ = this.bitstreams$.pipe(
toBitstreamsArray(),
switchMap((bitstreams: Bitstream[]) => this.objectUpdatesService.getFieldUpdatesExclusive(this.url, bitstreams) as Observable<FieldUpdates>),
switchMap((bitstreams: Bitstream[]) => this.objectUpdatesService.getFieldUpdates(this.url, bitstreams, true) as Observable<FieldUpdates>),
map((fieldUpdates: FieldUpdates) => Object.values(fieldUpdates).filter((fieldUpdate: FieldUpdate) => fieldUpdate.changeType === FieldChangeType.REMOVE)),
map((fieldUpdates: FieldUpdate[]) => fieldUpdates.map((fieldUpdate: FieldUpdate) => fieldUpdate.field)),
isNotEmptyOperator()

View File

@@ -88,12 +88,14 @@ export class ObjectUpdatesService {
* a FieldUpdates object
* @param url The URL of the page for which the FieldUpdates should be requested
* @param initialFields The initial values of the fields
* @param ignoreStates Ignore the fieldStates to loop over the fieldUpdates instead
*/
getFieldUpdates(url: string, initialFields: Identifiable[]): Observable<FieldUpdates> {
getFieldUpdates(url: string, initialFields: Identifiable[], ignoreStates?: boolean): Observable<FieldUpdates> {
const objectUpdates = this.getObjectEntry(url);
return objectUpdates.pipe(map((objectEntry) => {
const fieldUpdates: FieldUpdates = {};
Object.keys(objectEntry.fieldStates).forEach((uuid) => {
console.log(objectEntry);
Object.keys(ignoreStates ? objectEntry.fieldUpdates : objectEntry.fieldStates).forEach((uuid) => {
let fieldUpdate = objectEntry.fieldUpdates[uuid];
if (isEmpty(fieldUpdate)) {
const identifiable = initialFields.find((object: Identifiable) => object.uuid === uuid);