Fixed pagination for environments in project/view page and ajax builds update.

This commit is contained in:
Dmitry Khomutov 2017-05-08 14:51:32 +07:00
commit 446deca0cb
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
9 changed files with 71 additions and 57 deletions

View file

@ -4,6 +4,7 @@
var PROJECT_ENVIRONMENT = '<?= $environment; ?>';
var PROJECT_BRANCH = '<?= $branch; ?>';
var PER_PAGE = <?= $perPage; ?>;
var PAGE = <?= $page; ?>;
</script>
<div class="clearfix" style="margin-bottom: 20px;">
@ -115,10 +116,19 @@
print '<div><ul class="pagination">';
$project_url = APP_URL . 'project/view/' . $project->getId() . ((!empty($branch)) ? '/' . urlencode($branch) : '');
$project_url = APP_URL . 'project/view/' . $project->getId();
$params = [];
if (!empty($branch)) {
$params['branch'] = $branch;
}
if (!empty($environment)) {
$params['environment'] = $environment;
}
if ($page > 1) {
print '<li><a href="' . $project_url . '?p='.($page == 1 ? '1' : $page - 1).'">'.Lang::get('prev_link').'</a></li>';
print '<li><a href="' . $project_url . '?' . http_build_query(array_merge($params, ['page' => ($page - 1)])) . '">' . Lang::get('prev_link') . '</a></li>';
}
if ($pages > 1) {
@ -136,27 +146,29 @@
}
if ($start > 1) {
print '<li><a href="' . $project_url . '">1...</a></li>';
print '<li><a href="' . $project_url . '?' . http_build_query($params) . '">1...</a></li>';
}
for($i = $start; $i <= $end; $i++)
{
if ($pages > $end && $i == $pages) continue;
if ($pages > $end && $i == $pages) {
continue;
}
if ($i == $page) {
print '<li class="bg-blue"><span>' . $i . '</span></li>';
} else {
print '<li><a href="' . $project_url . '?p=' . $i . '">' . $i . '</a></li>';
print '<li><a href="' . $project_url . '?' . http_build_query(array_merge($params, ['page' => $i])) . '">' . $i . '</a></li>';
}
}
if ($pages > $end) {
print '<li><a href="' . $project_url . '?p='.$pages.'">...'.$pages.'</a></li>';
print '<li><a href="' . $project_url . '?' . http_build_query(array_merge($params, ['page' => $pages])) . '">...' . $pages . '</a></li>';
}
}
if ($page < $pages - 1) {
print '<li><a href="' . $project_url . '?p='.($page == $pages ? $pages : $page + 1).'">'.Lang::get('next_link').'</a></li>';
if ($page < ($pages - 1)) {
print '<li><a href="' . $project_url . '?' . http_build_query(array_merge($params, ['page' => ($page == $pages) ? $pages : ($page + 1)])) . '">' . Lang::get('next_link') . '</a></li>';
}
print '</ul></div>';