Skip to content

Commit

Permalink
Updates to release v3.2.4 fixes #828 fixes #829
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Sep 26, 2018
1 parent bb3a841 commit 7f38124
Show file tree
Hide file tree
Showing 47 changed files with 93 additions and 74 deletions.
7 changes: 7 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Change Log: `yii2-grid`
=======================

## Version 3.2.4

**Date:** 22-Sep-2018

- (enh #829): Enhancements in parsing Bootstrap CSS classes (ref: kartik-v/yii2-krajee-base#100).
- (enh #828): Enhance `ActionColumn::dropdownButton` to be setup as a callback.

## Version 3.2.3

**Date:** 22-Sep-2018
Expand Down
28 changes: 20 additions & 8 deletions src/ActionColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
/**
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2018
* @package yii2-grid
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;

use Closure;
use Yii;
use yii\grid\ActionColumn as YiiActionColumn;
use yii\helpers\ArrayHelper;
Expand Down Expand Up @@ -56,12 +57,20 @@ class ActionColumn extends YiiActionColumn
public $dropdownMenu = ['class' => 'text-left'];

/**
* @var array the dropdown button options. This configuration will be applicable only if [[dropdown]] is `true`.
* The following special options are recognized:
* @var array|Closure the dropdown button options. This configuration will be applicable only if [[dropdown]] is
* `true`. When set as an array, the following special options are recognized:
*
* - `label`: _string_', the button label to be displayed. Defaults to `Actions`.
* - `caret`: _string_', the caret symbol to be appended to the dropdown button.
* Defaults to ` <span class="caret"></span>`.
* - `caret`: _string_', the caret symbol to be appended to the dropdown button. Applicable only for Bootstrap 3.x
* versions when `GridView::bsVersion = 3.x`. Defaults to ` <span class="caret"></span>`.
*
* This can also be setup as a `Closure` callback function of the following signature that returns the above array:
*
* `function ($model, $key, $index) {}`, where:
*
* - `$model`: _\yii\db\ActiveRecordInterface_ is the data model of current row
* - `$key`: _mixed_, is the key associated with the data model
* - `$index`: _int_, is the current row index
*/
public $dropdownButton = [];

Expand Down Expand Up @@ -140,9 +149,6 @@ public function init()
}
$this->parseFormat();
$this->parseVisibility();
if (!isset($this->dropdownButton['class'])) {
$this->dropdownButton['class'] = 'btn ' . $this->grid->getDefaultBtnCss();
}
parent::init();
$this->initDefaultButtons();
$this->setPageRows();
Expand Down Expand Up @@ -263,6 +269,12 @@ protected function renderDataCellContent($model, $key, $index)
}
$content = parent::renderDataCellContent($model, $key, $index);
$options = $this->dropdownButton;
if (is_callable($options)) {
$options = $options($model, $key, $index);
}
if (!isset($options['class'])) {
$options['class'] = 'btn ' . $this->grid->getDefaultBtnCss();
}
$trimmed = trim($content);
if ($this->_isDropdown && !empty($trimmed)) {
$label = ArrayHelper::remove($options, 'label', Yii::t('kvgrid', 'Actions'));
Expand Down
2 changes: 1 addition & 1 deletion src/ActionColumnAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
2 changes: 1 addition & 1 deletion src/BooleanColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
4 changes: 2 additions & 2 deletions src/CheckboxColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down Expand Up @@ -69,7 +69,7 @@ public function init()
'width' => '50px'
]);
if (!isset($this->rowSelectedClass)) {
$this->rowSelectedClass = ($this->grid->isBs4() ? 'table-' : '') . GridView::TYPE_DANGER;
$this->rowSelectedClass = $this->grid->getCssClass(GridView::BS_TABLE_DANGER);
}
$id = $this->grid->options['id'];
$view = $this->grid->getView();
Expand Down
2 changes: 1 addition & 1 deletion src/CheckboxColumnAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
2 changes: 1 addition & 1 deletion src/ColumnTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
2 changes: 1 addition & 1 deletion src/DataColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
2 changes: 1 addition & 1 deletion src/Demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
2 changes: 1 addition & 1 deletion src/EditableColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
2 changes: 1 addition & 1 deletion src/EditableColumnAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
2 changes: 1 addition & 1 deletion src/EditableColumnAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
4 changes: 2 additions & 2 deletions src/ExpandRowColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down Expand Up @@ -232,7 +232,7 @@ protected static function parseData($data, $model, $key, $index, $column)
public function init()
{
if (!isset($this->detailRowCssClass)) {
$this->detailRowCssClass = $this->grid->isBs4() ? 'table-' . GridView::TYPE_INFO : GridView::TYPE_INFO;
$this->detailRowCssClass = $this->grid->getCssClass(GridView::BS_TABLE_INFO);
}
$this->initColumnSettings([
'hiddenFromExport' => true,
Expand Down
2 changes: 1 addition & 1 deletion src/ExpandRowColumnAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
2 changes: 1 addition & 1 deletion src/FormulaColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
2 changes: 1 addition & 1 deletion src/GridExportAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
2 changes: 1 addition & 1 deletion src/GridFloatHeadAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
2 changes: 1 addition & 1 deletion src/GridGroupAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
2 changes: 1 addition & 1 deletion src/GridPerfectScrollbarAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
2 changes: 1 addition & 1 deletion src/GridResizeColumnsAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
2 changes: 1 addition & 1 deletion src/GridResizeStoreAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
2 changes: 1 addition & 1 deletion src/GridToggleDataAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
36 changes: 18 additions & 18 deletions src/GridView.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down Expand Up @@ -834,13 +834,13 @@ class GridView extends YiiGridView implements BootstrapInterface
* 'all' => [
* 'icon' => 'resize-full',
* 'label' => 'All',
* 'class' => 'btn btn-default',
* 'class' => 'btn btn-default', // 'btn btn-secondary' for BS4.x
* 'title' => 'Show all data'
* ],
* 'page' => [
* 'icon' => 'resize-small',
* 'label' => 'Page',
* 'class' => 'btn btn-default',
* 'class' => 'btn btn-default', // 'btn btn-secondary' for BS4.x
* 'title' => 'Show first page data'
* ],
* ]
Expand Down Expand Up @@ -894,7 +894,8 @@ class GridView extends YiiGridView implements BootstrapInterface
* This should be similar to the `items` property as supported by `\yii\bootstrap\ButtonDropdown` widget. Note
* the page export items will be automatically generated based on settings in the `exportConfig` property.
* - `options`: _array_, HTML attributes for the export menu button. Defaults to
* `['class' => 'btn btn-default', 'title'=>'Export']`.
* - `['class' => 'btn btn-default']` for [[bsVersion]] = '3.x' or .
* - `['class' => 'btn btn-secondary']` for [[bsVersion]] = '4.x'
* - `encoding`: _string_, the export output file encoding. If not set, defaults to `utf-8`.
* - `bom`: `boolean`, whether a BOM is to be embedded for text or CSV files with utf-8 encoding. Defaults to
* `true`.
Expand Down Expand Up @@ -1073,9 +1074,6 @@ public function init()
if (!isset($this->itemLabelMany)) {
$this->itemLabelMany = Yii::t('kvgrid', 'items-many');
}
if (!isset($this->panelPrefix)) {
$this->panelPrefix = $this->isBs4() ? 'card' : 'panel panel-';
}
$isBs4 = $this->isBs4();
if ($isBs4) {
Html::addCssClass($this->options, 'kv-grid-bs4');
Expand Down Expand Up @@ -1755,7 +1753,7 @@ protected function initBootstrapStyle()
Html::addCssClass($this->tableOptions, 'table-striped');
}
if ($this->condensed) {
Html::addCssClass($this->tableOptions, ($this->isBs4() ? 'table-sm' : 'table-condensed'));
$this->addCssClass($this->tableOptions, self::BS_TABLE_CONDENSED);

This comment has been minimized.

Copy link
@sumanta-ghosh

sumanta-ghosh Sep 27, 2018

self::BS_TABLE_CONDENSED is use here but you never define it anywhere.

}
if ($this->floatHeader) {
if ($this->perfectScrollbar) {
Expand Down Expand Up @@ -1909,19 +1907,22 @@ protected function renderPanel()
$panelAfter = '';
$panelFooter = '';
$isBs4 = $this->isBs4();
static::initCss($options, $isBs4 ? 'card border-' . $type : $this->panelPrefix . $type);
static::initCss($summaryOptions, $isBs4 ? 'float-right' : 'pull-right');
$titleTag = ArrayHelper::remove($titleOptions, 'tag', ($isBs4 ? 'span' : 'h3'));
if (!$isBs4) {
static::initCss($titleOptions, 'panel-title');
if (isset($this->panelPrefix)) {
static::initCss($options, $this->panelPrefix . $type);
} else {
$this->addCssClass($options, self::BS_PANEL);
Html::addCssClass($options, $isBs4 ? "border-{$type}" : "panel-{$type}");
}
static::initCss($summaryOptions, $this->getCssClass(self::BS_PULL_RIGHT));
$titleTag = ArrayHelper::remove($titleOptions, 'tag', ($isBs4 ? 'h5' : 'h3'));
static::initCss($titleOptions, $isBs4 ? 'm-0' : $this->getCssClass(self::BS_PANEL_TITLE));
if ($heading !== false) {
$color = $type === 'default' ? 'bg-light' : 'text-white bg-' . $type;
static::initCss($headingOptions, $isBs4 ? 'card-header ' . $color : 'panel-heading');
$color = $isBs4 ? ($type === 'default' ? ' bg-light' : " text-white bg-{$type}") : '';
static::initCss($headingOptions, $this->getCssClass(self::BS_PANEL_HEADING) . $color);
$panelHeading = Html::tag('div', $this->panelHeadingTemplate, $headingOptions);
}
if ($footer !== false) {
static::initCss($footerOptions, $isBs4 ? 'card-footer' : 'panel-footer');
static::initCss($footerOptions, $this->getCssClass(self::BS_PANEL_FOOTER));
$content = strtr($this->panelFooterTemplate, ['{footer}' => $footer]);
$panelFooter = Html::tag('div', $content, $footerOptions);
}
Expand Down Expand Up @@ -1983,8 +1984,7 @@ protected function renderToolbar()
protected function renderToolbarContainer()
{
$tag = ArrayHelper::remove($this->toolbarContainerOptions, 'tag', 'div');
$css = $this->isBs4() ? 'float-right' : 'pull-right';
Html::addCssClass($this->toolbarContainerOptions, $css);
$this->addCssClass($this->toolbarContainerOptions, self::BS_PULL_RIGHT);
return Html::tag($tag, $this->renderToolbar(), $this->toolbarContainerOptions);
}

Expand Down
2 changes: 1 addition & 1 deletion src/GridViewAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
2 changes: 1 addition & 1 deletion src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.3
* @version 3.2.4
*/

namespace kartik\grid;
Expand Down
Loading

0 comments on commit 7f38124

Please sign in to comment.