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
|
|
|
namespace WellCommerce\Bundle\ReviewBundle\DataGrid; |
13
|
|
|
|
14
|
|
|
use WellCommerce\Bundle\CoreBundle\DataGrid\AbstractDataGrid; |
15
|
|
|
use WellCommerce\Component\DataGrid\Column\Column; |
16
|
|
|
use WellCommerce\Component\DataGrid\Column\ColumnCollection; |
17
|
|
|
use WellCommerce\Component\DataGrid\Column\Options\Appearance; |
18
|
|
|
use WellCommerce\Component\DataGrid\Column\Options\Filter; |
19
|
|
|
use WellCommerce\Component\DataGrid\Column\Options\Sorting; |
20
|
|
|
use WellCommerce\Component\DataGrid\Configuration\EventHandler\CustomRowEventHandler; |
21
|
|
|
use WellCommerce\Component\DataGrid\Options\OptionsInterface; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Class ReviewDataGrid |
25
|
|
|
* |
26
|
|
|
* @author Adam Piotrowski <[email protected]> |
27
|
|
|
*/ |
28
|
|
|
class ReviewDataGrid extends AbstractDataGrid |
29
|
|
|
{ |
30
|
|
|
public function configureColumns(ColumnCollection $collection) |
31
|
|
|
{ |
32
|
|
|
$collection->add(new Column([ |
33
|
|
|
'id' => 'id', |
34
|
|
|
'caption' => 'review.label.id', |
35
|
|
|
'sorting' => new Sorting([ |
36
|
|
|
'default_order' => Sorting::SORT_DIR_DESC, |
37
|
|
|
]), |
38
|
|
|
'appearance' => new Appearance([ |
39
|
|
|
'width' => 90, |
40
|
|
|
'visible' => false, |
41
|
|
|
]), |
42
|
|
|
'filter' => new Filter([ |
43
|
|
|
'type' => Filter::FILTER_BETWEEN, |
44
|
|
|
]), |
45
|
|
|
])); |
46
|
|
|
|
47
|
|
|
$collection->add(new Column([ |
48
|
|
|
'id' => 'nick', |
49
|
|
|
'caption' => 'review.label.nick', |
50
|
|
|
'appearance' => new Appearance([ |
51
|
|
|
'width' => 70, |
52
|
|
|
'align' => Appearance::ALIGN_CENTER, |
53
|
|
|
]), |
54
|
|
|
'filter' => new Filter([ |
55
|
|
|
'type' => Filter::FILTER_INPUT, |
56
|
|
|
]), |
57
|
|
|
])); |
58
|
|
|
|
59
|
|
|
$collection->add(new Column([ |
60
|
|
|
'id' => 'createdAt', |
61
|
|
|
'caption' => 'review.label.created_at', |
62
|
|
|
'appearance' => new Appearance([ |
63
|
|
|
'width' => 70, |
64
|
|
|
'align' => Appearance::ALIGN_CENTER, |
65
|
|
|
]), |
66
|
|
|
'filter' => new Filter([ |
67
|
|
|
'type' => Filter::FILTER_INPUT, |
68
|
|
|
]), |
69
|
|
|
])); |
70
|
|
|
|
71
|
|
|
$collection->add(new Column([ |
72
|
|
|
'id' => 'product', |
73
|
|
|
'caption' => 'review.label.product', |
74
|
|
|
'appearance' => new Appearance([ |
75
|
|
|
'width' => 70, |
76
|
|
|
]), |
77
|
|
|
'filter' => new Filter([ |
78
|
|
|
'type' => Filter::FILTER_INPUT, |
79
|
|
|
]), |
80
|
|
|
])); |
81
|
|
|
|
82
|
|
|
$collection->add(new Column([ |
83
|
|
|
'id' => 'review', |
84
|
|
|
'caption' => 'review.label.review', |
85
|
|
|
'appearance' => new Appearance([ |
86
|
|
|
'width' => 200, |
87
|
|
|
]), |
88
|
|
|
])); |
89
|
|
|
|
90
|
|
|
$collection->add(new Column([ |
91
|
|
|
'id' => 'rating', |
92
|
|
|
'caption' => 'review.label.rating', |
93
|
|
|
'appearance' => new Appearance([ |
94
|
|
|
'width' => 70, |
95
|
|
|
'align' => Appearance::ALIGN_CENTER, |
96
|
|
|
]), |
97
|
|
|
'filter' => new Filter([ |
98
|
|
|
'type' => Filter::FILTER_BETWEEN, |
99
|
|
|
]), |
100
|
|
|
])); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function configureOptions(OptionsInterface $options) |
104
|
|
|
{ |
105
|
|
|
parent::configureOptions($options); |
106
|
|
|
|
107
|
|
|
$eventHandlers = $options->getEventHandlers(); |
108
|
|
|
|
109
|
|
|
$eventHandlers->add(new CustomRowEventHandler([ |
110
|
|
|
'function' => $this->getJavascriptFunctionName('enableOpinion'), |
111
|
|
|
'function_name' => 'enableOpinion', |
112
|
|
|
'row_action' => 'action_enableOpinion', |
113
|
|
|
])); |
114
|
|
|
|
115
|
|
|
$eventHandlers->add(new CustomRowEventHandler([ |
116
|
|
|
'function' => $this->getJavascriptFunctionName('disableOpinion'), |
117
|
|
|
'function_name' => 'disableOpinion', |
118
|
|
|
'row_action' => 'action_disableOpinion', |
119
|
|
|
])); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function getIdentifier(): string |
123
|
|
|
{ |
124
|
|
|
return 'review'; |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|