Completed
Push — master ( 0c1c6f...58b419 )
by eXeCUT
32:28
created

DynaGrid   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 84
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
B init() 0 55 2
A getGridId() 0 3 1
A run() 0 13 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: execut
5
 * Date: 11/15/17
6
 * Time: 12:14 PM
7
 */
8
9
namespace execut\actions\widgets;
10
11
use execut\actions\action\adapter\viewRenderer\DynaGridRow;
12
use execut\yii\jui\WidgetTrait;
13
use kartik\export\ExportMenu;
14
use yii\helpers\ArrayHelper;
15
use yii\helpers\Html;
16
use \kartik\dynagrid\DynaGrid as KartikDynaGrid;
17
18
class DynaGrid extends KartikDynaGrid
19
{
20
    use WidgetTrait;
21
    public $dataProvider = null;
22
    public $storage = KartikDynaGrid::TYPE_DB;
23
    public $filter = null;
24
25
    public function init()
26
    {
27
        $columns = $this->filter->getGridColumns();
28
//        foreach ($exportColumns as &$column) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
66% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
29
//            unset($column['visible']);
30
//        }
31
32
        $fullExportMenu = ExportMenu::widget([
33
            'dataProvider' => $this->dataProvider,
34
            'columns' => $columns,
35
            'showColumnSelector' => true,
36
            'target' => ExportMenu::TARGET_BLANK,
37
            'batchSize' => 1000,
38
            'fontAwesome' => true,
39
            'asDropdown' => false,
40
            'dynagrid' => true,
41
            'dynagridOptions' => [
42
                'options' => ['id' => $this->options['id']],
43
//                'columns' => $columns,
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
44
            ],
45
            'dropdownOptions' => [
46
                'label' => '<i class="glyphicon glyphicon-export"></i> Full'
47
            ],
48
        ]);
49
50
        $this->columns = $columns;
51
52
        $this->gridOptions = ArrayHelper::merge([
53
            'class' => GridView::class,
54
            'responsive' => false,
55
            'responsiveWrap' => false,
56
            'rowOptions' => function ($row) {
57
                if ($row instanceof DynaGridRow) {
58
                    return $row->getRowOptions();
59
                }
60
            },
61
            'panel' => false,
62
            'export' => [
63
                'fontAwesome' => true,
64
                'itemsAfter'=> [
65
                    '<li role="presentation" class="divider"></li>',
66
                    '<li class="dropdown-header">Export All Data</li>',
67
                    $fullExportMenu
68
                ]
69
            ],
70
            'toggleDataOptions' => [
71
                'maxCount' => 100000,
72
            ],
73
            'filterModel' => $this->filter,
74
//            'toolbar' => $this->getToolbarConfig(),
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
75
            'dataProvider' => $this->dataProvider,
76
        ], $this->gridOptions);
77
78
        parent::init(); // TODO: Change the autogenerated stub
79
    }
80
81
    public function getGridId() {
82
        return $this->id . '-grid';
83
    }
84
85
    /**
86
     * @inheritdoc
87
     */
88
    public function run()
89
    {
90
        if (method_exists($this, 'initWidget')) {
91
            $this->initWidget();
92
        }
93
94
        $this->gridOptions['options']['id'] = $this->id;
95
96
        Html::addCssClass($this->options, $this->getDefaultCssClass());
97
        $this->_registerBundle();
98
99
        echo Html::tag('div', GridView::widget($this->gridOptions), $this->options);
100
    }
101
}