Skip to content

Commit

Permalink
Updates to release v3.3.1 fixes #896 fixes #902
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed May 17, 2019
1 parent 910e8f8 commit 0eb1700
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 41 deletions.
19 changes: 19 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- bug
- enhancement
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
5 changes: 4 additions & 1 deletion CHANGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ Change Log: `yii2-grid`

## Version 3.3.1

**Date:** 15-May-2019
**Date:** 17-May-2019

- Implement stale bot.
- (enh #902): Ability to merge columns at page summary (via `pageSummaryOptions['colspan']` set at column level).
- (enh #901): Update Latvian Translations.
- (enh #896): Enhance generation of pjax container identifier.
- (bug #889): Correct nested expand row validation.
- (enh #888): Enhance `BooleanColumn` data rendering for grid export.
- (bug #885, #886): Fix for `CheckboxColumn::checkboxOptions` to be set as Closure.
Expand Down
26 changes: 13 additions & 13 deletions src/ColumnTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@ public function renderHeaderCell()
return parent::renderHeaderCell();
}

/**
* Renders the page summary cell.
*
* @return string the rendered result
*/
public function renderPageSummaryCell()
{
$prepend = ArrayHelper::remove($this->pageSummaryOptions, 'prepend', '');
$append = ArrayHelper::remove($this->pageSummaryOptions, 'append', '');
return Html::tag('td', $prepend . $this->renderPageSummaryCellContent() . $append, $this->pageSummaryOptions);
}

/**
* Renders the filter cell.
*
Expand All @@ -212,18 +224,6 @@ public function renderFilterCell()
return parent::renderFilterCell();
}

/**
* Renders the page summary cell.
*
* @return string the rendered result
*/
public function renderPageSummaryCell()
{
$prepend = ArrayHelper::remove($this->pageSummaryOptions, 'prepend', '');
$append = ArrayHelper::remove($this->pageSummaryOptions, 'append', '');
return Html::tag('td', $prepend . $this->renderPageSummaryCellContent() . $append, $this->pageSummaryOptions);
}

/**
* Parses Excel Cell Formats for export
*
Expand Down Expand Up @@ -563,7 +563,7 @@ protected function initPjax($script = '')
if (!$this->grid->pjax || empty($script)) {
return;
}
$cont = 'jQuery("#' . $this->grid->pjaxSettings['options']['id'] . '")';
$cont = 'jQuery("#' . $this->grid->getPjaxContainerId() . '")';
$view = $this->grid->getView();
$ev = 'pjax:complete.' . hash('crc32', $script);
$view->registerJs("{$cont}.off('{$ev}').on('{$ev}', function(){ {$script} });");
Expand Down
2 changes: 1 addition & 1 deletion src/DataColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ protected function renderFilterCellContent()
];
if (is_array($this->filter)) {
if (Config::isInputWidget($this->filterType) && $this->grid->pjax) {
$options['pjaxContainerId'] = $this->grid->pjaxSettings['options']['id'];
$options['pjaxContainerId'] = $this->grid->getPjaxContainerId();
}
if ($this->filterType === GridView::FILTER_SELECT2 || $this->filterType === GridView::FILTER_TYPEAHEAD) {
$options['data'] = $this->filter;
Expand Down
2 changes: 1 addition & 1 deletion src/EditableColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function renderDataCellContent($model, $key, $index)
Html::addCssClass($options, $this->_css);
$this->_editableOptions['containerOptions'] = $options;
if ($this->grid->pjax && empty($this->_editableOptions['pjaxContainerId'])) {
$this->_editableOptions['pjaxContainerId'] = $this->grid->pjaxSettings['options']['id'];
$this->_editableOptions['pjaxContainerId'] = $this->grid->getPjaxContainerId();
}
if (!isset($key)) {
throw new InvalidConfigException('Invalid or no primary key found for the grid data.');
Expand Down
57 changes: 48 additions & 9 deletions src/GridView.php
Original file line number Diff line number Diff line change
Expand Up @@ -1092,12 +1092,7 @@ public function init()
}
$this->initBsVersion();
Html::addCssClass($this->options, 'is-bs' . ($this->isBs4() ? '4' : '3'));
if (empty($this->options['id'])) {
$this->options['id'] = $this->getId();
}
if (empty($this->pjaxSettings['options']['id'])) {
$this->pjaxSettings['options']['id'] = $this->options['id'] . '-pjax';
}
$this->initPjaxContainerId();
if (!isset($this->itemLabelSingle)) {
$this->itemLabelSingle = Yii::t('kvgrid', 'item');
}
Expand Down Expand Up @@ -1141,6 +1136,29 @@ public function init()
parent::init();
}

/**
* Get pjax container identifier
* @return string
*/
public function getPjaxContainerId()
{
$this->initPjaxContainerId();
return $this->pjaxSettings['options']['id'];
}

/**
* Initializes pjax container identifier
*/
public function initPjaxContainerId()
{
if (empty($this->options['id'])) {
$this->options['id'] = $this->getId();
}
if (empty($this->pjaxSettings['options']['id'])) {
$this->pjaxSettings['options']['id'] = $this->options['id'] . '-pjax';
}
}

/**
* Adds CSS class to the pager parameter
* @param string $param the pager param
Expand Down Expand Up @@ -1202,12 +1220,33 @@ public function renderPageSummary()
$this->pageSummaryRowOptions['class'] = ($this->isBs4() ? 'table-' : '') . 'warning kv-page-summary';
}
$cells = [];
/** @var DataColumn $column */
foreach ($this->columns as $column) {
$skipped = [];
$cols = count($this->columns);
for ($i = 0; $i < $cols; $i++) {
/** @var DataColumn $column */
$column = $this->columns[$i];
if (!method_exists($column, 'renderPageSummaryCell')) {
$cells[] = Html::tag('td');
continue;
}
$cells[] = $column->renderPageSummaryCell();
if (!empty($column->pageSummaryOptions['colspan'])) {
$span = (int) $column->pageSummaryOptions['colspan'];
if ($span > 0) {
$skipCols = range($i + 1, $i + $span - 1);
$skipped = array_merge($skipCols, $skipped);
}
}
}
if (!empty($skipped )) {
for ($i = 0; $i < $cols; $i++) {
if (in_array($i, $skipped )) {
$cells[$i] = '';
}
}
}
$tag = ArrayHelper::remove($this->pageSummaryContainer, 'tag', 'tbody');
$content = Html::tag('tr', implode('', $cells), $this->pageSummaryRowOptions);
$content = Html::tag('tr', implode(' ', $cells), $this->pageSummaryRowOptions);
return Html::tag($tag, $content, $this->pageSummaryContainer);
}

Expand Down
33 changes: 19 additions & 14 deletions src/assets/js/jquery.floatThead.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @preserve jQuery.floatThead 2.1.1 - http://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2018 Misha Koryak **/
/** @preserve jQuery.floatThead 2.1.3 - https://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2018 Misha Koryak **/
// @license MIT

/* @author Misha Koryak
Expand All @@ -7,7 +7,7 @@
* Dependencies:
* jquery 1.9.0 + [required] OR jquery 1.7.0 + jquery UI core
*
* http://mkoryak.github.io/floatThead/
* https://mkoryak.github.io/floatThead/
*
* Tested on FF13+, Chrome 21+, IE8, IE9, IE10, IE11
*/
Expand Down Expand Up @@ -141,11 +141,11 @@
var _afterPrint = window.onafterprint;
window.onbeforeprint = function () {
_beforePrint && _beforePrint();
$window.triggerHandler("beforeprint");
$window.triggerHandler("fth-beforeprint");
};
window.onafterprint = function () {
_afterPrint && _afterPrint();
$window.triggerHandler("afterprint");
$window.triggerHandler("fth-afterprint");
};
}

Expand Down Expand Up @@ -213,7 +213,7 @@
}

/**
* Check if a given table has been datatableized (http://datatables.net)
* Check if a given table has been datatableized (https://datatables.net)
* @param $table
* @return {Boolean}
*/
Expand Down Expand Up @@ -501,14 +501,14 @@
function setFloatWidth(){
var tw = tableWidth($table, $fthCells, true);
var $container = responsive ? $responsiveContainer : $scrollContainer;
var width = $container.width() || tw;
var width = $container.length ? getOffsetWidth($container[0]) : tw;
var floatContainerWidth = $container.css("overflow-y") != 'hidden' ? width - scrollbarOffset.vertical : width;
$floatContainer.width(floatContainerWidth);
if(locked){
var percent = 100 * tw / (floatContainerWidth);
$floatTable.css('width', percent+'%');
} else {
$floatTable.outerWidth(tw);
$floatTable.css('width', tw+'px');
}
}

Expand Down Expand Up @@ -780,6 +780,9 @@
var gap = tableContainerGap - scrollingContainerTop + tableTopGap;
top = gap > 0 ? gap : 0;
triggerFloatEvent(false);
} else if(scrollingContainerTop - tableContainerGap > tableHeight - floatContainerHeight){
// scrolled past table but there is space in the container under it..
top = tableHeight - floatContainerHeight - scrollingContainerTop - tableContainerGap;
} else {
top = wrappedContainer ? tableTopGap : scrollingContainerTop;
//headers stop at the top of the viewport
Expand All @@ -788,7 +791,7 @@
left = tableLeftGap;
} else if(!locked && useAbsolutePositioning) { //window scrolling, absolute positioning
if(windowTop > floatEnd + tableHeight + captionScrollOffset){
top = tableHeight - floatContainerHeight + captionScrollOffset; //scrolled past table
top = tableHeight - floatContainerHeight + captionScrollOffset + scrollingBottom; //scrolled past table
} else if (tableOffset.top >= windowTop + scrollingTop) {
top = 0; //scrolling to table
unfloat();
Expand Down Expand Up @@ -847,15 +850,16 @@
});
} else {
var transform = 'translateX(' + pos.left + 'px) translateY(' + pos.top + 'px)';
$floatContainer.css({
var cssObj = {
'-webkit-transform' : transform,
'-moz-transform' : transform,
'-ms-transform' : transform,
'-o-transform' : transform,
'transform' : transform,
'top': 0,
'left': 0
});
};
cssObj[/rtl/i.test(document.documentElement.dir || '') ? 'right': 'left'] = 0;
$floatContainer.css(cssObj);
}
oldTop = pos.top;
oldLeft = pos.left;
Expand Down Expand Up @@ -974,8 +978,8 @@
matchMediaPrint = window.matchMedia("print");
matchMediaPrint.addListener(printEvent);
} else {
$window.on('beforeprint', beforePrint);
$window.on('afterprint', afterPrint);
$window.on('fth-beforeprint', beforePrint);
$window.on('fth-afterprint', afterPrint);
}
////// end printing stuff

Expand Down Expand Up @@ -1072,6 +1076,7 @@
$floatContainer.remove();
$table.data('floatThead-attached', false);
$window.off(ns);
$window.off('fth-beforeprint fth-afterprint'); // Not bound with id, so cant use ns.
if (matchMediaPrint) {
matchMediaPrint.removeListener(printEvent);
}
Expand Down Expand Up @@ -1108,4 +1113,4 @@
$ = require('jquery');
}
return $;
})());
})());
Loading

0 comments on commit 0eb1700

Please sign in to comment.