Corrected selectors for backend appointment & unavailable modals.

This commit is contained in:
Alex Tselegidis 2016-01-24 15:40:06 +01:00
parent b69ad58853
commit 181595d8bd
3 changed files with 32 additions and 34 deletions

View file

@ -327,7 +327,7 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="modal-message alert" style="display: none;"></div> <div class="modal-message alert hidden"></div>
<form class="form-horizontal"> <form class="form-horizontal">
<fieldset> <fieldset>

View file

@ -126,7 +126,7 @@ root {
display: block; display: block;
} }
#modal-message { .modal-message {
margin: 10px; margin: 10px;
} }

View file

@ -577,21 +577,19 @@ var BackendCalendar = {
var successCallback = function(response) { var successCallback = function(response) {
if (!GeneralFunctions.handleAjaxExceptions(response)) { if (!GeneralFunctions.handleAjaxExceptions(response)) {
$dialog.find('.modal-message').text(EALang['unexpected_issues_occurred']); $dialog.find('.modal-message').text(EALang['unexpected_issues_occurred']);
$dialog.find('.modal-message').addClass('alert-error'); $dialog.find('.modal-message').addClass('alert-danger').removeClass('hidden');
$dialog.find('.modal-message').fadeIn();
return false; return false;
} }
// Display success message to the user. // Display success message to the user.
$dialog.find('.modal-message').text(EALang['appointment_saved']); $dialog.find('.modal-message').text(EALang['appointment_saved']);
$dialog.find('.modal-message').addClass('alert-success').removeClass('alert-error'); $dialog.find('.modal-message').addClass('alert-success').removeClass('alert-danger hidden');
$dialog.find('.modal-message').fadeIn();
$dialog.find('.modal-body').scrollTop(0); $dialog.find('.modal-body').scrollTop(0);
// Close the modal dialog and refresh the calendar appointments // Close the modal dialog and refresh the calendar appointments
// after one second. // after one second.
setTimeout(function() { setTimeout(function() {
$dialog.find('.alert').fadeOut(); $dialog.find('.alert').addClass('hidden');
$dialog.modal('hide'); $dialog.modal('hide');
$('#select-filter-item').trigger('change'); $('#select-filter-item').trigger('change');
}, 2000); }, 2000);
@ -600,8 +598,7 @@ var BackendCalendar = {
// :: DEFINE AJAX ERROR EVENT CALLBACK // :: DEFINE AJAX ERROR EVENT CALLBACK
var errorCallback = function() { var errorCallback = function() {
$dialog.find('.modal-message').text(EALang['server_communication_error']); $dialog.find('.modal-message').text(EALang['server_communication_error']);
$dialog.find('.modal-message').addClass('alert-error'); $dialog.find('.modal-message').addClass('alert-danger').removeClass('hidden');
$dialog.find('.modal-message').fadeIn();
$dialog.find('.modal-body').scrollTop(0); $dialog.find('.modal-body').scrollTop(0);
}; };
@ -616,16 +613,16 @@ var BackendCalendar = {
* Stores the unavailable period changes or inserts a new record. * Stores the unavailable period changes or inserts a new record.
*/ */
$('#manage-unavailable #save-unavailable').click(function() { $('#manage-unavailable #save-unavailable').click(function() {
var $dialog = $('#manage-unavailable'); var $dialog = $('#manage-unavailable'),
start = $dialog.find('#unavailable-start').datetimepicker('getDate'),
var start = $dialog.find('#unavailable-start').datetimepicker('getDate'); end = $dialog.find('#unavailable-end').datetimepicker('getDate');
var end = $dialog.find('#unavailable-end').datetimepicker('getDate');
if (start > end) { if (start > end) {
// Start time is after end time - display message to user. // Start time is after end time - display message to user.
$dialog.find('.modal-message').text(EALang['start_date_before_end_error']); $dialog.find('.modal-message')
$dialog.find('.modal-message').addClass('alert-error'); .text(EALang['start_date_before_end_error'])
$dialog.find('.modal-message').fadeIn(); .addClass('alert-danger')
.removeClass('hidden');
return; return;
} }
@ -644,7 +641,7 @@ var BackendCalendar = {
var successCallback = function(response) { var successCallback = function(response) {
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
console.log('Save Unavailable Time Period Response:', response); //console.log('Save Unavailable Time Period Response:', response);
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
if (response.exceptions) { if (response.exceptions) {
@ -652,9 +649,10 @@ var BackendCalendar = {
GeneralFunctions.displayMessageBox(GeneralFunctions.EXCEPTIONS_TITLE, GeneralFunctions.EXCEPTIONS_MESSAGE); GeneralFunctions.displayMessageBox(GeneralFunctions.EXCEPTIONS_TITLE, GeneralFunctions.EXCEPTIONS_MESSAGE);
$('#message_box').append(GeneralFunctions.exceptionsToHtml(response.exceptions)); $('#message_box').append(GeneralFunctions.exceptionsToHtml(response.exceptions));
$dialog.find('.modal-message').text(EALang['unexpected_issues_occurred']); $dialog.find('.modal-message')
$dialog.find('.modal-message').addClass('alert-error'); .text(EALang['unexpected_issues_occurred'])
$dialog.find('.modal-message').fadeIn(); .addClass('alert-danger')
.removeClass('hidden');
return; return;
} }
@ -666,15 +664,16 @@ var BackendCalendar = {
} }
// Display success message to the user. // Display success message to the user.
$dialog.find('.modal-message').text(EALang['unavailable_saved']); $dialog.find('.modal-message')
$dialog.find('.modal-message').removeClass('alert-error'); .text(EALang['unavailable_saved'])
$dialog.find('.modal-message').addClass('alert-success'); .addClass('alert-success')
$dialog.find('.modal-message').fadeIn(); .removeClass('alert-danger hidden');
// Close the modal dialog and refresh the calendar appointments // Close the modal dialog and refresh the calendar appointments
// after one second. // after one second.
setTimeout(function() { setTimeout(function() {
$dialog.find('.alert').fadeOut(); $dialog.find('.alert').addClass('hidden');
$dialog.modal('hide'); $dialog.modal('hide');
$('#select-filter-item').trigger('change'); $('#select-filter-item').trigger('change');
}, 2000); }, 2000);
@ -689,8 +688,7 @@ var BackendCalendar = {
'the operation could not complete due to server communication errors.'); 'the operation could not complete due to server communication errors.');
$dialog.find('.modal-message').txt(EALang['service_communication_error']); $dialog.find('.modal-message').txt(EALang['service_communication_error']);
$dialog.find('.modal-message').addClass('alert-error'); $dialog.find('.modal-message').addClass('alert-danger').removeClass('hidden');
$dialog.find('.modal-message').fadeIn();
}; };
BackendCalendar.saveUnavailable(unavailable, successCallback, errorCallback); BackendCalendar.saveUnavailable(unavailable, successCallback, errorCallback);
@ -1998,15 +1996,15 @@ var BackendCalendar = {
var $dialog = $('#manage-appointment'); var $dialog = $('#manage-appointment');
// Reset previous validation css formating. // Reset previous validation css formating.
$dialog.find('.control-group').removeClass('error'); $dialog.find('.form-group').removeClass('has-error');
$dialog.find('.modal-message').fadeOut(); $dialog.find('.modal-message').addClass('hidden');
try { try {
// :: CHECK REQUIRED FIELDS // :: CHECK REQUIRED FIELDS
var missingRequiredField = false; var missingRequiredField = false;
$dialog.find('.required').each(function() { $dialog.find('.required').each(function() {
if ($(this).val() == '' || $(this).val() == null) { if ($(this).val() == '' || $(this).val() == null) {
$(this).parents().eq(1).addClass('error'); $(this).parents('.form-group').addClass('has-error');
missingRequiredField = true; missingRequiredField = true;
} }
}); });
@ -2016,7 +2014,7 @@ var BackendCalendar = {
// :: CHECK EMAIL ADDRESS // :: CHECK EMAIL ADDRESS
if (!GeneralFunctions.validateEmail($dialog.find('#email').val())) { if (!GeneralFunctions.validateEmail($dialog.find('#email').val())) {
$dialog.find('#email').parents().eq(1).addClass('error'); $dialog.find('#email').parents('.form-group').eq(1).addClass('has-error');
throw EALang['invalid_email']; throw EALang['invalid_email'];
} }
@ -2024,14 +2022,14 @@ var BackendCalendar = {
var start = $('#start-datetime').datepicker('getDate'); var start = $('#start-datetime').datepicker('getDate');
var end = $('#end-datetime').datepicker('getDate'); var end = $('#end-datetime').datepicker('getDate');
if (start > end) { if (start > end) {
$dialog.find('#start-datetime').parents().eq(1).addClass('error'); $dialog.find('#start-datetime').parents('.form-group').addClass('has-error');
$dialog.find('#end-datetime').parents().eq(1).addClass('error'); $dialog.find('#end-datetime').parents('.form-group').addClass('has-error');
throw EALang['start_date_before_end_error']; throw EALang['start_date_before_end_error'];
} }
return true; return true;
} catch(exc) { } catch(exc) {
$dialog.find('.modal-message').addClass('alert-error').text(exc).show('fade'); $dialog.find('.modal-message').addClass('alert-danger').text(exc).removeClass('hidden');
return false; return false;
} }
}, },