Revize d052c689
Přidáno uživatelem Jan Šedivý před téměř 6 roky(ů)
app/AdminModule/component/Object/ObjectTypeGrid.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
namespace App\AdminModule\Components; |
|
4 |
|
|
5 |
|
|
6 |
use App\Model\Repository\ObjectTypeRepository; |
|
7 |
|
|
8 |
class ObjectTypeGrid extends \App\Utils\DataGrid\DataGrid |
|
9 |
{ |
|
10 |
/** @var \App\Model\Repository\ObjectTypeRepository */ |
|
11 |
private $objectTypeRepository; |
|
12 |
|
|
13 |
/** |
|
14 |
* ObjectTypeGrid constructor. |
|
15 |
* @param \App\Model\Repository\ObjectTypeRepository $objectTypeRepository |
|
16 |
* @throws \Ublaboo\DataGrid\Exception\DataGridException |
|
17 |
*/ |
|
18 |
public function __construct(\App\Model\Repository\ObjectTypeRepository $objectTypeRepository) |
|
19 |
{ |
|
20 |
$this->objectTypeRepository = $objectTypeRepository; |
|
21 |
|
|
22 |
parent::__construct(FALSE); |
|
23 |
} |
|
24 |
|
|
25 |
|
|
26 |
public function init() |
|
27 |
{ |
|
28 |
$this->setPrimaryKey(ObjectTypeRepository::COLUMN_ID); |
|
29 |
$this->setDataSource($this->objectTypeRepository->findAll()); |
|
30 |
} |
|
31 |
|
|
32 |
/** |
|
33 |
* Definice sloupečků, akcí, vyhledávácích filtrů gridu |
|
34 |
* |
|
35 |
* @throws \Ublaboo\DataGrid\Exception\DataGridException |
|
36 |
*/ |
|
37 |
public function define() |
|
38 |
{ |
|
39 |
$this->addColumnText(ObjectTypeRepository::COLUMN_ID, 'Id'); |
|
40 |
$this->addColumnText(ObjectTypeRepository::COLUMN_OBJECT_TYPE, 'Object Type'); |
|
41 |
|
|
42 |
$this->addFilterText(ObjectTypeRepository::COLUMN_OBJECT_TYPE, 'Object Type'); |
|
43 |
|
|
44 |
$this->addAction('edit', 'edit', 'Object:editType', ['id' => ObjectTypeRepository::COLUMN_ID]) |
|
45 |
->setTitle('Edit'); |
|
46 |
|
|
47 |
$this->addAction('delete', 'delete', 'Object:deleteType', ['id' => ObjectTypeRepository::COLUMN_ID]) |
|
48 |
->setConfirm('Do you really want to delete the object type "%s".', ObjectTypeRepository::COLUMN_OBJECT_TYPE) |
|
49 |
->setTitle('Delete') |
|
50 |
->setClass('btn btn-xs btn-danger ajax'); |
|
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
interface IObjectTypeGridFactory |
|
55 |
{ |
|
56 |
/** |
|
57 |
* @return ObjectTypeGrid |
|
58 |
*/ |
|
59 |
public function create(); |
|
60 |
} |
app/AdminModule/presenters/ObjectPresenter.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
namespace App\AdminModule\Presenters; |
|
4 |
|
|
5 |
|
|
6 |
use App\AdminModule\Components\IObjectTypeGridFactory; |
|
7 |
use App\Model\Repository\ObjectTypeRepository; |
|
8 |
|
|
9 |
class ObjectPresenter extends BaseUserPresenter |
|
10 |
{ |
|
11 |
/** @var ObjectTypeRepository */ |
|
12 |
private $objectTypeRepository; |
|
13 |
|
|
14 |
/** @var IObjectTypeGridFactory */ |
|
15 |
private $objectTypeGridFactory; |
|
16 |
|
|
17 |
/** |
|
18 |
* ObjectPresenter constructor. |
|
19 |
* @param ObjectTypeRepository $objectTypeRepository |
|
20 |
*/ |
|
21 |
public function __construct( |
|
22 |
ObjectTypeRepository $objectTypeRepository, |
|
23 |
IObjectTypeGridFactory $objectTypeGridFactory |
|
24 |
) |
|
25 |
{ |
|
26 |
$this->objectTypeRepository = $objectTypeRepository; |
|
27 |
$this->objectTypeGridFactory = $objectTypeGridFactory; |
|
28 |
|
|
29 |
parent::__construct(); |
|
30 |
} |
|
31 |
|
|
32 |
public function actionDefault() |
|
33 |
{ |
|
34 |
|
|
35 |
} |
|
36 |
|
|
37 |
public function actionEditType(int $id) |
|
38 |
{ |
|
39 |
|
|
40 |
} |
|
41 |
|
|
42 |
public function actionDeleteType(int $id) |
|
43 |
{ |
|
44 |
|
|
45 |
} |
|
46 |
|
|
47 |
public function createComponentObjectTypeGrid() |
|
48 |
{ |
|
49 |
return $this->objectTypeGridFactory->create(); |
|
50 |
} |
|
51 |
|
|
52 |
} |
app/AdminModule/templates/@layout.latte | ||
---|---|---|
109 | 109 |
Transliteration </a></li> |
110 | 110 |
<li class="nav-item"><a href="#" class="nav-link" title="Book type"> |
111 | 111 |
Book type </a></li> |
112 |
<li class="nav-item"><a href="#" class="nav-link" title="Object type">
|
|
112 |
<li class="nav-item"><a n:href="Object:default" n:class="nav-link, $presenter->isLinkCurrent('Object:*') ? active" title="Object type">
|
|
113 | 113 |
Object type </a></li> |
114 | 114 |
<li class="nav-item"><a href="#" class="nav-link" title="Surface type"> |
115 | 115 |
Surface type </a></li> |
app/AdminModule/templates/Object/default.latte | ||
---|---|---|
1 |
{block content} |
|
2 |
<div class="row"> |
|
3 |
<div class="col-11"> |
|
4 |
<div class="display-5">Object Type List</div> |
|
5 |
</div> |
|
6 |
<div class="col-1"> |
|
7 |
<a n:href="User:add" class="btn btn-sm btn-success"><span class="fa fa-fw fa-plus"></span> New Object Type</a> |
|
8 |
</div> |
|
9 |
</div> |
|
10 |
<div class="row"> |
|
11 |
<div class="col-10 offset-1"> |
|
12 |
{control objectTypeGrid} |
|
13 |
</div> |
|
14 |
</div> |
|
15 |
{/block} |
app/config/components.neon | ||
---|---|---|
3 | 3 |
- App\FrontModule\Components\IExampleGirdFactory |
4 | 4 |
- App\AdminModule\Components\IUserGridFactory |
5 | 5 |
- App\AdminModule\Components\IMuseumGridFactory |
6 |
- App\AdminModule\Components\IObjectTypeGridFactory |
|
6 | 7 |
|
7 | 8 |
# Formuláře |
8 | 9 |
- App\FrontModule\Components\ILoginFormFactory |
Také k dispozici: Unified diff
Re #7335 Vytvoření presenteru a gridu pro správu typu objektů v administraci