Merge branch 'feature-delete-confirm'
This commit is contained in:
commit
b3dee9d7a2
|
@ -567,3 +567,7 @@ h6,
|
|||
.visible-line-breaks {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.btn-group-right {
|
||||
float: right;
|
||||
}
|
||||
|
|
|
@ -164,11 +164,13 @@ if (!Function.prototype.bind) {
|
|||
/**
|
||||
* 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({
|
||||
message: subject + ' will be permanently deleted. Are you sure?',
|
||||
confirmBtnCaption: 'Delete',
|
||||
title: Lang.get('confirm_title'),
|
||||
message: Lang.get('confirm_message'),
|
||||
confirmBtnCaption: Lang.get('confirm_ok'),
|
||||
cancelBtnCaption: Lang.get('confirm_cancel'),
|
||||
/*
|
||||
confirm-btn click handler
|
||||
*/
|
||||
|
@ -188,10 +190,10 @@ function confirmDelete(url, subject, reloadAfter) {
|
|||
};
|
||||
}
|
||||
|
||||
dialog.showStatusMessage('Successfully deleted!', 1000);
|
||||
dialog.showStatusMessage(Lang.get('confirm_success'), 500);
|
||||
},
|
||||
error: function (data) {
|
||||
dialog.showStatusMessage('Deletion failed! Server says "' + data.statusText + '"');
|
||||
dialog.showStatusMessage(Lang.get('confirm_failed') + data.statusText);
|
||||
|
||||
if (data.status == 401) {
|
||||
handleFailedAjax(data);
|
||||
|
@ -210,8 +212,8 @@ function confirmDelete(url, subject, reloadAfter) {
|
|||
* @type {{message: string, title: string, confirmBtnCaption: string, cancelBtnCaption: string, confirmed: Function}}
|
||||
*/
|
||||
var PHPCensorConfirmDialogOptions = {
|
||||
message: 'The action will be performed and cannot be undone. Are you sure?',
|
||||
title: 'Confirmation Dialog',
|
||||
message: 'Are you sure?',
|
||||
title: 'Confirmation',
|
||||
confirmBtnCaption: 'Ok',
|
||||
cancelBtnCaption: 'Cancel',
|
||||
confirmed: function (e) {
|
||||
|
@ -239,22 +241,22 @@ var PHPCensorConfirmDialog = Class.extend({
|
|||
*/
|
||||
$('body').append(
|
||||
'<div class="modal fade" id="confirm-dialog">'
|
||||
+ '<div class="modal-dialog">'
|
||||
+ '<div class="modal-content">'
|
||||
+ '<div class="modal-header">'
|
||||
+ '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'
|
||||
+ '<h4 class="modal-title"></h4>'
|
||||
+ '</div>'
|
||||
+ '<div class="modal-body">'
|
||||
+ '<p></p>'
|
||||
+ '</div>'
|
||||
+ '<div class="modal-footer">'
|
||||
+ '<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>'
|
||||
+ '<button type="button" class="btn btn-primary"></button>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+ '<div class="modal-dialog">'
|
||||
+ '<div class="modal-content">'
|
||||
+ '<div class="modal-header">'
|
||||
+ '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>'
|
||||
+ '<h4 class="modal-title"></h4>'
|
||||
+ '</div>'
|
||||
+ '<div class="modal-body">'
|
||||
+ '<p></p>'
|
||||
+ '</div>'
|
||||
+ '<div class="modal-footer">'
|
||||
+ '<button id="confirm-cancel" type="button" class="btn btn-default pull-left" data-dismiss="modal">Cancel</button>'
|
||||
+ '<button id="confirm-ok" type="button" class="btn btn-danger"></button>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -262,8 +264,8 @@ var PHPCensorConfirmDialog = Class.extend({
|
|||
Define dialog controls
|
||||
*/
|
||||
this.$dialog = $('#confirm-dialog');
|
||||
this.$cancelBtn = this.$dialog.find('div.modal-footer button.btn-default');
|
||||
this.$confirmBtn = this.$dialog.find('div.modal-footer button.btn-primary');
|
||||
this.$cancelBtn = this.$dialog.find('#confirm-cancel');
|
||||
this.$confirmBtn = this.$dialog.find('#confirm-ok');
|
||||
this.$title = this.$dialog.find('h4.modal-title');
|
||||
this.$body = this.$dialog.find('div.modal-body');
|
||||
|
||||
|
@ -350,7 +352,7 @@ var PHPCensorConfirmDialog = Class.extend({
|
|||
|
||||
showStatusMessage: function (message, closeTimeout) {
|
||||
this.$confirmBtn.hide();
|
||||
this.$cancelBtn.html('Close');
|
||||
this.$cancelBtn.hide();
|
||||
|
||||
/*
|
||||
Status message
|
||||
|
@ -468,7 +470,7 @@ var Lang = {
|
|||
return sprintf.apply(sprintf[0], args);
|
||||
}
|
||||
|
||||
return 'MISSING: ' + string;
|
||||
return string;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/**
|
||||
* Initialization of frontend of the application goes here
|
||||
*
|
||||
* @author Pavel Pavlov <Pavel.Pavlov@alera.ru>
|
||||
*/
|
||||
|
||||
$(function () {
|
||||
$('#latest-builds').on('latest-builds:reload', bindAppDeleteEvents);
|
||||
$('#latest-builds').trigger('latest-builds:reload');
|
||||
});
|
||||
|
||||
function bindAppDeleteEvents () {
|
||||
$('.app-delete-build').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
confirmDelete(e.target.href, 'Build').onClose = function () {
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.app-delete-user').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
confirmDelete(e.target.href, 'User', true);
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
|
@ -97,7 +97,7 @@ class BuildController extends Controller
|
|||
$actions = "<a class=\"btn btn-default\" href=\"{$rebuildLink}\">{$rebuild}</a> ";
|
||||
|
||||
if ($this->currentUserIsAdmin()) {
|
||||
$actions .= " <a class=\"btn btn-danger\" href=\"{$deleteLink}\">{$delete}</a>";
|
||||
$actions .= " <a class=\"btn btn-danger\" id=\"delete-build\" href=\"{$deleteLink}\">{$delete}</a>";
|
||||
}
|
||||
|
||||
$this->layout->actions = $actions;
|
||||
|
|
|
@ -58,7 +58,8 @@ class GroupController extends Controller
|
|||
$groups[] = $thisGroup;
|
||||
}
|
||||
|
||||
$this->view->groups = $groups;
|
||||
$this->layout->title = Lang::get('group_projects');
|
||||
$this->view->groups = $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,6 +97,7 @@ class GroupController extends Controller
|
|||
$title->setValue($group->getTitle());
|
||||
|
||||
$submit = new Form\Element\Submit();
|
||||
$submit->setClass('btn btn-success');
|
||||
$submit->setValue(Lang::get('group_save'));
|
||||
|
||||
$form->addField($title);
|
||||
|
|
|
@ -159,7 +159,8 @@ PHP Censor',
|
|||
Services</a> section of your Bitbucket repository.',
|
||||
|
||||
// Project Groups
|
||||
'group_projects' => 'Projects',
|
||||
'group_projects' => 'Project Groups',
|
||||
'group_count' => 'Projects Count',
|
||||
'group_edit' => 'Edit',
|
||||
'group_delete' => 'Delete',
|
||||
'group_add' => 'Add Group',
|
||||
|
@ -489,4 +490,11 @@ PHP Censor',
|
|||
'slack_notify' => 'Slack',
|
||||
'technical_debt' => 'Technical Debt',
|
||||
'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: ',
|
||||
];
|
||||
|
|
|
@ -153,7 +153,8 @@ PHP Censor',
|
|||
Services</a> вашего Bitbucket репозитория.',
|
||||
|
||||
// Project Groups
|
||||
'group_projects' => 'Проекты',
|
||||
'group_projects' => 'Группы проектов',
|
||||
'group_count' => 'Количество проектов',
|
||||
'group_edit' => 'Редактировать',
|
||||
'group_delete' => 'Удалить',
|
||||
'group_add' => 'Добавить группу',
|
||||
|
@ -473,4 +474,11 @@ PHP Censor',
|
|||
'slack_notify' => 'Slack',
|
||||
'technical_debt' => 'Technical Debt',
|
||||
'xmpp' => 'XMPP',
|
||||
|
||||
'confirm_message' => 'Элемент будет удален навсегда. Вы уверены?',
|
||||
'confirm_title' => 'Подтвержение удаления',
|
||||
'confirm_ok' => 'Удалить',
|
||||
'confirm_cancel' => 'Отмена',
|
||||
'confirm_success' => 'Элемент успешно удален.',
|
||||
'confirm_failed' => 'Удаление провалилось! Ответ сервера: ',
|
||||
];
|
||||
|
|
|
@ -180,11 +180,8 @@ foreach ($plugins as $plugin) {
|
|||
|
||||
$('#delete-build').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
confirmDelete(
|
||||
"<?php echo APP_URL ?>build/delete/<?php print $build->getId(); ?>", "Build"
|
||||
).onCloseConfirmed = function () {window.location = '/'};
|
||||
confirmDelete("<?= APP_URL; ?>build/delete/<?= $build->getId(); ?>")
|
||||
.onCloseConfirmed = function () {window.location = '<?= APP_URL; ?>project/view/<?= $build->getProjectId(); ?>'};
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
|
|
@ -71,17 +71,27 @@ switch($build->getStatus())
|
|||
<span class='label label-<?php echo $subcls ?>'><?php echo $status ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<div class="btn-group btn-group-right">
|
||||
<a class="btn btn-default btn-sm" href="<?php echo APP_URL ?>build/view/<?php print $build->getId(); ?>"><?php Lang::out('view'); ?></a>
|
||||
<?php if($this->User()->getIsAdmin()): ?>
|
||||
<button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="<?php echo APP_URL ?>build/delete/<?php print $build->getId(); ?>" class="app-delete-build"><?php Lang::out('delete_build'); ?></a></li>
|
||||
<li><a href="<?php echo APP_URL ?>build/delete/<?php print $build->getId(); ?>" class="delete-build"><?php Lang::out('delete_build'); ?></a></li>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.delete-build').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
confirmDelete(e.target.href)
|
||||
.onCloseConfirmed = function () {window.location = window.location.href};
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -6,16 +6,12 @@
|
|||
</div>
|
||||
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title"><?php Lang::out('project_groups'); ?></h3>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php Lang::out('group_title'); ?></th>
|
||||
<th style="width: 100px;"><?php Lang::out('group_projects'); ?></th>
|
||||
<th style="width: 150px"></th>
|
||||
<th><?php Lang::out('group_count'); ?></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -24,18 +20,29 @@
|
|||
<td><?php print $group['title']; ?></td>
|
||||
<td><?php print count($group['projects']); ?></td>
|
||||
<td>
|
||||
<a class="btn btn-sm btn-default" href="<?php print APP_URL . 'group/edit/' . $group['id']; ?>">
|
||||
<?php Lang::out('group_edit'); ?>
|
||||
</a>
|
||||
|
||||
<?php if (!count($group['projects'])): ?>
|
||||
<a class="btn btn-sm btn-danger delete-group" href="<?php print APP_URL . 'group/delete/' . $group['id']; ?>">
|
||||
<?php Lang::out('group_delete'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<div class="btn-group btn-group-right">
|
||||
<a class="btn btn-default btn-sm" href="<?php echo APP_URL ?>group/edit/<?php print $group['id']; ?>"><?php Lang::out('group_edit'); ?></a>
|
||||
<?php if($this->User()->getIsAdmin() && (!count($group['projects']))): ?>
|
||||
<button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="<?php echo APP_URL ?>group/delete/<?php print $group['id']; ?>" class="delete-group"><?php Lang::out('group_delete'); ?></a></li>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.delete-group').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
confirmDelete(e.target.href).onCloseConfirmed = function () {window.location = window.location.href};
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -10,7 +10,7 @@
|
|||
<?php Lang::out('edit_project'); ?>
|
||||
</a>
|
||||
|
||||
<a class="btn btn-danger" href="javascript:confirmDelete('<?php print APP_URL . 'project/delete/' . $project->getId(); ?>', '<?php print Lang::out('project'); ?>', true)">
|
||||
<a class="btn btn-danger" id="delete-project">
|
||||
<?php Lang::out('delete_project'); ?>
|
||||
</a>
|
||||
|
||||
|
@ -56,7 +56,7 @@
|
|||
<th class="hidden-md hidden-sm hidden-xs"><?php Lang::out('commit'); ?></th>
|
||||
<th><?php Lang::out('branch'); ?></th>
|
||||
<th><?php Lang::out('status'); ?></th>
|
||||
<th style="width: 100px"></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="latest-builds">
|
||||
|
@ -152,14 +152,20 @@ if ($pages > 1) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($page < $pages - 1) {
|
||||
print '<li><a href="' . $project_url . '?p='.($page == $pages ? $pages : $page + 1).'">'.Lang::get('next_link').'</a></li>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
print '</ul></div>';
|
||||
|
||||
?>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('#delete-project').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
confirmDelete("<?= APP_URL; ?>project/delete/<?= $project->getId(); ?>")
|
||||
.onCloseConfirmed = function () {window.location = '/'};
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php use PHPCensor\Helper\Lang; ?>
|
||||
<div class="clearfix" style="margin-bottom: 20px;">
|
||||
<div class="pull-right btn-group">
|
||||
<a class="btn btn-primary" href="<?php print APP_URL; ?>user/add"><?php Lang::out('add_user'); ?></a>
|
||||
<a class="btn btn-success" href="<?php print APP_URL; ?>user/add"><?php Lang::out('add_user'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
|||
<th><?php Lang::out('email_address'); ?></th>
|
||||
<th><?php Lang::out('name'); ?></th>
|
||||
<th><?php Lang::out('is_admin'); ?></th>
|
||||
<th style="width: 100px"></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="users">
|
||||
|
@ -40,13 +40,13 @@
|
|||
<td><?php print $status; ?></td>
|
||||
<td>
|
||||
<?php if($this->User()->getIsAdmin()): ?>
|
||||
<div class="btn-group pull-right">
|
||||
<a class="btn btn-default btn-small" href="<?php echo APP_URL ?>user/edit/<?php print $user->getId(); ?>"><?php Lang::out('edit'); ?></a>
|
||||
<button class="btn btn-default btn-small dropdown-toggle" data-toggle="dropdown">
|
||||
<div class="btn-group btn-group-right">
|
||||
<a class="btn btn-default btn-sm" href="<?php echo APP_URL ?>user/edit/<?php print $user->getId(); ?>"><?php Lang::out('edit'); ?></a>
|
||||
<button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="<?php echo APP_URL ?>user/delete/<?php print $user->getId(); ?>" class="app-delete-user"><?php Lang::out('delete_user'); ?></a></li>
|
||||
<li><a href="<?php echo APP_URL ?>user/delete/<?php print $user->getId(); ?>" class="delete-user"><?php Lang::out('delete_user'); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
@ -58,3 +58,13 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.delete-user').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
confirmDelete(e.target.href)
|
||||
.onCloseConfirmed = function () {window.location = window.location.href};
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue