fix dynamic table validation (#1741)

- dynamic table widget no longer creates a copy of field model, but
uses original one, fixes the problem with validation and state
management
- update unit tests
This commit is contained in:
Denys Vuika
2017-03-22 09:58:12 +00:00
committed by Eugenio Romano
parent d32ed969a7
commit 44808a31a3
6 changed files with 24 additions and 23 deletions

View File

@@ -16,7 +16,6 @@
*/
import { FormWidgetModel } from './../core/form-widget.model';
import { FormModel } from './../core/form.model';
import { FormFieldModel } from './../core/form-field.model';
import * as moment from 'moment';
@@ -50,19 +49,19 @@ export class DynamicTableModel extends FormWidgetModel {
}
}
constructor(form: FormModel, json?: any) {
super(form, json);
constructor(field: FormFieldModel) {
super(field.form, field.json);
this.field = field;
if (json) {
this.field = new FormFieldModel(form, json);
if (field.json) {
if (json.columnDefinitions) {
this.columns = json.columnDefinitions.map(obj => <DynamicTableColumn> obj);
if (field.json.columnDefinitions) {
this.columns = field.json.columnDefinitions.map(obj => <DynamicTableColumn> obj);
this.visibleColumns = this.columns.filter(col => col.visible);
}
if (json.value) {
this.rows = json.value.map(obj => <DynamicTableRow> {selected: false, value: obj});
if (field.json.value) {
this.rows = field.json.value.map(obj => <DynamicTableRow> {selected: false, value: obj});
}
}