mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-8086] Remove form rules events that kill performance (#7583)
* [AAE-8086] Remove form rules events that kill performance * [AAE-8086] Handle form loaded event in form rules
This commit is contained in:
committed by
GitHub
parent
2db6d9e506
commit
61cd711cec
@@ -21,9 +21,6 @@ import { FormService } from './form.service';
|
||||
import { setupTestBed } from '../../testing/setup-test-bed';
|
||||
import { CoreTestingModule } from '../../testing/core.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { FormEvent, ValidateDynamicTableRowEvent, ValidateFormEvent, ValidateFormFieldEvent } from '../events';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { FormModel } from '../components/widgets/core/form.model';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -412,68 +409,4 @@ describe('Form service', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Form rules', () => {
|
||||
const event = new FormEvent('mock');
|
||||
|
||||
it('should emit the formLoaded in the formRulesEvent observable', async(done) => {
|
||||
service.formRulesEvent.pipe(take(1)).subscribe(formRuleEvent => {
|
||||
expect(formRuleEvent.event).toBeFalsy();
|
||||
expect(formRuleEvent.field).toBeFalsy();
|
||||
expect(formRuleEvent.form).toEqual('mock');
|
||||
expect(formRuleEvent.type).toEqual('formLoaded');
|
||||
done();
|
||||
});
|
||||
|
||||
service.formLoaded.next(event);
|
||||
});
|
||||
|
||||
it('should emit the formDataRefreshed in the formRulesEvent observable', async(done) => {
|
||||
service.formRulesEvent.pipe(take(1)).subscribe(formRuleEvent => {
|
||||
expect(formRuleEvent.event).toBeFalsy();
|
||||
expect(formRuleEvent.field).toBeFalsy();
|
||||
expect(formRuleEvent.form).toEqual('mock');
|
||||
expect(formRuleEvent.type).toEqual('formDataRefreshed');
|
||||
done();
|
||||
});
|
||||
|
||||
service.formDataRefreshed.next(event);
|
||||
});
|
||||
|
||||
it('should emit the formValidated in the formRulesEvent observable', async(done) => {
|
||||
service.formRulesEvent.pipe(take(1)).subscribe(formRuleEvent => {
|
||||
expect(formRuleEvent.event).toBeFalsy();
|
||||
expect(formRuleEvent.field).toBeFalsy();
|
||||
expect(formRuleEvent.form).toEqual('mock');
|
||||
expect(formRuleEvent.type).toEqual('formValidated');
|
||||
done();
|
||||
});
|
||||
|
||||
service.validateForm.next(new ValidateFormEvent('mock'));
|
||||
});
|
||||
|
||||
it('should emit the fieldValidated in the formRulesEvent observable', async(done) => {
|
||||
service.formRulesEvent.pipe(take(1)).subscribe(formRuleEvent => {
|
||||
expect(formRuleEvent.event).toBeFalsy();
|
||||
expect(formRuleEvent.field).toBeFalsy();
|
||||
expect(formRuleEvent.form).toEqual('mock');
|
||||
expect(formRuleEvent.type).toEqual('fieldValidated');
|
||||
done();
|
||||
});
|
||||
|
||||
service.validateFormField.next(new ValidateFormFieldEvent('mock', null));
|
||||
});
|
||||
|
||||
it('should emit the fieldDynamicTableRowValidated in the formRulesEvent observable', async(done) => {
|
||||
service.formRulesEvent.pipe(take(1)).subscribe(formRuleEvent => {
|
||||
expect(formRuleEvent.event).toBeFalsy();
|
||||
expect(formRuleEvent.field).toBeFalsy();
|
||||
expect(formRuleEvent.form).toEqual('mock');
|
||||
expect(formRuleEvent.type).toEqual('fieldDynamicTableRowValidated');
|
||||
done();
|
||||
});
|
||||
|
||||
service.validateDynamicTableRow.next(new ValidateDynamicTableRowEvent('mock' as unknown as FormModel, null, null, null));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -136,12 +136,6 @@ export class FormService implements FormValidationService {
|
||||
constructor(private ecmModelService: EcmModelService,
|
||||
private apiService: AlfrescoApiService,
|
||||
protected logService: LogService) {
|
||||
|
||||
this.formLoaded.subscribe(event => this.formRulesEvent.next(new FormRulesEvent('formLoaded', event)));
|
||||
this.formDataRefreshed.subscribe(event => this.formRulesEvent.next(new FormRulesEvent('formDataRefreshed', event)));
|
||||
this.validateForm.subscribe(event => this.formRulesEvent.next(new FormRulesEvent('formValidated', event)));
|
||||
this.validateFormField.subscribe(event => this.formRulesEvent.next(new FormRulesEvent('fieldValidated', event)));
|
||||
this.validateDynamicTableRow.subscribe(event => this.formRulesEvent.next(new FormRulesEvent('fieldDynamicTableRowValidated', event)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user