Added localization for delete confirmation dialog

This commit is contained in:
Dmitry Khomutov 2017-01-14 16:58:55 +07:00
parent 839cd9ed48
commit 56cfe58c0a
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
8 changed files with 34 additions and 18 deletions

View file

@ -164,11 +164,13 @@ if (!Function.prototype.bind) {
/** /**
* Used for delete buttons in the system, just to prevent accidental clicks. * Used for delete buttons in the system, just to prevent accidental clicks.
*/ */
function confirmDelete(url, subject, reloadAfter) { function confirmDelete(url, reloadAfter) {
var dialog = new PHPCensorConfirmDialog({ var dialog = new PHPCensorConfirmDialog({
message: subject + ' will be permanently deleted. Are you sure?', title: Lang.get('confirm_title'),
confirmBtnCaption: 'Delete', message: Lang.get('confirm_message'),
confirmBtnCaption: Lang.get('confirm_ok'),
cancelBtnCaption: Lang.get('confirm_cancel'),
/* /*
confirm-btn click handler confirm-btn click handler
*/ */
@ -188,10 +190,10 @@ function confirmDelete(url, subject, reloadAfter) {
}; };
} }
dialog.showStatusMessage('Successfully deleted!', 500); dialog.showStatusMessage(Lang.get('confirm_success'), 500);
}, },
error: function (data) { error: function (data) {
dialog.showStatusMessage('Deletion failed! Server says "' + data.statusText + '"'); dialog.showStatusMessage(Lang.get('confirm_failed') + data.statusText);
if (data.status == 401) { if (data.status == 401) {
handleFailedAjax(data); handleFailedAjax(data);
@ -210,8 +212,8 @@ function confirmDelete(url, subject, reloadAfter) {
* @type {{message: string, title: string, confirmBtnCaption: string, cancelBtnCaption: string, confirmed: Function}} * @type {{message: string, title: string, confirmBtnCaption: string, cancelBtnCaption: string, confirmed: Function}}
*/ */
var PHPCensorConfirmDialogOptions = { var PHPCensorConfirmDialogOptions = {
message: 'The action will be performed and cannot be undone. Are you sure?', message: 'Are you sure?',
title: 'Confirmation Dialog', title: 'Confirmation',
confirmBtnCaption: 'Ok', confirmBtnCaption: 'Ok',
cancelBtnCaption: 'Cancel', cancelBtnCaption: 'Cancel',
confirmed: function (e) { confirmed: function (e) {
@ -350,7 +352,7 @@ var PHPCensorConfirmDialog = Class.extend({
showStatusMessage: function (message, closeTimeout) { showStatusMessage: function (message, closeTimeout) {
this.$confirmBtn.hide(); this.$confirmBtn.hide();
this.$cancelBtn.html('Close'); this.$cancelBtn.hide();
/* /*
Status message Status message
@ -468,7 +470,7 @@ var Lang = {
return sprintf.apply(sprintf[0], args); return sprintf.apply(sprintf[0], args);
} }
return 'MISSING: ' + string; return string;
} }
}; };

View file

@ -490,4 +490,11 @@ PHP Censor',
'slack_notify' => 'Slack', 'slack_notify' => 'Slack',
'technical_debt' => 'Technical Debt', 'technical_debt' => 'Technical Debt',
'xmpp' => 'XMPP', 'xmpp' => 'XMPP',
'confirm_message' => 'Item will be permanently deleted. Are you sure?',
'confirm_title' => 'Item delete confirmation',
'confirm_ok' => 'Delete',
'confirm_cancel' => 'Cancel',
'confirm_success' => 'Item successfully deleted.',
'confirm_failed' => 'Deletion failed! Server says: ',
]; ];

View file

@ -474,4 +474,11 @@ PHP Censor',
'slack_notify' => 'Slack', 'slack_notify' => 'Slack',
'technical_debt' => 'Technical Debt', 'technical_debt' => 'Technical Debt',
'xmpp' => 'XMPP', 'xmpp' => 'XMPP',
'confirm_message' => 'Элемент будет удален навсегда. Вы уверены?',
'confirm_title' => 'Подтвержение удаления',
'confirm_ok' => 'Удалить',
'confirm_cancel' => 'Отмена',
'confirm_success' => 'Элемент успешно удален.',
'confirm_failed' => 'Удаление провалилось! Ответ сервера: ',
]; ];

View file

@ -180,9 +180,8 @@ foreach ($plugins as $plugin) {
$('#delete-build').on('click', function (e) { $('#delete-build').on('click', function (e) {
e.preventDefault(); e.preventDefault();
confirmDelete( confirmDelete("<?= APP_URL; ?>build/delete/<?= $build->getId(); ?>")
"<?= APP_URL; ?>build/delete/<?= $build->getId(); ?>", "Build" .onCloseConfirmed = function () {window.location = '<?= APP_URL; ?>project/view/<?= $build->getProjectId(); ?>'};
).onCloseConfirmed = function () {window.location = '<?= APP_URL; ?>project/view/<?= $build->getProjectId(); ?>'};
}); });
}); });
</script> </script>

View file

@ -90,7 +90,8 @@ switch($build->getStatus())
$(document).ready(function() { $(document).ready(function() {
$('.delete-build').on('click', function (e) { $('.delete-build').on('click', function (e) {
e.preventDefault(); e.preventDefault();
confirmDelete(e.target.href, "Build").onCloseConfirmed = function () {window.location = window.location.href}; confirmDelete(e.target.href)
.onCloseConfirmed = function () {window.location = window.location.href};
}); });
}); });
</script> </script>

View file

@ -42,7 +42,7 @@
$(document).ready(function() { $(document).ready(function() {
$('.delete-group').on('click', function (e) { $('.delete-group').on('click', function (e) {
e.preventDefault(); e.preventDefault();
confirmDelete(e.target.href, "Group").onCloseConfirmed = function () {window.location = window.location.href}; confirmDelete(e.target.href).onCloseConfirmed = function () {window.location = window.location.href};
}); });
}); });
</script> </script>

View file

@ -164,9 +164,8 @@ print '</ul></div>';
$(function() { $(function() {
$('#delete-project').on('click', function (e) { $('#delete-project').on('click', function (e) {
e.preventDefault(); e.preventDefault();
confirmDelete( confirmDelete("<?= APP_URL; ?>project/delete/<?= $project->getId(); ?>")
"<?= APP_URL; ?>project/delete/<?= $project->getId(); ?>", "Project" .onCloseConfirmed = function () {window.location = '/'};
).onCloseConfirmed = function () {window.location = '/'};
}); });
}) })
</script> </script>

View file

@ -63,7 +63,8 @@
$(document).ready(function() { $(document).ready(function() {
$('.delete-user').on('click', function (e) { $('.delete-user').on('click', function (e) {
e.preventDefault(); e.preventDefault();
confirmDelete(e.target.href, "User").onCloseConfirmed = function () {window.location = window.location.href}; confirmDelete(e.target.href)
.onCloseConfirmed = function () {window.location = window.location.href};
}); });
}); });
</script> </script>