diff --git a/lib/core/form/components/widgets/core/form-field.model.ts b/lib/core/form/components/widgets/core/form-field.model.ts index b859da13df..3ae937cac0 100644 --- a/lib/core/form/components/widgets/core/form-field.model.ts +++ b/lib/core/form/components/widgets/core/form-field.model.ts @@ -83,8 +83,8 @@ export class FormFieldModel extends FormWidgetModel { return this._value; } - set value(value: any) { - this._value = value; + set value(v: any) { + this._value = v; this.updateForm(); } diff --git a/lib/core/form/components/widgets/date-time/date-time.widget.spec.ts b/lib/core/form/components/widgets/date-time/date-time.widget.spec.ts index 9b6755bf0a..aca2a7b4cd 100644 --- a/lib/core/form/components/widgets/date-time/date-time.widget.spec.ts +++ b/lib/core/form/components/widgets/date-time/date-time.widget.spec.ts @@ -87,6 +87,23 @@ describe('DateTimeWidgetComponent', () => { expect(widget.maxDate.isSame(expected)).toBeTruthy(); }); + it('should eval visibility on date changed', () => { + spyOn(widget, 'onFieldChanged').and.callThrough(); + + const field = new FormFieldModel(new FormModel(), { + id: 'date-field-id', + name: 'date-name', + value: '09-12-9999 10:00 AM', + type: 'datetime', + readOnly: 'false' + }); + + widget.field = field; + + widget.onDateChanged({ value: moment('1982-03-13T10:00:000Z') }); + expect(widget.onFieldChanged).toHaveBeenCalledWith(field); + }); + describe('template check', () => { it('should show visible date widget', async(() => { diff --git a/lib/core/form/components/widgets/date-time/date-time.widget.ts b/lib/core/form/components/widgets/date-time/date-time.widget.ts index 778d6c69a0..5462bc0921 100644 --- a/lib/core/form/components/widgets/date-time/date-time.widget.ts +++ b/lib/core/form/components/widgets/date-time/date-time.widget.ts @@ -94,6 +94,7 @@ export class DateTimeWidgetComponent extends WidgetComponent implements OnInit, } else { this.field.value = null; } + this.onFieldChanged(this.field); } } diff --git a/lib/core/form/components/widgets/date/date.widget.spec.ts b/lib/core/form/components/widgets/date/date.widget.spec.ts index 44d7396e3e..3f94065877 100644 --- a/lib/core/form/components/widgets/date/date.widget.spec.ts +++ b/lib/core/form/components/widgets/date/date.widget.spec.ts @@ -81,6 +81,23 @@ describe('DateWidgetComponent', () => { expect(widget.maxDate.isSame(expected)).toBeTruthy(); }); + it('should eval visibility on date changed', () => { + spyOn(widget, 'onFieldChanged').and.callThrough(); + + const field = new FormFieldModel(new FormModel(), { + id: 'date-field-id', + name: 'date-name', + value: '9-9-9999', + type: 'date', + readOnly: 'false' + }); + + widget.field = field; + + widget.onDateChanged({ value: moment('12/12/2012') }); + expect(widget.onFieldChanged).toHaveBeenCalledWith(field); + }); + describe('template check', () => { afterEach(() => { diff --git a/lib/core/form/components/widgets/date/date.widget.ts b/lib/core/form/components/widgets/date/date.widget.ts index 3f09e9325b..4f8966de88 100644 --- a/lib/core/form/components/widgets/date/date.widget.ts +++ b/lib/core/form/components/widgets/date/date.widget.ts @@ -89,5 +89,6 @@ export class DateWidgetComponent extends WidgetComponent implements OnInit, OnDe } else { this.field.value = null; } + this.onFieldChanged(this.field); } } diff --git a/lib/process-services-cloud/src/lib/form/components/date-cloud/date-cloud.widget.spec.ts b/lib/process-services-cloud/src/lib/form/components/date-cloud/date-cloud.widget.spec.ts index c41098bd2e..728f9069af 100644 --- a/lib/process-services-cloud/src/lib/form/components/date-cloud/date-cloud.widget.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/date-cloud/date-cloud.widget.spec.ts @@ -80,6 +80,23 @@ describe('DateWidgetComponent', () => { expect(widget.maxDate.isSame(expected)).toBeTruthy(); }); + it('should eval visibility on date changed', () => { + spyOn(widget, 'onFieldChanged').and.callThrough(); + + const field = new FormFieldModel(new FormModel(), { + id: 'date-field-id', + name: 'date-name', + value: '9999-9-9', + type: 'date', + readOnly: 'false' + }); + + widget.field = field; + + widget.onDateChanged({ value: moment('12/12/2012') }); + expect(widget.onFieldChanged).toHaveBeenCalledWith(field); + }); + describe('template check', () => { afterEach(() => { diff --git a/lib/process-services-cloud/src/lib/form/components/date-cloud/date-cloud.widget.ts b/lib/process-services-cloud/src/lib/form/components/date-cloud/date-cloud.widget.ts index 2d8a520d68..633e4bbe85 100644 --- a/lib/process-services-cloud/src/lib/form/components/date-cloud/date-cloud.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/date-cloud/date-cloud.widget.ts @@ -86,5 +86,6 @@ export class DateCloudWidgetComponent extends WidgetComponent implements OnInit, } else { this.field.value = null; } + this.onFieldChanged(this.field); } }