@qikdev/vue-ui 0.0.4 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components.js +36 -8
- package/src/content/browser.vue +510 -161
- package/src/content/render/field.vue +8 -0
- package/src/content/render/group.vue +6 -6
- package/src/filter/FilterBuilder.vue +2 -1
- package/src/filter/FilterCondition.vue +46 -8
- package/src/filter/FilterRule.vue +3 -1
- package/src/form/field.vue +6 -0
- package/src/form/getDefaultValue.js +2 -0
- package/src/form/inputs/group.vue +6 -6
- package/src/form/inputs/html.vue +39 -0
- package/src/form/inputs/select.vue +18 -0
- package/src/layout/flex-row.vue +1 -1
- package/src/layout/flex-spacer.vue +1 -0
- package/src/layout/tab.vue +34 -0
- package/src/layout/tabset.vue +72 -0
- package/src/mixins/RememberScroll.js +30 -0
- package/src/modal/ContentModal.vue +34 -25
- package/src/modal/Modal.vue +2 -1
- package/src/services/device.js +211 -0
- package/src/services/selection.js +37 -12
- package/src/table/Table.vue +60 -13
- package/src/table/TableCell.vue +80 -31
- package/src/table/TableRow.vue +8 -20
- package/src/table/cells/Button.vue +56 -0
- package/src/table/cells/Thumbnail.vue +2 -1
- package/src/table/cells/Value.vue +46 -0
- package/src/ui/image.vue +2 -2
- package/src/ui/list-item.vue +6 -0
- package/src/ui/menu.vue +16 -4
- package/src/ui/pager.vue +156 -0
- package/src/version.js +1 -1
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
|
|
2
|
+
import { reactive } from 'vue'
|
|
3
|
+
|
|
4
|
+
export default function() {
|
|
5
|
+
|
|
6
|
+
var service = reactive({
|
|
7
|
+
mounted:false,
|
|
8
|
+
screen: {
|
|
9
|
+
width: 1024,
|
|
10
|
+
height: 768,
|
|
11
|
+
},
|
|
12
|
+
limits: {
|
|
13
|
+
xs: 600,
|
|
14
|
+
sm: 960,
|
|
15
|
+
md: 1264,
|
|
16
|
+
lg: 1904,
|
|
17
|
+
},
|
|
18
|
+
breakpoint: {
|
|
19
|
+
mobile: false,
|
|
20
|
+
tablet: false,
|
|
21
|
+
desktop: false,
|
|
22
|
+
xs: false,
|
|
23
|
+
sm: false,
|
|
24
|
+
md: false,
|
|
25
|
+
lg: false,
|
|
26
|
+
xl: false,
|
|
27
|
+
xsOnly: false,
|
|
28
|
+
smOnly: false,
|
|
29
|
+
smAndDown: false,
|
|
30
|
+
smAndUp: false,
|
|
31
|
+
mdOnly: false,
|
|
32
|
+
mdAndDown: false,
|
|
33
|
+
mdAndUp: false,
|
|
34
|
+
lgOnly: false,
|
|
35
|
+
lgAndDown: false,
|
|
36
|
+
lgAndUp: false,
|
|
37
|
+
xlOnly: false,
|
|
38
|
+
point: 0,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
////////////////////////////////
|
|
43
|
+
|
|
44
|
+
var mounted;
|
|
45
|
+
let WindowReference;
|
|
46
|
+
|
|
47
|
+
////////////////////////////////
|
|
48
|
+
|
|
49
|
+
service.resize = function() {
|
|
50
|
+
console.log('RESIZE')
|
|
51
|
+
|
|
52
|
+
var width = Math.max(WindowReference.innerWidth || 0);
|
|
53
|
+
var height = Math.max(WindowReference.innerHeight || 0);
|
|
54
|
+
|
|
55
|
+
service.screen = {
|
|
56
|
+
width,
|
|
57
|
+
height,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
///////////////////////////////////////////
|
|
61
|
+
|
|
62
|
+
var breakpoint = {
|
|
63
|
+
mobile: false,
|
|
64
|
+
tablet: false,
|
|
65
|
+
desktop: false,
|
|
66
|
+
xs: false,
|
|
67
|
+
sm: false,
|
|
68
|
+
md: false,
|
|
69
|
+
lg: false,
|
|
70
|
+
xl: false,
|
|
71
|
+
xsOnly: false,
|
|
72
|
+
smOnly: false,
|
|
73
|
+
smAndDown: false,
|
|
74
|
+
smAndUp: false,
|
|
75
|
+
mdOnly: false,
|
|
76
|
+
mdAndDown: false,
|
|
77
|
+
mdAndUp: false,
|
|
78
|
+
lgOnly: false,
|
|
79
|
+
lgAndDown: false,
|
|
80
|
+
lgAndUp: false,
|
|
81
|
+
xlOnly: false,
|
|
82
|
+
point: 0,
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
///////////////////////////////////////////
|
|
86
|
+
|
|
87
|
+
var point = 0;
|
|
88
|
+
|
|
89
|
+
if (width > service.limits.xs) {
|
|
90
|
+
point++;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (width > service.limits.sm) {
|
|
94
|
+
point++;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (width > service.limits.md) {
|
|
98
|
+
point++;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (width > service.limits.lg) {
|
|
102
|
+
point++;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
///////////////////////////////////////////
|
|
106
|
+
|
|
107
|
+
//XS Mobile
|
|
108
|
+
if (point < 1) {
|
|
109
|
+
breakpoint.mobile = true;
|
|
110
|
+
breakpoint.xs = true;
|
|
111
|
+
breakpoint.xsOnly = true;
|
|
112
|
+
|
|
113
|
+
//Down
|
|
114
|
+
breakpoint.smAndDown = true;
|
|
115
|
+
breakpoint.mdAndDown = true;
|
|
116
|
+
breakpoint.lgAndDown = true;
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
//SM Tablet
|
|
121
|
+
if (point == 1) {
|
|
122
|
+
breakpoint.tablet = true;
|
|
123
|
+
breakpoint.sm = true;
|
|
124
|
+
breakpoint.smOnly = true;
|
|
125
|
+
|
|
126
|
+
//Down
|
|
127
|
+
breakpoint.smAndDown = true;
|
|
128
|
+
breakpoint.mdAndDown = true;
|
|
129
|
+
breakpoint.lgAndDown = true;
|
|
130
|
+
|
|
131
|
+
//Up
|
|
132
|
+
breakpoint.smAndUp = true;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
//MD Tablet
|
|
136
|
+
if (point == 2) {
|
|
137
|
+
breakpoint.desktop = true;
|
|
138
|
+
breakpoint.md = true;
|
|
139
|
+
breakpoint.mdOnly = true;
|
|
140
|
+
//Down
|
|
141
|
+
breakpoint.mdAndDown = true;
|
|
142
|
+
breakpoint.lgAndDown = true;
|
|
143
|
+
|
|
144
|
+
//Up
|
|
145
|
+
breakpoint.smAndUp = true;
|
|
146
|
+
breakpoint.mdAndUp = true;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
//LG Desktop
|
|
150
|
+
if (point == 3) {
|
|
151
|
+
breakpoint.desktop = true;
|
|
152
|
+
breakpoint.lg = true;
|
|
153
|
+
breakpoint.lgOnly = true;
|
|
154
|
+
//Down
|
|
155
|
+
breakpoint.lgAndDown = true;
|
|
156
|
+
|
|
157
|
+
//Up
|
|
158
|
+
breakpoint.smAndUp = true;
|
|
159
|
+
breakpoint.mdAndUp = true;
|
|
160
|
+
breakpoint.lgAndUp = true;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
//XL Desktop
|
|
164
|
+
if (point > 3) {
|
|
165
|
+
breakpoint.desktop = true;
|
|
166
|
+
breakpoint.xl = true;
|
|
167
|
+
breakpoint.xlOnly = true;
|
|
168
|
+
//Up
|
|
169
|
+
breakpoint.smAndUp = true;
|
|
170
|
+
breakpoint.mdAndUp = true;
|
|
171
|
+
breakpoint.lgAndUp = true;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
service.point = point;
|
|
176
|
+
service.breakpoint = breakpoint;
|
|
177
|
+
|
|
178
|
+
// console.log('SERVICE', point, service.screen, breakpoint)
|
|
179
|
+
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
////////////////////////////////
|
|
184
|
+
|
|
185
|
+
service.mount = function(window) {
|
|
186
|
+
if (mounted) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
WindowReference = window;
|
|
191
|
+
service.resize();
|
|
192
|
+
mounted = true;
|
|
193
|
+
service.mounted = true;
|
|
194
|
+
WindowReference.addEventListener('resize', service.resize);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
////////////////////////////////
|
|
199
|
+
|
|
200
|
+
service.unmount = function() {
|
|
201
|
+
WindowReference.removeEventListener('resize', service.resize);
|
|
202
|
+
WindowReference = false;
|
|
203
|
+
mounted = false;
|
|
204
|
+
service.mounted = false;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
////////////////////////////////
|
|
208
|
+
|
|
209
|
+
return service;
|
|
210
|
+
|
|
211
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { reactive,
|
|
1
|
+
import { reactive, watch } from 'vue';
|
|
2
|
+
import { EventDispatcher } from '@qikdev/sdk';
|
|
2
3
|
|
|
3
4
|
export default function(options) {
|
|
4
5
|
|
|
@@ -8,7 +9,7 @@ export default function(options) {
|
|
|
8
9
|
|
|
9
10
|
///////////////////////////////////
|
|
10
11
|
|
|
11
|
-
const service = {}
|
|
12
|
+
const service = EventDispatcher({})
|
|
12
13
|
|
|
13
14
|
///////////////////////////////////
|
|
14
15
|
|
|
@@ -17,7 +18,8 @@ export default function(options) {
|
|
|
17
18
|
|
|
18
19
|
///////////////////////////////////
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
|
|
22
|
+
watch(selection, function() {
|
|
21
23
|
recreateHash();
|
|
22
24
|
});
|
|
23
25
|
|
|
@@ -33,6 +35,7 @@ export default function(options) {
|
|
|
33
35
|
set[id] = item;
|
|
34
36
|
return set;
|
|
35
37
|
}, {});
|
|
38
|
+
|
|
36
39
|
}
|
|
37
40
|
///////////////////////////////////
|
|
38
41
|
|
|
@@ -40,7 +43,8 @@ export default function(options) {
|
|
|
40
43
|
return hash[item._id || item.id];
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
service.select = function(item) {
|
|
46
|
+
service.select = function(item, ignoreDispatch) {
|
|
47
|
+
|
|
44
48
|
|
|
45
49
|
//If there is a limit set
|
|
46
50
|
if (maximum) {
|
|
@@ -60,9 +64,14 @@ export default function(options) {
|
|
|
60
64
|
|
|
61
65
|
//Add the item into the selection array
|
|
62
66
|
selection.push(item);
|
|
67
|
+
|
|
68
|
+
if (!ignoreDispatch) {
|
|
69
|
+
service.dispatch('change', selection);
|
|
70
|
+
}
|
|
63
71
|
}
|
|
64
72
|
|
|
65
|
-
service.deselect = function(item) {
|
|
73
|
+
service.deselect = function(item, ignoreDispatch) {
|
|
74
|
+
|
|
66
75
|
|
|
67
76
|
//If we can only select one item
|
|
68
77
|
//then just clear the selection
|
|
@@ -77,44 +86,60 @@ export default function(options) {
|
|
|
77
86
|
})
|
|
78
87
|
|
|
79
88
|
//If there was no index found
|
|
80
|
-
if(index == -1) {
|
|
89
|
+
if (index == -1) {
|
|
81
90
|
return;
|
|
82
91
|
}
|
|
83
92
|
|
|
84
93
|
//remove it from the array
|
|
85
94
|
selection.splice(index, 1);
|
|
95
|
+
if (!ignoreDispatch) {
|
|
96
|
+
service.dispatch('change', selection);
|
|
97
|
+
}
|
|
98
|
+
|
|
86
99
|
}
|
|
87
100
|
|
|
88
|
-
service.toggle = function(item) {
|
|
101
|
+
service.toggle = function(item, ignoreDispatch) {
|
|
102
|
+
|
|
89
103
|
if (service.isSelected(item)) {
|
|
90
|
-
service.deselect(item);
|
|
104
|
+
service.deselect(item, ignoreDispatch);
|
|
91
105
|
} else {
|
|
92
|
-
service.select(item);
|
|
106
|
+
service.select(item, ignoreDispatch);
|
|
93
107
|
}
|
|
94
108
|
}
|
|
95
109
|
|
|
96
110
|
service.selectMultiple = function(array) {
|
|
111
|
+
|
|
112
|
+
|
|
97
113
|
array.forEach(function(item) {
|
|
98
|
-
service.select(item);
|
|
114
|
+
service.select(item, true);
|
|
99
115
|
})
|
|
116
|
+
|
|
117
|
+
service.dispatch('change', selection);
|
|
100
118
|
}
|
|
101
119
|
|
|
102
120
|
service.deselectMultiple = function(array) {
|
|
121
|
+
|
|
122
|
+
|
|
103
123
|
array.forEach(function(item) {
|
|
104
|
-
service.deselect(item);
|
|
124
|
+
service.deselect(item, true);
|
|
105
125
|
})
|
|
126
|
+
|
|
127
|
+
service.dispatch('change', selection);
|
|
106
128
|
}
|
|
107
129
|
|
|
108
130
|
service.setSelection = function(array) {
|
|
131
|
+
|
|
132
|
+
|
|
109
133
|
selection.length = 0;
|
|
110
134
|
setTimeout(function() {
|
|
111
135
|
service.selectMultiple(array);
|
|
112
136
|
})
|
|
113
|
-
|
|
137
|
+
|
|
114
138
|
}
|
|
115
139
|
|
|
116
140
|
service.deselectAll = function() {
|
|
117
141
|
selection.length = 0;
|
|
142
|
+
service.dispatch('change', selection);
|
|
118
143
|
}
|
|
119
144
|
|
|
120
145
|
///////////////////////////////////
|
package/src/table/Table.vue
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<table>
|
|
5
5
|
<thead>
|
|
6
6
|
<tr>
|
|
7
|
-
<th v-if="enableSelection" class="first shrink">
|
|
7
|
+
<th v-if="enableSelection" class="first table-select shrink">
|
|
8
8
|
<ux-menu>
|
|
9
9
|
<template #activator="{ on }">
|
|
10
10
|
<ux-checkbox v-on="on" :value="pageSelected"></ux-checkbox>
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
<ux-list-item @click="selectPage()">
|
|
14
14
|
Select Page
|
|
15
15
|
</ux-list-item>
|
|
16
|
-
|
|
17
16
|
<ux-list-item v-if="someSelectedOnPage" @click="deselectPage()">
|
|
18
17
|
Deselect Page
|
|
19
18
|
</ux-list-item>
|
|
@@ -23,14 +22,15 @@
|
|
|
23
22
|
<ux-list-item v-if="deselectAll" @click="deselectAll()">
|
|
24
23
|
Deselect All
|
|
25
24
|
</ux-list-item>
|
|
26
|
-
|
|
27
25
|
</ux-list>
|
|
28
26
|
</ux-menu>
|
|
29
27
|
</th>
|
|
30
28
|
<th @click="toggleSort(column)" :class="column.class" v-for="column in renderColumns">
|
|
31
29
|
{{column.title}}
|
|
32
30
|
</th>
|
|
33
|
-
<th v-if="enableActions" class="last shrink"
|
|
31
|
+
<th v-if="enableActions" class="last shrink">
|
|
32
|
+
<slot name="corner"></slot>
|
|
33
|
+
</th>
|
|
34
34
|
</tr>
|
|
35
35
|
</thead>
|
|
36
36
|
<tbody>
|
|
@@ -44,8 +44,11 @@
|
|
|
44
44
|
import TableRow from './TableRow.vue';
|
|
45
45
|
import TableCell from './TableCell.vue';
|
|
46
46
|
|
|
47
|
+
import RememberScrollMixin from '../mixins/RememberScroll.js';
|
|
48
|
+
|
|
47
49
|
|
|
48
50
|
export default {
|
|
51
|
+
mixins:[RememberScrollMixin],
|
|
49
52
|
components: {
|
|
50
53
|
TableRow,
|
|
51
54
|
TableCell,
|
|
@@ -59,8 +62,8 @@ export default {
|
|
|
59
62
|
}
|
|
60
63
|
},
|
|
61
64
|
props: {
|
|
62
|
-
total:{
|
|
63
|
-
type:Number,
|
|
65
|
+
total: {
|
|
66
|
+
type: Number,
|
|
64
67
|
},
|
|
65
68
|
columns: {
|
|
66
69
|
type: Array,
|
|
@@ -98,11 +101,11 @@ export default {
|
|
|
98
101
|
return []
|
|
99
102
|
},
|
|
100
103
|
},
|
|
101
|
-
selectAll:{
|
|
102
|
-
type:Function,
|
|
104
|
+
selectAll: {
|
|
105
|
+
type: Function,
|
|
103
106
|
},
|
|
104
|
-
deselectAll:{
|
|
105
|
-
type:Function,
|
|
107
|
+
deselectAll: {
|
|
108
|
+
type: Function,
|
|
106
109
|
},
|
|
107
110
|
},
|
|
108
111
|
computed: {
|
|
@@ -147,12 +150,11 @@ export default {
|
|
|
147
150
|
},
|
|
148
151
|
},
|
|
149
152
|
methods: {
|
|
150
|
-
|
|
151
153
|
togglePage() {
|
|
152
154
|
|
|
153
155
|
var self = this;
|
|
154
156
|
|
|
155
|
-
|
|
157
|
+
|
|
156
158
|
if (self.pageSelected) {
|
|
157
159
|
self.deselectPage();
|
|
158
160
|
} else {
|
|
@@ -167,7 +169,7 @@ export default {
|
|
|
167
169
|
var self = this;
|
|
168
170
|
self.$emit('deselect:multiple', self.rows);
|
|
169
171
|
},
|
|
170
|
-
|
|
172
|
+
|
|
171
173
|
isSelected(row) {
|
|
172
174
|
|
|
173
175
|
var self = this;
|
|
@@ -189,15 +191,18 @@ export default {
|
|
|
189
191
|
|
|
190
192
|
},
|
|
191
193
|
clickRow(row) {
|
|
194
|
+
|
|
192
195
|
this.$emit('click:row', row);
|
|
193
196
|
},
|
|
194
197
|
clickCell({ row, column }) {
|
|
198
|
+
|
|
195
199
|
this.$emit('click:cell', { row, column });
|
|
196
200
|
},
|
|
197
201
|
clickActions(row) {
|
|
198
202
|
this.$emit('click:actions', row);
|
|
199
203
|
},
|
|
200
204
|
clickSelect(row) {
|
|
205
|
+
|
|
201
206
|
this.$emit('select:row:toggle', row);
|
|
202
207
|
},
|
|
203
208
|
|
|
@@ -223,6 +228,8 @@ export default {
|
|
|
223
228
|
width: 100%;
|
|
224
229
|
border-collapse: collapse;
|
|
225
230
|
|
|
231
|
+
|
|
232
|
+
|
|
226
233
|
thead {
|
|
227
234
|
th {
|
|
228
235
|
top: 0;
|
|
@@ -236,6 +243,10 @@ export default {
|
|
|
236
243
|
background: #fff;
|
|
237
244
|
z-index: 2;
|
|
238
245
|
text-align: left;
|
|
246
|
+
|
|
247
|
+
&.table-select {
|
|
248
|
+
font-size: clamp(17px, 1em, 20px);
|
|
249
|
+
}
|
|
239
250
|
}
|
|
240
251
|
|
|
241
252
|
border-bottom: 1px solid rgba(#000, 0.05);
|
|
@@ -247,6 +258,7 @@ export default {
|
|
|
247
258
|
position: sticky;
|
|
248
259
|
left: 0;
|
|
249
260
|
// z-index: 1;
|
|
261
|
+
text-align: center;
|
|
250
262
|
}
|
|
251
263
|
|
|
252
264
|
th.last,
|
|
@@ -254,16 +266,51 @@ export default {
|
|
|
254
266
|
position: sticky;
|
|
255
267
|
right: 0;
|
|
256
268
|
// z-index: 1;
|
|
269
|
+
text-align: center;
|
|
257
270
|
}
|
|
258
271
|
|
|
259
272
|
td,
|
|
260
273
|
th {
|
|
261
274
|
padding: 0.5em;
|
|
275
|
+
font-size: clamp(17px, 1em, 20px);
|
|
262
276
|
|
|
263
277
|
&.shrink {
|
|
264
278
|
width: 1px;
|
|
265
279
|
}
|
|
266
280
|
}
|
|
281
|
+
|
|
282
|
+
tr {
|
|
283
|
+
border-bottom: 1px solid rgba(#000, 0.05);
|
|
284
|
+
|
|
285
|
+
&:last-of-type {
|
|
286
|
+
border-bottom: none;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
tr:nth-child(odd) {
|
|
291
|
+
background: darken(#fff, 1%);
|
|
292
|
+
|
|
293
|
+
th.first,
|
|
294
|
+
td.first,
|
|
295
|
+
th.last,
|
|
296
|
+
td.last {
|
|
297
|
+
background: darken(#fff, 1%);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
tr:nth-child(even) {
|
|
302
|
+
|
|
303
|
+
th.first,
|
|
304
|
+
td.first,
|
|
305
|
+
th.last,
|
|
306
|
+
td.last {
|
|
307
|
+
background: #fff;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
tr.selected {
|
|
312
|
+
background: rgba(orange, 0.1);
|
|
313
|
+
}
|
|
267
314
|
}
|
|
268
315
|
}
|
|
269
316
|
</style>
|
package/src/table/TableCell.vue
CHANGED
|
@@ -1,23 +1,43 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
2
|
+
<component v-if="component" :is="component" :column="column" :row="row" :value="value" />
|
|
3
3
|
<td v-else class="table-cell">
|
|
4
|
-
|
|
4
|
+
<template v-if="multiValue">
|
|
5
|
+
<template v-if="complex">
|
|
6
|
+
<span class="value" v-for="entry in value">
|
|
7
|
+
<value-renderer :value="entry" />
|
|
8
|
+
</span>
|
|
9
|
+
</template>
|
|
10
|
+
<template v-else>
|
|
11
|
+
<span class="value" v-for="entry in value">
|
|
12
|
+
<value-renderer :value="entry" />,
|
|
13
|
+
</span>
|
|
14
|
+
</template>
|
|
15
|
+
</template>
|
|
16
|
+
<template v-else>
|
|
17
|
+
<value-renderer :value="value" />
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
|
|
5
21
|
</td>
|
|
6
22
|
</template>
|
|
7
23
|
<script>
|
|
8
|
-
|
|
9
24
|
import _get from 'lodash/get';
|
|
10
|
-
import {defineAsyncComponent} from 'vue';
|
|
25
|
+
import { defineAsyncComponent } from 'vue';
|
|
11
26
|
|
|
12
27
|
import ThumbnailCell from './cells/Thumbnail.vue';
|
|
28
|
+
import ButtonCell from './cells/Button.vue';
|
|
29
|
+
import ValueRenderer from './cells/Value.vue';
|
|
13
30
|
|
|
14
31
|
export default {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
32
|
+
data() {
|
|
33
|
+
return {
|
|
34
|
+
component: null,
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
components: {
|
|
38
|
+
ValueRenderer,
|
|
39
|
+
},
|
|
40
|
+
async created() {
|
|
21
41
|
var self = this;
|
|
22
42
|
|
|
23
43
|
var component;
|
|
@@ -25,6 +45,9 @@ export default {
|
|
|
25
45
|
///////////////////////////////
|
|
26
46
|
|
|
27
47
|
switch (this.column.renderer) {
|
|
48
|
+
case 'button':
|
|
49
|
+
component = ButtonCell;
|
|
50
|
+
break;
|
|
28
51
|
case 'thumbnail':
|
|
29
52
|
// simple usage
|
|
30
53
|
component = ThumbnailCell;
|
|
@@ -35,30 +58,56 @@ export default {
|
|
|
35
58
|
|
|
36
59
|
this.component = component;
|
|
37
60
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
</script>
|
|
61
|
+
props: {
|
|
62
|
+
column: {
|
|
63
|
+
type: Object,
|
|
64
|
+
required: true,
|
|
65
|
+
},
|
|
66
|
+
row: {
|
|
67
|
+
type: Object,
|
|
68
|
+
required: true,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
computed: {
|
|
72
|
+
multiValue() {
|
|
73
|
+
return Array.isArray(this.value);
|
|
74
|
+
},
|
|
75
|
+
complex() {
|
|
76
|
+
if (this.multiValue) {
|
|
58
77
|
|
|
78
|
+
} else {
|
|
59
79
|
|
|
60
|
-
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
renderer() {
|
|
83
|
+
return this.column.renderer;
|
|
84
|
+
},
|
|
85
|
+
renderValue() {
|
|
86
|
+
|
|
87
|
+
var value = this.value;
|
|
61
88
|
|
|
89
|
+
if (value === undefined || value === null) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
62
92
|
|
|
93
|
+
return value.title || value.name || value;
|
|
94
|
+
},
|
|
95
|
+
value() {
|
|
96
|
+
var v = _get(this.row, this.column.key);
|
|
63
97
|
|
|
98
|
+
if(!v) {
|
|
99
|
+
console.log(this.row, this.column.key)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return v;
|
|
103
|
+
},
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
</script>
|
|
107
|
+
<style scoped lang="scss">
|
|
108
|
+
.value {
|
|
109
|
+
display: inline-block;
|
|
110
|
+
margin: 0.05em;
|
|
111
|
+
|
|
112
|
+
}
|
|
64
113
|
</style>
|