Avoid translation conflicts by setting the interal text value of message dialog butons.

This commit is contained in:
alext 2017-09-23 03:49:46 +02:00
parent de23443559
commit f166feb32f
3 changed files with 73 additions and 52 deletions

View file

@ -459,13 +459,13 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
.add({ minutes: -minuteDelta }) .add({ minutes: -minuteDelta })
.toString('yyyy-MM-dd HH:mm:ss'); .toString('yyyy-MM-dd HH:mm:ss');
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_unavailable'; var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_unavailable';
var postData = { var data = {
csrfToken: GlobalVariables.csrfToken, csrfToken: GlobalVariables.csrfToken,
unavailable: JSON.stringify(unavailable) unavailable: JSON.stringify(unavailable)
}; };
$.post(postUrl, postData, function(response) { $.post(url, data, function(response) {
$('#notification').hide('blind'); $('#notification').hide('blind');
revertFunc(); revertFunc();
}, 'json').fail(GeneralFunctions.ajaxFailureHandler); }, 'json').fail(GeneralFunctions.ajaxFailureHandler);

View file

@ -318,56 +318,71 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
$(this).parents().eq(2).popover('destroy'); // Hide the popover $(this).parents().eq(2).popover('destroy'); // Hide the popover
if (lastFocusedEventData.is_unavailable == false) { if (lastFocusedEventData.is_unavailable == false) {
var messageButtons = {}; var buttons = [
messageButtons['OK'] = function() { {
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_appointment'; text: 'OK',
var postData = { click: function() {
csrfToken: GlobalVariables.csrfToken, var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_appointment';
appointment_id : lastFocusedEventData['id'], var postData = {
delete_reason: $('#delete-reason').val() csrfToken: GlobalVariables.csrfToken,
}; appointment_id : lastFocusedEventData['id'],
delete_reason: $('#delete-reason').val()
};
$.post(postUrl, postData, function(response) { $.post(postUrl, postData, function(response) {
$('#message_box').dialog('close'); $('#message_box').dialog('close');
if (response.exceptions) { if (response.exceptions) {
response.exceptions = GeneralFunctions.parseExceptions(response.exceptions); response.exceptions = GeneralFunctions.parseExceptions(response.exceptions);
GeneralFunctions.displayMessageBox(GeneralFunctions.EXCEPTIONS_TITLE, GeneralFunctions.displayMessageBox(GeneralFunctions.EXCEPTIONS_TITLE,
GeneralFunctions.EXCEPTIONS_MESSAGE); GeneralFunctions.EXCEPTIONS_MESSAGE);
$('#message_box').append(GeneralFunctions.exceptionsToHtml(response.exceptions)); $('#message_box').append(GeneralFunctions.exceptionsToHtml(response.exceptions));
return; return;
}
if (response.warnings) {
response.warnings = GeneralFunctions.parseExceptions(response.warnings);
GeneralFunctions.displayMessageBox(GeneralFunctions.WARNINGS_TITLE,
GeneralFunctions.WARNINGS_MESSAGE);
$('#message_box').append(GeneralFunctions.exceptionsToHtml(response.warnings));
}
// Refresh calendar event items.
$('#select-filter-item').trigger('change');
}, 'json').fail(GeneralFunctions.ajaxFailureHandler);
} }
},
if (response.warnings) { {
response.warnings = GeneralFunctions.parseExceptions(response.warnings); text: EALang.cancel,
GeneralFunctions.displayMessageBox(GeneralFunctions.WARNINGS_TITLE, click: function() {
GeneralFunctions.WARNINGS_MESSAGE); $('#message_box').dialog('close');
$('#message_box').append(GeneralFunctions.exceptionsToHtml(response.warnings));
} }
}
// Refresh calendar event items. ];
$('#select-filter-item').trigger('change');
}, 'json').fail(GeneralFunctions.ajaxFailureHandler);
};
messageButtons[EALang.cancel] = function() {
$('#message_box').dialog('close');
};
GeneralFunctions.displayMessageBox(EALang.delete_appointment_title, GeneralFunctions.displayMessageBox(EALang.delete_appointment_title,
EALang.write_appointment_removal_reason, messageButtons); EALang.write_appointment_removal_reason, buttons);
$('#message_box').append('<textarea id="delete-reason" rows="3"></textarea>'); var $formGroup = $('<div/>', {
$('#delete-reason').css('width', '100%'); 'class': 'form-group'
})
.appendTo('#message_box');
$('<textarea/>', {
'id': 'delete-reason',
'class': 'form-control'
})
.appendTo($formGroup);
} else { } else {
// Do not display confirmation promt. // Do not display confirmation promt.
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_unavailable'; var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_unavailable';
var postData = { var data = {
csrfToken: GlobalVariables.csrfToken, csrfToken: GlobalVariables.csrfToken,
unavailable_id : lastFocusedEventData.id unavailable_id : lastFocusedEventData.id
}; };
$.post(postUrl, postData, function(response) { $.post(url, data, function(response) {
$('#message_box').dialog('close'); $('#message_box').dialog('close');
if (response.exceptions) { if (response.exceptions) {

View file

@ -279,22 +279,28 @@ window.FrontendBook = window.FrontendBook || {};
* @param {jQuery.Event} event * @param {jQuery.Event} event
*/ */
$('#cancel-appointment').click(function(event) { $('#cancel-appointment').click(function(event) {
var dialogButtons = {}; var buttons = [
dialogButtons['OK'] = function() { {
if ($('#cancel-reason').val() === '') { text: 'OK',
$('#cancel-reason').css('border', '2px solid red'); click: function() {
return; if ($('#cancel-reason').val() === '') {
$('#cancel-reason').css('border', '2px solid red');
return;
}
$('#cancel-appointment-form textarea').val($('#cancel-reason').val());
$('#cancel-appointment-form').submit();
}
},
{
text: EALang.cancel,
click: function() {
$('#message_box').dialog('close');
}
} }
$('#cancel-appointment-form textarea').val($('#cancel-reason').val()); ];
$('#cancel-appointment-form').submit();
};
dialogButtons[EALang.cancel] = function() {
$('#message_box').dialog('close');
};
GeneralFunctions.displayMessageBox(EALang.cancel_appointment_title, GeneralFunctions.displayMessageBox(EALang.cancel_appointment_title,
EALang.write_appointment_removal_reason, dialogButtons); EALang.write_appointment_removal_reason, buttons);
$('#message_box').append('<textarea id="cancel-reason" rows="3"></textarea>'); $('#message_box').append('<textarea id="cancel-reason" rows="3"></textarea>');
$('#cancel-reason').css('width', '100%'); $('#cancel-reason').css('width', '100%');