mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
AAE-23165 Not blocking task completion when there's no value selected in required radio buttons widget (#9836)
* AAE-23165 Fix * AAE-23165 Update
This commit is contained in:
committed by
GitHub
parent
9a544307d4
commit
af552bfbb9
@@ -22,7 +22,6 @@ import { FormFieldModel } from './form-field.model';
|
||||
import { FormModel } from './form.model';
|
||||
|
||||
describe('FormFieldModel', () => {
|
||||
|
||||
it('should store the form reference', () => {
|
||||
const form = new FormModel();
|
||||
const model = new FormFieldModel(form);
|
||||
@@ -251,7 +250,7 @@ describe('FormFieldModel', () => {
|
||||
expect(field.value).toBe('28-04-2017');
|
||||
});
|
||||
|
||||
it('should set the value to today\'s date when the value is today', () => {
|
||||
it('should set the value to todays date when the value is today', () => {
|
||||
const form = new FormModel();
|
||||
const field = new FormFieldModel(form, {
|
||||
fieldType: 'FormFieldRepresentation',
|
||||
@@ -606,7 +605,7 @@ describe('FormFieldModel', () => {
|
||||
expect(form.values['radio-1']).toEqual(field.options[1]);
|
||||
});
|
||||
|
||||
it('radio button value should be null when no default is set', () => {
|
||||
it('should update form with null when radio button value does NOT match any option', () => {
|
||||
const form = new FormModel();
|
||||
const field = new FormFieldModel(form, {
|
||||
id: 'radio-2',
|
||||
@@ -618,7 +617,22 @@ describe('FormFieldModel', () => {
|
||||
});
|
||||
|
||||
field.value = 'missing';
|
||||
expect(form.values['radio-2']).toBeUndefined();
|
||||
expect(form.values['radio-2']).toBe(null);
|
||||
});
|
||||
|
||||
it('should update form with null when radio button value is null', () => {
|
||||
const form = new FormModel();
|
||||
const field = new FormFieldModel(form, {
|
||||
id: 'radio-2',
|
||||
type: FormFieldTypes.RADIO_BUTTONS,
|
||||
options: [
|
||||
{ id: 'opt1', name: 'Option 1' },
|
||||
{ id: 'opt2', name: 'Option 2' }
|
||||
]
|
||||
});
|
||||
|
||||
field.value = null;
|
||||
expect(form.values['radio-2']).toBe(null);
|
||||
});
|
||||
|
||||
it('should not update form with display-only field value', () => {
|
||||
@@ -840,7 +854,6 @@ describe('FormFieldModel', () => {
|
||||
});
|
||||
|
||||
describe('variables', () => {
|
||||
|
||||
let form: FormModel;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -907,7 +920,6 @@ describe('FormFieldModel', () => {
|
||||
|
||||
expect(field.value).toBe('default hello');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should validate readOnly field if it is validatable', () => {
|
||||
|
@@ -406,10 +406,8 @@ export class FormFieldModel extends FormWidgetModel {
|
||||
break;
|
||||
}
|
||||
case FormFieldTypes.RADIO_BUTTONS: {
|
||||
const radioButton: FormFieldOption[] = this.options.filter((opt) => opt.id === this.value);
|
||||
if (radioButton.length > 0) {
|
||||
this.form.values[this.id] = radioButton[0];
|
||||
}
|
||||
const radioButton: FormFieldOption = this.options.find((opt) => opt.id === this.value);
|
||||
this.form.values[this.id] = radioButton || null;
|
||||
break;
|
||||
}
|
||||
case FormFieldTypes.UPLOAD: {
|
||||
@@ -472,7 +470,7 @@ export class FormFieldModel extends FormWidgetModel {
|
||||
case FormFieldTypes.DECIMAL: {
|
||||
this.form.values[this.id] = parseFloat(this.value);
|
||||
break;
|
||||
};
|
||||
}
|
||||
case FormFieldTypes.BOOLEAN: {
|
||||
this.form.values[this.id] = this.value !== null && this.value !== undefined ? this.value : false;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user