mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-11480] - Fix required error is displayed for a non required drop… (#8021)
* [AAE-11480] - Fix required error is displayed for a non required dropdown * Use alias for async pipe instead of subscribing 2 times
This commit is contained in:
@@ -531,7 +531,7 @@ describe('FormFieldModel', () => {
|
||||
expect(field.value).toBe(false);
|
||||
});
|
||||
|
||||
it('should delete empty dropdown value from the form values', () => {
|
||||
it('should set the value as null for a dropdown field that has the None value selected', () => {
|
||||
const form = new FormModel();
|
||||
const field = new FormFieldModel(form, {
|
||||
id: 'dropdown-1',
|
||||
@@ -539,10 +539,13 @@ describe('FormFieldModel', () => {
|
||||
});
|
||||
|
||||
field.value = 'empty';
|
||||
expect(form.values['dropdown-1']).toBe(undefined);
|
||||
expect(form.values['dropdown-1']).toBe(null);
|
||||
|
||||
field.value = '';
|
||||
expect(form.values['dropdown-1']).toBe(undefined);
|
||||
expect(form.values['dropdown-1']).toBe(null);
|
||||
|
||||
field.value = undefined;
|
||||
expect(form.values['dropdown-1']).toBe(null);
|
||||
});
|
||||
|
||||
it('should update form with dropdown value', () => {
|
||||
|
@@ -361,6 +361,12 @@ export class FormFieldModel extends FormWidgetModel {
|
||||
|
||||
switch (this.type) {
|
||||
case FormFieldTypes.DROPDOWN:
|
||||
|
||||
if (!this.value) {
|
||||
this.form.values[this.id] = null;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
This is needed due to Activiti reading dropdown values as string
|
||||
but saving back as object: { id: <id>, name: <name> }
|
||||
@@ -372,7 +378,7 @@ export class FormFieldModel extends FormWidgetModel {
|
||||
|
||||
if (typeof this.value === 'string') {
|
||||
if (this.value === 'empty' || this.value === '') {
|
||||
delete this.form.values[this.id];
|
||||
this.form.values[this.id] = null;
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user