mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-08 17:12:25 +03:00
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();
|
||||
$('#categories .add-edit-delete-group').hide();
|
||||
$('#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 .results').css('color', '#AAA');
|
||||
});
|
||||
|
@ -93,8 +93,7 @@
|
|||
$('#edit-category').on('click', function () {
|
||||
$('#categories .add-edit-delete-group').hide();
|
||||
$('#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 .results').css('color', '#AAA');
|
||||
});
|
||||
|
@ -278,6 +277,9 @@
|
|||
*/
|
||||
CategoriesHelper.prototype.validate = function () {
|
||||
$('#categories .has-error').removeClass('has-error');
|
||||
$('#categories .form-message')
|
||||
.removeClass('alert-danger')
|
||||
.hide();
|
||||
|
||||
try {
|
||||
var missingRequired = false;
|
||||
|
@ -295,6 +297,10 @@
|
|||
|
||||
return true;
|
||||
} catch (error) {
|
||||
$('#categories .form-message')
|
||||
.addClass('alert-danger')
|
||||
.text(error.message)
|
||||
.show();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
@ -303,17 +309,20 @@
|
|||
* Bring the category form back to its initial state.
|
||||
*/
|
||||
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 .save-cancel-group').hide();
|
||||
$('#categories .record-details').find('input, textarea').val('');
|
||||
$('#categories .record-details').find('input, textarea').prop('readonly', true);
|
||||
$('#categories .record-details')
|
||||
.find('input, select, textarea')
|
||||
.val('')
|
||||
.prop('disabled', true);
|
||||
$('#edit-category, #delete-category').prop('disabled', true);
|
||||
|
||||
$('.record-details .has-error').removeClass('has-error');
|
||||
|
||||
$('#filter-categories .selected').removeClass('selected');
|
||||
$('#filter-categories .results').css('color', '');
|
||||
$('#filter-categories button').prop('disabled', false);
|
||||
$('#categories .record-details .has-error').removeClass('has-error');
|
||||
$('#categories .record-details .form-message').hide();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -105,9 +105,9 @@
|
|||
instance.resetForm();
|
||||
$('#add-edit-delete-group').hide();
|
||||
$('#save-cancel-group').show();
|
||||
$('.record-details').find('input, textarea').prop('readonly', false);
|
||||
$('.record-details').find('select').prop('disabled', false);
|
||||
|
||||
$('.record-details')
|
||||
.find('input, select, textarea')
|
||||
.prop('disabled', false);
|
||||
$('#filter-customers button').prop('disabled', true);
|
||||
$('#filter-customers .results').css('color', '#AAA');
|
||||
});
|
||||
|
@ -116,11 +116,11 @@
|
|||
* Event: Edit Customer Button "Click"
|
||||
*/
|
||||
$('#edit-customer').on('click', function () {
|
||||
$('.record-details').find('input, textarea').prop('readonly', false);
|
||||
$('.record-details select').prop('disabled', false);
|
||||
$('.record-details')
|
||||
.find('input, select, textarea')
|
||||
.prop('disabled', false);
|
||||
$('#add-edit-delete-group').hide();
|
||||
$('#save-cancel-group').show();
|
||||
|
||||
$('#filter-customers button').prop('disabled', true);
|
||||
$('#filter-customers .results').css('color', '#AAA');
|
||||
});
|
||||
|
@ -278,9 +278,10 @@
|
|||
* Bring the customer form back to its initial state.
|
||||
*/
|
||||
CustomersHelper.prototype.resetForm = function () {
|
||||
$('.record-details').find('input, textarea').val('');
|
||||
$('.record-details').find('input, textarea').prop('readonly', true);
|
||||
$('.record-details').find('select').prop('disabled', true);
|
||||
$('.record-details')
|
||||
.find('input, select, textarea')
|
||||
.val('')
|
||||
.prop('disabled', true);
|
||||
|
||||
$('#customer-appointments').empty();
|
||||
$('#appointment-details').toggleClass('d-none', true).empty();
|
||||
|
|
|
@ -97,9 +97,9 @@
|
|||
instance.resetForm();
|
||||
$('#services .add-edit-delete-group').hide();
|
||||
$('#services .save-cancel-group').show();
|
||||
$('#services .record-details').find('input, textarea').prop('disabled', false);
|
||||
$('#services .record-details').find('select').prop('disabled', false);
|
||||
|
||||
$('#services .record-details')
|
||||
.find('input, select textarea')
|
||||
.prop('disabled', false);
|
||||
$('#filter-services button').prop('disabled', true);
|
||||
$('#filter-services .results').css('color', '#AAA');
|
||||
});
|
||||
|
@ -155,9 +155,9 @@
|
|||
$('#edit-service').on('click', function () {
|
||||
$('#services .add-edit-delete-group').hide();
|
||||
$('#services .save-cancel-group').show();
|
||||
$('#services .record-details').find('input, textarea').prop('disabled', false);
|
||||
$('#services .record-details select').prop('disabled', false);
|
||||
|
||||
$('#services .record-details')
|
||||
.find('input, select textarea')
|
||||
.prop('disabled', false);
|
||||
$('#filter-services button').prop('disabled', true);
|
||||
$('#filter-services .results').css('color', '#AAA');
|
||||
});
|
||||
|
@ -242,6 +242,9 @@
|
|||
*/
|
||||
ServicesHelper.prototype.validate = function () {
|
||||
$('#services .has-error').removeClass('has-error');
|
||||
$('#services .form-message')
|
||||
.removeClass('alert-danger')
|
||||
.hide();
|
||||
|
||||
try {
|
||||
// validate required fields.
|
||||
|
@ -260,6 +263,10 @@
|
|||
|
||||
return true;
|
||||
} catch (error) {
|
||||
$('#services .form-message')
|
||||
.addClass('alert-danger')
|
||||
.text(error.message)
|
||||
.show();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
@ -268,19 +275,21 @@
|
|||
* Resets the service tab form back to its initial state.
|
||||
*/
|
||||
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 button').prop('disabled', false);
|
||||
$('#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('select').prop('disabled', false);
|
||||
$('#admin-password, #admin-password-confirm').addClass('required');
|
||||
$('#admin-notifications').prop('disabled', false);
|
||||
$('#filter-admins button').prop('disabled', true);
|
||||
$('#filter-admins .results').css('color', '#AAA');
|
||||
}.bind(this));
|
||||
|
@ -98,7 +97,6 @@
|
|||
$('#admins .record-details').find('input, textarea').prop('disabled', false);
|
||||
$('#admins .record-details').find('select').prop('disabled', false);
|
||||
$('#admin-password, #admin-password-confirm').removeClass('required');
|
||||
$('#admin-notifications').prop('disabled', false);
|
||||
$('#filter-admins button').prop('disabled', true);
|
||||
$('#filter-admins .results').css('color', '#AAA');
|
||||
});
|
||||
|
@ -289,21 +287,18 @@
|
|||
* Resets the admin form back to its initial state.
|
||||
*/
|
||||
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 button').prop('disabled', false);
|
||||
$('#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');
|
||||
$('#providers .record-details').find('input, select, textarea').prop('disabled', false);
|
||||
$('#provider-password, #provider-password-confirm').removeClass('required');
|
||||
$('#provider-notifications').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 input:checkbox').prop('disabled', false);
|
||||
|
@ -269,6 +268,9 @@
|
|||
*/
|
||||
ProvidersHelper.prototype.validate = function () {
|
||||
$('#providers .has-error').removeClass('has-error');
|
||||
$('#providers .form-message')
|
||||
.removeClass('alert-danger')
|
||||
.hide();
|
||||
|
||||
try {
|
||||
// Validate required fields.
|
||||
|
@ -331,7 +333,6 @@
|
|||
$('#providers .record-details').find('input, select, textarea')
|
||||
.val('')
|
||||
.prop('disabled', true);
|
||||
$('#providers .form-message').hide();
|
||||
$('#providers .add-break, .add-extra-periods, #reset-working-plan').prop('disabled', true);
|
||||
BackendUsers.wp.timepickers(true);
|
||||
$('#providers .working-plan input:text').timepicker('destroy');
|
||||
|
@ -339,7 +340,8 @@
|
|||
$('.breaks').find('.edit-break, .delete-break').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);
|
||||
$('#provider-services input:checkbox')
|
||||
|
|
|
@ -301,7 +301,12 @@
|
|||
* Resets the secretary tab form back to its initial state.
|
||||
*/
|
||||
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('')
|
||||
.prop('disabled', true);
|
||||
$('#secretaries .add-edit-delete-group').show();
|
||||
|
@ -310,10 +315,6 @@
|
|||
$('#secretaries .form-message').hide();
|
||||
$('#secretary-providers input:checkbox').prop('checked', false);
|
||||
$('#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