1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Nayjest\Grids\Components; |
4
|
|
|
|
5
|
|
|
use Nayjest\Grids\FieldConfig; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class TableCell |
9
|
|
|
* |
10
|
|
|
* The component for rendering TD html tag inside grid. |
11
|
|
|
* |
12
|
|
|
* @package Nayjest\Grids\Components |
13
|
|
|
*/ |
14
|
|
|
class TableCell extends HtmlTag |
15
|
|
|
{ |
16
|
|
|
protected $tag_name = 'td'; |
17
|
|
|
|
18
|
|
|
/** @var FieldConfig */ |
19
|
|
|
protected $column; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Constructor. |
23
|
|
|
* |
24
|
|
|
* @param FieldConfig $column |
25
|
|
|
*/ |
26
|
|
|
public function __construct(FieldConfig $column) { |
27
|
|
|
|
28
|
|
|
$this->setColumn($column); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function getAttributes() |
32
|
|
|
{ |
33
|
|
|
if (empty($this->attributes['class'])) { |
34
|
|
|
$this->attributes['class'] = 'column-' . $this->getColumn()->getName(); |
35
|
|
|
} |
36
|
|
|
if ($this->column->isHidden()) { |
37
|
|
|
$this->attributes['style'] = 'display:none;'; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
if ($this->column->isHiddenXs()) { |
41
|
|
|
$this->attributes['class'] .= ' hidden-xs'; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
if ($this->column->isHiddenSm()) { |
45
|
|
|
$this->attributes['class'] .= ' hidden-sm'; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
if ($this->column->isHiddenMd()) { |
49
|
|
|
$this->attributes['class'] .= ' hidden-md'; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
if ($this->column->isHiddenLg()) { |
53
|
|
|
$this->attributes['class'] .= ' hidden-lg'; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return $this->attributes; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Returns component name. |
61
|
|
|
* By default it's column_{$column_name} |
62
|
|
|
* |
63
|
|
|
* @return string|null |
64
|
|
|
*/ |
65
|
|
|
public function getName() |
66
|
|
|
{ |
67
|
|
|
return $this->name ? : 'column_' . $this->column->getName(); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Returns associated column. |
72
|
|
|
* |
73
|
|
|
* @return FieldConfig $column |
74
|
|
|
*/ |
75
|
|
|
public function getColumn() |
76
|
|
|
{ |
77
|
|
|
return $this->column; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @param FieldConfig $column |
82
|
|
|
* @return $this |
83
|
|
|
*/ |
84
|
|
|
public function setColumn(FieldConfig $column) |
85
|
|
|
{ |
86
|
|
|
$this->column = $column; |
87
|
|
|
return $this; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|