mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-2840] Not able to complete a task with attach file widget with mappings (#5809)
* [AAE-2840] Check pipeline with possible fix * Remove update form loop causing overwriting of the form values * Revert ACA-3235 causing form values regression
This commit is contained in:
@@ -32,7 +32,6 @@ import { fakeTaskProcessVariableModels,
|
||||
formValues, complexVisibilityJsonVisible,
|
||||
complexVisibilityJsonNotVisible, tabVisibilityJsonMock,
|
||||
tabInvalidFormVisibility } from 'core/mock/form/widget-visibility.service.mock';
|
||||
import { formWithOneVisibleAndOneInvisibleFieldMock, formWithOneVisibleAndOneInvisibleTabMock } from '../components/mock/form-renderer.component.mock';
|
||||
import { CoreTestingModule } from '../../testing/core.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
@@ -1052,55 +1051,4 @@ describe('WidgetVisibilityService', () => {
|
||||
expect(invalidTabVisibilityJsonModel.isValid).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Remove invisible field values', () => {
|
||||
|
||||
let fakeFormWithField: FormModel;
|
||||
let fakeFormWithTab: FormModel;
|
||||
|
||||
beforeEach(() => {
|
||||
fakeFormWithField = new FormModel(formWithOneVisibleAndOneInvisibleFieldMock);
|
||||
fakeFormWithTab = new FormModel(formWithOneVisibleAndOneInvisibleTabMock);
|
||||
});
|
||||
|
||||
it('Should remove invisible field value from the form values', () => {
|
||||
service.refreshVisibility(fakeFormWithField);
|
||||
service.removeInvisibleFormValues(fakeFormWithField);
|
||||
expect(fakeFormWithField.values).toEqual({ mockname: 'Mock value' });
|
||||
});
|
||||
|
||||
it('Should be able to add field value to the form values if the field get visible', () => {
|
||||
service.refreshVisibility(fakeFormWithField);
|
||||
service.removeInvisibleFormValues(fakeFormWithField);
|
||||
expect(fakeFormWithField.values).toEqual({ mockname: 'Mock value' });
|
||||
|
||||
const mockNameFiled = fakeFormWithField.getFormFields().find((field) => field.id === 'mockname');
|
||||
mockNameFiled.value = 'test';
|
||||
mockNameFiled.updateForm();
|
||||
|
||||
service.refreshVisibility(fakeFormWithField);
|
||||
service.removeInvisibleFormValues(fakeFormWithField);
|
||||
expect(fakeFormWithField.values).toEqual({ mockname: 'test', mockmobilenumber: 'Mock invisible value' });
|
||||
});
|
||||
|
||||
it('Should be able to remove invisible tab fields value from the form values', () => {
|
||||
service.refreshVisibility(fakeFormWithTab);
|
||||
expect(fakeFormWithTab.values).toEqual({ mockname: null, mockmobilenumber: null, mockemail: null, mockaddress: null });
|
||||
service.removeInvisibleFormValues(fakeFormWithTab);
|
||||
expect(fakeFormWithTab.values).toEqual({ mockname: null });
|
||||
});
|
||||
|
||||
it('Should be able to add tab fields value to the form values if the tab get visible', () => {
|
||||
service.refreshVisibility(fakeFormWithTab);
|
||||
expect(fakeFormWithTab.values).toEqual({ mockname: null, mockmobilenumber: null, mockemail: null, mockaddress: null });
|
||||
|
||||
const mockNameFiled = fakeFormWithTab.getFormFields().find((field) => field.id === 'mockname');
|
||||
mockNameFiled.value = 'test';
|
||||
mockNameFiled.updateForm();
|
||||
|
||||
service.refreshVisibility(fakeFormWithTab);
|
||||
service.removeInvisibleFormValues(fakeFormWithTab);
|
||||
expect(fakeFormWithTab.values).toEqual({ mockname: 'test', mockmobilenumber: null, mockemail: null, mockaddress: null });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -20,7 +20,7 @@ import { LogService } from '../../services/log.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import moment from 'moment-es6';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { FormFieldModel, FormModel, TabModel, ContainerModel, FormFieldTypes } from '../components/widgets/core/index';
|
||||
import { FormFieldModel, FormModel, TabModel, ContainerModel } from '../components/widgets/core/index';
|
||||
import { TaskProcessVariableModel } from '../models/task-process-variable.model';
|
||||
import { WidgetVisibilityModel, WidgetTypeEnum } from '../models/widget-visibility.model';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
@@ -323,22 +323,6 @@ export class WidgetVisibilityService {
|
||||
return res || {};
|
||||
}
|
||||
|
||||
removeInvisibleFormValues(formModel: FormModel) {
|
||||
if (formModel) {
|
||||
formModel.getFormFields().map((field: FormFieldModel) => {
|
||||
if (field.type !== FormFieldTypes.CONTAINER) {
|
||||
if (!field.isVisible) {
|
||||
delete formModel.values[field.id];
|
||||
} else {
|
||||
field.updateForm();
|
||||
}
|
||||
}
|
||||
return field;
|
||||
});
|
||||
}
|
||||
return formModel;
|
||||
}
|
||||
|
||||
private isValidOperator(operator: string): boolean {
|
||||
return operator !== undefined;
|
||||
}
|
||||
|
Reference in New Issue
Block a user