/** * FIXME: document and implement this method !!! * @param errorObj * @param showAlert * @param modal */ function errorHandler(errorObj, showAlert = false, modal = null) { console.log(errorObj); if (showAlert) { alert('ERROR [' + errorObj.code + ']: ' + errorObj.message); } else { showAlertMessage('error', errorObj.message, modal); } } function loginErrorHandler(errorObj, type = 'error', modal = null) { var typeMap = { error: 'danger', warning: 'warning', info: 'info', success: 'success' }; var alertClass = 'alert-' + typeMap[type]; var cleanUpAlertClass = function(alertDiv) { for (var key in typeMap) { if (typeMap.hasOwnProperty(key) && alertDiv.hasClass('alert-' + typeMap[key])) { alertDiv.removeClass('alert-' + typeMap[key]) } } }; var loginAlertMessageDiv; if (modal) { loginAlertMessageDiv = modal.find('.login_modal_alert_message'); loginAlertMessageDiv = loginAlertMessageDiv[0]; $(loginAlertMessageDiv).hide(); cleanUpAlertClass($(loginAlertMessageDiv)); $(loginAlertMessageDiv).addClass(alertClass); $(loginAlertMessageDiv).find('[data-context="alert_message_text"]').html('Oups! ' + errorObj.message); $(loginAlertMessageDiv).show(); } else { loginAlertMessageDiv = $('#login_alert_message'); loginAlertMessageDiv.css('visibility', 'hidden'); loginAlertMessageDiv.find('[data-context="alert_message_text"]').html(errorObj.message); loginAlertMessageDiv.css('visibility', 'visible'); } } function activateAccountErrorHandler(errorObj, event) { var activateAccAlertMessageDiv = $('#activate_acc_alert_message'); activateAccAlertMessageDiv.css('visibility', 'hidden'); switch(event) { case 'error': if (activateAccAlertMessageDiv.hasClass('onSuccess')) { activateAccAlertMessageDiv.removeClass('onSuccess'); } activateAccAlertMessageDiv.find('[data-context="alert_message_text"]').html('').html(errorObj.message); break; case 'success': if (!activateAccAlertMessageDiv.hasClass('onSuccess')) { activateAccAlertMessageDiv.addClass('onSuccess'); } var successMessage = 'Contul dumneavoastră a fost activat cu success!
'; successMessage += 'Apăsați aici pentru a fi redirecționat către pagina de autentificare.'; activateAccAlertMessageDiv.find('[data-context="alert_message_text"]').html('').html(successMessage); break; } activateAccAlertMessageDiv.css('visibility', 'visible'); } var _errorMap = { 'validator': { 'general': { 'current_page': {code: 'general_001', message: 'Invalid current page number'} }, 'activity': { 'activity_id': {code: 'activity_001', message: 'Invalid activity IDe'}, 'title': {code: 'activity_002', message: 'Invalid activity title'}, 'date_started_at': {code: 'activity_003', message: 'Invalid activity started_at date'}, 'date_finished_at': {code: 'activity_004', message: 'Invalid activity finished_at date'}, 'location': {code: 'activity_005', message: 'Invalid activity location'}, 'responsible': {code: 'activity_006', message: 'Invalid activity responsible user ID'}, 'category': {code: 'activity_007', message: 'Invalid activity category ID'}, 'group': {code: 'activity_008', message: 'Invalid activity group ID'}, 'activity_label': {code: 'activity_009', message: 'Invalid activity label ID'}, 'training_title': {code: 'activity_010', message: 'Invalid training title'}, 'training_label': {code: 'activity_011', message: 'Invalid training label ID'}, 'motion_title': {code: 'activity_012', message: 'Invalid motion title'}, 'motion_label': {code: 'activity_013', message: 'Invalid motion label ID'}, 'observation': {code: 'activity_014', message: 'Invalid activity notes'}, 'participant': {code: 'activity_015', message: 'Invalid participant user ID'} }, 'user_management': { 'user_role': {code: 'um_001', message: 'Invalid user role'}, 'user_club': {code: 'um_002', message: 'Invalid user club ID'}, 'email': {code: 'um_003', message: 'Invalid user email address'}, 'first_name': {code: 'um_004', message: 'Invalid user first name'}, 'last_name': {code: 'um_005', message: 'Invalid user last name'}, 'club_name': {code: 'um_006', message: 'Invalid club name'}, 'club_region': {code: 'um_007', message: 'Invalid club region ID'} }, 'groups': { 'group_id': {code: 'groups_001', message: 'Invalid group ID'}, 'name': {code: 'groups_002', message: 'Invalid group name'}, 'label': {code: 'groups_003', message: 'Invalid group label'} }, 'login': { 'email': {code: 'login_001', message: 'Invalid email address'}, 'username': {code: 'login_002', message: 'Invalid username'}, 'password': {code: 'login_003', message: 'Invalid password'}, 'activation_id': {code: 'login_004', message: 'Invalid activation link'} } } };