diff --git a/demo-shell/src/app/components/activiti/activiti.component.ts b/demo-shell/src/app/components/activiti/activiti.component.ts index f1b4f26d87..a0ee23ca9e 100644 --- a/demo-shell/src/app/components/activiti/activiti.component.ts +++ b/demo-shell/src/app/components/activiti/activiti.component.ts @@ -179,7 +179,7 @@ export class ActivitiComponent implements AfterViewInit, OnDestroy, OnInit { const row: DynamicTableRow = e.row; if (row && row.value && row.value.name === 'admin') { e.summary.isValid = false; - e.summary.text = 'Sorry, wrong value. You cannot use "admin".'; + e.summary.message = 'Sorry, wrong value. You cannot use "admin".'; e.preventDefault(); } } diff --git a/lib/core/form/components/widgets/dynamic-table/date-cell-validator-model.ts b/lib/core/form/components/widgets/dynamic-table/date-cell-validator-model.ts index 9a73abd880..552efcdae7 100644 --- a/lib/core/form/components/widgets/dynamic-table/date-cell-validator-model.ts +++ b/lib/core/form/components/widgets/dynamic-table/date-cell-validator-model.ts @@ -41,7 +41,7 @@ export class DateCellValidator implements CellValidator { if (!dateValue.isValid()) { if (summary) { summary.isValid = false; - summary.text = `Invalid '${column.name}' format.`; + summary.message = `Invalid '${column.name}' format.`; } return false; } diff --git a/lib/core/form/components/widgets/dynamic-table/dynamic-row-validation-summary.model.ts b/lib/core/form/components/widgets/dynamic-table/dynamic-row-validation-summary.model.ts index 24cfb7980a..027de5f935 100644 --- a/lib/core/form/components/widgets/dynamic-table/dynamic-row-validation-summary.model.ts +++ b/lib/core/form/components/widgets/dynamic-table/dynamic-row-validation-summary.model.ts @@ -17,9 +17,14 @@ /* tslint:disable:component-selector */ -export interface DynamicRowValidationSummary { +import { ErrorMessageModel } from '../core/index'; + +export class DynamicRowValidationSummary extends ErrorMessageModel { isValid: boolean; - text: string; + constructor(json?: any) { + super(json); + this.isValid = json.isValid; + } } diff --git a/lib/core/form/components/widgets/dynamic-table/dynamic-table.widget.model.ts b/lib/core/form/components/widgets/dynamic-table/dynamic-table.widget.model.ts index a508b4bd6c..b4770732bb 100644 --- a/lib/core/form/components/widgets/dynamic-table/dynamic-table.widget.model.ts +++ b/lib/core/form/components/widgets/dynamic-table/dynamic-table.widget.model.ts @@ -145,10 +145,10 @@ export class DynamicTableModel extends FormWidgetModel { } validateRow(row: DynamicTableRow): DynamicRowValidationSummary { - const summary = { + const summary = new DynamicRowValidationSummary( { isValid: true, - text: null - }; + message: null + }); const event = new ValidateDynamicTableRowEvent(this.form, this.field, row, summary); this.formService.validateDynamicTableRow.next(event); diff --git a/lib/core/form/components/widgets/dynamic-table/editors/row.editor.html b/lib/core/form/components/widgets/dynamic-table/editors/row.editor.html index d26a343ada..cc4b07d634 100644 --- a/lib/core/form/components/widgets/dynamic-table/editors/row.editor.html +++ b/lib/core/form/components/widgets/dynamic-table/editors/row.editor.html @@ -33,7 +33,7 @@ - +
diff --git a/lib/core/form/components/widgets/dynamic-table/editors/row.editor.spec.ts b/lib/core/form/components/widgets/dynamic-table/editors/row.editor.spec.ts index 2b32f57905..9c99822df5 100644 --- a/lib/core/form/components/widgets/dynamic-table/editors/row.editor.spec.ts +++ b/lib/core/form/components/widgets/dynamic-table/editors/row.editor.spec.ts @@ -37,7 +37,7 @@ describe('RowEditorComponent', () => { it('should be valid upon init', () => { expect(component.validationSummary.isValid).toBeTruthy(); - expect(component.validationSummary.text).toBeNull(); + expect(component.validationSummary.message).toBe(''); }); it('should emit [cancel] event', (done) => { @@ -58,7 +58,7 @@ describe('RowEditorComponent', () => { it('should emit [save] event', (done) => { spyOn(component.table, 'validateRow').and.returnValue( - {isValid: true, text: null} + {isValid: true, message: null} ); component.save.subscribe(e => { expect(e.table).toBe(component.table); @@ -71,7 +71,7 @@ describe('RowEditorComponent', () => { it('should not emit [save] event for invalid row', () => { spyOn(component.table, 'validateRow').and.returnValue( - {isValid: false, text: 'error'} + {isValid: false, message: 'error'} ); let raised = false; component.save.subscribe(e => raised = true); diff --git a/lib/core/form/components/widgets/dynamic-table/editors/row.editor.ts b/lib/core/form/components/widgets/dynamic-table/editors/row.editor.ts index 5f9b476146..783aff7fda 100644 --- a/lib/core/form/components/widgets/dynamic-table/editors/row.editor.ts +++ b/lib/core/form/components/widgets/dynamic-table/editors/row.editor.ts @@ -45,7 +45,11 @@ export class RowEditorComponent { @Output() cancel: EventEmitter = new EventEmitter(); - validationSummary: DynamicRowValidationSummary = { isValid: true, text: null }; + validationSummary: DynamicRowValidationSummary; + + constructor() { + this.validationSummary = new DynamicRowValidationSummary({ isValid: true, message: '' }); + } onCancelChanges() { this.cancel.emit({ diff --git a/lib/core/form/components/widgets/dynamic-table/number-cell-validator.model.ts b/lib/core/form/components/widgets/dynamic-table/number-cell-validator.model.ts index 680b7e5c3b..7b0b568d11 100644 --- a/lib/core/form/components/widgets/dynamic-table/number-cell-validator.model.ts +++ b/lib/core/form/components/widgets/dynamic-table/number-cell-validator.model.ts @@ -54,7 +54,7 @@ export class NumberCellValidator implements CellValidator { if (summary) { summary.isValid = false; - summary.text = `Field '${column.name}' must be a number.`; + summary.message = `Field '${column.name}' must be a number.`; } return false; } diff --git a/lib/core/form/components/widgets/dynamic-table/required-cell-validator.model.ts b/lib/core/form/components/widgets/dynamic-table/required-cell-validator.model.ts index 99114b7789..9fd9f4c747 100644 --- a/lib/core/form/components/widgets/dynamic-table/required-cell-validator.model.ts +++ b/lib/core/form/components/widgets/dynamic-table/required-cell-validator.model.ts @@ -43,7 +43,7 @@ export class RequiredCellValidator implements CellValidator { if (value === null || value === undefined || value === '') { if (summary) { summary.isValid = false; - summary.text = `Field '${column.name}' is required.`; + summary.message = `Field '${column.name}' is required.`; } return false; } diff --git a/lib/core/form/components/widgets/error/error.component.html b/lib/core/form/components/widgets/error/error.component.html index c9b8e9490a..6a42f7b114 100644 --- a/lib/core/form/components/widgets/error/error.component.html +++ b/lib/core/form/components/widgets/error/error.component.html @@ -1,5 +1,5 @@
-
+
{{error.message | translate:translateParameters}}
warning
diff --git a/lib/core/form/components/widgets/error/error.component.ts b/lib/core/form/components/widgets/error/error.component.ts index f6fa7fc3bf..5aa82df601 100644 --- a/lib/core/form/components/widgets/error/error.component.ts +++ b/lib/core/form/components/widgets/error/error.component.ts @@ -60,7 +60,7 @@ export class ErrorWidgetComponent extends WidgetComponent implements OnChanges { this.required = changes.required.currentValue; this._subscriptAnimationState = 'enter'; } - if (changes['error']) { + if (changes['error'] && changes['error'].currentValue) { if (changes.error.currentValue.isActive()) { this.error = changes.error.currentValue; this.translateParameters = this.error.getAttributesAsJsonObj();