forked from Neovici/cosmoz-omnitable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcosmoz-omnitable.html
222 lines (208 loc) · 9.22 KB
/
cosmoz-omnitable.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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<link rel="import" href="../polymer/polymer.html"/>
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html"/>
<link rel="import" href="../iron-flex-layout/iron-flex-layout-classes.html"/>
<link rel="import" href="../iron-icons/iron-icons.html"/>
<link rel="import" href="../iron-icon/iron-icon.html"/>
<link rel="import" href="../iron-label/iron-label.html"/>
<link rel="import" href="../paper-button/paper-button.html"/>
<link rel="import" href="../paper-checkbox/paper-checkbox.html"/>
<link rel="import" href="../paper-dropdown-menu/paper-dropdown-menu.html"/>
<link rel="import" href="../paper-icon-button/paper-icon-button.html"/>
<link rel="import" href="../paper-item/paper-item.html"/>
<link rel="import" href="../paper-listbox/paper-listbox.html"/>
<link rel="import" href="../paper-spinner/paper-spinner-lite.html">
<link rel="import" href="../cosmoz-grouped-list/cosmoz-grouped-list.html"/>
<link rel="import" href="../cosmoz-i18next/cosmoz-i18next.html">
<link rel="import" href="../cosmoz-bottom-bar/cosmoz-bottom-bar.html"/>
<link rel="import" href="../cosmoz-page-router/cosmoz-page-location.html">
<link rel="import" href="../import-filesaver/import-filesaver.html"/>
<link rel="import" href="../nullxlsx/dist/import-nullxlsx.html"/>
<link rel="import" href="cosmoz-omnitable-column.html">
<link rel="import" href="cosmoz-omnitable-header-row.html">
<link rel="import" href="cosmoz-omnitable-item-row.html">
<link rel="import" href="cosmoz-omnitable-item-expand.html">
<link rel="import" href="cosmoz-omnitable-item-expand-line.html">
<link rel="import" href="cosmoz-omnitable-group-row.html">
<link rel="import" href="cosmoz-omnitable-styles.html">
<link rel="import" href="cosmoz-omnitable-item.html">
<link rel="import" href="cosmoz-omnitable-columns.html">
<!--
`<cosmoz-omnitable>`
@group Cosmoz Elements
@element cosmoz-omnitable
@demo demo/index.html
-->
<dom-module id="cosmoz-omnitable">
<template>
<style include="cosmoz-omnitable-styles iron-flex"></style>
<cosmoz-page-location id="location" route-hash="{{ _routeHash }}"></cosmoz-page-location>
<div class="mainContainer">
<div class="header" id="header">
<div class="selectAllCheckbox" hidden$="[[ !_showCheckboxes ]]">
<paper-checkbox checked$="{{ _allSelected }}" on-change="_onAllCheckboxChange" hidden$="[[ !_dataIsValid ]]">
</paper-checkbox>
</div>
<cosmoz-omnitable-header-row columns="[[ visibleColumns ]]" group-on-column="[[ groupOnColumn ]]"></cosmoz-omnitable-header-row>
</div>
<div class="tableContent" id="tableContent">
<template is="dom-if" if="[[ !_dataIsValid ]]">
<div class="tableContent-empty">
<iron-icon icon="icons:announcement"></iron-icon>
<div>
<h3>[[ _('Working set empty', t) ]]</h3>
<p>[[ _('No data to display', t) ]]</p>
</div>
</div>
</template>
<template is="dom-if" if="[[ _filterIsTooStrict ]]">
<div class="tableContent-empty">
<iron-icon icon="icons:announcement"></iron-icon>
<div>
<h3>[[ _('Filter too strict', t) ]]</h3>
<p>[[ _('No matches for selection', t) ]]</p>
</div>
</div>
</template>
<template is="dom-if" if="[[ loading ]]">
<div class="tableContent-empty overlay">
<paper-spinner-lite active="[[ loading ]]"></paper-spinner-lite>
<div>
<h3>[[ _('Data set is updating', t) ]]</h3>
</div>
</div>
</template>
<div class="tableContent-scroller" id="scroller">
<cosmoz-grouped-list id="groupedList" data="{{ sortedFilteredGroupedItems }}"
selected-items="{{ selectedItems }}" highlighted-items="{{ highlightedItems }}" display-empty-groups="[[ displayEmptyGroups ]]">
<cosmoz-grouped-list-template id="itemTemplate">
<template>
<div class="item-row-wrapper">
<div selected$="[[selected]]" class="itemRow" highlighted$="[[highlighted]]">
<div class="selectItemCheckbox" hidden$="[[ !_showCheckboxes ]]">
<paper-checkbox checked="{{ selected }}" on-change="_onItemCheckboxChange"></paper-checkbox>
</div>
<cosmoz-omnitable-item-row
columns="[[ visibleColumns ]]"
selected="{{ selected }}"
expanded="{{ expanded }}"
item="[[ item ]]"
group-on-column="[[ groupOnColumn ]]">
</cosmoz-omnitable-item-row>
<div class="item-expander" hidden="[[ _isEmpty(disabledColumns.length) ]]">
<paper-icon-button icon="[[ _getFoldIcon(expanded) ]]" on-tap="_toggleItem"></paper-icon-button>
</div>
</div>
<cosmoz-omnitable-item-expand
columns="[[ disabledColumns ]]"
item="[[item]]"
selected="{{ selected }}"
expanded="{{ expanded }}"
group-on-column="[[ groupOnColumn ]]">
</cosmoz-omnitable-item-expand>
</div>
</template>
</cosmoz-grouped-list-template>
<cosmoz-grouped-list-template id="groupTemplate">
<template>
<div class$="[[ _getGroupRowClasses(folded) ]]">
<div class="selectGroupCheckbox" hidden$="[[ !_showCheckboxes ]]">
<paper-checkbox checked="{{ selected }}" on-change="_onGroupCheckboxChange"></paper-checkbox>
</div>
<h3 class="groupRow-label">
<div><span>[[ groupOnColumn.title ]]</span>: </div>
<cosmoz-omnitable-group-row
column="[[ groupOnColumn ]]"
item="[[ item.items.0 ]]"
selected="[[ selected ]]"
folded="[[ folded ]]">
</cosmoz-omnitable-group-row>
</h3>
<div>[[ item.items.length ]]</div>
<paper-icon-button icon="[[ _getFoldIcon(folded) ]]" on-tap="_toggleGroup"></paper-icon-button>
</div>
</template>
</cosmoz-grouped-list-template>
</cosmoz-grouped-list>
</div>
</div>
<div class="footer">
<div class="footer-controls">
<div class="footer-control">
<paper-dropdown-menu vertical-align="bottom" horizontal-align="left" id="groupOnSelector"
label="[[ _('Group on', t) ]] [[ _computeSortDirection(groupOnDescending, t) ]]">
<paper-listbox class="dropdown-content menu" slot="dropdown-content" selected="{{ groupOn }}" attr-for-selected="data-group-on">
<cosmoz-omnitable-item data-group-on="" style="font-style: italic" label="[[ _('No grouping', t) ]]"></cosmoz-omnitable-item>
<template is="dom-repeat" items="[[ columns ]]" as="column">
<cosmoz-omnitable-item
data-group-on$="[[ column.name ]]"
hidden$="[[ !column.groupOn ]]"
label="[[ column.title ]]"
on-tap="_applySortingDirection">
</cosmoz-omnitable-item>
</template>
</paper-listbox>
</paper-dropdown-menu>
</div>
<div class="footer-control">
<paper-dropdown-menu vertical-align="bottom" horizontal-align="right"
label="[[_('Sort on', t)]] [[ _computeSortDirection(descending, t) ]]">
<paper-listbox
slot="dropdown-content"
class="dropdown-content menu"
attr-for-selected="data-name"
selected="{{ sortOn }}">
<cosmoz-omnitable-item data-name="" label="[[ _('No sorting', t) ]]"></cosmoz-omnitable-item>
<template is="dom-repeat" items="[[ columns ]]" as="column">
<cosmoz-omnitable-item
hidden$="[[ !column.sortOn ]]"
data-name$="[[ column.name ]]"
label="[[ column.title ]]"
on-tap="_applySortingDirection">
</cosmoz-omnitable-item>
</template>
</paper-listbox>
</paper-dropdown-menu>
</div>
</div>
<div class="footer-tableStats">
<span>[[ ngettext('{0} group', '{0} groups', _groupsCount, t) ]]</span>
<span>[[ ngettext('{0} row', '{0} rows', filteredItems.length, t) ]]</span>
</div>
<cosmoz-bottom-bar id="bottomBar" class="footer-actionBar" match-parent has-actions="{{ hasActions }}" on-action="_onAction" active$="[[ !_isEmpty(selectedItems.length) ]]" computed-bar-height="{{ computedBarHeight }}">
<div slot="info">[[ ngettext('{0} selected item', '{0} selected items', selectedItems.length, t) ]]</div>
<slot name="actions" id="actions"></slot>
<!-- These slots are neened by cosmoz-bottom-bar
as it might change the slot of the actions to distribute them in the menu -->
<slot name="bottom-bar-toolbar"></slot>
<slot name="bottom-bar-menu"></slot>
<paper-menu-button
id="extraMenu"
slot="extra"
no-animations
vertical-offset="[[ computedBarHeight ]]"
vertical-align="bottom"
horizontal-align="right">
<paper-icon-button id="dropdownExtraButton"
class="dropdown-trigger"
slot="dropdown-trigger"
icon="file-download"
toggles
raised>
</paper-icon-button>
<paper-listbox id="dropdownExtra"
class="dropdown-content"
slot="dropdown-content">
<span id="listboxSizer"></span>
<paper-button on-click="_saveAsCsvAction">[[ _('Save as CSV', t) ]]</paper-button>
<paper-button on-click="_saveAsXlsxAction">[[ _('Save as XLSX', t) ]]</paper-button>
</paper-listbox>
</paper-menu-button>
</cosmoz-bottom-bar>
</div>
</div>
<div id="columns">
<slot></slot>
</div>
</template>
<script type="text/javascript" src="cosmoz-omnitable.js"></script>
</dom-module>