1 |
58bf410f
|
Filip Jani
|
<?php
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
namespace App\AdminModule\Components;
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
use App\Model\Repository\MuseumRepository;
|
8 |
|
|
use App\Utils\DataGrid\DataGrid;
|
9 |
|
|
use Ublaboo\DataGrid\Exception\DataGridException;
|
10 |
|
|
|
11 |
|
|
/**
|
12 |
|
|
* Grid pro seznam muzeí, je přístupný všem uživatelům s právy editace, proto textace v ENG
|
13 |
|
|
*
|
14 |
|
|
* @package App\AdminModule\Components
|
15 |
|
|
*/
|
16 |
|
|
class MuseumGrid extends DataGrid
|
17 |
|
|
{
|
18 |
|
|
/**
|
19 |
|
|
* @var MuseumRepository
|
20 |
|
|
*/
|
21 |
|
|
private $museumRepository;
|
22 |
|
|
|
23 |
|
|
public function __construct(MuseumRepository $museumRepository)
|
24 |
|
|
{
|
25 |
|
|
$this->museumRepository = $museumRepository;
|
26 |
|
|
|
27 |
|
|
parent::__construct(FALSE);
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
/**
|
31 |
|
|
* Abstraktní metoda, slouží k nastavení primárního klíče a nastavení datasource
|
32 |
|
|
* 1. $this->setPrimaryKey();
|
33 |
|
|
* 2. $this->setDataSource();
|
34 |
|
|
*
|
35 |
|
|
* @throws DataGridException
|
36 |
|
|
*/
|
37 |
|
|
public function init()
|
38 |
|
|
{
|
39 |
|
|
$this->setPrimaryKey(MuseumRepository::COLUMN_ID);
|
40 |
|
|
$this->setDataSource($this->museumRepository->findAll());
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
/**
|
44 |
|
|
* Definice sloupečků, akcí, vyhledávácích filtrů gridu
|
45 |
|
|
*
|
46 |
|
|
* @throws DataGridException
|
47 |
|
|
*/
|
48 |
|
|
public function define()
|
49 |
|
|
{
|
50 |
|
|
// Definice sloupečků
|
51 |
|
|
$this->addColumnNumber(MuseumRepository::COLUMN_ID, 'ID')->setDefaultHide(TRUE);
|
52 |
|
|
$this->addColumnText(MuseumRepository::COLUMN_NAME, 'Museum');
|
53 |
|
|
$this->addColumnText(MuseumRepository::COLUMN_PLACE, 'Place');
|
54 |
|
|
|
55 |
|
|
// Definice filtrů
|
56 |
|
|
$this->addFilterText(MuseumRepository::COLUMN_NAME, 'Museum');
|
57 |
|
|
$this->addFilterText(MuseumRepository::COLUMN_PLACE, 'Place');
|
58 |
|
|
|
59 |
|
|
// Definice akcí
|
60 |
|
|
$this->addAction('edit', 'edit', 'Museum:edit', ['id' => MuseumRepository::COLUMN_ID])
|
61 |
|
|
->setTitle('Edit');
|
62 |
|
|
|
63 |
|
|
$this->addAction('delete', 'delete', 'deleteMuseum!', ['id' => MuseumRepository::COLUMN_ID])
|
64 |
|
|
->setConfirm('Do you really want to delete museum %s.', MuseumRepository::COLUMN_NAME)
|
65 |
|
|
->setTitle('Delete')
|
66 |
|
|
->setClass('btn btn-xs btn-danger ajax');
|
67 |
|
|
}
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
interface IMuseumGridFactory
|
71 |
|
|
{
|
72 |
|
|
/**
|
73 |
|
|
* @return MuseumGrid
|
74 |
|
|
*/
|
75 |
|
|
public function create();
|
76 |
|
|
}
|