fix: mostly working paginator

This commit is contained in:
2025-05-13 16:11:30 -05:00
parent e230913c89
commit 6c0e42d291
3 changed files with 46 additions and 12 deletions

View File

@@ -6,6 +6,8 @@ use App\Download\Framework\Repository\DownloadRepository;
use App\Util\Paginator;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\Attribute\LiveAction;
use Symfony\UX\LiveComponent\Attribute\LiveArg;
use Symfony\UX\LiveComponent\Attribute\LiveProp;
use Symfony\UX\LiveComponent\DefaultActionTrait;
@@ -14,6 +16,7 @@ final class DownloadList extends AbstractController
{
use DefaultActionTrait;
#[LiveProp(writable: true)]
public string $type;
#[LiveProp(writable: true)]
@@ -39,4 +42,10 @@ final class DownloadList extends AbstractController
return [];
}
#[LiveAction]
public function paginate(#[LiveArg] int $page)
{
$this->pageNumber = $page;
}
}

View File

@@ -20,6 +20,8 @@ class Paginator
private $items;
public $currentPage = 1;
/**
* @param QueryBuilder|Query $query
* @param int $page
@@ -38,6 +40,7 @@ class Paginator
$this->total = $paginator->count();
$this->lastPage = (int) ceil($paginator->count() / $paginator->getQuery()->getMaxResults());
$this->items = $paginator;
$this->currentPage = $page;
return $this;
}