-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
LocalizationPresenter.php
67 lines (50 loc) · 1.88 KB
/
LocalizationPresenter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php declare(strict_types = 1);
namespace App\Presenters;
use App\Model\Utils\DateTime;
use App\UI\TEmptyLayoutView;
use Dibi\Row;
use Ublaboo\DataGrid\DataGrid;
use Ublaboo\DataGrid\Localization\SimpleTranslator;
final class LocalizationPresenter extends AbstractPresenter
{
use TEmptyLayoutView;
public function createComponentGrid(): DataGrid
{
$grid = new DataGrid();
$grid->setDataSource($this->dibiConnection->select('*')->from('users'));
$grid->setItemsPerPageList([20, 50, 100], true);
$grid->addColumnText('id', 'Id')
->setSortable();
$grid->addColumnText('email', 'E-mail')
->setSortable()
->setFilterText();
$grid->addColumnText('name', 'Name')
->setFilterText();
$grid->addColumnDateTime('birth_date', 'Birthday')
->setFormat('j. n. Y');
$grid->addColumnNumber('age', 'Age')
->setRenderer(fn (Row $row): ?int => DateTime::fromSafe($row->asDateTime('birth_date'))?->diff(new DateTime())->y);
$translator = new SimpleTranslator([
'ublaboo_datagrid.no_item_found_reset' => 'Žádné položky nenalezeny. Filtr můžete vynulovat',
'ublaboo_datagrid.no_item_found' => 'Žádné položky nenalezeny.',
'ublaboo_datagrid.here' => 'zde',
'ublaboo_datagrid.items' => 'Položky',
'ublaboo_datagrid.all' => 'všechny',
'ublaboo_datagrid.from' => 'z',
'ublaboo_datagrid.reset_filter' => 'Resetovat filtr',
'ublaboo_datagrid.group_actions' => 'Hromadné akce',
'ublaboo_datagrid.show_all_columns' => 'Zobrazit všechny sloupce',
'ublaboo_datagrid.hide_column' => 'Skrýt sloupec',
'ublaboo_datagrid.action' => 'Akce',
'ublaboo_datagrid.previous' => 'Předchozí',
'ublaboo_datagrid.next' => 'Další',
'ublaboo_datagrid.choose' => 'Vyberte',
'ublaboo_datagrid.execute' => 'Provést',
'Name' => 'Jméno',
'Birthday' => 'Narozky',
'Age' => 'Věk',
]);
$grid->setTranslator($translator);
return $grid;
}
}