forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable-header.js
More file actions
129 lines (112 loc) · 3.23 KB
/
table-header.js
File metadata and controls
129 lines (112 loc) · 3.23 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
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
import QCheckbox from '../checkbox/QCheckbox.js'
import QTh from './QTh.js'
import cache from '../../utils/cache.js'
export default {
computed: {
headerSelectedValue () {
return this.someRowsSelected === true
? null
: this.allRowsSelected
}
},
methods: {
__getTHead (h) {
const child = this.__getTHeadTR(h)
if (this.loading === true && this.$scopedSlots.loading === void 0) {
child.push(
h('tr', { staticClass: 'q-table__progress' }, [
h('th', {
staticClass: 'relative-position',
attrs: { colspan: this.computedColspan }
}, this.__getProgress(h))
])
)
}
return h('thead', child)
},
__getTHeadTR (h) {
const
header = this.$scopedSlots.header,
headerCell = this.$scopedSlots['header-cell']
if (header !== void 0) {
return header(
this.__getHeaderScope({ header: true })
).slice()
}
const child = this.computedCols.map(col => {
const
headerCellCol = this.$scopedSlots[`header-cell-${col.name}`],
slot = headerCellCol !== void 0 ? headerCellCol : headerCell,
props = this.__getHeaderScope({ col })
return slot !== void 0
? slot(props)
: h(QTh, {
key: col.name,
props: { props }
}, col.label)
})
if (this.singleSelection === true && this.grid !== true) {
child.unshift(h('th', { staticClass: 'q-table--col-auto-width' }, [' ']))
}
else if (this.multipleSelection === true) {
const slot = this.$scopedSlots['header-selection']
const content = slot !== void 0
? slot(this.__getHeaderScope({}))
: [
h(QCheckbox, {
props: {
color: this.color,
value: this.headerSelectedValue,
dark: this.isDark,
dense: this.dense
},
on: cache(this, 'inp', {
input: this.__onMultipleSelectionSet
})
})
]
child.unshift(
h('th', { staticClass: 'q-table--col-auto-width' }, content)
)
}
return [
h('tr', {
style: this.tableHeaderStyle,
class: this.tableHeaderClass
}, child)
]
},
__getHeaderScope (data) {
Object.assign(data, {
cols: this.computedCols,
sort: this.sort,
colsMap: this.computedColsMap,
color: this.color,
dark: this.isDark,
dense: this.dense
})
if (this.multipleSelection === true) {
Object.defineProperty(data, 'selected', {
get: () => this.headerSelectedValue,
set: this.__onMultipleSelectionSet,
configurable: true,
enumerable: true
})
// TODO: remove in v2
data.partialSelected = this.someRowsSelected
data.multipleSelect = true
}
return data
},
__onMultipleSelectionSet (val) {
if (this.someRowsSelected === true) {
val = false
}
this.__updateSelection(
this.computedRows.map(this.getRowKey),
this.computedRows,
val
)
}
}
}