mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 23:13:04 +00:00
[CST-4504] Fixed multiple delete & multiple add in modal and changed unit testing
This commit is contained in:
@@ -34,6 +34,7 @@ import { NoContent } from '../../../core/shared/NoContent.model';
|
||||
import { hasValue } from '../../../shared/empty.util';
|
||||
import { RelationshipTypeService } from '../../../core/data/relationship-type.service';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list.model';
|
||||
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-item-relationships',
|
||||
@@ -69,6 +70,7 @@ export class ItemRelationshipsComponent extends AbstractItemUpdateComponent {
|
||||
public entityTypeService: EntityTypeService,
|
||||
protected relationshipTypeService: RelationshipTypeService,
|
||||
public cdr: ChangeDetectorRef,
|
||||
protected modalService: NgbModal,
|
||||
) {
|
||||
super(itemService, objectUpdatesService, router, notificationsService, translateService, route);
|
||||
}
|
||||
@@ -108,10 +110,6 @@ export class ItemRelationshipsComponent extends AbstractItemUpdateComponent {
|
||||
*/
|
||||
public submit(): void {
|
||||
|
||||
this.relationshipService.getItemRelationshipsArray(this.item).pipe(
|
||||
take(1)
|
||||
).subscribe(res=>console.log(res));
|
||||
|
||||
// Get all the relationships that should be removed
|
||||
const removedRelationshipIDs$: Observable<DeleteRelationship[]> = this.relationshipService.getItemRelationshipsArray(this.item).pipe(
|
||||
startWith([]),
|
||||
@@ -119,13 +117,12 @@ export class ItemRelationshipsComponent extends AbstractItemUpdateComponent {
|
||||
Object.assign(new Relationship(), relationship, { uuid: relationship.id })
|
||||
)),
|
||||
switchMap((relationships: Relationship[]) => {
|
||||
return this.objectUpdatesService.getFieldUpdatesAll(this.url, relationships) as Observable<FieldUpdates>;
|
||||
return this.objectUpdatesService.getFieldUpdates(this.url, relationships) as Observable<FieldUpdates>;
|
||||
}),
|
||||
map((fieldUpdates: FieldUpdates) =>{
|
||||
console.log(fieldUpdates);
|
||||
map((fieldUpdates: FieldUpdates) => {
|
||||
return Object.values(fieldUpdates)
|
||||
.filter((fieldUpdate: FieldUpdate) => fieldUpdate.changeType === FieldChangeType.REMOVE)
|
||||
.map((fieldUpdate: FieldUpdate) => fieldUpdate.field as DeleteRelationship)
|
||||
.map((fieldUpdate: FieldUpdate) => fieldUpdate.field as DeleteRelationship);
|
||||
}
|
||||
),
|
||||
);
|
||||
@@ -155,6 +152,7 @@ export class ItemRelationshipsComponent extends AbstractItemUpdateComponent {
|
||||
this.initializeOriginalFields();
|
||||
this.cdr.detectChanges();
|
||||
this.displayNotifications(response);
|
||||
this.modalService.dismissAll();
|
||||
}
|
||||
})
|
||||
);
|
||||
@@ -162,7 +160,6 @@ export class ItemRelationshipsComponent extends AbstractItemUpdateComponent {
|
||||
}
|
||||
|
||||
deleteRelationships(deleteRelationshipIDs: DeleteRelationship[]): Observable<RemoteData<NoContent>[]> {
|
||||
console.log(deleteRelationshipIDs);
|
||||
return observableZip(...deleteRelationshipIDs.map((deleteRelationship) => {
|
||||
let copyVirtualMetadata: string;
|
||||
if (deleteRelationship.keepLeftVirtualMetadata && deleteRelationship.keepRightVirtualMetadata) {
|
||||
|
Reference in New Issue
Block a user