2
0
mirror of https://github.com/frappe/books.git synced 2025-01-22 14:48:25 +00:00

validate each step of setup wizard before next

This commit is contained in:
Faris Ansari 2018-04-02 22:36:16 +05:30
parent e4dd0a9954
commit 56aa6c70af
5 changed files with 1836 additions and 1319 deletions

View File

@ -23,14 +23,6 @@ module.exports = {
fieldtype: "Account"
},
{
"fieldname": "file",
"label": "File",
"fieldtype": "Data",
"required": 1,
"directory": 1
},
{
"fieldname": "country",
"label": "Country",
@ -53,13 +45,6 @@ module.exports = {
"required": 1
},
{
"fieldname": "abbreviation",
"label": "Abbreviation",
"fieldtype": "Data",
"required": 1
},
{
"fieldname": "bankName",
"label": "Bank Name",

View File

@ -30,7 +30,8 @@ module.exports = {
"fieldname": "email",
"label": "Email",
"fieldtype": "Data",
"required": 1
"required": 1,
"inputType": "email"
},
{
@ -40,13 +41,6 @@ module.exports = {
"required": 1
},
{
"fieldname": "abbreviation",
"label": "Abbreviation",
"fieldtype": "Data",
"required": 1
},
{
"fieldname": "bankName",
"label": "Bank Name",
@ -73,14 +67,7 @@ module.exports = {
{
title: 'Add your Company',
columns: [
{
fields: ['companyName', 'bankName']
},
{
fields: ['abbreviation']
},
]
fields: ['companyName', 'bankName']
}
]
}

View File

@ -89,7 +89,29 @@ module.exports = class SetupWizard {
}
nextSlide() {
this.showSlide(this.currentIndex + 1);
const isValid = this.validateCurrentSlide();
frappe.ui.toggleClass(this.formLayout.sections[this.currentIndex], 'was-validated', !isValid);
if (isValid) {
this.showSlide(this.currentIndex + 1);
}
}
validateCurrentSlide() {
const fields = this.getFieldsInSlide(this.currentIndex);
const inputValidityMap = fields.map(field => this.formLayout.controls[field].input.checkValidity());
const isValid = !inputValidityMap.includes(false);
return isValid;
}
getFieldsInSlide(index) {
const visibleSection = slideConfigs.layout[index];
const fieldsInSlide = visibleSection.fields ||
visibleSection.columns.reduce(
(col, fields) => fields.concat(col.fields), []
);
return fieldsInSlide;
}
activateIndicator(index) {

View File

@ -7587,3 +7587,5 @@ input[type=file] {
overflow: hidden;
position: absolute;
z-index: -1; }
.was-validated input[type=file]:invalid + button {
border-color: #dc3545; }

3095
www/dist/js/bundle.js vendored

File diff suppressed because it is too large Load Diff