1 | <?php |
||
19 | class Action extends Column |
||
20 | { |
||
21 | |||
22 | use Traits\ButtonIconTrait; |
||
23 | |||
24 | /** |
||
25 | * @var string|callable |
||
26 | */ |
||
27 | protected $title; |
||
28 | |||
29 | /** |
||
30 | * @var string|callable |
||
31 | */ |
||
32 | protected $class; |
||
33 | |||
34 | /** |
||
35 | * @var string|callable |
||
36 | */ |
||
37 | protected $icon; |
||
38 | |||
39 | /** |
||
40 | * @var DataGrid |
||
41 | */ |
||
42 | protected $grid; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $href; |
||
48 | |||
49 | /** |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $name; |
||
53 | |||
54 | /** |
||
55 | * @var array |
||
56 | */ |
||
57 | protected $params; |
||
58 | |||
59 | /** |
||
60 | * @var array|callable |
||
61 | */ |
||
62 | protected $confirm; |
||
63 | |||
64 | /** |
||
65 | * @var array |
||
66 | */ |
||
67 | protected $data_attributes = []; |
||
68 | |||
69 | |||
70 | /** |
||
71 | * @param DataGrid $grid |
||
72 | * @param string $href |
||
73 | * @param string $name |
||
74 | * @param array $params |
||
75 | */ |
||
76 | public function __construct(DataGrid $grid, $href, $name, $params) |
||
77 | { |
||
78 | $this->grid = $grid; |
||
79 | $this->href = $href; |
||
80 | $this->name = $name; |
||
81 | $this->params = $params; |
||
82 | |||
83 | $this->class = 'btn btn-xs btn-default'; |
||
84 | } |
||
85 | |||
86 | |||
87 | /** |
||
88 | * Render row item into template |
||
89 | * @param Row $row |
||
90 | * @return mixed |
||
91 | */ |
||
92 | public function render(Row $row) |
||
125 | |||
126 | |||
127 | /** |
||
128 | * Set attribute title |
||
129 | * @param string|callable $title |
||
130 | * @return static |
||
131 | * @throws DataGridException |
||
132 | */ |
||
133 | public function setTitle($title) |
||
141 | |||
142 | |||
143 | /** |
||
144 | * Get attribute title |
||
145 | * @param Row $row |
||
146 | * @return string |
||
147 | * @throws DataGridException |
||
148 | */ |
||
149 | public function getTitle(Row $row) |
||
156 | |||
157 | |||
158 | /** |
||
159 | * Set attribute class |
||
160 | * @param string|callable $class |
||
161 | * @return static |
||
162 | * @throws DataGridException |
||
163 | */ |
||
164 | public function setClass($class) |
||
172 | |||
173 | |||
174 | /** |
||
175 | * Get attribute class |
||
176 | * @param Row $row |
||
177 | * @return string |
||
178 | * @throws DataGridException |
||
179 | */ |
||
180 | public function getClass(Row $row) |
||
187 | |||
188 | |||
189 | /** |
||
190 | * Set icon |
||
191 | * @param string|callable $icon |
||
192 | * @return static|callable |
||
193 | * @throws DataGridException |
||
194 | */ |
||
195 | public function setIcon($icon) |
||
203 | |||
204 | |||
205 | /** |
||
206 | * Get icon |
||
207 | * @param Row $row |
||
208 | * @return string |
||
209 | * @throws DataGridException |
||
210 | */ |
||
211 | public function getIcon(Row $row) |
||
218 | |||
219 | |||
220 | /** |
||
221 | * Set confirm dialog |
||
222 | * @param string|callable $message |
||
223 | * @param string $column |
||
224 | * @return static |
||
225 | * @throws DataGridException |
||
226 | */ |
||
227 | public function setConfirm($message, $column = NULL) |
||
235 | |||
236 | |||
237 | /** |
||
238 | * Get confirm dialog for particular row item |
||
239 | * @param Row $row |
||
240 | * @return string |
||
241 | * @throws DataGridException |
||
242 | */ |
||
243 | public function getConfirm(Row $row) |
||
262 | |||
263 | |||
264 | /** |
||
265 | * Setting data attributes |
||
266 | * @param string $key |
||
267 | * @param mixed $value |
||
268 | * @return static |
||
269 | */ |
||
270 | public function setDataAttribute($key, $value) |
||
276 | |||
277 | |||
278 | /** |
||
279 | * Check whether given property is string or callable |
||
280 | * @param mixed $property |
||
281 | * @return void |
||
282 | * @throws DataGridException |
||
283 | */ |
||
284 | protected function checkPropertyStringOrCallable($property, $name) |
||
292 | |||
293 | |||
294 | /** |
||
295 | * Check whether given property is string or callable |
||
296 | * in that case call callback and check property and return it |
||
297 | * @param Row $row |
||
298 | * @param string|callable|null $property |
||
299 | * @param string $name |
||
300 | * @return string |
||
301 | * @throws DataGridException |
||
302 | */ |
||
303 | public function getPropertyStringOrCallableGetString(Row $row, $property, $name) |
||
325 | |||
326 | |||
327 | /** |
||
328 | * Translator helper |
||
329 | * @param string $message |
||
330 | * @return string |
||
331 | */ |
||
332 | protected function translate($message) |
||
336 | |||
337 | } |
||
338 |