-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathangular.tableview.html
128 lines (119 loc) · 5.22 KB
/
angular.tableview.html
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
<script type="text/ng-template" id="tableview.head.cell">
<span>{{$column.title}}</span>
<span ng-if="$column.sortable && $column.field" class="sort"></span>
<input ng-if="$column.filterable && $column.field"
ng-model="tableview.request.like[$column.field]"
placeholder="{{$column.placeholder || 'Search...'}}"
ng-click="$event.stopPropagation();"
ng-change="like($index)"
type="text"
required
/>
</script>
<script type="text/ng-template" id="tableview.head.cell.select">
<label><input
type="checkbox"
class="hidden"
ng-checked="isRowsSelected()"
ng-click="onSelectPageRows($event)"
/><i class="ui-checkbox"></i></label>
</script>
<script type="text/ng-template" id="tableview.body.cell.select">
<label><input type="checkbox" class="hidden" ng-checked="isRowSelected($row)" ng-click="switchRowSelection($row)" /><i class="ui-checkbox"></i></label>
</script>
<script type="text/ng-template" id="tableview.body.cell">{{$row[$column.field]}}</script>
<script type="text/ng-template" id="tableview.body.cell.edit">
<input
ng-if="!$column.editable.type || $column.editable.type == 'text'"
ng-model="$mode.value"
ng-change="validate($index, $row, $mode)"
ng-blur="edition($index, $row, $mode)"
tableview-autofocus
type="text"
/>
<textarea
ng-if="$column.editable.type == 'textarea'"
ng-model="$mode.value"
ng-change="validate($index, $row, $mode)"
ng-blur="edition($index, $row, $mode)"
tableview-autofocus
></textarea>
<span class="message" ng-if="$mode.validation.message">{{$mode.validation.message}}</span>
</script>
<script type="text/ng-template" id="tableview.pager">
<div class="limit" ng-include="templateName('pager.limit')"></div>
<div class="selection" ng-include="templateName('pager.selection')" ng-if="tableview.selection.length"></div>
<div class="controls" ng-include="templateName('pager.controls')"></div>
</script>
<script type="text/ng-template" id="tableview.pager.limit">
<select ng-model="tableview.request.limit" ng-options="o as o for o in tableview.limits" ng-change="limit()"></select>
</script>
<script type="text/ng-template" id="tableview.pager.selection">
<span class="selected">Selected {{tableview.selection.length}} entries</span>
<button class="deselect" ng-click="tableview.selection = []" title="Deselect all">×</button>
</script>
<script type="text/ng-template" id="tableview.pager.controls">
<span class="pageOf">Page {{tableview.request.page}} of {{tableview.pages}}</span>
<button class="prev" ng-click="prev()" ng-disabled="tableview.request.page < 2">Prev</button><button class="next" ng-click="next()" ng-disabled="tableview.request.page >= tableview.pages">Next</button>
</script>
<div class="holder" ng-class="{'scroller': !!tableview.scrollable}" ng-style="tableview.scrollable">
<table>
<thead>
<tr>
<th ng-if="tableview.selectableBy"
class="selectable"
ng-include="templateName('head.cell.select')"
></th>
<th ng-repeat="$column in tableview.columns"
ng-include="templateName('head.cell', $index)"
class="{{
$column.name ? 'column-'+$column.name : ''
}} {{
$column.field ? 'column-'+$column.field : ''
}}"
ng-class="{
'sortable':$column.sortable && $column.field,
'sortable-asc':$column.sorting == 'ASC',
'sortable-desc':$column.sorting == 'DESC',
'filterable':$column.filterable && $column.field,
'editable':$column.editable && $column.field
}"
ng-click="switchSort($column.field)"
></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="$row in tableview.rows" ng-if="$index < tableview.request.limit" ng-class="{'selected': tableview.selectableBy && isRowSelected($row)}">
<td ng-if="tableview.selectableBy"
class="selectable"
ng-include="templateName('body.cell.select')"
></td>
<td ng-repeat="$column in tableview.columns"
ng-init="
$cell = $row[$column.field];
$mode={edition:false, value:$cell};
"
ng-click="$mode.edition=$column.editable?true:false"
ng-include="$mode.edition ? templateName('body.cell.edit', $index) : templateName('body.cell', $index)"
class="{{
$column.name ? 'column-'+$column.name : ''
}} {{
$column.field ? 'column-'+$column.field : ''
}}"
ng-class="{
'sortable':$column.sortable && $column.field,
'sortable-asc':$column.sorting == 'ASC',
'sortable-desc':$column.sorting == 'DESC',
'filterable':$column.filterable && $column.field,
'editable':$column.editable && $column.field,
'edition':$mode.edition,
'invalid':$mode.validation && !$mode.validation.status
}"
></td>
</tr>
</tbody>
<tfoot ng-if="templateName('template.foot')" ng-include="templateName('template.foot')"></tfoot>
</table>
</div>
<pager ng-include="templateName('pager')"></pager>
<pre ng-if="tableview.debug">{{tableview | json}}</pre>