mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge pull request #1253 from 4Science/#1234
Fix issue when switching submission's collection between those with different submission definition
This commit is contained in:
@@ -261,9 +261,10 @@ describe('SubmissionFormCollectionComponent Component', () => {
|
||||
expect(comp.toggled).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should ', () => {
|
||||
it('should change collection properly', () => {
|
||||
spyOn(comp.collectionChange, 'emit').and.callThrough();
|
||||
jsonPatchOpServiceStub.jsonPatchByResourceID.and.returnValue(of(submissionRestResponse));
|
||||
submissionServiceStub.retrieveSubmission.and.returnValue(createSuccessfulRemoteDataObject$(submissionRestResponse[0]));
|
||||
comp.ngOnInit();
|
||||
comp.onSelect(mockCollectionList[1]);
|
||||
fixture.detectChanges();
|
||||
|
@@ -13,7 +13,7 @@ import {
|
||||
import { BehaviorSubject, Observable, of as observableOf, Subscription } from 'rxjs';
|
||||
import {
|
||||
find,
|
||||
map
|
||||
map, mergeMap
|
||||
} from 'rxjs/operators';
|
||||
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
@@ -27,6 +27,7 @@ import { SubmissionJsonPatchOperationsService } from '../../../core/submission/s
|
||||
import { CollectionDataService } from '../../../core/data/collection-data.service';
|
||||
import { CollectionDropdownComponent } from '../../../shared/collection-dropdown/collection-dropdown.component';
|
||||
import { SectionsService } from '../../sections/sections.service';
|
||||
import { getFirstSucceededRemoteDataPayload } from '../../../core/shared/operators';
|
||||
|
||||
/**
|
||||
* This component allows to show the current collection the submission belonging to and to change it.
|
||||
@@ -164,11 +165,17 @@ export class SubmissionFormCollectionComponent implements OnChanges, OnInit {
|
||||
this.submissionService.getSubmissionObjectLinkName(),
|
||||
this.submissionId,
|
||||
'sections',
|
||||
'collection')
|
||||
.subscribe((submissionObject: SubmissionObject[]) => {
|
||||
'collection').pipe(
|
||||
mergeMap((submissionObject: SubmissionObject[]) => {
|
||||
// retrieve the full submission object with embeds
|
||||
return this.submissionService.retrieveSubmission(submissionObject[0].id).pipe(
|
||||
getFirstSucceededRemoteDataPayload()
|
||||
);
|
||||
})
|
||||
).subscribe((submissionObject: SubmissionObject) => {
|
||||
this.selectedCollectionId = event.collection.id;
|
||||
this.selectedCollectionName$ = observableOf(event.collection.name);
|
||||
this.collectionChange.emit(submissionObject[0]);
|
||||
this.collectionChange.emit(submissionObject);
|
||||
this.submissionService.changeSubmissionCollection(this.submissionId, event.collection.id);
|
||||
this.processingChange$.next(false);
|
||||
this.cdr.detectChanges();
|
||||
|
Reference in New Issue
Block a user