-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathDatagrid.blocks.latte
182 lines (167 loc) · 5.18 KB
/
Datagrid.blocks.latte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
{**
* This file is part of the Nextras community extensions of Nette Framework
*
* @license MIT
* @link https://github.com/nextras
*}
{define table-open-tag}
<table>
{/define}
{define table-close-tag}
</table>
{/define}
{define global-filter-actions}
{input filter}
{if $showCancel}
{input cancel}
{/if}
{/define}
{define row-head-columns}
<tr class="grid-columns">
{ifset $form[actions]}
<th class="grid-col-global-actions"></th>
{/ifset}
{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>
{if $column->isAsc()}
<span class="grid-sort-symbol grid-sort-symbol-asc"><em>▲</em></span>
{elseif $column->isDesc()}
<span class="grid-sort-symbol grid-sort-symbol-desc"><em>▼</em></span>
{else}
<span class="grid-sort-symbol grid-sort-symbol-no"></span>
{/if}
{else}
{$column->label}
{/if}
</th>
{/foreach}
{if $hasActionsColumn}
<th class="grid-col-actions"></th>
{/if}
</tr>
{/define}
{define col-filter}
{input $column->name}
{/define}
{define global-actions}
<div class="grid-global-actions">
{input $form[actions][action]}
{input $form[actions][process]}
</div>
{/define}
{define row-head-filter}
<tr class="grid-filters">
{ifset $form[actions]}
<th class="grid-col-global-actions"></th>
{/ifset}
{formContainer filter}
{foreach $columns as $column}
<th class="grid-col-{$column->name}">
{if isset($form['filter'][$column->name])}
{ifset #col-filter-{$column->name}}
{include #"col-filter-{$column->name}" column => $column}
{else}
{include #col-filter column => $column}
{/ifset}
{/if}
</th>
{/foreach}
<th class="grid-col-actions">
{include #global-filter-actions showCancel => $showFilterCancel}
</th>
{/formContainer}
</tr>
{/define}
{define row-actions-edit}
{input save}
{input cancel}
{/define}
{define row-actions-edit-link}
<a href="{link edit! $primary}" class="ajax" data-datagrid-edit>{_}nextras.datagrid.edit.label{/_}</a>
{/define}
{define row}
<tr id={$rowId}>
{include #row-inner row => $row}
</tr>
{/define}
{define row-inner}
{var $primary = $control->getter($row, $rowPrimaryKey)}
{php if (!$sendOnlyRowParentSnippet): $this->global->snippetDriver->enter("rows-$primary", "dynamic"); endif;}
{var $editRow = $editRowKey == $primary && $primary !== NULL && $editRowKey !== NULL}
{ifset $form[actions]}
<td class="grid-col-global-actions">
{formContainer actions}
{input items:$primary}
{/formContainer}
</td>
{/ifset}
{foreach $columns as $column}
{var $cell = $control->getter($row, $column->name, FALSE)}
{if $editRow && $column->name != $rowPrimaryKey && (isset($form['edit'][$column->name]) || isset($this->blockQueue["cell-edit-{$column->name}"]))}
<td class="grid-col-{$column->name}">
{ifset #cell-edit-$column->name}
{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}
{/formContainer}
{/ifset}
</td>
{else}
{ifset #col-$column->name}
{include #"col-{$column->name}" row => $row, cell => $cell, iterator => $iterator}
{else}
<td class="grid-col-{$column->name}">
{ifset #cell-$column->name}
{include #"cell-{$column->name}" row => $row, cell => $cell, iterator => $iterator}
{else}
{$cell}
{/ifset}
</td>
{/ifset}
{/if}
{/foreach}
{if $hasActionsColumn}
<td class="grid-col-actions">
{if $editRow}
{formContainer edit}
{input $rowPrimaryKey class => 'grid-primary-value'}
{include #row-actions-edit}
{/formContainer}
{else}
{ifset #row-actions}
{include #row-actions row => $row, primary => $primary}
{elseif $control->getEditFormFactory()}
{include #row-actions-edit-link row => $row, primary => $primary}
{/ifset}
{/if}
</td>
{/if}
{php if (!$sendOnlyRowParentSnippet): $this->global->snippetDriver->leave(); endif;}
{/define}
{define pagination}
<div class="grid-paginator">
{if $paginator->isFirst()}
<span>« {_}nextras.datagrid.pagination.first{/_}</span>
<span>« {_}nextras.datagrid.pagination.previous{/_}</span>
{else}
<a href="{link paginate!, 'page' => 1}" class="ajax">« {_}nextras.datagrid.pagination.first{/_}</a>
<a href="{link paginate!, 'page' => $paginator->page - 1}" class="ajax">« {_}nextras.datagrid.pagination.previous{/_}</a>
{/if}
<span>
<span>{$paginator->page}</span> / <span>{$paginator->pageCount}</span>
</span>
{if $paginator->isLast()}
<span>{_}nextras.datagrid.pagination.next{/_} »</span>
<span>{_}nextras.datagrid.pagination.last{/_} »</span>
{else}
<a href="{link paginate!, 'page' => $paginator->page + 1}" class="ajax">{_}nextras.datagrid.pagination.next{/_} »</a>
<a href="{link paginate!, 'page' => $paginator->pageCount}" class="ajax">{_}nextras.datagrid.pagination.last{/_} »</a>
{/if}
</div>
{/define}