-
Notifications
You must be signed in to change notification settings - Fork 39
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
Fixes and few new features (insert, delete) #92
base: master
Are you sure you want to change the base?
Changes from all commits
c5997b7
c0e3567
e1f5c85
cc420ce
4980b48
e042f45
52b21a0
d81e42f
6ed4cf3
7a78cd2
990ad5f
e38a400
b03889a
428f0b8
7844c57
f806dd8
d4ea1f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,10 @@ | |
{/if} | ||
{/define} | ||
|
||
{define row-head-cell} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please document this. |
||
{$column->label} | ||
{/define} | ||
|
||
{define row-head-columns} | ||
<tr class="grid-columns"> | ||
{ifset $form[actions]} | ||
|
@@ -28,7 +32,7 @@ | |
{foreach $columns as $column} | ||
<th class="grid-col-{$column->name}"> | ||
{if $column->canSort()} | ||
<a href="{link sort! orderColumn => $column->name, orderType => $column->getNewState()}" class="ajax">{$column->label}</a> | ||
<a href="{link sort! orderColumn => $column->name, orderType => $column->getNewState()}" class="ajax">{include #row-head-cell column => $column}</a> | ||
{if $column->isAsc()} | ||
<span class="grid-sort-symbol grid-sort-symbol-asc"><em>▲</em></span> | ||
{elseif $column->isDesc()} | ||
|
@@ -37,7 +41,7 @@ | |
<span class="grid-sort-symbol grid-sort-symbol-no"></span> | ||
{/if} | ||
{else} | ||
{$column->label} | ||
{include #row-head-cell column => $column} | ||
{/if} | ||
</th> | ||
{/foreach} | ||
|
@@ -91,6 +95,40 @@ | |
<a href="{link edit! $primary}" class="ajax" data-datagrid-edit>{$control->translate(Edit)}</a> | ||
{/define} | ||
|
||
{define row-edit-control} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please document this. |
||
{input $column->name} | ||
<p class="error" n:foreach="$formContainer[$column->name]->getErrors() as $error">{$error}</p> | ||
{/define} | ||
|
||
{define row-insert-control} | ||
{input $formContainer[$column->name]} | ||
{/define} | ||
|
||
{define row-insert-empty} | ||
{/define} | ||
|
||
{define row-insert-button} | ||
{input button} | ||
{/define} | ||
|
||
{define row-actions-delete-link} | ||
<a href="{link delete! $primary}" class="ajax" data-datagrid-delete>{$control->translate(Delete)}</a> | ||
{/define} | ||
|
||
{define row-insert} | ||
{formContainer insert-data} | ||
{foreach $columns as $column} | ||
{ifset $formContainer[$column->name]} | ||
<td class="grid-col-{$column->name}">{include #row-insert-control form => $form, formContainer => $formContainer, column => $column}</td> | ||
{else} | ||
<td class="grid-col-{$column->name}">{include #row-insert-empty form => $form, formContainer => $formContainer, column => $column}</td> | ||
{/} | ||
{/foreach} | ||
{/formContainer} | ||
<td class="grid-col-actions" n:formContainer="insert">{include #row-insert-button form => $form}</td> | ||
{/define} | ||
|
||
|
||
{define row} | ||
<tr id={$rowId}> | ||
{include #row-inner row => $row} | ||
|
@@ -117,10 +155,7 @@ | |
{include #"cell-edit-{$column->name}" form => $form, column => $column, row => $row} | ||
{else} | ||
{formContainer edit} | ||
{input $column->name} | ||
{if $form[edit][$column->name]->hasErrors()} | ||
<p class="error" n:foreach="$form[edit][$column->name]->getErrors() as $error">{$error}</p> | ||
{/if} | ||
{include #row-edit-control form => $form, formContainer => $formContainer, column => $column, row => $row} | ||
{/formContainer} | ||
{/ifset} | ||
</td> | ||
|
@@ -148,8 +183,13 @@ | |
{else} | ||
{ifset #row-actions} | ||
{include #row-actions row => $row, primary => $primary} | ||
{elseif $control->getEditFormFactory()} | ||
{include #row-actions-edit-link row => $row, primary => $primary} | ||
{else} | ||
{if $control->getEditFormFactory()} | ||
{include #row-actions-edit-link row => $row, primary => $primary} | ||
{/if} | ||
{if $control->getDeleteCallback()} | ||
{include #row-actions-delete-link row => $row, primary => $primary} | ||
{/if} | ||
{/ifset} | ||
{/if} | ||
</td> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @license MIT | ||
* @link https://github.com/nextras | ||
*} | ||
<div class="grid" data-grid-name="{$control->getUniqueId()}"> | ||
<div class="grid" data-grid-name="{$control->getUniqueId()}" id="{$control->getUniqueId()}"> | ||
{snippet rows} | ||
|
||
{var $_templates = []} | ||
|
@@ -21,7 +21,10 @@ | |
{php | ||
$hasActionsColumn = | ||
(bool) $control->getEditFormFactory() /* we may render only one row so the form[filter] may not be created */ | ||
|| isset($this->blockQueue["row-actions"]); | ||
|| isset($this->blockQueue["row-actions"]) | ||
|| isset($form["insert"]) | ||
|| isset($form["filter"]) | ||
|| $control->getDeleteCallback(); | ||
$hasGlobalActionsColumn = isset($form['actions']); | ||
|
||
foreach ($_templates as $_template): | ||
|
@@ -50,6 +53,11 @@ | |
{ifset #empty-result}{include #empty-result}{/ifset} | ||
{/if} | ||
</tbody> | ||
<tfoot n:ifset="$form[insert]"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it tfoot corrent for inserting? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure where to render. In header, it can be accidentally interchanged with filter by user. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean like last tbody's tr? But probbaly its ok :) /shrug |
||
<tr class="grid-inserts"> | ||
{include #row-insert} | ||
</tr> | ||
</tfoot> | ||
<tfoot n:if="isset($paginator) || $hasGlobalActionsColumn"> | ||
<tr> | ||
<th colspan="{=count($columns) + $hasGlobalActionsColumn + $hasActionsColumn}"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea what is the purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example
and then you can render nice help icon in column head.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🆗