Skip to content

Commit

Permalink
Always show column with checkboxes when group actions is defined. (#516)
Browse files Browse the repository at this point in the history
* Always show column with checkboxes when group actions is defined.
* Used template variable instead of repeated method call.
  • Loading branch information
radekprokes authored and juniwalk committed Apr 19, 2017
1 parent 8f0bee6 commit 3e62fd9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/DataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ public function render()
$this->getTemplate()->inlineEdit = $this->inlineEdit;
$this->getTemplate()->inlineAdd = $this->inlineAdd;

$this->getTemplate()->hasGroupActions = $this->hasGroupActions();
$this->getTemplate()->hasGroupActionOnRows = $hasGroupActionOnRows;

/**
Expand Down Expand Up @@ -2404,6 +2405,7 @@ public function reload($snippets = [])
if ($this->getPresenter()->isAjax()) {
$this->redrawControl('tbody');
$this->redrawControl('pagination');
$this->redrawControl('thead-group-action');

/**
* manualy reset exports links...
Expand Down
18 changes: 9 additions & 9 deletions src/templates/datagrid.latte
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@
{/if}
<table class="{block table-class}table table-hover table-striped table-bordered{/block}" n:snippet="table" n:block="data">
<thead n:block="header">
<tr class="row-group-actions" n:if="$hasGroupActionOnRows || $exports || $toolbar_buttons || $control->canHideColumns() || $inlineAdd" n:block="group-actions">
<tr class="row-group-actions" n:if="$hasGroupActions || $exports || $toolbar_buttons || $control->canHideColumns() || $inlineAdd" n:block="group-actions">
<th colspan="{$control->getColumnsCount()}" class="form-inline">
{if $hasGroupActionOnRows}
{if $hasGroupActions}
{block group_actions}
{='ublaboo_datagrid.group_actions'|translate}:
{foreach $filter['group_action']->getControls() as $form_control}
Expand Down Expand Up @@ -140,8 +140,8 @@
</th>
</tr>
<tr n:block="header-column-row">
<th n:if="$hasGroupActionOnRows" rowspan="2" class="col-checkbox">
<input n:class="$control->useHappyComponents() ? 'happy gray-border' , primary" name="{$control->getName()|lower}-toggle-all" type="checkbox" data-check="{$control->getName()}" data-check-all="{$control->getName()}">
<th n:snippet="thead-group-action" n:if="$hasGroupActions" rowspan="2" class="col-checkbox">
<input n:if="$hasGroupActionOnRows" n:class="$control->useHappyComponents() ? 'happy gray-border' , primary" name="{$control->getName()|lower}-toggle-all" type="checkbox" data-check="{$control->getName()}" data-check-all="{$control->getName()}">
</th>
{foreach $columns as $key => $column}
{var $th = $column->getElementForRender('th', $key)}
Expand Down Expand Up @@ -244,7 +244,7 @@
{php $inlineEdit->onSetDefaults($filter['inline_edit'], $item); }

<tr data-id="{$row->getId()}" n:snippet="item-{$row->getId()}" n:class="$row->getControlClass()">
<td n:if="$hasGroupActionOnRows" class="col-checkbox"></td>
<td n:if="$hasGroupActions" class="col-checkbox"></td>

{foreach $columns as $key => $column}
{var $col = 'col-' . $key}
Expand All @@ -269,7 +269,7 @@
</tr>
{else}
<tr data-id="{$row->getId()}" n:snippet="item-{$row->getId()}" n:class="$row->getControlClass()">
<td n:if="$hasGroupActionOnRows" class="col-checkbox">
<td n:if="$hasGroupActions" class="col-checkbox">
{if $row->hasGroupAction()}
<input n:class="$control->useHappyComponents() ? 'happy gray-border' , primary" type="checkbox" data-check="{$control->getName()}" data-check-all-{$control->getName()|noescape} name="{$control->getName()|lower}_group_action_item[{$row->getId()}]">
{/if}
Expand Down Expand Up @@ -414,7 +414,7 @@
{php $inlineAdd->onSetDefaults($filter['inline_add']); }

<tr class="datagrid-row-inline-add datagrid-row-inline-add-hidden">
<td n:if="$hasGroupActionOnRows" class="col-checkbox"></td>
<td n:if="$hasGroupActions" class="col-checkbox"></td>

{foreach $columns as $key => $column}
{var $col = 'col-' . $key}
Expand All @@ -438,7 +438,7 @@

{define columnsSummary}
<tr class="datagrid-row-columns-summary" n:if="$columnsSummary->someColumnsExist($columns)">
<td n:if="$control->hasGroupActions()" class="col-checkbox"></td>
<td n:if="$hasGroupActions" class="col-checkbox"></td>

{foreach $columns as $key => $column}
{var $td = $column->getElementForRender('td', $key)}
Expand All @@ -456,7 +456,7 @@

{define aggregationFunctions}
<tr class="datagrid-row-columns-summary">
<td n:if="$control->hasGroupActions()" class="col-checkbox"></td>
<td n:if="$hasGroupActions" class="col-checkbox"></td>

{foreach $columns as $key => $column}
{var $td = $column->getElementForRender('td', $key)}
Expand Down

0 comments on commit 3e62fd9

Please sign in to comment.