mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 05:23:21 +00:00
Fix #1697 : Add pagination to quarantine
This commit is contained in:
@@ -592,6 +592,8 @@ class Application extends SilexApplication
|
||||
$twig->addFilter('stripdoublequotes', new \Twig_Filter_Function('stripdoublequotes'));
|
||||
$twig->addFilter('get_collection_logo', new \Twig_Filter_Function('collection::getLogo'));
|
||||
$twig->addFilter('floor', new \Twig_Filter_Function('floor'));
|
||||
$twig->addFilter('ceil', new \Twig_Filter_Function('ceil'));
|
||||
$twig->addFilter('max', new \Twig_Filter_Function('max'));
|
||||
$twig->addFilter('min', new \Twig_Filter_Function('min'));
|
||||
$twig->addFilter('bas_labels', new \Twig_Filter_Function('phrasea::bas_labels'));
|
||||
$twig->addFilter('sbas_names', new \Twig_Filter_Function('phrasea::sbas_names'));
|
||||
|
@@ -179,18 +179,20 @@ class Lazaret implements ControllerProviderInterface
|
||||
$baseIds = array_keys($app['authentication']->getUser()->ACL()->get_granted_base(array('canaddrecord')));
|
||||
|
||||
$lazaretFiles = null;
|
||||
$perPage = 10;
|
||||
$page = max(1, $request->query->get('page', 1));
|
||||
$offset = ($page - 1) * $perPage;
|
||||
|
||||
if (count($baseIds) > 0) {
|
||||
$lazaretRepository = $app['EM']->getRepository('Entities\LazaretFile');
|
||||
|
||||
$lazaretFiles = $lazaretRepository->findPerPage(
|
||||
$baseIds, $request->query->get('offset', 0), $request->query->get('limit', 10)
|
||||
);
|
||||
$lazaretFiles = $lazaretRepository->findPerPage($baseIds, $offset, $perPage);
|
||||
}
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/upload/lazaret.html.twig', array('lazaretFiles' => $lazaretFiles)
|
||||
);
|
||||
return $app['twig']->render('prod/upload/lazaret.html.twig', array(
|
||||
'lazaretFiles' => $lazaretFiles,
|
||||
'currentPage' => $page,
|
||||
'perPage' => $perPage,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace Repositories;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
|
||||
/**
|
||||
* LazaretFileRepository
|
||||
@@ -12,12 +13,11 @@ use Doctrine\ORM\EntityRepository;
|
||||
*/
|
||||
class LazaretFileRepository extends EntityRepository
|
||||
{
|
||||
|
||||
public function findPerPage(array $base_ids, $offset = 0, $perPage = 10)
|
||||
{
|
||||
$base_ids = implode(', ', array_map(function ($int) {
|
||||
return (int) $int;
|
||||
}, $base_ids));
|
||||
return (int) $int;
|
||||
}, $base_ids));
|
||||
|
||||
$dql = '
|
||||
SELECT f
|
||||
@@ -29,8 +29,6 @@ class LazaretFileRepository extends EntityRepository
|
||||
$query->setFirstResult($offset)
|
||||
->setMaxResults($perPage);
|
||||
|
||||
$paginator = new \Doctrine\ORM\Tools\Pagination\Paginator($query, true);
|
||||
|
||||
return $paginator;
|
||||
return new Paginator($query, true);
|
||||
}
|
||||
}
|
||||
|
@@ -2,10 +2,27 @@
|
||||
|
||||
{% if lazaretFiles is not none %}
|
||||
{% if lazaretFiles|length > 0 %}
|
||||
<div class="btn-group" style="text-align:center; padding:5px 0;">
|
||||
<button class="btn empty-lazaret" title="{% trans "Empty quarantine"%}">
|
||||
<img src="/skins/icons/delete.png">{% trans "Empty quarantine"%}
|
||||
</button>
|
||||
<div class="btn-toolbar">
|
||||
<div class="btn-group" style="text-align:center; padding:5px 0;">
|
||||
<button class="btn empty-lazaret" title="{% trans "Empty quarantine"%}">
|
||||
<img src="/skins/icons/delete.png">{% trans "Empty quarantine"%}
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group" style="text-align:center; padding:5px 0;">
|
||||
<button class="btn" title="{% trans "Page"%}">
|
||||
{% trans "Page"%}
|
||||
</button>
|
||||
{% set items = lazaretFiles | length %}
|
||||
{% set pages = (items / perPage) | ceil | min(10) %}
|
||||
|
||||
{% for i in 1..pages %}
|
||||
<button class="btn page-lazaret{% if currentPage == i %} active{% endif %}" title="{{ i }}">
|
||||
<a href="{{ path('lazaret_elements', { 'page' : i }) }}">
|
||||
{{ i }}
|
||||
</a>
|
||||
</button>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="unstyled">
|
||||
|
@@ -10,7 +10,7 @@
|
||||
</li>
|
||||
<li>
|
||||
{# template prod/upload/lazaret.html.twig loaded via ajax #}
|
||||
<a href="{{ path('lazaret_elements') }}">
|
||||
<a class="lazaret-target" href="{{ path('lazaret_elements') }}">
|
||||
{# <span> </span> element is required for the jQuery loading spinner appears && disappears properly #}
|
||||
{% trans 'Quarantine' %}<span> </span>
|
||||
</a>
|
||||
@@ -174,11 +174,18 @@ $(document).ready(function () {
|
||||
$( anchor.hash ).html(language.error);
|
||||
});
|
||||
|
||||
ui.tab.find('span').html(language.loading + '<img src="/skins/icons/loader404040.gif"/>');
|
||||
ui.tab.find('span').html(' <img src="/skins/icons/loader404040.gif"/>');
|
||||
},
|
||||
load: function(event, ui)
|
||||
{
|
||||
ui.tab.find('span').empty();
|
||||
$('.btn.page-lazaret', UploaderManager.getContainer()).bind('click', function () {
|
||||
$('.lazaret-target').attr('href', $('a', $(this)).attr('href'));
|
||||
$(".upload-tabs", UploaderManager.getContainer()).tabs('load', 1);
|
||||
$('#lazaretBox').empty();
|
||||
|
||||
return false;
|
||||
});
|
||||
},
|
||||
create : function () {
|
||||
$('#tab-upload').css('overflow', 'hidden');
|
||||
@@ -488,3 +495,8 @@ $(document).ready(function () {
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.btn.page-lazaret a {
|
||||
color: black;
|
||||
}
|
||||
</style>
|
||||
|
Reference in New Issue
Block a user