diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.ts index 908659376d..cba352484d 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.ts @@ -44,7 +44,7 @@ export class DsDynamicLookupComponent extends DynamicFormControlComponent implem public optionsList: any; protected searchOptions: IntegrationSearchOptions; - protected sub: Subscription; + protected subs: Subscription[] = []; constructor(private authorityService: AuthorityService, private cdr: ChangeDetectorRef, @@ -69,14 +69,14 @@ export class DsDynamicLookupComponent extends DynamicFormControlComponent implem this.setInputsValue(this.model.value); - this.model.valueUpdates + this.subs.push(this.model.valueUpdates .subscribe((value) => { if (isEmpty(value)) { this.resetFields(); } else if (!this.editMode) { this.setInputsValue(this.model.value); } - }); + })); } protected getCurrentValue(): string { @@ -234,7 +234,7 @@ export class DsDynamicLookupComponent extends DynamicFormControlComponent implem this.searchOptions.query = this.getCurrentValue(); this.loading = true; - this.authorityService.getEntriesByName(this.searchOptions).pipe( + this.subs.push(this.authorityService.getEntriesByName(this.searchOptions).pipe( catchError(() => { const emptyResult = new IntegrationData( new PageInfo(), @@ -248,7 +248,7 @@ export class DsDynamicLookupComponent extends DynamicFormControlComponent implem this.pageInfo = object.pageInfo; this.loading = false; this.cdr.detectChanges(); - }); + })); } public switchEditMode() { @@ -263,8 +263,8 @@ export class DsDynamicLookupComponent extends DynamicFormControlComponent implem } ngOnDestroy() { - if (hasValue(this.sub)) { - this.sub.unsubscribe(); - } + this.subs + .filter((sub) => hasValue(sub)) + .forEach((sub) => sub.unsubscribe()); } } diff --git a/src/app/submission/form/submission-upload-files/submission-upload-files.component.ts b/src/app/submission/form/submission-upload-files/submission-upload-files.component.ts index 055a58f852..0cc226772c 100644 --- a/src/app/submission/form/submission-upload-files/submission-upload-files.component.ts +++ b/src/app/submission/form/submission-upload-files/submission-upload-files.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnChanges } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; -import { Observable, of as observableOf } from 'rxjs'; +import { Observable, of as observableOf, Subscription } from 'rxjs'; import { first } from 'rxjs/operators'; import { SectionsService } from '../../sections/sections.service'; @@ -33,11 +33,13 @@ export class SubmissionUploadFilesComponent implements OnChanges { private uploadEnabled: Observable = observableOf(false); public onBeforeUpload = () => { - this.operationsService.jsonPatchByResourceType( + const sub: Subscription = this.operationsService.jsonPatchByResourceType( this.submissionService.getSubmissionObjectLinkName(), this.submissionId, 'sections') .subscribe(); + this.subs.push(sub); + return sub; }; constructor(private notificationsService: NotificationsService,