mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
fixed tests in relaitonship service
This commit is contained in:
@@ -11,11 +11,11 @@ import { getMockRequestService } from '../../shared/mocks/mock-request.service';
|
|||||||
import { Item } from '../shared/item.model';
|
import { Item } from '../shared/item.model';
|
||||||
import { PaginatedList } from './paginated-list';
|
import { PaginatedList } from './paginated-list';
|
||||||
import { PageInfo } from '../shared/page-info.model';
|
import { PageInfo } from '../shared/page-info.model';
|
||||||
import { DeleteRequest } from './request.models';
|
import { DeleteRequest, FindListOptions } from './request.models';
|
||||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||||
import { Observable } from 'rxjs/internal/Observable';
|
import { Observable } from 'rxjs/internal/Observable';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
|
import { createSuccessfulRemoteDataObject$, spyOnOperator } from '../../shared/testing/utils';
|
||||||
import { fakeAsync, tick } from '@angular/core/testing';
|
import * as ItemRelationshipsUtils from '../../+item-page/simple/item-types/shared/item-relationships-utils';
|
||||||
|
|
||||||
describe('RelationshipService', () => {
|
describe('RelationshipService', () => {
|
||||||
let service: RelationshipService;
|
let service: RelationshipService;
|
||||||
@@ -74,7 +74,8 @@ describe('RelationshipService', () => {
|
|||||||
const rdbService = getMockRemoteDataBuildService(undefined, buildList$);
|
const rdbService = getMockRemoteDataBuildService(undefined, buildList$);
|
||||||
const objectCache = Object.assign({
|
const objectCache = Object.assign({
|
||||||
/* tslint:disable:no-empty */
|
/* tslint:disable:no-empty */
|
||||||
remove: () => {},
|
remove: () => {
|
||||||
|
},
|
||||||
hasBySelfLinkObservable: () => observableOf(false)
|
hasBySelfLinkObservable: () => observableOf(false)
|
||||||
/* tslint:enable:no-empty */
|
/* tslint:enable:no-empty */
|
||||||
}) as ObjectCacheService;
|
}) as ObjectCacheService;
|
||||||
@@ -107,9 +108,6 @@ describe('RelationshipService', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jasmine.clock().uninstall();
|
|
||||||
jasmine.clock().install();
|
|
||||||
|
|
||||||
requestService = getMockRequestService(getRequestEntry$(true));
|
requestService = getMockRequestService(getRequestEntry$(true));
|
||||||
service = initTestService();
|
service = initTestService();
|
||||||
});
|
});
|
||||||
@@ -129,8 +127,8 @@ describe('RelationshipService', () => {
|
|||||||
it('should clear the cache of the related items', () => {
|
it('should clear the cache of the related items', () => {
|
||||||
expect(objectCache.remove).toHaveBeenCalledWith(relatedItem1.self);
|
expect(objectCache.remove).toHaveBeenCalledWith(relatedItem1.self);
|
||||||
expect(objectCache.remove).toHaveBeenCalledWith(item.self);
|
expect(objectCache.remove).toHaveBeenCalledWith(item.self);
|
||||||
expect(requestService.removeByHrefSubstring).toHaveBeenCalledWith(relatedItem1.self);
|
expect(requestService.removeByHrefSubstring).toHaveBeenCalledWith(relatedItem1.uuid);
|
||||||
expect(requestService.removeByHrefSubstring).toHaveBeenCalledWith(item.self);
|
expect(requestService.removeByHrefSubstring).toHaveBeenCalledWith(item.uuid);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -142,22 +140,55 @@ describe('RelationshipService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getRelatedItems', () => {
|
describe('getRelatedItemsByLabel', () => {
|
||||||
it('should return the related items', () => {
|
let relationsList;
|
||||||
service.getRelatedItems(item).subscribe((result) => {
|
let mockItem;
|
||||||
expect(result).toEqual(relatedItems);
|
let mockLabel;
|
||||||
|
let mockOptions;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
relationsList = new PaginatedList(new PageInfo({
|
||||||
|
elementsPerPage: relationships.length,
|
||||||
|
totalElements: relationships.length,
|
||||||
|
currentPage: 1,
|
||||||
|
totalPages: 1
|
||||||
|
}), relationships);
|
||||||
|
mockItem = { uuid: 'someid' } as Item;
|
||||||
|
mockLabel = 'label';
|
||||||
|
mockOptions = { label: 'options' } as FindListOptions;
|
||||||
|
|
||||||
|
const rd$ = createSuccessfulRemoteDataObject$(relationsList);
|
||||||
|
spyOn(service, 'getItemRelationshipsByLabel').and.returnValue(rd$);
|
||||||
|
|
||||||
|
spyOnOperator(ItemRelationshipsUtils, 'paginatedRelationsToItems').and.returnValue((v) => v);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should call getItemRelationshipsByLabel with the correct params', (done) => {
|
||||||
|
service.getRelatedItemsByLabel(
|
||||||
|
mockItem,
|
||||||
|
mockLabel,
|
||||||
|
mockOptions
|
||||||
|
).subscribe((result) => {
|
||||||
|
expect(service.getItemRelationshipsByLabel).toHaveBeenCalledWith(
|
||||||
|
mockItem,
|
||||||
|
mockLabel,
|
||||||
|
mockOptions,
|
||||||
|
);
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getRelatedItemsByLabel', () => {
|
it('should use the paginatedRelationsToItems operator', (done) => {
|
||||||
it('should return the related items by label', () => {
|
service.getRelatedItemsByLabel(
|
||||||
service.getRelatedItemsByLabel(item, relationshipType.rightwardType).subscribe((result) => {
|
mockItem,
|
||||||
expect(result.payload.page).toEqual(relatedItems);
|
mockLabel,
|
||||||
|
mockOptions
|
||||||
|
).subscribe((result) => {
|
||||||
|
expect(ItemRelationshipsUtils.paginatedRelationsToItems).toHaveBeenCalledWith(mockItem.uuid);
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function getRemotedataObservable(obj: any): Observable<RemoteData<any>> {
|
function getRemotedataObservable(obj: any): Observable<RemoteData<any>> {
|
||||||
|
@@ -21,7 +21,6 @@ import {
|
|||||||
RollbacktPatchOperationsAction,
|
RollbacktPatchOperationsAction,
|
||||||
StartTransactionPatchOperationsAction
|
StartTransactionPatchOperationsAction
|
||||||
} from './json-patch-operations.actions';
|
} from './json-patch-operations.actions';
|
||||||
import { MockStore } from '../../shared/testing/mock-store';
|
|
||||||
import { RequestEntry } from '../data/request.reducer';
|
import { RequestEntry } from '../data/request.reducer';
|
||||||
import { catchError } from 'rxjs/operators';
|
import { catchError } from 'rxjs/operators';
|
||||||
|
|
||||||
@@ -98,27 +97,22 @@ describe('JsonPatchOperationsService test suite', () => {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(async(() => {
|
function getStore() {
|
||||||
TestBed.configureTestingModule({
|
return jasmine.createSpyObj('store', {
|
||||||
imports: [
|
dispatch: {},
|
||||||
StoreModule.forRoot({}),
|
select: observableOf(mockState['json/patch'][testJsonPatchResourceType]),
|
||||||
],
|
pipe: observableOf(true)
|
||||||
providers: [
|
});
|
||||||
{ provide: Store, useClass: MockStore }
|
}
|
||||||
]
|
|
||||||
}).compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
store = TestBed.get(Store);
|
store = getStore();
|
||||||
requestService = getMockRequestService(getRequestEntry$(true));
|
requestService = getMockRequestService(getRequestEntry$(true));
|
||||||
rdbService = getMockRemoteDataBuildService();
|
rdbService = getMockRemoteDataBuildService();
|
||||||
scheduler = getTestScheduler();
|
scheduler = getTestScheduler();
|
||||||
halService = new HALEndpointServiceStub(resourceEndpointURL);
|
halService = new HALEndpointServiceStub(resourceEndpointURL);
|
||||||
service = initTestService();
|
service = initTestService();
|
||||||
|
|
||||||
spyOn(store, 'select').and.returnValue(observableOf(mockState['json/patch'][testJsonPatchResourceType]));
|
|
||||||
spyOn(store, 'dispatch').and.callThrough();
|
|
||||||
spyOn(Date.prototype, 'getTime').and.callFake(() => {
|
spyOn(Date.prototype, 'getTime').and.callFake(() => {
|
||||||
return timestamp;
|
return timestamp;
|
||||||
});
|
});
|
||||||
@@ -163,7 +157,7 @@ describe('JsonPatchOperationsService test suite', () => {
|
|||||||
|
|
||||||
describe('when request is not successful', () => {
|
describe('when request is not successful', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
store = TestBed.get(Store);
|
store = getStore();
|
||||||
requestService = getMockRequestService(getRequestEntry$(false));
|
requestService = getMockRequestService(getRequestEntry$(false));
|
||||||
rdbService = getMockRemoteDataBuildService();
|
rdbService = getMockRemoteDataBuildService();
|
||||||
scheduler = getTestScheduler();
|
scheduler = getTestScheduler();
|
||||||
@@ -226,7 +220,7 @@ describe('JsonPatchOperationsService test suite', () => {
|
|||||||
|
|
||||||
describe('when request is not successful', () => {
|
describe('when request is not successful', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
store = TestBed.get(Store);
|
store = getStore();
|
||||||
requestService = getMockRequestService(getRequestEntry$(false));
|
requestService = getMockRequestService(getRequestEntry$(false));
|
||||||
rdbService = getMockRemoteDataBuildService();
|
rdbService = getMockRemoteDataBuildService();
|
||||||
scheduler = getTestScheduler();
|
scheduler = getTestScheduler();
|
||||||
|
@@ -7,12 +7,14 @@ import { SubmissionObjectDataService } from './submission-object-data.service';
|
|||||||
import { SubmissionScopeType } from './submission-scope-type';
|
import { SubmissionScopeType } from './submission-scope-type';
|
||||||
import { WorkflowItemDataService } from './workflowitem-data.service';
|
import { WorkflowItemDataService } from './workflowitem-data.service';
|
||||||
import { WorkspaceitemDataService } from './workspaceitem-data.service';
|
import { WorkspaceitemDataService } from './workspaceitem-data.service';
|
||||||
|
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||||
|
|
||||||
describe('SubmissionObjectDataService', () => {
|
describe('SubmissionObjectDataService', () => {
|
||||||
let service: SubmissionObjectDataService;
|
let service: SubmissionObjectDataService;
|
||||||
let submissionService: SubmissionService;
|
let submissionService: SubmissionService;
|
||||||
let workspaceitemDataService: WorkspaceitemDataService;
|
let workspaceitemDataService: WorkspaceitemDataService;
|
||||||
let workflowItemDataService: WorkflowItemDataService;
|
let workflowItemDataService: WorkflowItemDataService;
|
||||||
|
let halService: HALEndpointService;
|
||||||
|
|
||||||
const submissionId = '1234';
|
const submissionId = '1234';
|
||||||
const wsiResult = 'wsiResult' as any;
|
const wsiResult = 'wsiResult' as any;
|
||||||
@@ -25,6 +27,9 @@ describe('SubmissionObjectDataService', () => {
|
|||||||
workflowItemDataService = jasmine.createSpyObj('WorkflowItemDataService', {
|
workflowItemDataService = jasmine.createSpyObj('WorkflowItemDataService', {
|
||||||
findById: wfiResult
|
findById: wfiResult
|
||||||
});
|
});
|
||||||
|
halService = jasmine.createSpyObj('HALEndpointService', {
|
||||||
|
getEndpoint: '/workspaceItem'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('findById', () => {
|
describe('findById', () => {
|
||||||
@@ -32,7 +37,7 @@ describe('SubmissionObjectDataService', () => {
|
|||||||
submissionService = jasmine.createSpyObj('SubmissionService', {
|
submissionService = jasmine.createSpyObj('SubmissionService', {
|
||||||
getSubmissionScope: {}
|
getSubmissionScope: {}
|
||||||
});
|
});
|
||||||
service = new SubmissionObjectDataService(workspaceitemDataService, workflowItemDataService, submissionService);
|
service = new SubmissionObjectDataService(workspaceitemDataService, workflowItemDataService, submissionService, halService);
|
||||||
service.findById(submissionId);
|
service.findById(submissionId);
|
||||||
expect(submissionService.getSubmissionScope).toHaveBeenCalled();
|
expect(submissionService.getSubmissionScope).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@@ -42,7 +47,7 @@ describe('SubmissionObjectDataService', () => {
|
|||||||
submissionService = jasmine.createSpyObj('SubmissionService', {
|
submissionService = jasmine.createSpyObj('SubmissionService', {
|
||||||
getSubmissionScope: SubmissionScopeType.WorkspaceItem
|
getSubmissionScope: SubmissionScopeType.WorkspaceItem
|
||||||
});
|
});
|
||||||
service = new SubmissionObjectDataService(workspaceitemDataService, workflowItemDataService, submissionService);
|
service = new SubmissionObjectDataService(workspaceitemDataService, workflowItemDataService, submissionService, halService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should forward the result of WorkspaceitemDataService.findById()', () => {
|
it('should forward the result of WorkspaceitemDataService.findById()', () => {
|
||||||
@@ -57,7 +62,7 @@ describe('SubmissionObjectDataService', () => {
|
|||||||
submissionService = jasmine.createSpyObj('SubmissionService', {
|
submissionService = jasmine.createSpyObj('SubmissionService', {
|
||||||
getSubmissionScope: SubmissionScopeType.WorkflowItem
|
getSubmissionScope: SubmissionScopeType.WorkflowItem
|
||||||
});
|
});
|
||||||
service = new SubmissionObjectDataService(workspaceitemDataService, workflowItemDataService, submissionService);
|
service = new SubmissionObjectDataService(workspaceitemDataService, workflowItemDataService, submissionService, halService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should forward the result of WorkflowItemDataService.findById()', () => {
|
it('should forward the result of WorkflowItemDataService.findById()', () => {
|
||||||
@@ -72,7 +77,7 @@ describe('SubmissionObjectDataService', () => {
|
|||||||
submissionService = jasmine.createSpyObj('SubmissionService', {
|
submissionService = jasmine.createSpyObj('SubmissionService', {
|
||||||
getSubmissionScope: 'Something else'
|
getSubmissionScope: 'Something else'
|
||||||
});
|
});
|
||||||
service = new SubmissionObjectDataService(workspaceitemDataService, workflowItemDataService, submissionService);
|
service = new SubmissionObjectDataService(workspaceitemDataService, workflowItemDataService, submissionService, halService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shouldn\'t call any data service methods', () => {
|
it('shouldn\'t call any data service methods', () => {
|
||||||
|
@@ -20,7 +20,7 @@ import { WorkspaceItem } from './models/workspaceitem.model';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class WorkspaceitemDataService extends DataService<WorkspaceItem> {
|
export class WorkspaceitemDataService extends DataService<WorkspaceItem> {
|
||||||
protected linkPath = 'workspaceitems';
|
protected linkPath = 'workspaceitems';
|
||||||
protected responseMsToLive = 10 * 1000;
|
// protected responseMsToLive = 10 * 1000;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected comparator: DSOChangeAnalyzer<WorkspaceItem>,
|
protected comparator: DSOChangeAnalyzer<WorkspaceItem>,
|
||||||
|
@@ -46,6 +46,9 @@ import { FormRowModel } from '../../../core/config/models/config-submission-form
|
|||||||
import { WorkspaceitemDataService } from '../../../core/submission/workspaceitem-data.service';
|
import { WorkspaceitemDataService } from '../../../core/submission/workspaceitem-data.service';
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import { WorkspaceItem } from '../../../core/submission/models/workspaceitem.model';
|
import { WorkspaceItem } from '../../../core/submission/models/workspaceitem.model';
|
||||||
|
import { SubmissionObjectDataService } from '../../../core/submission/submission-object-data.service';
|
||||||
|
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
||||||
|
import { RequestService } from '../../../core/data/request.service';
|
||||||
|
|
||||||
function getMockSubmissionFormsConfigService(): SubmissionFormsConfigService {
|
function getMockSubmissionFormsConfigService(): SubmissionFormsConfigService {
|
||||||
return jasmine.createSpyObj('FormOperationsService', {
|
return jasmine.createSpyObj('FormOperationsService', {
|
||||||
@@ -178,11 +181,13 @@ describe('SubmissionSectionformComponent test suite', () => {
|
|||||||
{ provide: SectionsService, useClass: SectionsServiceStub },
|
{ provide: SectionsService, useClass: SectionsServiceStub },
|
||||||
{ provide: SubmissionService, useClass: SubmissionServiceStub },
|
{ provide: SubmissionService, useClass: SubmissionServiceStub },
|
||||||
{ provide: TranslateService, useValue: getMockTranslateService() },
|
{ provide: TranslateService, useValue: getMockTranslateService() },
|
||||||
|
{ provide: ObjectCacheService, useValue: { remove: () => {/*do nothing*/}, hasBySelfLinkObservable: () => observableOf(false) } },
|
||||||
|
{ provide: RequestService, useValue: { removeByHrefSubstring: () => {/*do nothing*/}, hasByHrefObservable: () => observableOf(false) } },
|
||||||
{ provide: GLOBAL_CONFIG, useValue: envConfig },
|
{ provide: GLOBAL_CONFIG, useValue: envConfig },
|
||||||
{ provide: 'collectionIdProvider', useValue: collectionId },
|
{ provide: 'collectionIdProvider', useValue: collectionId },
|
||||||
{ provide: 'sectionDataProvider', useValue: sectionObject },
|
{ provide: 'sectionDataProvider', useValue: sectionObject },
|
||||||
{ provide: 'submissionIdProvider', useValue: submissionId },
|
{ provide: 'submissionIdProvider', useValue: submissionId },
|
||||||
{ provide: WorkspaceitemDataService, useValue: {findById: () => observableOf(new RemoteData(false, false, true, null, new WorkspaceItem()))}},
|
{ provide: SubmissionObjectDataService, useValue: { getHrefByID: () => observableOf('testUrl'), findById: () => observableOf(new RemoteData(false, false, true, null, new WorkspaceItem())) } },
|
||||||
ChangeDetectorRef,
|
ChangeDetectorRef,
|
||||||
SubmissionSectionformComponent
|
SubmissionSectionformComponent
|
||||||
],
|
],
|
||||||
@@ -255,7 +260,6 @@ describe('SubmissionSectionformComponent test suite', () => {
|
|||||||
expect(comp.isLoading).toBeFalsy();
|
expect(comp.isLoading).toBeFalsy();
|
||||||
expect(comp.initForm).toHaveBeenCalledWith(sectionData);
|
expect(comp.initForm).toHaveBeenCalledWith(sectionData);
|
||||||
expect(comp.subscriptions).toHaveBeenCalled();
|
expect(comp.subscriptions).toHaveBeenCalled();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should init form model properly', () => {
|
it('should init form model properly', () => {
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { ChangeDetectorRef, Component, Inject, ViewChild } from '@angular/core';
|
import { ChangeDetectorRef, Component, Inject, ViewChild } from '@angular/core';
|
||||||
import { DynamicFormControlEvent, DynamicFormControlModel } from '@ng-dynamic-forms/core';
|
import { DynamicFormControlEvent, DynamicFormControlModel } from '@ng-dynamic-forms/core';
|
||||||
|
|
||||||
import { Observable, Subscription } from 'rxjs';
|
import { combineLatest, Observable, Subscription } from 'rxjs';
|
||||||
import { distinctUntilChanged, filter, find, flatMap, map, take, tap } from 'rxjs/operators';
|
import { distinctUntilChanged, filter, find, flatMap, map, switchMap, take, tap } from 'rxjs/operators';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
|
|
||||||
@@ -34,8 +34,11 @@ import { WorkspaceitemSectionFormObject } from '../../../core/submission/models/
|
|||||||
import { WorkspaceItem } from '../../../core/submission/models/workspaceitem.model';
|
import { WorkspaceItem } from '../../../core/submission/models/workspaceitem.model';
|
||||||
import { WorkspaceitemDataService } from '../../../core/submission/workspaceitem-data.service';
|
import { WorkspaceitemDataService } from '../../../core/submission/workspaceitem-data.service';
|
||||||
import { combineLatest as combineLatestObservable } from 'rxjs';
|
import { combineLatest as combineLatestObservable } from 'rxjs';
|
||||||
import { getSucceededRemoteData } from '../../../core/shared/operators';
|
import { getRemoteDataPayload, getSucceededRemoteData } from '../../../core/shared/operators';
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { SubmissionObject } from '../../../core/submission/models/submission-object.model';
|
||||||
|
import { SubmissionObjectDataService } from '../../../core/submission/submission-object-data.service';
|
||||||
|
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
||||||
|
import { RequestService } from '../../../core/data/request.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component represents a section that contains a Form.
|
* This component represents a section that contains a Form.
|
||||||
@@ -126,6 +129,9 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
|
|||||||
* @param {SectionsService} sectionService
|
* @param {SectionsService} sectionService
|
||||||
* @param {SubmissionService} submissionService
|
* @param {SubmissionService} submissionService
|
||||||
* @param {TranslateService} translate
|
* @param {TranslateService} translate
|
||||||
|
* @param {SubmissionObjectDataService} submissionObjectService
|
||||||
|
* @param {ObjectCacheService} objectCache
|
||||||
|
* @param {RequestService} requestService
|
||||||
* @param {GlobalConfig} EnvConfig
|
* @param {GlobalConfig} EnvConfig
|
||||||
* @param {string} injectedCollectionId
|
* @param {string} injectedCollectionId
|
||||||
* @param {SectionDataObject} injectedSectionData
|
* @param {SectionDataObject} injectedSectionData
|
||||||
@@ -140,7 +146,9 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
|
|||||||
protected sectionService: SectionsService,
|
protected sectionService: SectionsService,
|
||||||
protected submissionService: SubmissionService,
|
protected submissionService: SubmissionService,
|
||||||
protected translate: TranslateService,
|
protected translate: TranslateService,
|
||||||
protected workspaceItemDataService: WorkspaceitemDataService,
|
protected submissionObjectService: SubmissionObjectDataService,
|
||||||
|
protected objectCache: ObjectCacheService,
|
||||||
|
protected requestService: RequestService,
|
||||||
@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
||||||
@Inject('collectionIdProvider') public injectedCollectionId: string,
|
@Inject('collectionIdProvider') public injectedCollectionId: string,
|
||||||
@Inject('sectionDataProvider') public injectedSectionData: SectionDataObject,
|
@Inject('sectionDataProvider') public injectedSectionData: SectionDataObject,
|
||||||
@@ -160,7 +168,20 @@ export class SubmissionSectionformComponent extends SectionModelComponent {
|
|||||||
flatMap(() =>
|
flatMap(() =>
|
||||||
combineLatestObservable(
|
combineLatestObservable(
|
||||||
this.sectionService.getSectionData(this.submissionId, this.sectionData.id),
|
this.sectionService.getSectionData(this.submissionId, this.sectionData.id),
|
||||||
this.workspaceItemDataService.findById(this.submissionId).pipe(getSucceededRemoteData(), map((wsiRD: RemoteData<WorkspaceItem>) => wsiRD.payload))
|
this.submissionObjectService.getHrefByID(this.submissionId).pipe(take(1)).pipe(
|
||||||
|
switchMap((href: string) => {
|
||||||
|
this.objectCache.remove(href);
|
||||||
|
this.requestService.removeByHrefSubstring(this.submissionId);
|
||||||
|
return combineLatest(
|
||||||
|
this.objectCache.hasBySelfLinkObservable(href),
|
||||||
|
this.requestService.hasByHrefObservable(href)
|
||||||
|
).pipe(
|
||||||
|
filter(([existsInOC, existsInRC]) => !existsInOC && !existsInRC),
|
||||||
|
take(1),
|
||||||
|
switchMap(() => this.submissionObjectService.findById(this.submissionId).pipe(getSucceededRemoteData(), getRemoteDataPayload()) as Observable<SubmissionObject>)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
)
|
||||||
)),
|
)),
|
||||||
take(1))
|
take(1))
|
||||||
.subscribe(([sectionData, workspaceItem]: [WorkspaceitemSectionFormObject, WorkspaceItem]) => {
|
.subscribe(([sectionData, workspaceItem]: [WorkspaceitemSectionFormObject, WorkspaceItem]) => {
|
||||||
|
Reference in New Issue
Block a user