mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-17 07:51:12 +08:00
Refactored PR, updated CHANGELOG
This commit is contained in:
@ -243,6 +243,7 @@ Yii Framework 2 Change Log
|
|||||||
- Bug #9046: Fixed problem with endless error loop when an error occurred after sending a stream or file download response to the user (cebe)
|
- Bug #9046: Fixed problem with endless error loop when an error occurred after sending a stream or file download response to the user (cebe)
|
||||||
- Bug #9059: Fixed PHP Notice in error handler view (dynasource, andrewnester, samdark)
|
- Bug #9059: Fixed PHP Notice in error handler view (dynasource, andrewnester, samdark)
|
||||||
- Bug #9063: Workaround for MySQL losing table case when adding index (sebathi)
|
- Bug #9063: Workaround for MySQL losing table case when adding index (sebathi)
|
||||||
|
- Bug #9074: Fixed JS call `$('#grid').yiiGridView('getSelectedRows')` when `GridView::$showHeader` is set to false (NekitoSP, silverfire)
|
||||||
- Bug #9076: Fixed `yii\filters\PageCache` not using the configured duration and dependency when caching the response data (kidol)
|
- Bug #9076: Fixed `yii\filters\PageCache` not using the configured duration and dependency when caching the response data (kidol)
|
||||||
- Bug #9091: `UrlManager::createUrl()` did not create correct url when defaults were used, internal cache is now skipped in certain situations (cebe)
|
- Bug #9091: `UrlManager::createUrl()` did not create correct url when defaults were used, internal cache is now skipped in certain situations (cebe)
|
||||||
- Bug #9127, #9128: Fixed MSSQL `QueryBuilder::renameColumn()` and `QueryBuilder::renameTable()` escaping (sitawit)
|
- Bug #9127, #9128: Fixed MSSQL `QueryBuilder::renameColumn()` and `QueryBuilder::renameTable()` escaping (sitawit)
|
||||||
|
@ -55,7 +55,12 @@
|
|||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
var $e = $(this);
|
var $e = $(this);
|
||||||
var settings = $.extend({}, defaults, options || {});
|
var settings = $.extend({}, defaults, options || {});
|
||||||
gridData[$e.attr('id')] = {settings: settings};
|
var id = $e.attr('id');
|
||||||
|
if (gridData[id] === undefined) {
|
||||||
|
gridData[id] = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
gridData[id] = $.extend(gridData[id], {settings: settings});
|
||||||
|
|
||||||
var enterPressed = false;
|
var enterPressed = false;
|
||||||
$(document).off('change.yiiGridView keydown.yiiGridView', settings.filterSelector)
|
$(document).off('change.yiiGridView keydown.yiiGridView', settings.filterSelector)
|
||||||
@ -142,6 +147,9 @@
|
|||||||
setSelectionColumn: function (options) {
|
setSelectionColumn: function (options) {
|
||||||
var $grid = $(this);
|
var $grid = $(this);
|
||||||
var id = $(this).attr('id');
|
var id = $(this).attr('id');
|
||||||
|
if (gridData.id === undefined) {
|
||||||
|
gridData[id] = {};
|
||||||
|
}
|
||||||
gridData[id].selectionColumn = options.name;
|
gridData[id].selectionColumn = options.name;
|
||||||
if (!options.multiple || !options.checkAll) {
|
if (!options.multiple || !options.checkAll) {
|
||||||
return;
|
return;
|
||||||
|
@ -10,6 +10,7 @@ namespace yii\grid;
|
|||||||
use Closure;
|
use Closure;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
|
use yii\helpers\Json;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CheckboxColumn displays a column of checkboxes in a grid view.
|
* CheckboxColumn displays a column of checkboxes in a grid view.
|
||||||
@ -82,14 +83,7 @@ class CheckboxColumn extends Column
|
|||||||
$this->name .= '[]';
|
$this->name .= '[]';
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = $this->grid->showHeader ? $this->getHeaderCheckBoxName() : NULL;
|
$this->registerClientScript();
|
||||||
$id = $this->grid->options['id'];
|
|
||||||
$options = json_encode([
|
|
||||||
'name' => $this->name,
|
|
||||||
'multiple' => $this->multiple,
|
|
||||||
'checkAll' => $name,
|
|
||||||
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
|
||||||
$this->grid->getView()->registerJs("jQuery('#$id').yiiGridView('setSelectionColumn', $options);");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,28 +94,10 @@ class CheckboxColumn extends Column
|
|||||||
*/
|
*/
|
||||||
protected function renderHeaderCellContent()
|
protected function renderHeaderCellContent()
|
||||||
{
|
{
|
||||||
$name = $this->name;
|
|
||||||
if (substr_compare($name, '[]', -2, 2) === 0) {
|
|
||||||
$name = substr($name, 0, -2);
|
|
||||||
}
|
|
||||||
if (substr_compare($name, ']', -1, 1) === 0) {
|
|
||||||
$name = substr($name, 0, -1) . '_all]';
|
|
||||||
} else {
|
|
||||||
$name .= '_all';
|
|
||||||
}
|
|
||||||
|
|
||||||
$id = $this->grid->options['id'];
|
|
||||||
$options = json_encode([
|
|
||||||
'name' => $this->name,
|
|
||||||
'multiple' => $this->multiple,
|
|
||||||
'checkAll' => $name,
|
|
||||||
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
|
||||||
$this->grid->getView()->registerJs("jQuery('#$id').yiiGridView('setSelectionColumn', $options);");
|
|
||||||
|
|
||||||
if ($this->header !== null || !$this->multiple) {
|
if ($this->header !== null || !$this->multiple) {
|
||||||
return parent::renderHeaderCellContent();
|
return parent::renderHeaderCellContent();
|
||||||
} else {
|
} else {
|
||||||
return Html::checkbox($name, false, ['class' => 'select-on-check-all']);
|
return Html::checkbox($this->getHeaderCheckBoxName(), false, ['class' => 'select-on-check-all']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +113,7 @@ class CheckboxColumn extends Column
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($options['value'])) {
|
if (!isset($options['value'])) {
|
||||||
$options['value'] = is_array($key) ? json_encode($key, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : $key;
|
$options['value'] = is_array($key) ? Json::encode($key) : $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Html::checkbox($this->name, !empty($options['checked']), $options);
|
return Html::checkbox($this->name, !empty($options['checked']), $options);
|
||||||
@ -146,9 +122,35 @@ class CheckboxColumn extends Column
|
|||||||
/**
|
/**
|
||||||
* Returns header checkbox name
|
* Returns header checkbox name
|
||||||
* @return string header checkbox name
|
* @return string header checkbox name
|
||||||
|
* @since 2.0.8
|
||||||
*/
|
*/
|
||||||
private function getHeaderCheckBoxName()
|
protected function getHeaderCheckBoxName()
|
||||||
{
|
{
|
||||||
return rtrim($this->name, '[]') . '_all';
|
$name = $this->name;
|
||||||
|
if (substr_compare($name, '[]', -2, 2) === 0) {
|
||||||
|
$name = substr($name, 0, -2);
|
||||||
|
}
|
||||||
|
if (substr_compare($name, ']', -1, 1) === 0) {
|
||||||
|
$name = substr($name, 0, -1) . '_all]';
|
||||||
|
} else {
|
||||||
|
$name .= '_all';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers the needed JavaScript
|
||||||
|
* @since 2.0.8
|
||||||
|
*/
|
||||||
|
public function registerClientScript()
|
||||||
|
{
|
||||||
|
$id = $this->grid->options['id'];
|
||||||
|
$options = Json::encode([
|
||||||
|
'name' => $this->name,
|
||||||
|
'multiple' => $this->multiple,
|
||||||
|
'checkAll' => $this->grid->showHeader ? $this->getHeaderCheckBoxName() : null,
|
||||||
|
]);
|
||||||
|
$this->grid->getView()->registerJs("jQuery('#$id').yiiGridView('setSelectionColumn', $options);");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,11 +272,6 @@ class GridView extends BaseListView
|
|||||||
$this->filterRowOptions['id'] = $this->options['id'] . '-filters';
|
$this->filterRowOptions['id'] = $this->options['id'] . '-filters';
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $this->options['id'];
|
|
||||||
$options = Json::htmlEncode($this->getClientOptions());
|
|
||||||
$view = $this->getView();
|
|
||||||
$view->registerJs("jQuery('#$id').yiiGridView($options);");
|
|
||||||
|
|
||||||
$this->initColumns();
|
$this->initColumns();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,9 +280,11 @@ class GridView extends BaseListView
|
|||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
|
$id = $this->options['id'];
|
||||||
|
$options = Json::htmlEncode($this->getClientOptions());
|
||||||
$view = $this->getView();
|
$view = $this->getView();
|
||||||
GridViewAsset::register($view);
|
GridViewAsset::register($view);
|
||||||
|
$view->registerJs("jQuery('#$id').yiiGridView($options);");
|
||||||
parent::run();
|
parent::run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user