Refactored the backend resetForm and validation methods for consistency between pages.
This commit is contained in:
parent
64cdbfb445
commit
34e4d6ea13
6 changed files with 74 additions and 57 deletions
|
@ -82,7 +82,7 @@
|
||||||
instance.resetForm();
|
instance.resetForm();
|
||||||
$('#categories .add-edit-delete-group').hide();
|
$('#categories .add-edit-delete-group').hide();
|
||||||
$('#categories .save-cancel-group').show();
|
$('#categories .save-cancel-group').show();
|
||||||
$('#categories .record-details').find('input, textarea').prop('readonly', false);
|
$('#categories .record-details').find('input, select, textarea').prop('disabled', false);
|
||||||
$('#filter-categories button').prop('disabled', true);
|
$('#filter-categories button').prop('disabled', true);
|
||||||
$('#filter-categories .results').css('color', '#AAA');
|
$('#filter-categories .results').css('color', '#AAA');
|
||||||
});
|
});
|
||||||
|
@ -93,8 +93,7 @@
|
||||||
$('#edit-category').on('click', function () {
|
$('#edit-category').on('click', function () {
|
||||||
$('#categories .add-edit-delete-group').hide();
|
$('#categories .add-edit-delete-group').hide();
|
||||||
$('#categories .save-cancel-group').show();
|
$('#categories .save-cancel-group').show();
|
||||||
$('#categories .record-details').find('input, textarea').prop('readonly', false);
|
$('#categories .record-details').find('input, select, textarea').prop('disbaled', false);
|
||||||
|
|
||||||
$('#filter-categories button').prop('disabled', true);
|
$('#filter-categories button').prop('disabled', true);
|
||||||
$('#filter-categories .results').css('color', '#AAA');
|
$('#filter-categories .results').css('color', '#AAA');
|
||||||
});
|
});
|
||||||
|
@ -278,6 +277,9 @@
|
||||||
*/
|
*/
|
||||||
CategoriesHelper.prototype.validate = function () {
|
CategoriesHelper.prototype.validate = function () {
|
||||||
$('#categories .has-error').removeClass('has-error');
|
$('#categories .has-error').removeClass('has-error');
|
||||||
|
$('#categories .form-message')
|
||||||
|
.removeClass('alert-danger')
|
||||||
|
.hide();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var missingRequired = false;
|
var missingRequired = false;
|
||||||
|
@ -295,6 +297,10 @@
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
$('#categories .form-message')
|
||||||
|
.addClass('alert-danger')
|
||||||
|
.text(error.message)
|
||||||
|
.show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -303,17 +309,20 @@
|
||||||
* Bring the category form back to its initial state.
|
* Bring the category form back to its initial state.
|
||||||
*/
|
*/
|
||||||
CategoriesHelper.prototype.resetForm = function () {
|
CategoriesHelper.prototype.resetForm = function () {
|
||||||
|
$('#filter-categories .selected').removeClass('selected');
|
||||||
|
$('#filter-categories button').prop('disabled', false);
|
||||||
|
$('#filter-categories .results').css('color', '');
|
||||||
|
|
||||||
$('#categories .add-edit-delete-group').show();
|
$('#categories .add-edit-delete-group').show();
|
||||||
$('#categories .save-cancel-group').hide();
|
$('#categories .save-cancel-group').hide();
|
||||||
$('#categories .record-details').find('input, textarea').val('');
|
$('#categories .record-details')
|
||||||
$('#categories .record-details').find('input, textarea').prop('readonly', true);
|
.find('input, select, textarea')
|
||||||
|
.val('')
|
||||||
|
.prop('disabled', true);
|
||||||
$('#edit-category, #delete-category').prop('disabled', true);
|
$('#edit-category, #delete-category').prop('disabled', true);
|
||||||
|
|
||||||
$('.record-details .has-error').removeClass('has-error');
|
$('#categories .record-details .has-error').removeClass('has-error');
|
||||||
|
$('#categories .record-details .form-message').hide();
|
||||||
$('#filter-categories .selected').removeClass('selected');
|
|
||||||
$('#filter-categories .results').css('color', '');
|
|
||||||
$('#filter-categories button').prop('disabled', false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -105,9 +105,9 @@
|
||||||
instance.resetForm();
|
instance.resetForm();
|
||||||
$('#add-edit-delete-group').hide();
|
$('#add-edit-delete-group').hide();
|
||||||
$('#save-cancel-group').show();
|
$('#save-cancel-group').show();
|
||||||
$('.record-details').find('input, textarea').prop('readonly', false);
|
$('.record-details')
|
||||||
$('.record-details').find('select').prop('disabled', false);
|
.find('input, select, textarea')
|
||||||
|
.prop('disabled', false);
|
||||||
$('#filter-customers button').prop('disabled', true);
|
$('#filter-customers button').prop('disabled', true);
|
||||||
$('#filter-customers .results').css('color', '#AAA');
|
$('#filter-customers .results').css('color', '#AAA');
|
||||||
});
|
});
|
||||||
|
@ -116,11 +116,11 @@
|
||||||
* Event: Edit Customer Button "Click"
|
* Event: Edit Customer Button "Click"
|
||||||
*/
|
*/
|
||||||
$('#edit-customer').on('click', function () {
|
$('#edit-customer').on('click', function () {
|
||||||
$('.record-details').find('input, textarea').prop('readonly', false);
|
$('.record-details')
|
||||||
$('.record-details select').prop('disabled', false);
|
.find('input, select, textarea')
|
||||||
|
.prop('disabled', false);
|
||||||
$('#add-edit-delete-group').hide();
|
$('#add-edit-delete-group').hide();
|
||||||
$('#save-cancel-group').show();
|
$('#save-cancel-group').show();
|
||||||
|
|
||||||
$('#filter-customers button').prop('disabled', true);
|
$('#filter-customers button').prop('disabled', true);
|
||||||
$('#filter-customers .results').css('color', '#AAA');
|
$('#filter-customers .results').css('color', '#AAA');
|
||||||
});
|
});
|
||||||
|
@ -278,9 +278,10 @@
|
||||||
* Bring the customer form back to its initial state.
|
* Bring the customer form back to its initial state.
|
||||||
*/
|
*/
|
||||||
CustomersHelper.prototype.resetForm = function () {
|
CustomersHelper.prototype.resetForm = function () {
|
||||||
$('.record-details').find('input, textarea').val('');
|
$('.record-details')
|
||||||
$('.record-details').find('input, textarea').prop('readonly', true);
|
.find('input, select, textarea')
|
||||||
$('.record-details').find('select').prop('disabled', true);
|
.val('')
|
||||||
|
.prop('disabled', true);
|
||||||
|
|
||||||
$('#customer-appointments').empty();
|
$('#customer-appointments').empty();
|
||||||
$('#appointment-details').toggleClass('d-none', true).empty();
|
$('#appointment-details').toggleClass('d-none', true).empty();
|
||||||
|
|
|
@ -97,9 +97,9 @@
|
||||||
instance.resetForm();
|
instance.resetForm();
|
||||||
$('#services .add-edit-delete-group').hide();
|
$('#services .add-edit-delete-group').hide();
|
||||||
$('#services .save-cancel-group').show();
|
$('#services .save-cancel-group').show();
|
||||||
$('#services .record-details').find('input, textarea').prop('disabled', false);
|
$('#services .record-details')
|
||||||
$('#services .record-details').find('select').prop('disabled', false);
|
.find('input, select textarea')
|
||||||
|
.prop('disabled', false);
|
||||||
$('#filter-services button').prop('disabled', true);
|
$('#filter-services button').prop('disabled', true);
|
||||||
$('#filter-services .results').css('color', '#AAA');
|
$('#filter-services .results').css('color', '#AAA');
|
||||||
});
|
});
|
||||||
|
@ -155,9 +155,9 @@
|
||||||
$('#edit-service').on('click', function () {
|
$('#edit-service').on('click', function () {
|
||||||
$('#services .add-edit-delete-group').hide();
|
$('#services .add-edit-delete-group').hide();
|
||||||
$('#services .save-cancel-group').show();
|
$('#services .save-cancel-group').show();
|
||||||
$('#services .record-details').find('input, textarea').prop('disabled', false);
|
$('#services .record-details')
|
||||||
$('#services .record-details select').prop('disabled', false);
|
.find('input, select textarea')
|
||||||
|
.prop('disabled', false);
|
||||||
$('#filter-services button').prop('disabled', true);
|
$('#filter-services button').prop('disabled', true);
|
||||||
$('#filter-services .results').css('color', '#AAA');
|
$('#filter-services .results').css('color', '#AAA');
|
||||||
});
|
});
|
||||||
|
@ -242,6 +242,9 @@
|
||||||
*/
|
*/
|
||||||
ServicesHelper.prototype.validate = function () {
|
ServicesHelper.prototype.validate = function () {
|
||||||
$('#services .has-error').removeClass('has-error');
|
$('#services .has-error').removeClass('has-error');
|
||||||
|
$('#services .form-message')
|
||||||
|
.removeClass('alert-danger')
|
||||||
|
.hide();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// validate required fields.
|
// validate required fields.
|
||||||
|
@ -260,6 +263,10 @@
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
$('#services .form-message')
|
||||||
|
.addClass('alert-danger')
|
||||||
|
.text(error.message)
|
||||||
|
.show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -268,19 +275,21 @@
|
||||||
* Resets the service tab form back to its initial state.
|
* Resets the service tab form back to its initial state.
|
||||||
*/
|
*/
|
||||||
ServicesHelper.prototype.resetForm = function () {
|
ServicesHelper.prototype.resetForm = function () {
|
||||||
$('#services .record-details').find('input, textarea').val('');
|
|
||||||
$('#service-category').val('null');
|
|
||||||
$('#services .add-edit-delete-group').show();
|
|
||||||
$('#services .save-cancel-group').hide();
|
|
||||||
$('#edit-service, #delete-service').prop('disabled', true);
|
|
||||||
$('#services .record-details').find('input, textarea').prop('disabled', true);
|
|
||||||
$('#services .record-details').find('select').prop('disabled', true);
|
|
||||||
|
|
||||||
$('.record-details .has-error').removeClass('has-error');
|
|
||||||
|
|
||||||
$('#filter-services .selected').removeClass('selected');
|
$('#filter-services .selected').removeClass('selected');
|
||||||
$('#filter-services button').prop('disabled', false);
|
$('#filter-services button').prop('disabled', false);
|
||||||
$('#filter-services .results').css('color', '');
|
$('#filter-services .results').css('color', '');
|
||||||
|
|
||||||
|
$('#services .record-details')
|
||||||
|
.find('input, select, textarea')
|
||||||
|
.val('')
|
||||||
|
.prop('disabled', true);
|
||||||
|
|
||||||
|
$('#services .add-edit-delete-group').show();
|
||||||
|
$('#services .save-cancel-group').hide();
|
||||||
|
$('#edit-service, #delete-service').prop('disabled', true);
|
||||||
|
|
||||||
|
$('#services .record-details .has-error').removeClass('has-error');
|
||||||
|
$('#services .record-details .form-message').hide();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -84,7 +84,6 @@
|
||||||
$('#admins .record-details').find('input, textarea').prop('disabled', false);
|
$('#admins .record-details').find('input, textarea').prop('disabled', false);
|
||||||
$('#admins .record-details').find('select').prop('disabled', false);
|
$('#admins .record-details').find('select').prop('disabled', false);
|
||||||
$('#admin-password, #admin-password-confirm').addClass('required');
|
$('#admin-password, #admin-password-confirm').addClass('required');
|
||||||
$('#admin-notifications').prop('disabled', false);
|
|
||||||
$('#filter-admins button').prop('disabled', true);
|
$('#filter-admins button').prop('disabled', true);
|
||||||
$('#filter-admins .results').css('color', '#AAA');
|
$('#filter-admins .results').css('color', '#AAA');
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
@ -98,7 +97,6 @@
|
||||||
$('#admins .record-details').find('input, textarea').prop('disabled', false);
|
$('#admins .record-details').find('input, textarea').prop('disabled', false);
|
||||||
$('#admins .record-details').find('select').prop('disabled', false);
|
$('#admins .record-details').find('select').prop('disabled', false);
|
||||||
$('#admin-password, #admin-password-confirm').removeClass('required');
|
$('#admin-password, #admin-password-confirm').removeClass('required');
|
||||||
$('#admin-notifications').prop('disabled', false);
|
|
||||||
$('#filter-admins button').prop('disabled', true);
|
$('#filter-admins button').prop('disabled', true);
|
||||||
$('#filter-admins .results').css('color', '#AAA');
|
$('#filter-admins .results').css('color', '#AAA');
|
||||||
});
|
});
|
||||||
|
@ -289,21 +287,18 @@
|
||||||
* Resets the admin form back to its initial state.
|
* Resets the admin form back to its initial state.
|
||||||
*/
|
*/
|
||||||
AdminsHelper.prototype.resetForm = function () {
|
AdminsHelper.prototype.resetForm = function () {
|
||||||
$('#admins .add-edit-delete-group').show();
|
|
||||||
$('#admins .save-cancel-group').hide();
|
|
||||||
$('#admins .record-details').find('input, textarea').prop('disabled', true);
|
|
||||||
$('#admins .record-details').find('select').prop('disabled', true);
|
|
||||||
$('#admins .form-message').hide();
|
|
||||||
$('#admin-notifications').prop('disabled', true);
|
|
||||||
$('#admins .record-details').find('input, textarea').val('');
|
|
||||||
$('#admin-notifications').removeClass('active');
|
|
||||||
$('#edit-admin, #delete-admin').prop('disabled', true);
|
|
||||||
|
|
||||||
$('#admins .has-error').removeClass('has-error');
|
|
||||||
|
|
||||||
$('#filter-admins .selected').removeClass('selected');
|
$('#filter-admins .selected').removeClass('selected');
|
||||||
$('#filter-admins button').prop('disabled', false);
|
$('#filter-admins button').prop('disabled', false);
|
||||||
$('#filter-admins .results').css('color', '');
|
$('#filter-admins .results').css('color', '');
|
||||||
|
|
||||||
|
$('#admins .add-edit-delete-group').show();
|
||||||
|
$('#admins .save-cancel-group').hide();
|
||||||
|
$('#admins .record-details').find('input, select, textarea').prop('disabled', true);
|
||||||
|
$('#admins .record-details').find('input, textarea').val('');
|
||||||
|
$('#edit-admin, #delete-admin').prop('disabled', true);
|
||||||
|
|
||||||
|
$('#admins .has-error').removeClass('has-error');
|
||||||
|
$('#admins .form-message').hide();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -104,7 +104,6 @@
|
||||||
$('#filter-providers .results').css('color', '#AAA');
|
$('#filter-providers .results').css('color', '#AAA');
|
||||||
$('#providers .record-details').find('input, select, textarea').prop('disabled', false);
|
$('#providers .record-details').find('input, select, textarea').prop('disabled', false);
|
||||||
$('#provider-password, #provider-password-confirm').removeClass('required');
|
$('#provider-password, #provider-password-confirm').removeClass('required');
|
||||||
$('#provider-notifications').prop('disabled', false);
|
|
||||||
$('#provider-services input:checkbox').prop('disabled', false);
|
$('#provider-services input:checkbox').prop('disabled', false);
|
||||||
$('#providers').find('.add-break, .edit-break, .delete-break, .add-extra-periods, .edit-extra, .delete-extra, #reset-working-plan').prop('disabled', false);
|
$('#providers').find('.add-break, .edit-break, .delete-break, .add-extra-periods, .edit-extra, .delete-extra, #reset-working-plan').prop('disabled', false);
|
||||||
$('#providers input:checkbox').prop('disabled', false);
|
$('#providers input:checkbox').prop('disabled', false);
|
||||||
|
@ -269,6 +268,9 @@
|
||||||
*/
|
*/
|
||||||
ProvidersHelper.prototype.validate = function () {
|
ProvidersHelper.prototype.validate = function () {
|
||||||
$('#providers .has-error').removeClass('has-error');
|
$('#providers .has-error').removeClass('has-error');
|
||||||
|
$('#providers .form-message')
|
||||||
|
.removeClass('alert-danger')
|
||||||
|
.hide();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
|
@ -331,7 +333,6 @@
|
||||||
$('#providers .record-details').find('input, select, textarea')
|
$('#providers .record-details').find('input, select, textarea')
|
||||||
.val('')
|
.val('')
|
||||||
.prop('disabled', true);
|
.prop('disabled', true);
|
||||||
$('#providers .form-message').hide();
|
|
||||||
$('#providers .add-break, .add-extra-periods, #reset-working-plan').prop('disabled', true);
|
$('#providers .add-break, .add-extra-periods, #reset-working-plan').prop('disabled', true);
|
||||||
BackendUsers.wp.timepickers(true);
|
BackendUsers.wp.timepickers(true);
|
||||||
$('#providers .working-plan input:text').timepicker('destroy');
|
$('#providers .working-plan input:text').timepicker('destroy');
|
||||||
|
@ -339,7 +340,8 @@
|
||||||
$('.breaks').find('.edit-break, .delete-break').prop('disabled', true);
|
$('.breaks').find('.edit-break, .delete-break').prop('disabled', true);
|
||||||
$('.extra-periods').find('.edit-extra, .delete-extra').prop('disabled', true);
|
$('.extra-periods').find('.edit-extra, .delete-extra').prop('disabled', true);
|
||||||
|
|
||||||
$('#providers .has-error').removeClass('has-error');
|
$('#providers .record-details .has-error').removeClass('has-error');
|
||||||
|
$('#providers .record-details .form-message').hide();
|
||||||
|
|
||||||
$('#edit-provider, #delete-provider').prop('disabled', true);
|
$('#edit-provider, #delete-provider').prop('disabled', true);
|
||||||
$('#provider-services input:checkbox')
|
$('#provider-services input:checkbox')
|
||||||
|
|
|
@ -301,7 +301,12 @@
|
||||||
* Resets the secretary tab form back to its initial state.
|
* Resets the secretary tab form back to its initial state.
|
||||||
*/
|
*/
|
||||||
SecretariesHelper.prototype.resetForm = function () {
|
SecretariesHelper.prototype.resetForm = function () {
|
||||||
$('#secretaries .record-details').find('input, select, textarea')
|
$('#filter-secretaries .selected').removeClass('selected');
|
||||||
|
$('#filter-secretaries button').prop('disabled', false);
|
||||||
|
$('#filter-secretaries .results').css('color', '');
|
||||||
|
|
||||||
|
$('#secretaries .record-details')
|
||||||
|
.find('input, select, textarea')
|
||||||
.val('')
|
.val('')
|
||||||
.prop('disabled', true);
|
.prop('disabled', true);
|
||||||
$('#secretaries .add-edit-delete-group').show();
|
$('#secretaries .add-edit-delete-group').show();
|
||||||
|
@ -310,10 +315,6 @@
|
||||||
$('#secretaries .form-message').hide();
|
$('#secretaries .form-message').hide();
|
||||||
$('#secretary-providers input:checkbox').prop('checked', false);
|
$('#secretary-providers input:checkbox').prop('checked', false);
|
||||||
$('#secretaries .has-error').removeClass('has-error');
|
$('#secretaries .has-error').removeClass('has-error');
|
||||||
|
|
||||||
$('#filter-secretaries .selected').removeClass('selected');
|
|
||||||
$('#filter-secretaries button').prop('disabled', false);
|
|
||||||
$('#filter-secretaries .results').css('color', '');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue