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