diff --git a/client/style/style.scss b/client/style/style.scss index dabe2a84..ee2a8799 100644 --- a/client/style/style.scss +++ b/client/style/style.scss @@ -12,11 +12,13 @@ html { .main { border-left: 1px solid $gray-300; + min-height: calc(100vh - 50px); } .sidebar { .list-group-item { padding: $spacer-2 $spacer-3; + border: none; } .list-group-flush { diff --git a/client/view/controls/table.js b/client/view/controls/table.js index 1c6c82ed..86f801f4 100644 --- a/client/view/controls/table.js +++ b/client/view/controls/table.js @@ -72,6 +72,7 @@ class TableControl extends BaseControl { return { initValue: (value, rowIndex, column) => { + column.activeControl = control; control.parent_control = this; control.doc = this.doc[this.fieldname][rowIndex]; control.set_focus(); @@ -134,11 +135,29 @@ class TableControl extends BaseControl { return []; } if (!this.doc[this.fieldname]) { - this.doc[this.fieldname] = [{}]; + this.doc[this.fieldname] = [{idx: 0}]; } return this.doc[this.fieldname]; } + + checkValidity() { + let data = this.getTableData(); + for (let rowIndex=0; rowIndex < data.length; rowIndex++) { + let row = data[rowIndex]; + for (let column of this.datatable.datamanager.columns) { + if (column.field && column.field.required) { + let value = row[column.field.fieldname]; + if (value==='' || value===undefined || value===null) { + let $cell = this.datatable.cellmanager.getCell$(column.colIndex, rowIndex); + this.datatable.cellmanager.activateEditing($cell); + return false; + } + } + } + } + return true; + } }; module.exports = TableControl; \ No newline at end of file diff --git a/client/view/form.js b/client/view/form.js index 1a549a53..f83d62c7 100644 --- a/client/view/form.js +++ b/client/view/form.js @@ -84,8 +84,24 @@ module.exports = class BaseForm extends Observable { }); } + checkValidity() { + let validity = this.form.checkValidity(); + if (validity) { + for (let control of this.controlList) { + // check validity in table + if (control.fieldtype==='Table') { + validity = control.checkValidity(); + if (!validity) { + break; + } + } + } + } + return validity; + } + async submit() { - if (!this.form.checkValidity()) { + if (!this.checkValidity()) { this.form.classList.add('was-validated'); return; }