1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* WellCommerce Open-Source E-Commerce Platform |
4
|
|
|
* |
5
|
|
|
* This file is part of the WellCommerce package. |
6
|
|
|
* |
7
|
|
|
* (c) Adam Piotrowski <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, |
10
|
|
|
* please view the LICENSE file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace WellCommerce\Bundle\TemplateEditorBundle\DataGrid; |
14
|
|
|
|
15
|
|
|
use WellCommerce\Bundle\CoreBundle\DataGrid\AbstractDataGrid; |
16
|
|
|
use WellCommerce\Component\DataGrid\Column\Column; |
17
|
|
|
use WellCommerce\Component\DataGrid\Column\ColumnCollection; |
18
|
|
|
use WellCommerce\Component\DataGrid\Column\Options\Appearance; |
19
|
|
|
use WellCommerce\Component\DataGrid\Column\Options\Filter; |
20
|
|
|
use WellCommerce\Component\DataGrid\Column\Options\Sorting; |
21
|
|
|
use WellCommerce\Component\DataGrid\Configuration\EventHandler\ClickRowEventHandler; |
22
|
|
|
use WellCommerce\Component\DataGrid\Configuration\EventHandler\EditRowEventHandler; |
23
|
|
|
use WellCommerce\Component\DataGrid\Configuration\EventHandler\LoadEventHandler; |
24
|
|
|
use WellCommerce\Component\DataGrid\DataGridInterface; |
25
|
|
|
use WellCommerce\Component\DataGrid\Options\OptionsInterface; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Class TemplateEditorDataGrid |
29
|
|
|
* |
30
|
|
|
* @author Adam Piotrowski <[email protected]> |
31
|
|
|
*/ |
32
|
|
|
class TemplateEditorDataGrid extends AbstractDataGrid |
33
|
|
|
{ |
34
|
|
|
public function configureColumns(ColumnCollection $collection) |
35
|
|
|
{ |
36
|
|
|
$collection->add(new Column([ |
37
|
|
|
'id' => 'id', |
38
|
|
|
'caption' => 'common.label.id', |
39
|
|
|
'sorting' => new Sorting([ |
40
|
|
|
'default_order' => Sorting::SORT_DIR_DESC, |
41
|
|
|
]), |
42
|
|
|
'appearance' => new Appearance([ |
43
|
|
|
'width' => 90, |
44
|
|
|
'visible' => false, |
45
|
|
|
]), |
46
|
|
|
'filter' => new Filter([ |
47
|
|
|
'type' => Filter::FILTER_BETWEEN, |
48
|
|
|
]), |
49
|
|
|
])); |
50
|
|
|
|
51
|
|
|
$collection->add(new Column([ |
52
|
|
|
'id' => 'name', |
53
|
|
|
'caption' => 'common.label.name', |
54
|
|
|
])); |
55
|
|
|
|
56
|
|
|
$collection->add(new Column([ |
57
|
|
|
'id' => 'folder', |
58
|
|
|
'caption' => 'theme.label.folder', |
59
|
|
|
])); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
|
63
|
|
|
public function configureOptions(OptionsInterface $options) |
64
|
|
|
{ |
65
|
|
|
$eventHandlers = $options->getEventHandlers(); |
66
|
|
|
|
67
|
|
|
$eventHandlers->add(new LoadEventHandler([ |
68
|
|
|
'function' => $this->getJavascriptFunctionName('load'), |
69
|
|
|
'route' => $this->getActionUrl('grid'), |
70
|
|
|
])); |
71
|
|
|
|
72
|
|
|
$eventHandlers->add(new EditRowEventHandler([ |
73
|
|
|
'function' => $this->getJavascriptFunctionName('edit'), |
74
|
|
|
'row_action' => DataGridInterface::ACTION_EDIT, |
75
|
|
|
'route' => $this->getActionUrl('edit'), |
76
|
|
|
])); |
77
|
|
|
|
78
|
|
|
$eventHandlers->add(new ClickRowEventHandler([ |
79
|
|
|
'function' => $this->getJavascriptFunctionName('click'), |
80
|
|
|
'route' => $this->getActionUrl('edit'), |
81
|
|
|
])); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function getIdentifier(): string |
85
|
|
|
{ |
86
|
|
|
return 'template_editor'; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|