initial commit
This commit is contained in:
@@ -0,0 +1,140 @@
|
||||
"use strict";
|
||||
|
||||
// Class definition
|
||||
var KTModalCreateProjectBudget = function () {
|
||||
// Variables
|
||||
var nextButton;
|
||||
var previousButton;
|
||||
var validator;
|
||||
var form;
|
||||
var stepper;
|
||||
|
||||
// Private functions
|
||||
var initValidation = function() {
|
||||
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
|
||||
validator = FormValidation.formValidation(
|
||||
form,
|
||||
{
|
||||
fields: {
|
||||
'budget_setup': {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Budget amount is required'
|
||||
},
|
||||
callback: {
|
||||
message: 'The budget amount must be greater than $100',
|
||||
callback: function(input) {
|
||||
var currency = input.value;
|
||||
currency = currency.replace(/[$,]+/g,"");
|
||||
|
||||
if (parseFloat(currency) < 100) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'budget_usage': {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Budget usage type is required'
|
||||
}
|
||||
}
|
||||
},
|
||||
'budget_allow': {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Allowing budget is required'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap: new FormValidation.plugins.Bootstrap5({
|
||||
rowSelector: '.fv-row',
|
||||
eleInvalidClass: '',
|
||||
eleValidClass: ''
|
||||
})
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Revalidate on change
|
||||
KTDialer.getInstance(form.querySelector('#kt_modal_create_project_budget_setup')).on('kt.dialer.changed', function() {
|
||||
// Revalidate the field when an option is chosen
|
||||
validator.revalidateField('budget_setup');
|
||||
});
|
||||
}
|
||||
|
||||
var handleForm = function() {
|
||||
nextButton.addEventListener('click', function (e) {
|
||||
// Prevent default button action
|
||||
e.preventDefault();
|
||||
|
||||
// Disable button to avoid multiple click
|
||||
nextButton.disabled = true;
|
||||
|
||||
// Validate form before submit
|
||||
if (validator) {
|
||||
validator.validate().then(function (status) {
|
||||
console.log('validated!');
|
||||
|
||||
if (status == 'Valid') {
|
||||
// Show loading indication
|
||||
nextButton.setAttribute('data-kt-indicator', 'on');
|
||||
|
||||
// Simulate form submission
|
||||
setTimeout(function() {
|
||||
// Simulate form submission
|
||||
nextButton.removeAttribute('data-kt-indicator');
|
||||
|
||||
// Enable button
|
||||
nextButton.disabled = false;
|
||||
|
||||
// Go to next step
|
||||
stepper.goNext();
|
||||
}, 1500);
|
||||
} else {
|
||||
// Enable button
|
||||
nextButton.disabled = false;
|
||||
|
||||
// Show popup warning. For more info check the plugin's official documentation: https://sweetalert2.github.io/
|
||||
Swal.fire({
|
||||
text: "Sorry, looks like there are some errors detected, please try again.",
|
||||
icon: "error",
|
||||
buttonsStyling: false,
|
||||
confirmButtonText: "Ok, got it!",
|
||||
customClass: {
|
||||
confirmButton: "btn btn-primary"
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
previousButton.addEventListener('click', function () {
|
||||
stepper.goPrevious();
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
// Public functions
|
||||
init: function () {
|
||||
form = KTModalCreateProject.getForm();
|
||||
stepper = KTModalCreateProject.getStepperObj();
|
||||
nextButton = KTModalCreateProject.getStepper().querySelector('[data-kt-element="budget-next"]');
|
||||
previousButton = KTModalCreateProject.getStepper().querySelector('[data-kt-element="budget-previous"]');
|
||||
|
||||
initValidation();
|
||||
handleForm();
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
// Webpack support
|
||||
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
|
||||
window.KTModalCreateProjectBudget = module.exports = KTModalCreateProjectBudget;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
// Class definition
|
||||
var KTModalCreateProjectComplete = function () {
|
||||
// Variables
|
||||
var startButton;
|
||||
var form;
|
||||
var stepper;
|
||||
|
||||
// Private functions
|
||||
var handleForm = function() {
|
||||
startButton.addEventListener('click', function () {
|
||||
stepper.goTo(1);
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
// Public functions
|
||||
init: function () {
|
||||
form = KTModalCreateProject.getForm();
|
||||
stepper = KTModalCreateProject.getStepperObj();
|
||||
startButton = KTModalCreateProject.getStepper().querySelector('[data-kt-element="complete-start"]');
|
||||
|
||||
handleForm();
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
// Webpack support
|
||||
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
|
||||
window.KTModalCreateProjectComplete = module.exports = KTModalCreateProjectComplete;
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
|
||||
// Class definition
|
||||
var KTModalCreateProjectFiles = function () {
|
||||
// Variables
|
||||
var nextButton;
|
||||
var previousButton;
|
||||
var form;
|
||||
var stepper;
|
||||
|
||||
// Private functions
|
||||
var initForm = function() {
|
||||
// Project logo
|
||||
// For more info about Dropzone plugin visit: https://www.dropzonejs.com/#usage
|
||||
var myDropzone = new Dropzone("#kt_modal_create_project_files_upload", {
|
||||
url: "https://keenthemes.com/scripts/void.php", // Set the url for your upload script location
|
||||
paramName: "file", // The name that will be used to transfer the file
|
||||
maxFiles: 10,
|
||||
maxFilesize: 10, // MB
|
||||
addRemoveLinks: true,
|
||||
accept: function(file, done) {
|
||||
if (file.name == "justinbieber.jpg") {
|
||||
done("Naha, you don't.");
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var handleForm = function() {
|
||||
nextButton.addEventListener('click', function (e) {
|
||||
// Prevent default button action
|
||||
e.preventDefault();
|
||||
|
||||
// Disable button to avoid multiple click
|
||||
nextButton.disabled = true;
|
||||
|
||||
// Show loading indication
|
||||
nextButton.setAttribute('data-kt-indicator', 'on');
|
||||
|
||||
// Simulate form submission
|
||||
setTimeout(function() {
|
||||
// Hide loading indication
|
||||
nextButton.removeAttribute('data-kt-indicator');
|
||||
|
||||
// Enable button
|
||||
nextButton.disabled = false;
|
||||
|
||||
// Go to next step
|
||||
stepper.goNext();
|
||||
}, 1500);
|
||||
});
|
||||
|
||||
previousButton.addEventListener('click', function () {
|
||||
stepper.goPrevious();
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
// Public functions
|
||||
init: function () {
|
||||
form = KTModalCreateProject.getForm();
|
||||
stepper = KTModalCreateProject.getStepperObj();
|
||||
nextButton = KTModalCreateProject.getStepper().querySelector('[data-kt-element="files-next"]');
|
||||
previousButton = KTModalCreateProject.getStepper().querySelector('[data-kt-element="files-previous"]');
|
||||
|
||||
initForm();
|
||||
handleForm();
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
// Webpack support
|
||||
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
|
||||
window.KTModalCreateProjectFiles = module.exports = KTModalCreateProjectFiles;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
|
||||
// Class definition
|
||||
var KTModalCreateProject = function () {
|
||||
// Private variables
|
||||
var stepper;
|
||||
var stepperObj;
|
||||
var form;
|
||||
|
||||
// Private functions
|
||||
var initStepper = function () {
|
||||
// Initialize Stepper
|
||||
stepperObj = new KTStepper(stepper);
|
||||
}
|
||||
|
||||
return {
|
||||
// Public functions
|
||||
init: function () {
|
||||
stepper = document.querySelector('#kt_modal_create_project_stepper');
|
||||
form = document.querySelector('#kt_modal_create_project_form');
|
||||
|
||||
initStepper();
|
||||
},
|
||||
|
||||
getStepperObj: function () {
|
||||
return stepperObj;
|
||||
},
|
||||
|
||||
getStepper: function () {
|
||||
return stepper;
|
||||
},
|
||||
|
||||
getForm: function () {
|
||||
return form;
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
// On document ready
|
||||
KTUtil.onDOMContentLoaded(function () {
|
||||
if (!document.querySelector('#kt_modal_create_project')) {
|
||||
return;
|
||||
}
|
||||
|
||||
KTModalCreateProject.init();
|
||||
KTModalCreateProjectType.init();
|
||||
KTModalCreateProjectBudget.init();
|
||||
KTModalCreateProjectSettings.init();
|
||||
KTModalCreateProjectTeam.init();
|
||||
KTModalCreateProjectTargets.init();
|
||||
KTModalCreateProjectFiles.init();
|
||||
KTModalCreateProjectComplete.init();
|
||||
});
|
||||
|
||||
// Webpack support
|
||||
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
|
||||
window.KTModalCreateProject = module.exports = KTModalCreateProject;
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
"use strict";
|
||||
|
||||
// Class definition
|
||||
var KTModalCreateProjectSettings = function () {
|
||||
// Variables
|
||||
var nextButton;
|
||||
var previousButton;
|
||||
var validator;
|
||||
var form;
|
||||
var stepper;
|
||||
|
||||
// Private functions
|
||||
var initForm = function() {
|
||||
// Project logo
|
||||
// For more info about Dropzone plugin visit: https://www.dropzonejs.com/#usage
|
||||
var myDropzone = new Dropzone("#kt_modal_create_project_settings_logo", {
|
||||
url: "https://keenthemes.com/scripts/void.php", // Set the url for your upload script location
|
||||
paramName: "file", // The name that will be used to transfer the file
|
||||
maxFiles: 10,
|
||||
maxFilesize: 10, // MB
|
||||
addRemoveLinks: true,
|
||||
accept: function(file, done) {
|
||||
if (file.name == "justinbieber.jpg") {
|
||||
done("Naha, you don't.");
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Due date. For more info, please visit the official plugin site: https://flatpickr.js.org/
|
||||
var releaseDate = $(form.querySelector('[name="settings_release_date"]'));
|
||||
releaseDate.flatpickr({
|
||||
enableTime: true,
|
||||
dateFormat: "d, M Y, H:i",
|
||||
});
|
||||
|
||||
// Expiry year. For more info, plase visit the official plugin site: https://select2.org/
|
||||
$(form.querySelector('[name="settings_customer"]')).on('change', function() {
|
||||
// Revalidate the field when an option is chosen
|
||||
validator.revalidateField('settings_customer');
|
||||
});
|
||||
}
|
||||
|
||||
var initValidation = function() {
|
||||
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
|
||||
validator = FormValidation.formValidation(
|
||||
form,
|
||||
{
|
||||
fields: {
|
||||
'settings_name': {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Project name is required'
|
||||
}
|
||||
}
|
||||
},
|
||||
'settings_customer': {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Customer is required'
|
||||
}
|
||||
}
|
||||
},
|
||||
'settings_description': {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Description is required'
|
||||
}
|
||||
}
|
||||
},
|
||||
'settings_release_date': {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Release date is required'
|
||||
}
|
||||
}
|
||||
},
|
||||
'settings_notifications[]': {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Notifications are required'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap: new FormValidation.plugins.Bootstrap5({
|
||||
rowSelector: '.fv-row',
|
||||
eleInvalidClass: '',
|
||||
eleValidClass: ''
|
||||
})
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
var handleForm = function() {
|
||||
nextButton.addEventListener('click', function (e) {
|
||||
// Prevent default button action
|
||||
e.preventDefault();
|
||||
|
||||
// Disable button to avoid multiple click
|
||||
nextButton.disabled = true;
|
||||
|
||||
// Validate form before submit
|
||||
if (validator) {
|
||||
validator.validate().then(function (status) {
|
||||
console.log('validated!');
|
||||
|
||||
if (status == 'Valid') {
|
||||
// Show loading indication
|
||||
nextButton.setAttribute('data-kt-indicator', 'on');
|
||||
|
||||
// Simulate form submission
|
||||
setTimeout(function() {
|
||||
// Simulate form submission
|
||||
nextButton.removeAttribute('data-kt-indicator');
|
||||
|
||||
// Enable button
|
||||
nextButton.disabled = false;
|
||||
|
||||
// Go to next step
|
||||
stepper.goNext();
|
||||
}, 1500);
|
||||
} else {
|
||||
// Enable button
|
||||
nextButton.disabled = false;
|
||||
|
||||
// Show popup warning. For more info check the plugin's official documentation: https://sweetalert2.github.io/
|
||||
Swal.fire({
|
||||
text: "Sorry, looks like there are some errors detected, please try again.",
|
||||
icon: "error",
|
||||
buttonsStyling: false,
|
||||
confirmButtonText: "Ok, got it!",
|
||||
customClass: {
|
||||
confirmButton: "btn btn-primary"
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
previousButton.addEventListener('click', function () {
|
||||
// Go to previous step
|
||||
stepper.goPrevious();
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
// Public functions
|
||||
init: function () {
|
||||
form = KTModalCreateProject.getForm();
|
||||
stepper = KTModalCreateProject.getStepperObj();
|
||||
nextButton = KTModalCreateProject.getStepper().querySelector('[data-kt-element="settings-next"]');
|
||||
previousButton = KTModalCreateProject.getStepper().querySelector('[data-kt-element="settings-previous"]');
|
||||
|
||||
initForm();
|
||||
initValidation();
|
||||
handleForm();
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
// Webpack support
|
||||
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
|
||||
window.KTModalCreateProjectSettings = module.exports = KTModalCreateProjectSettings;
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
"use strict";
|
||||
|
||||
// Class definition
|
||||
var KTModalCreateProjectTargets = function () {
|
||||
// Variables
|
||||
var nextButton;
|
||||
var previousButton;
|
||||
var validator;
|
||||
var form;
|
||||
var stepper;
|
||||
|
||||
// Private functions
|
||||
var initForm = function() {
|
||||
// Tags. For more info, please visit the official plugin site: https://yaireo.github.io/tagify/
|
||||
var tags = new Tagify(form.querySelector('[name="target_tags"]'), {
|
||||
whitelist: ["Important", "Urgent", "High", "Medium", "Low"],
|
||||
maxTags: 5,
|
||||
dropdown: {
|
||||
maxItems: 10, // <- mixumum allowed rendered suggestions
|
||||
enabled: 0, // <- show suggestions on focus
|
||||
closeOnSelect: false // <- do not hide the suggestions dropdown once an item has been selected
|
||||
}
|
||||
});
|
||||
tags.on("change", function(){
|
||||
// Revalidate the field when an option is chosen
|
||||
validator.revalidateField('tags');
|
||||
});
|
||||
|
||||
// Due date. For more info, please visit the official plugin site: https://flatpickr.js.org/
|
||||
var dueDate = $(form.querySelector('[name="target_due_date"]'));
|
||||
dueDate.flatpickr({
|
||||
enableTime: true,
|
||||
dateFormat: "d, M Y, H:i",
|
||||
});
|
||||
|
||||
// Expiry year. For more info, plase visit the official plugin site: https://select2.org/
|
||||
$(form.querySelector('[name="target_assign"]')).on('change', function() {
|
||||
// Revalidate the field when an option is chosen
|
||||
validator.revalidateField('target_assign');
|
||||
});
|
||||
}
|
||||
|
||||
var initValidation = function() {
|
||||
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
|
||||
validator = FormValidation.formValidation(
|
||||
form,
|
||||
{
|
||||
fields: {
|
||||
'target_title': {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Target title is required'
|
||||
}
|
||||
}
|
||||
},
|
||||
'target_assign': {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Customer is required'
|
||||
}
|
||||
}
|
||||
},
|
||||
'target_due_date': {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Due date is required'
|
||||
}
|
||||
}
|
||||
},
|
||||
'target_tags': {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Target tags are required'
|
||||
}
|
||||
}
|
||||
},
|
||||
'target_allow': {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Allowing target is required'
|
||||
}
|
||||
}
|
||||
},
|
||||
'target_notifications[]': {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Notifications are required'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap: new FormValidation.plugins.Bootstrap5({
|
||||
rowSelector: '.fv-row',
|
||||
eleInvalidClass: '',
|
||||
eleValidClass: ''
|
||||
})
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
var handleForm = function() {
|
||||
nextButton.addEventListener('click', function (e) {
|
||||
// Prevent default button action
|
||||
e.preventDefault();
|
||||
|
||||
// Disable button to avoid multiple click
|
||||
nextButton.disabled = true;
|
||||
|
||||
// Validate form before submit
|
||||
if (validator) {
|
||||
validator.validate().then(function (status) {
|
||||
console.log('validated!');
|
||||
|
||||
if (status == 'Valid') {
|
||||
// Show loading indication
|
||||
nextButton.setAttribute('data-kt-indicator', 'on');
|
||||
|
||||
// Simulate form submission
|
||||
setTimeout(function() {
|
||||
// Simulate form submission
|
||||
nextButton.removeAttribute('data-kt-indicator');
|
||||
|
||||
// Enable button
|
||||
nextButton.disabled = false;
|
||||
|
||||
// Go to next step
|
||||
stepper.goNext();
|
||||
}, 1500);
|
||||
} else {
|
||||
// Enable button
|
||||
nextButton.disabled = false;
|
||||
|
||||
// Show popup warning. For more info check the plugin's official documentation: https://sweetalert2.github.io/
|
||||
Swal.fire({
|
||||
text: "Sorry, looks like there are some errors detected, please try again.",
|
||||
icon: "error",
|
||||
buttonsStyling: false,
|
||||
confirmButtonText: "Ok, got it!",
|
||||
customClass: {
|
||||
confirmButton: "btn btn-primary"
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
previousButton.addEventListener('click', function () {
|
||||
// Go to previous step
|
||||
stepper.goPrevious();
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
// Public functions
|
||||
init: function () {
|
||||
form = KTModalCreateProject.getForm();
|
||||
stepper = KTModalCreateProject.getStepperObj();
|
||||
nextButton = KTModalCreateProject.getStepper().querySelector('[data-kt-element="targets-next"]');
|
||||
previousButton = KTModalCreateProject.getStepper().querySelector('[data-kt-element="targets-previous"]');
|
||||
|
||||
initForm();
|
||||
initValidation();
|
||||
handleForm();
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
// Webpack support
|
||||
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
|
||||
window.KTModalCreateProjectTargets = module.exports = KTModalCreateProjectTargets;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
"use strict";
|
||||
|
||||
// Class definition
|
||||
var KTModalCreateProjectTeam = function () {
|
||||
// Variables
|
||||
var nextButton;
|
||||
var previousButton;
|
||||
var form;
|
||||
var stepper;
|
||||
|
||||
// Private functions
|
||||
var handleForm = function() {
|
||||
nextButton.addEventListener('click', function (e) {
|
||||
// Prevent default button action
|
||||
e.preventDefault();
|
||||
|
||||
// Disable button to avoid multiple click
|
||||
nextButton.disabled = true;
|
||||
|
||||
// Show loading indication
|
||||
nextButton.setAttribute('data-kt-indicator', 'on');
|
||||
|
||||
// Simulate form submission
|
||||
setTimeout(function() {
|
||||
// Enable button
|
||||
nextButton.disabled = false;
|
||||
|
||||
// Simulate form submission
|
||||
nextButton.removeAttribute('data-kt-indicator');
|
||||
|
||||
// Go to next step
|
||||
stepper.goNext();
|
||||
}, 1500);
|
||||
});
|
||||
|
||||
previousButton.addEventListener('click', function () {
|
||||
stepper.goPrevious();
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
// Public functions
|
||||
init: function () {
|
||||
form = KTModalCreateProject.getForm();
|
||||
stepper = KTModalCreateProject.getStepperObj();
|
||||
nextButton = KTModalCreateProject.getStepper().querySelector('[data-kt-element="team-next"]');
|
||||
previousButton = KTModalCreateProject.getStepper().querySelector('[data-kt-element="team-previous"]');
|
||||
|
||||
handleForm();
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
// Webpack support
|
||||
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
|
||||
window.KTModalCreateProjectTeam = module.exports = KTModalCreateProjectTeam;
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
"use strict";
|
||||
|
||||
// Class definition
|
||||
var KTModalCreateProjectType = function () {
|
||||
// Variables
|
||||
var nextButton;
|
||||
var validator;
|
||||
var form;
|
||||
var stepper;
|
||||
|
||||
// Private functions
|
||||
var initValidation = function() {
|
||||
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
|
||||
validator = FormValidation.formValidation(
|
||||
form,
|
||||
{
|
||||
fields: {
|
||||
'project_type': {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Project type is required'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap: new FormValidation.plugins.Bootstrap5({
|
||||
rowSelector: '.fv-row',
|
||||
eleInvalidClass: '',
|
||||
eleValidClass: ''
|
||||
})
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
var handleForm = function() {
|
||||
nextButton.addEventListener('click', function (e) {
|
||||
// Prevent default button action
|
||||
e.preventDefault();
|
||||
|
||||
// Disable button to avoid multiple click
|
||||
nextButton.disabled = true;
|
||||
|
||||
// Validate form before submit
|
||||
if (validator) {
|
||||
validator.validate().then(function (status) {
|
||||
console.log('validated!');
|
||||
e.preventDefault();
|
||||
|
||||
if (status == 'Valid') {
|
||||
// Show loading indication
|
||||
nextButton.setAttribute('data-kt-indicator', 'on');
|
||||
|
||||
// Simulate form submission
|
||||
setTimeout(function() {
|
||||
// Simulate form submission
|
||||
nextButton.removeAttribute('data-kt-indicator');
|
||||
|
||||
// Enable button
|
||||
nextButton.disabled = false;
|
||||
|
||||
// Go to next step
|
||||
stepper.goNext();
|
||||
}, 1000);
|
||||
} else {
|
||||
// Enable button
|
||||
nextButton.disabled = false;
|
||||
|
||||
// Show popup warning. For more info check the plugin's official documentation: https://sweetalert2.github.io/
|
||||
Swal.fire({
|
||||
text: "Sorry, looks like there are some errors detected, please try again.",
|
||||
icon: "error",
|
||||
buttonsStyling: false,
|
||||
confirmButtonText: "Ok, got it!",
|
||||
customClass: {
|
||||
confirmButton: "btn btn-primary"
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
// Public functions
|
||||
init: function () {
|
||||
form = KTModalCreateProject.getForm();
|
||||
stepper = KTModalCreateProject.getStepperObj();
|
||||
nextButton = KTModalCreateProject.getStepper().querySelector('[data-kt-element="type-next"]');
|
||||
|
||||
initValidation();
|
||||
handleForm();
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
// Webpack support
|
||||
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
|
||||
window.KTModalCreateProjectType = module.exports = KTModalCreateProjectType;
|
||||
}
|
||||
Reference in New Issue
Block a user