1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* HiPanel core package |
4
|
|
|
* |
5
|
|
|
* @link https://hipanel.com/ |
6
|
|
|
* @package hipanel-core |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2014-2019, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hipanel\grid; |
12
|
|
|
|
13
|
|
|
use hipanel\assets\CheckboxStyleAsset; |
14
|
|
|
use hipanel\helpers\ArrayHelper; |
15
|
|
|
use hipanel\modules\client\grid\ClientColumn; |
16
|
|
|
use hipanel\modules\client\grid\SellerColumn; |
17
|
|
|
use hipanel\widgets\LinkSorter; |
18
|
|
|
use hipanel\widgets\PagerHook; |
19
|
|
|
use hipanel\widgets\SummaryHook; |
20
|
|
|
use hiqdev\assets\datatables\DataTablesAsset; |
21
|
|
|
use hiqdev\hiart\ActiveDataProvider; |
22
|
|
|
use Yii; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Class GridView. |
26
|
|
|
* HiPanel specific GridView. |
27
|
|
|
*/ |
28
|
|
|
class GridView extends \hiqdev\higrid\GridView |
29
|
|
|
{ |
30
|
|
|
public $sorter = [ |
31
|
|
|
'class' => LinkSorter::class, |
32
|
|
|
]; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
|
|
public $resizableColumns = [ |
38
|
|
|
'resizeFromBody' => false, |
39
|
|
|
]; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
*/ |
44
|
|
|
public $options = [ |
45
|
|
|
'class' => 'dataTables_wrapper form-inline', |
46
|
|
|
'role' => 'grid', |
47
|
|
|
]; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritdoc} |
51
|
|
|
*/ |
52
|
|
|
public $layout = "<div class='row'><div class='col-xs-12'>{sorter}</div></div><div class=\"table-responsive\">{items}</div>\n<div class='row'><div class='col-sm-6 col-xs-12'><div class='dataTables_info'>{summary}</div></div>\n<div class='col-sm-6 col-xs-12'><div class='dataTables_paginate paging_bootstrap'>{pager}</div></div></div>"; |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
public function init() |
56
|
|
|
{ |
57
|
|
|
parent::init(); |
58
|
|
|
|
59
|
|
|
if ($this->dataProvider instanceof ActiveDataProvider && $this->dataProvider->countSynchronously === false) { |
60
|
|
|
$this->pager = ['class' => PagerHook::class]; |
61
|
|
|
$this->summaryRenderer = static fn() => SummaryHook::widget(); |
|
|
|
|
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* {@inheritdoc} |
67
|
|
|
*/ |
68
|
|
|
public function columns() |
69
|
|
|
{ |
70
|
|
|
return array_merge(parent::columns(), [ |
71
|
|
|
'seller_id' => [ |
72
|
|
|
'class' => SellerColumn::class, |
73
|
|
|
], |
74
|
|
|
'client_id' => [ |
75
|
|
|
'class' => ClientColumn::class, |
76
|
|
|
], |
77
|
|
|
'checkbox' => [ |
78
|
|
|
'class' => CheckboxColumn::class, |
79
|
|
|
], |
80
|
|
|
'seller' => [ |
81
|
|
|
'class' => SellerColumn::class, |
82
|
|
|
'attribute' => 'seller_id', |
83
|
|
|
], |
84
|
|
|
'client' => [ |
85
|
|
|
'class' => ClientColumn::class, |
86
|
|
|
'attribute' => 'client_id', |
87
|
|
|
], |
88
|
|
|
'client_like' => [ |
89
|
|
|
'class' => ClientColumn::class, |
90
|
|
|
'filterOptions' => ['class' => 'narrow-filter'], |
91
|
|
|
], |
92
|
|
|
'blocking' => [ |
93
|
|
|
'label' => Yii::t('hipanel', 'Block'), |
94
|
|
|
'class' => BlockingColumn::class, |
95
|
|
|
], |
96
|
|
|
]); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* {@inheritdoc} |
101
|
|
|
*/ |
102
|
|
|
public function run() |
103
|
|
|
{ |
104
|
|
|
$this->tableOptions['class'] .= ' ' . Yii::$app->themeManager->settings->getCssClass('table_condensed'); |
105
|
|
|
parent::run(); |
106
|
|
|
$this->registerClientScript(); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* {@inheritdoc} |
111
|
|
|
*/ |
112
|
|
|
public static function detailView(array $config = []) |
113
|
|
|
{ |
114
|
|
|
$config = ArrayHelper::merge(['gridOptions' => ['resizableColumns' => ['resizeFromBody' => true]]], $config); |
115
|
|
|
|
116
|
|
|
return parent::detailView($config); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* {@inheritdoc} |
121
|
|
|
*/ |
122
|
|
|
private function registerClientScript() |
123
|
|
|
{ |
124
|
|
|
$view = $this->getView(); |
125
|
|
|
DataTablesAsset::register($view); |
126
|
|
|
CheckboxStyleAsset::register($view); |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|