mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
validate child table mandatory
This commit is contained in:
parent
3af4fb8671
commit
95cbd8ea61
@ -12,11 +12,13 @@ html {
|
|||||||
|
|
||||||
.main {
|
.main {
|
||||||
border-left: 1px solid $gray-300;
|
border-left: 1px solid $gray-300;
|
||||||
|
min-height: calc(100vh - 50px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar {
|
.sidebar {
|
||||||
.list-group-item {
|
.list-group-item {
|
||||||
padding: $spacer-2 $spacer-3;
|
padding: $spacer-2 $spacer-3;
|
||||||
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.list-group-flush {
|
.list-group-flush {
|
||||||
|
@ -72,6 +72,7 @@ class TableControl extends BaseControl {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
initValue: (value, rowIndex, column) => {
|
initValue: (value, rowIndex, column) => {
|
||||||
|
column.activeControl = control;
|
||||||
control.parent_control = this;
|
control.parent_control = this;
|
||||||
control.doc = this.doc[this.fieldname][rowIndex];
|
control.doc = this.doc[this.fieldname][rowIndex];
|
||||||
control.set_focus();
|
control.set_focus();
|
||||||
@ -134,11 +135,29 @@ class TableControl extends BaseControl {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if (!this.doc[this.fieldname]) {
|
if (!this.doc[this.fieldname]) {
|
||||||
this.doc[this.fieldname] = [{}];
|
this.doc[this.fieldname] = [{idx: 0}];
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.doc[this.fieldname];
|
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;
|
module.exports = TableControl;
|
@ -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() {
|
async submit() {
|
||||||
if (!this.form.checkValidity()) {
|
if (!this.checkValidity()) {
|
||||||
this.form.classList.add('was-validated');
|
this.form.classList.add('was-validated');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user