forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable-grid.js
More file actions
103 lines (92 loc) · 3.15 KB
/
table-grid.js
File metadata and controls
103 lines (92 loc) · 3.15 KB
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
import QCheckbox from '../checkbox/QCheckbox.js'
import QSeparator from '../separator/QSeparator.js'
export default {
methods: {
__getGridHeader (h) {
const child = this.gridHeader === true
? [
h('table', { staticClass: 'q-table' }, [
this.__getTHead(h)
])
]
: (
this.loading === true && this.$scopedSlots.loading === void 0
? this.__getProgress(h)
: void 0
)
return h('div', { staticClass: 'q-table__middle' }, child)
},
__getGridBody (h) {
const item = this.$scopedSlots.item !== void 0
? this.$scopedSlots.item
: scope => {
const child = scope.cols.map(
col => h('div', { staticClass: 'q-table__grid-item-row' }, [
h('div', { staticClass: 'q-table__grid-item-title' }, [ col.label ]),
h('div', { staticClass: 'q-table__grid-item-value' }, [ col.value ])
])
)
if (this.hasSelectionMode === true) {
const slot = this.$scopedSlots['body-selection']
const content = slot !== void 0
? slot(scope)
: [
h(QCheckbox, {
props: {
value: scope.selected,
color: this.color,
dark: this.isDark,
dense: this.dense
},
on: {
input: (adding, evt) => {
this.__updateSelection([ scope.key ], [ scope.row ], adding, evt)
}
}
})
]
child.unshift(
h('div', { staticClass: 'q-table__grid-item-row' }, content),
h(QSeparator, { props: { dark: this.isDark } })
)
}
const data = {
staticClass: 'q-table__grid-item-card' + this.cardDefaultClass,
class: this.cardClass,
style: this.cardStyle,
on: {}
}
if (this.qListeners['row-click'] !== void 0 || this.qListeners['row-dblclick'] !== void 0) {
data.staticClass += ' cursor-pointer'
}
if (this.qListeners['row-click'] !== void 0) {
data.on.click = evt => {
this.$emit('row-click', evt, scope.row, scope.pageIndex)
}
}
if (this.qListeners['row-dblclick'] !== void 0) {
data.on.dblclick = evt => {
this.$emit('row-dblclick', evt, scope.row, scope.pageIndex)
}
}
return h('div', {
staticClass: 'q-table__grid-item col-xs-12 col-sm-6 col-md-4 col-lg-3',
class: scope.selected === true ? 'q-table__grid-item--selected' : ''
}, [
h('div', data, child)
])
}
return h('div', {
staticClass: 'q-table__grid-content row',
class: this.cardContainerClass,
style: this.cardContainerStyle
}, this.computedRows.map((row, pageIndex) => {
return item(this.__getBodyScope({
key: this.getRowKey(row),
row,
pageIndex
}))
}))
}
}
}