mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-4745] memory leak fixes (#4931)
* fix app-layout component * fix card-view component * fix cloud-layout service * code fixes * code fixes * even more fixes * even more fixes * lint fixes * test fixes * fix code * remove useless pipes * fix code owners * enable spellcheck for cloud components * update test * update test
This commit is contained in:
committed by
Eugenio Romano
parent
e2311ab045
commit
1abb9bfc89
@@ -15,16 +15,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
import { Component, ViewChild, OnDestroy, OnInit } from '@angular/core';
|
||||
import { FormModel, FormService, LogService, FormOutcomeEvent } from '@alfresco/adf-core';
|
||||
import { FormComponent } from '@alfresco/adf-process-services';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'app-form-list',
|
||||
templateUrl: 'form-list.component.html',
|
||||
styleUrls: ['form-list.component.scss']
|
||||
})
|
||||
export class FormListComponent {
|
||||
export class FormListComponent implements OnInit, OnDestroy {
|
||||
|
||||
@ViewChild('adfForm')
|
||||
activitiForm: FormComponent;
|
||||
@@ -38,13 +40,24 @@ export class FormListComponent {
|
||||
restoredData: any = {};
|
||||
|
||||
showValidationIcon = false;
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(private formService: FormService, private logService: LogService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
// Prevent default outcome actions
|
||||
formService.executeOutcome.subscribe((formOutcomeEvent: FormOutcomeEvent) => {
|
||||
formOutcomeEvent.preventDefault();
|
||||
this.logService.log(formOutcomeEvent.outcome);
|
||||
});
|
||||
this.formService.executeOutcome
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe((formOutcomeEvent: FormOutcomeEvent) => {
|
||||
formOutcomeEvent.preventDefault();
|
||||
this.logService.log(formOutcomeEvent.outcome);
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
onRowDblClick(event: CustomEvent) {
|
||||
|
@@ -15,46 +15,60 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { FormModel, FormService, FormOutcomeEvent, CoreAutomationService } from '@alfresco/adf-core';
|
||||
import { Component, Inject, OnInit, OnDestroy } from '@angular/core';
|
||||
import {
|
||||
FormModel,
|
||||
FormService,
|
||||
FormOutcomeEvent,
|
||||
CoreAutomationService
|
||||
} from '@alfresco/adf-core';
|
||||
import { InMemoryFormService } from '../../services/in-memory-form.service';
|
||||
import { FakeFormService } from './fake-form.service';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'app-form-loading',
|
||||
templateUrl: 'form-loading.component.html',
|
||||
styleUrls: ['form-loading.component.scss'],
|
||||
providers: [
|
||||
{ provide: FormService, useClass: FakeFormService }
|
||||
]
|
||||
providers: [{ provide: FormService, useClass: FakeFormService }]
|
||||
})
|
||||
export class FormLoadingComponent implements OnInit {
|
||||
|
||||
export class FormLoadingComponent implements OnInit, OnDestroy {
|
||||
form: FormModel;
|
||||
typeaheadFieldValue = '';
|
||||
selectFieldValue = '';
|
||||
radioButtonFieldValue = '';
|
||||
formattedData = {};
|
||||
|
||||
constructor(@Inject(FormService) private formService: InMemoryFormService,
|
||||
private automationService: CoreAutomationService) {
|
||||
formService.executeOutcome.subscribe((formOutcomeEvent: FormOutcomeEvent) => {
|
||||
formOutcomeEvent.preventDefault();
|
||||
});
|
||||
}
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(
|
||||
@Inject(FormService) private formService: InMemoryFormService,
|
||||
private automationService: CoreAutomationService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.formService.executeOutcome
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe((formOutcomeEvent: FormOutcomeEvent) => {
|
||||
formOutcomeEvent.preventDefault();
|
||||
});
|
||||
|
||||
this.formattedData = {};
|
||||
const formDefinitionJSON: any = this.automationService.forms.getSimpleFormDefinition();
|
||||
this.form = this.formService.parseForm(formDefinitionJSON);
|
||||
}
|
||||
|
||||
onLoadButtonClicked() {
|
||||
this.formattedData = {
|
||||
'typeaheadField': this.typeaheadFieldValue,
|
||||
'selectBox': this.selectFieldValue,
|
||||
'radioButton': this.radioButtonFieldValue
|
||||
};
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
onLoadButtonClicked() {
|
||||
this.formattedData = {
|
||||
typeaheadField: this.typeaheadFieldValue,
|
||||
selectBox: this.selectFieldValue,
|
||||
radioButton: this.radioButtonFieldValue
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -18,7 +18,8 @@
|
||||
import { Component, Inject, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { FormModel, FormFieldModel, FormService, FormOutcomeEvent, NotificationService, CoreAutomationService } from '@alfresco/adf-core';
|
||||
import { InMemoryFormService } from '../../services/in-memory-form.service';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'app-form',
|
||||
@@ -35,7 +36,6 @@ export class FormComponent implements OnInit, OnDestroy {
|
||||
errorFields: FormFieldModel[] = [];
|
||||
formConfig: string;
|
||||
editor: any;
|
||||
private subscriptions: Subscription[] = [];
|
||||
|
||||
editorOptions = {
|
||||
theme: 'vs-dark',
|
||||
@@ -46,15 +46,11 @@ export class FormComponent implements OnInit, OnDestroy {
|
||||
automaticLayout: true
|
||||
};
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(@Inject(FormService) private formService: InMemoryFormService,
|
||||
private notificationService: NotificationService,
|
||||
private automationService: CoreAutomationService) {
|
||||
|
||||
this.subscriptions.push(
|
||||
formService.executeOutcome.subscribe((formOutcomeEvent: FormOutcomeEvent) => {
|
||||
formOutcomeEvent.preventDefault();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
logErrors(errorFields: FormFieldModel[]) {
|
||||
@@ -62,13 +58,21 @@ export class FormComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.formConfig = JSON.stringify(this.automationService.forms.getFormDefinition());
|
||||
this.formService.executeOutcome
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe((formOutcomeEvent: FormOutcomeEvent) => {
|
||||
formOutcomeEvent.preventDefault();
|
||||
});
|
||||
|
||||
this.formConfig = JSON.stringify(
|
||||
this.automationService.forms.getFormDefinition()
|
||||
);
|
||||
this.parseForm();
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach((subscription) => subscription.unsubscribe());
|
||||
this.subscriptions = [];
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
onInitFormEditor(editor) {
|
||||
|
Reference in New Issue
Block a user