Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Nette 3.2 #318

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
},
"require": {
"php": ">=7.1",
"nette/utils": "^3.2",
"nette/utils": "^3.2 || ^4.0",
"nette/forms": "^3.0",
"latte/latte": "^2.5",
"latte/latte": "^2.5 || ^3.0",
"nette/application": "^3.0",
"nette/component-model": "^3.0",
"symfony/property-access": "^5.3"
"symfony/property-access": "^5.3 || ^6.0 || ^7.0"
},
"require-dev": {
"tracy/tracy": "^2.6",
Expand Down
6 changes: 3 additions & 3 deletions src/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ public function getPropertyAccessor()
{
$this->propertyAccessor = new PropertyAccessor(
PropertyAccessor::MAGIC_CALL | PropertyAccessor::MAGIC_GET | PropertyAccessor::MAGIC_SET,
PropertyAccessor::THROW_ON_INVALID_INDEX | PropertyAccessor::THROW_ON_INVALID_PROPERTY_PATH
PropertyAccessor::THROW_ON_INVALID_INDEX
);

return $this->propertyAccessor;
Expand Down Expand Up @@ -835,9 +835,9 @@ public function reload()
/**
* @internal
*/
public function createTemplate(): \Nette\Application\UI\ITemplate
public function createTemplate(?string $class = null): \Nette\Application\UI\ITemplate
{
$template = parent::createTemplate();
$template = parent::createTemplate($class);
$template->setFile($this->getCustomization()->getTemplateFiles()[Customization::TEMPLATE_DEFAULT]);
$template->getLatte()->addFilter('translate', [$this->getTranslator(), 'translate']);

Expand Down
50 changes: 23 additions & 27 deletions src/templates/default.latte
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@

{snippet grid}

{php
$form->getElementPrototype()->class[] = 'ajax grido';
$form->getElementPrototype()->{"data-grido-refresh-handler"} = $control->link("refresh!", ['page' => NULL, 'perPage' => NULL, 'sort' => NULL, 'filter' => NULL]);

$filterRenderType = $control->getFilterRenderType();
{php $form->getElementPrototype()->class[] = 'ajax grido'}
{php $form->getElementPrototype()->{"data-grido-refresh-handler"} = $control->link("refresh!", ['page' => NULL, 'perPage' => NULL, 'sort' => NULL, 'filter' => NULL])}

$columnCount = count($columns) + ($control->hasOperation() ? 1 : 0);
$showActionsColumn = $actions || $buttons;
{php $filterRenderType = $control->getFilterRenderType()}

{php $columnCount = count($columns) + ($control->hasOperation() ? 1 : 0)}
{php $showActionsColumn = $actions || $buttons}

{php $actionThElement = \Nette\Utils\Html::el('th')}
{php $actionThElement->setText($control->translator->translate('Grido.Actions'))}
{php $actionThElement->class[] = 'actions center'}

$actionThElement = \Nette\Utils\Html::el('th');
$actionThElement->setText($control->translator->translate('Grido.Actions'));
$actionThElement->class[] = 'actions center';
}

{block customization}{/block}

Expand Down Expand Up @@ -55,11 +55,12 @@
{/if}

{block table}
{php $t = fn (string $v) => $control->getTranslator()->translate($v)}
{$control->getTablePrototype()->startTag()|noescape}
<thead>
<tr class="head">
<th n:if="$control->hasOperation()" class="checker"{if $formFilters} rowspan="{if $filterRenderType == \Grido\Components\Filters\Filter::RENDER_OUTER}1{else}2{/if}"{/if}>
<input type="checkbox" title="{_'Grido.Invert'}">
<input type="checkbox" title="{$t('Grido.Invert')}">
</th>
{foreach $columns as $column}
{$column->getHeaderPrototype()->startTag()|noescape}
Expand Down Expand Up @@ -109,16 +110,16 @@
<span n:block="search" class="search">
{input $form[buttons][search]}
</span>
<span n:if="$control->hasOperation()" n:block="operations" class="operations" title="{_'Grido.SelectSomeRow'}">
<span n:if="$control->hasOperation()" n:block="operations" class="operations" title="{$t('Grido.SelectSomeRow')}">
{$form[\Grido\Components\Operation::ID][\Grido\Components\Operation::ID]->control}
{php $form[\Grido\Grid::BUTTONS][\Grido\Components\Operation::ID]->controlPrototype->class[] = 'hide'}
{$form[\Grido\Grid::BUTTONS][\Grido\Components\Operation::ID]->control}
</span>
<span n:if="$paginator->steps && $paginator->pageCount > 1" n:block="paginator" class="paginator">
{if $control->page == 1}
<span class="disabled {$customization->buttonClass}" n:href="page! page => $paginator->getPage() - 1"><i class="{=$customization->getIconClass('arrow-left')}"></i> {_'Grido.Paginator.Previous'}</span>
<span class="disabled {$customization->buttonClass}" n:href="page! page => $paginator->getPage() - 1"><i class="{=$customization->getIconClass('arrow-left')}"></i> {$t('Grido.Paginator.Previous')}</span>
{else}
<a class="ajax {$customization->buttonClass}" n:href="page! page => $paginator->getPage() - 1"><i class="{=$customization->getIconClass('arrow-left')}"></i> {_'Grido.Paginator.Previous'}</a>
<a class="ajax {$customization->buttonClass}" n:href="page! page => $paginator->getPage() - 1"><i class="{=$customization->getIconClass('arrow-left')}"></i> {$t('Grido.Paginator.Previous')}</a>
{/if}
{var $steps = $paginator->getSteps()}
{foreach $steps as $step}
Expand All @@ -127,13 +128,13 @@
{else}
<a class="ajax {$customization->buttonClass}" n:href="page! page => $step">{$step}</a>
{/if}
<a n:if="$iterator->nextValue > $step + 1" class="prompt" data-grido-prompt="{_'Grido.EnterPage'}" data-grido-link="{link page! page => 0}">...</a>
<a n:if="$iterator->nextValue > $step + 1" class="prompt" data-grido-prompt="{$t('Grido.EnterPage')}" data-grido-link="{link page! page => 0}">...</a>
{var $prevStep = $step}
{/foreach}
{if $control->page == $paginator->getPageCount()}
<span class="disabled {$customization->buttonClass}" n:href="page! page => $paginator->getPage() + 1">{_'Grido.Paginator.Next'} <i class="{=$customization->getIconClass('arrow-right')}"></i></span>
<span class="disabled {$customization->buttonClass}" n:href="page! page => $paginator->getPage() + 1">{$t('Grido.Paginator.Next')} <i class="{=$customization->getIconClass('arrow-right')}"></i></span>
{else}
<a class="ajax {$customization->buttonClass}" n:href="page! page => $paginator->getPage() + 1">{_'Grido.Paginator.Next'} <i class="{=$customization->getIconClass('arrow-right')}"></i></a>
<a class="ajax {$customization->buttonClass}" n:href="page! page => $paginator->getPage() + 1">{$t('Grido.Paginator.Next')} <i class="{=$customization->getIconClass('arrow-right')}"></i></a>
{/if}
</span>
<span class="right" n:inner-block="right">
Expand All @@ -145,7 +146,7 @@
{input $form[buttons][perPage], class => 'hide'}
</span>
<span n:if="$control->hasExport()" class="export" n:inner-block="export">
<a n:class="$customization->buttonClass" href="{=$control->getComponent(\Grido\Components\Export::ID)->link('export!')}" title="{_'Grido.ExportAllItems'}">{_'Grido.Export'}</a>
<a n:class="$customization->buttonClass" href="{=$control->getComponent(\Grido\Components\Export::ID)->link('export!')}" title="{$t('Grido.ExportAllItems')}">{$t('Grido.Export')}</a>
</span>
<span n:block="reset" class="reset">
{input $form[buttons][reset]}
Expand All @@ -156,14 +157,9 @@
</tfoot>
<tbody>
{foreach $data as $row}
{php $checkbox = $control->hasOperation()
? $form[\Grido\Components\Operation::ID][\Grido\Helpers::formatColumnName($control->getProperty($row, $control->getComponent(\Grido\Components\Operation::ID)->getPrimaryKey()))]
: NULL;
$tr = $control->getRowPrototype($row);
$tr->class[] = $checkbox && $checkbox->getValue()
? 'selected'
: NULL;
}
{php $checkbox = $control->hasOperation() ? $form[\Grido\Components\Operation::ID][\Grido\Helpers::formatColumnName($control->getProperty($row, $control->getComponent(\Grido\Components\Operation::ID)->getPrimaryKey()))] : NULL}
{php $tr = $control->getRowPrototype($row)}
{php $tr->class[] = $checkbox && $checkbox->getValue() ? 'selected' : NULL}
{$tr->startTag()|noescape}
<td n:if="$checkbox" class="checker">
{$checkbox->getControl()}
Expand All @@ -190,7 +186,7 @@
</td>
{$tr->endTag()|noescape}
{/foreach}
<tr n:if="!$control->getCount()"><td colspan="{=$showActionsColumn ? $columnCount + 1 : $columnCount}" class="no-results">{_'Grido.NoResults'}</td></tr>
<tr n:if="!$control->getCount()"><td colspan="{=$showActionsColumn ? $columnCount + 1 : $columnCount}" class="no-results">{$t('Grido.NoResults')}</td></tr>
</tbody>
{$control->getTablePrototype()->endTag()|noescape}
{/block}
Expand Down