From 30f9a7de891e779f2c18e0549edf7d4c36d7470e Mon Sep 17 00:00:00 2001 From: bojovyletoun <662941+bojovyletoun@users.noreply.github.com> Date: Tue, 13 Dec 2022 19:35:45 +0100 Subject: [PATCH] Filtrovani,razeni VS (#936) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Použití atributu column pro sloupce místo Renderer * Použití addColumnLink pro buňky s odkazem * Správná filtrace řetězených sloupců zatím jen VS * Řazení řetězených sloupců zatím jen VS Co-authored-by: bojovyletoun <> --- .../Components/GroupsGridControl.php | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/app/AdminModule/Components/GroupsGridControl.php b/app/AdminModule/Components/GroupsGridControl.php index 252f8c4c1..aa34f68c2 100644 --- a/app/AdminModule/Components/GroupsGridControl.php +++ b/app/AdminModule/Components/GroupsGridControl.php @@ -10,13 +10,13 @@ use App\Services\ExcelExportService; use App\Utils\Helpers; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\ORM\QueryBuilder; use Exception; use Nette\Application\AbortException; use Nette\Application\UI\Control; use Nette\Http\Session; use Nette\Http\SessionSection; use Nette\Localization\Translator; -use Nette\Utils\Html; use Throwable; use Ublaboo\DataGrid\DataGrid; use Ublaboo\DataGrid\Exception\DataGridColumnStatusException; @@ -85,16 +85,23 @@ public function createComponentPatrolsGrid(string $name): DataGrid ->setSortable() ->setFilterText(); - $grid->addColumnText('variableSymbol', 'VS ')->setSortable() // je stejný jako název skupiny - ->setRenderer(static fn ($t) => $t->getVariableSymbolText()) - ->setFilterText(); - - $grid->addColumnText('leader', 'Vedoucí')->setSortable() - ->setRenderer(function (Troop $t) { - $leader = $t->getLeader(); - - return Html::el('a')->setAttribute('href', $this->getPresenter()->link('detail', $leader->getId()))->setText($leader->getDisplayName()); - }) + $grid->addColumnText('variableSymbol', 'VS ', 'variableSymbolText') + ->setSortable() + ->setSortableCallback(static function (QueryBuilder $qb, array $sort): void { + $sortRev = $sort['variableSymbolText'] === 'DESC' ? 'ASC' : 'DESC'; + $qb->join('p.variableSymbol', 'VS') + ->orderBy('VS.variableSymbol', $sortRev); + }) + ->setFilterText() + ->setCondition(static function (QueryBuilder $qb, string $value): void { +// $qb->join('p.applications', 'uAVS') + $qb->join('p.variableSymbol', 'VS') + ->andWhere('VS.variableSymbol LIKE :variableSymbol') + ->setParameter(':variableSymbol', '%' . $value . '%'); + }); + + $grid->addColumnLink('leader', 'Vedoucí', ':detail', 'leader.displayName', ['id' => 'leader.id'])->setSortable() +// return Html::el('a')->setAttribute('href', $this->getPresenter()->link('detail', $leader->getId()))->setText($leader->getDisplayName()); ->setFilterText(); $grid->addColumnDateTime('applicationDate', 'Datum založení')