vi-grid-builder 1.0.5 → 2.0.0
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/README.md +240 -11
- package/ViGridBuilderPlugin.js +35 -36
- package/package.json +5 -2
- package/playground/.vscode/extensions.json +3 -0
- package/playground/README.md +29 -0
- package/playground/index.html +13 -0
- package/playground/jsconfig.json +8 -0
- package/playground/package-lock.json +2524 -0
- package/playground/package.json +20 -0
- package/playground/public/favicon.ico +0 -0
- package/playground/src/App.vue +84 -0
- package/playground/src/assets/base.css +86 -0
- package/playground/src/assets/logo.svg +1 -0
- package/playground/src/assets/main.css +35 -0
- package/playground/src/components/ActionsField.vue +99 -0
- package/playground/src/components/ClickableRow.vue +68 -0
- package/playground/src/components/ClientSideData.vue +86 -0
- package/playground/src/components/ColumnVisibility.vue +85 -0
- package/playground/src/components/CustomField.vue +64 -0
- package/playground/src/components/CustomHeader.vue +85 -0
- package/playground/src/components/GlobalOptions.vue +68 -0
- package/playground/src/components/LoadingSlot.vue +11 -0
- package/playground/src/components/PaginationOptions.vue +130 -0
- package/playground/src/components/RowSelect.vue +72 -0
- package/playground/src/components/ServerSideData.vue +62 -0
- package/playground/src/components/SortableColumnServerSide.vue +73 -0
- package/playground/src/components/TableStyle.vue +112 -0
- package/playground/src/components/fields/SampleCustomField.vue +24 -0
- package/playground/src/components/icons/IconCommunity.vue +7 -0
- package/playground/src/components/icons/IconDocumentation.vue +7 -0
- package/playground/src/components/icons/IconEcosystem.vue +7 -0
- package/playground/src/components/icons/IconSupport.vue +7 -0
- package/playground/src/components/icons/IconTooling.vue +19 -0
- package/playground/src/main.js +51 -0
- package/playground/vite.config.js +17 -0
- package/src/ViGridBuilder.scss +157 -58
- package/src/ViGridBuilder.vue +367 -207
- package/src/ViGridField.scss +1 -2
- package/src/ViGridField.vue +13 -6
- package/src/ViGridHeadCell.vue +32 -0
- package/src/ViGridHeadColumnCell.vue +42 -0
- package/src/ViGridHeader.vue +67 -0
- package/src/composables/useColumns.js +21 -0
- package/src/composables/useGridActions.js +17 -3
- package/src/composables/useGridSettings.js +18 -0
- package/src/composables/usePagination.js +39 -0
- package/src/composables/useRowHelper.js +38 -0
- package/src/composables/useRowSelect.js +53 -0
- package/src/composables/useSettings.js +29 -0
- package/src/composables/useSort.js +103 -0
- package/src/fields/ViGridActions.scss +0 -1
- package/src/fields/ViGridActions.vue +37 -13
- package/src/fields/ViGridCheckbox.vue +31 -0
- package/src/fields/ViGridNumber.vue +18 -0
- package/src/fields/partials/ViGridKebabMenu.scss +60 -25
- package/src/fields/partials/ViGridKebabMenu.vue +75 -54
- package/src/fields/partials/{ViGridBuilderActions.vue → ViGridSimpleActions.vue} +3 -3
- package/src/settings/GridSettings.js +24 -0
- package/vite.config.js +12 -2
- package/src/examples/App.vue +0 -123
- package/src/examples/components/TableTitle.vue +0 -20
- package/src/examples/main.js +0 -11
- /package/src/fields/partials/{ViGridBuilderActions.scss → ViGridSimpleActions.scss} +0 -0
package/src/ViGridBuilder.vue
CHANGED
|
@@ -1,230 +1,390 @@
|
|
|
1
1
|
<template>
|
|
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
|
-
|
|
2
|
+
<div class="vi-grid-builder">
|
|
3
|
+
<div class="vi-table-container" :class="{'loading':isDataLoading}">
|
|
4
|
+
<table class="vi-table" :class="{'stripped': settings.stripped, 'bordered': settings.bordered}">
|
|
5
|
+
|
|
6
|
+
<!------------------- TABLE HEADER -------------->
|
|
7
|
+
<thead class="vi-table-head">
|
|
8
|
+
<!------------------- title -------------->
|
|
9
|
+
|
|
10
|
+
<tr v-if="title" class="vi-header-row vi-table-row vi-title-row">
|
|
11
|
+
<vi-grid-head-cell v-if="title" :colspan="visibleColumns.length" :align="settings.align" class="vi-title-cell">
|
|
12
|
+
<template #default>
|
|
13
|
+
<slot name="title" :title="title">
|
|
14
|
+
<span>{{ title }}}</span>
|
|
15
|
+
</slot>
|
|
16
|
+
</template>
|
|
17
|
+
</vi-grid-head-cell>
|
|
18
|
+
</tr>
|
|
19
|
+
<tr class="vi-header-row vi-table-row">
|
|
20
|
+
<!------------------- master select -------------->
|
|
21
|
+
|
|
22
|
+
<vi-grid-head-cell v-if="selectable" class="vi-select-cell" :align="settings.align">
|
|
23
|
+
<template #default>
|
|
24
|
+
<vi-grid-checkbox name="masterSelect"
|
|
25
|
+
:value="areAllRowsSelected"
|
|
26
|
+
@checkboxClicked="toggleMasterSelect($event.value)"
|
|
27
|
+
/>
|
|
28
|
+
</template>
|
|
29
|
+
</vi-grid-head-cell>
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<!------------------- columns -------------->
|
|
33
|
+
<vi-grid-head-column-cell v-for="column in visibleColumns"
|
|
34
|
+
:key="column.name"
|
|
35
|
+
:column="column"
|
|
36
|
+
:align="settings.align"
|
|
37
|
+
:sortable-state="getSortableState(column)"
|
|
38
|
+
@sort="setSortFields">
|
|
39
|
+
<template #default>
|
|
40
|
+
<slot :name="`vi-header-cell-${column.name}`" :column="column"/>
|
|
41
|
+
</template>
|
|
42
|
+
</vi-grid-head-column-cell>
|
|
43
|
+
</tr>
|
|
44
|
+
|
|
45
|
+
<!------------------- loading row -------------->
|
|
46
|
+
<tr v-if="isDataLoading" class="vi-body-row vi-table-row vi-loading-row">
|
|
47
|
+
|
|
48
|
+
<vi-grid-head-cell :colspan="totalColumns" class="vi-loading-cell">
|
|
49
|
+
<template #default>
|
|
50
|
+
<slot name="loading">
|
|
51
|
+
<component v-if="settings.defaultSlots.loading" :is="settings.defaultSlots.loading"/>
|
|
52
|
+
<div class="loading-bar-container" v-else>
|
|
53
|
+
<div class="loading-bar"></div>
|
|
54
|
+
</div>
|
|
55
|
+
</slot>
|
|
56
|
+
</template>
|
|
57
|
+
</vi-grid-head-cell>
|
|
58
|
+
</tr>
|
|
59
|
+
</thead>
|
|
60
|
+
<!------------------- END TABLE HEADER -------------->
|
|
61
|
+
|
|
62
|
+
<tbody v-if="!currentVisibleRows.length && !isDataLoading" class="vi-table-body">
|
|
63
|
+
|
|
64
|
+
<!------------------- TABLE NO DATA ROW -------------->
|
|
65
|
+
|
|
66
|
+
<tr class="vi-body-row vi-table-row vi-no-data-row">
|
|
67
|
+
<slot name="empty-data">
|
|
68
|
+
<component v-if="settings.defaultSlots.noRows" :is="settings.defaultSlots.noRows"/>
|
|
69
|
+
<td v-else :colspan="totalColumns" class="vi-body-cell vi-cell">
|
|
70
|
+
{{ settings.noDataLabel }}
|
|
71
|
+
</td>
|
|
72
|
+
</slot>
|
|
73
|
+
</tr>
|
|
74
|
+
</tbody>
|
|
75
|
+
<tbody v-else class="vi-table-body">
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
<!------------------- TABLE DATA ROWS. -------------->
|
|
79
|
+
<tr v-for="row in currentVisibleRows"
|
|
80
|
+
:key="row[rowKey]"
|
|
81
|
+
@click="$ev => onRowClicked(row)"
|
|
82
|
+
:class="{'clickable': clickableRow,'selected':isRowSelected(row) }"
|
|
83
|
+
class="vi-body-row vi-table-row"
|
|
84
|
+
>
|
|
85
|
+
|
|
86
|
+
<!------------------- SELECTABLE CELL -------------->
|
|
87
|
+
<td v-if="selectable" class="vi-cell vi-select-cell">
|
|
88
|
+
<div class="vi-grid-field" :class="settings.align">
|
|
89
|
+
<vi-grid-checkbox
|
|
90
|
+
:row="row"
|
|
91
|
+
:name="rowKey"
|
|
92
|
+
:value="selectedRows.includes(row[rowKey])"
|
|
93
|
+
@checkboxClicked="toggleRowSelect(row, $event.value)"
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
</td>
|
|
97
|
+
|
|
98
|
+
<td v-for="column in visibleColumns"
|
|
99
|
+
:key="column.name"
|
|
100
|
+
class="vi-body-cell vi-cell">
|
|
101
|
+
<vi-grid-field
|
|
102
|
+
:class="column.align ?? settings.align"
|
|
103
|
+
:field="column"
|
|
104
|
+
:field-value="column.format ? column.format(row) : row[column.name]"
|
|
105
|
+
:row-value="row"
|
|
106
|
+
:row-key="rowKey"
|
|
107
|
+
v-model:row-menu-opened="rowMenuOpened"
|
|
108
|
+
@actionClicked="$event => $emit($event.action, $event.row)"
|
|
109
|
+
@checkboxClicked="toggleRowSelect(row, $event.value)"
|
|
110
|
+
>
|
|
111
|
+
<template v-slot:custom-field="props">
|
|
112
|
+
<component
|
|
113
|
+
v-bind:is="column.type"
|
|
114
|
+
v-bind="props"
|
|
69
115
|
/>
|
|
116
|
+
</template>
|
|
117
|
+
</vi-grid-field>
|
|
118
|
+
|
|
119
|
+
</td>
|
|
120
|
+
</tr>
|
|
121
|
+
|
|
122
|
+
<tr class="vi-body-row vi-table-row vi-footer-row">
|
|
123
|
+
<td :colspan="totalColumns" class="vi-body-cell vi-cell vi-footer-cell">
|
|
124
|
+
|
|
125
|
+
<slot name="footer" :pagination="{...pagination, totalRows:totalRows}">
|
|
126
|
+
<component v-if="settings.defaultSlots.footer" :is="settings.defaultSlots.footer"
|
|
127
|
+
:pagination="{...pagination, totalRows:totalRows}"/>
|
|
128
|
+
<vi-pagination v-if="!settings.disablePagination"
|
|
129
|
+
:rows-per-page="localPagination.rowsPerPage ?? settings.rowsPerPage "
|
|
130
|
+
:current-page="localPagination.page"
|
|
131
|
+
:total-rows="totalRows"
|
|
132
|
+
:max-pages-displayed="3"
|
|
133
|
+
:compact="settings.compactPagination"
|
|
134
|
+
:rows-per-page-options="settings.rowsPerPageOptions"
|
|
135
|
+
@update="onPaginationChange"
|
|
136
|
+
/>
|
|
70
137
|
</slot>
|
|
71
|
-
|
|
138
|
+
</td>
|
|
139
|
+
|
|
140
|
+
</tr>
|
|
141
|
+
</tbody>
|
|
142
|
+
</table>
|
|
72
143
|
</div>
|
|
144
|
+
|
|
145
|
+
</div>
|
|
73
146
|
</template>
|
|
74
147
|
|
|
75
148
|
<script>
|
|
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
|
-
filter: {
|
|
120
|
-
type: Object
|
|
121
|
-
},
|
|
122
|
-
loading: {
|
|
123
|
-
type: Boolean,
|
|
124
|
-
default: false
|
|
125
|
-
},
|
|
126
|
-
defaultSlots: {
|
|
127
|
-
type: Object
|
|
128
|
-
},
|
|
129
|
-
noDataLabel: {
|
|
130
|
-
type: String,
|
|
131
|
-
},
|
|
132
|
-
noCellDataLabel: {
|
|
133
|
-
type: String,
|
|
134
|
-
default:'/'
|
|
135
|
-
},
|
|
136
|
-
clickableRow:{
|
|
137
|
-
type: Boolean,
|
|
138
|
-
default: false
|
|
139
|
-
}
|
|
149
|
+
import ViGridField from "./ViGridField.vue";
|
|
150
|
+
import ViGridCheckbox from "./fields/ViGridCheckbox.vue";
|
|
151
|
+
import {computed, ref, watch} from 'vue'
|
|
152
|
+
import useColumns from "./composables/useColumns.js";
|
|
153
|
+
import useRowHelper from "./composables/useRowHelper.js";
|
|
154
|
+
import useSort from "./composables/useSort.js";
|
|
155
|
+
import usePagination from "./composables/usePagination.js";
|
|
156
|
+
import ViGridHeadCell from "./ViGridHeadCell.vue";
|
|
157
|
+
import useRowSelect from "./composables/useRowSelect.js";
|
|
158
|
+
import ViGridHeadColumnCell from "./ViGridHeadColumnCell.vue";
|
|
159
|
+
import useSettings from "./composables/useSettings.js";
|
|
160
|
+
|
|
161
|
+
export default {
|
|
162
|
+
name: "ViGridBuilder",
|
|
163
|
+
components: {ViGridHeadColumnCell, ViGridHeadCell, ViGridCheckbox, ViGridField},
|
|
164
|
+
props: {
|
|
165
|
+
|
|
166
|
+
rows: {
|
|
167
|
+
type: Array,
|
|
168
|
+
},
|
|
169
|
+
rowKey: {
|
|
170
|
+
type: String,
|
|
171
|
+
},
|
|
172
|
+
columns: {
|
|
173
|
+
type: Array,
|
|
174
|
+
required: true
|
|
175
|
+
},
|
|
176
|
+
title: {
|
|
177
|
+
type: String
|
|
178
|
+
},
|
|
179
|
+
align: {
|
|
180
|
+
type: String,
|
|
181
|
+
},
|
|
182
|
+
pagination: {
|
|
183
|
+
type: Object,
|
|
184
|
+
// default: function () {
|
|
185
|
+
// return {
|
|
186
|
+
// page: 1,
|
|
187
|
+
// rowsPerPage: 10,
|
|
188
|
+
// sortBy: null,
|
|
189
|
+
// // rowsNumber:10
|
|
190
|
+
// }
|
|
191
|
+
// }
|
|
140
192
|
},
|
|
141
|
-
data: () => ({search: null, isFetchingData: false}),
|
|
142
|
-
computed: {
|
|
143
|
-
isServerSide() {
|
|
144
|
-
return this.fetchServerData!==undefined;
|
|
145
|
-
},
|
|
146
|
-
totalRows() {
|
|
147
|
-
return this.rowsNumber ?? this.rows.length;
|
|
148
|
-
},
|
|
149
|
-
currentVisibleRows() {
|
|
150
|
-
if (this.isServerSide || this.disablePagination) {
|
|
151
|
-
return this.rows;
|
|
152
|
-
}
|
|
153
193
|
|
|
154
|
-
const startIndex = (this.pagination.page - 1) * this.pagination.rowsPerPage;
|
|
155
|
-
const endIndex = startIndex + this.pagination.rowsPerPage;
|
|
156
194
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return this.loading || this.isFetchingData;
|
|
161
|
-
}
|
|
195
|
+
disablePagination: {
|
|
196
|
+
type: Boolean,
|
|
197
|
+
default:undefined
|
|
162
198
|
},
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
199
|
+
fetchServerData: {
|
|
200
|
+
type: Function
|
|
201
|
+
},
|
|
202
|
+
fetchOnInit: {
|
|
203
|
+
type: Boolean,
|
|
204
|
+
default: true
|
|
205
|
+
},
|
|
206
|
+
filter: {
|
|
207
|
+
type: Object
|
|
208
|
+
},
|
|
209
|
+
loading: {
|
|
210
|
+
type: Boolean,
|
|
211
|
+
default: false
|
|
212
|
+
},
|
|
213
|
+
//todo document this
|
|
214
|
+
|
|
215
|
+
noDataLabel: {
|
|
216
|
+
type: String,
|
|
217
|
+
},
|
|
218
|
+
noCellDataLabel: {
|
|
219
|
+
type: String,
|
|
220
|
+
// default: '/'
|
|
221
|
+
},
|
|
222
|
+
//todo document this
|
|
223
|
+
clickableRow: {
|
|
224
|
+
type: Boolean,
|
|
225
|
+
default: false
|
|
226
|
+
},
|
|
227
|
+
selectable: {
|
|
228
|
+
type: Boolean,
|
|
229
|
+
default: false
|
|
230
|
+
},
|
|
231
|
+
serverMode: {
|
|
232
|
+
type: Boolean,
|
|
233
|
+
default: true
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
//STYLE PROPS
|
|
237
|
+
stripped: {
|
|
238
|
+
type: Boolean,
|
|
239
|
+
default:undefined
|
|
240
|
+
},
|
|
241
|
+
bordered: {
|
|
242
|
+
type: Boolean,
|
|
243
|
+
default:undefined
|
|
244
|
+
},
|
|
245
|
+
compactPagination: {
|
|
246
|
+
type: Boolean,
|
|
247
|
+
default: undefined
|
|
248
|
+
},
|
|
249
|
+
rowsPerPageOptions: {
|
|
250
|
+
type: Array
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
setup(props, {emit}) {
|
|
255
|
+
let search = ref(null);
|
|
256
|
+
let rowMenuOpened = ref(null);
|
|
257
|
+
|
|
258
|
+
// FETCH DATA METHODS
|
|
259
|
+
let isFetchingData = ref(false);
|
|
260
|
+
const fetchData = ({pagination, filter, search} = {}) => {
|
|
261
|
+
const paginationData = pagination ?? props.pagination;
|
|
262
|
+
isFetchingData.value = true;
|
|
263
|
+
return props.fetchServerData({
|
|
175
264
|
...paginationData && {
|
|
176
|
-
pagination: this.formatPagination(paginationData)
|
|
265
|
+
// pagination: this.formatPagination(paginationData)
|
|
266
|
+
pagination: paginationData
|
|
177
267
|
},
|
|
178
268
|
|
|
179
|
-
filter: filter ??
|
|
180
|
-
search: search ??
|
|
269
|
+
filter: filter ?? props.filter,
|
|
270
|
+
search: search ?? props.search,
|
|
181
271
|
})
|
|
182
|
-
.finally(() =>
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
272
|
+
.finally(() => isFetchingData.value = false)
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
//COLUMN COMPUTED VALUES
|
|
276
|
+
const {visibleColumns, totalColumns} = useColumns(props);
|
|
277
|
+
|
|
278
|
+
//SORTING
|
|
279
|
+
const {
|
|
280
|
+
setSortFieldsFromPagination,
|
|
281
|
+
getSortableState,
|
|
282
|
+
clientSort,
|
|
283
|
+
setSortFields,
|
|
284
|
+
sortField,
|
|
285
|
+
sortDirection,
|
|
286
|
+
formatSortFields,
|
|
287
|
+
} = useSort(props);
|
|
288
|
+
|
|
289
|
+
setSortFieldsFromPagination(props.pagination);
|
|
290
|
+
|
|
291
|
+
const {localPagination, onPaginationChange} = usePagination(props, emit, fetchData)
|
|
292
|
+
|
|
293
|
+
watch([sortField, sortDirection], () => {
|
|
294
|
+
if (props.serverMode) {
|
|
295
|
+
fetchData({
|
|
296
|
+
pagination: {
|
|
297
|
+
...props.pagination,
|
|
298
|
+
page: 1,
|
|
299
|
+
sortBy: formatSortFields(),
|
|
207
300
|
}
|
|
208
301
|
})
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
this.fetchData()
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
watch:{
|
|
218
|
-
filter:{
|
|
219
|
-
handler: function (newValue, oldValue) {
|
|
220
|
-
this.fetchData()
|
|
221
|
-
},
|
|
222
|
-
deep:true,
|
|
302
|
+
} else {
|
|
303
|
+
localPagination.value = {
|
|
304
|
+
...localPagination.value,
|
|
305
|
+
page: 1,
|
|
306
|
+
}
|
|
223
307
|
}
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
//ROW SELECT, CLICK AND COMPUTED VALUES
|
|
311
|
+
const {currentVisibleRows, totalRows, onRowClicked} = useRowHelper(props, emit, clientSort);
|
|
312
|
+
const {
|
|
313
|
+
selectedRows,
|
|
314
|
+
toggleMasterSelect,
|
|
315
|
+
toggleRowSelect,
|
|
316
|
+
areAllRowsSelected,
|
|
317
|
+
isRowSelected
|
|
318
|
+
} = useRowSelect(props, emit);
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
const isDataLoading = computed(() => {
|
|
322
|
+
return props.loading || isFetchingData.value;
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
if (props.serverMode && props.fetchOnInit) {
|
|
326
|
+
fetchData()
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const {settings} = useSettings(props)
|
|
330
|
+
|
|
331
|
+
return {
|
|
332
|
+
search,
|
|
333
|
+
isFetchingData,
|
|
334
|
+
totalRows,
|
|
335
|
+
currentVisibleRows,
|
|
336
|
+
visibleColumns,
|
|
337
|
+
totalColumns,
|
|
338
|
+
selectedRows,
|
|
339
|
+
toggleMasterSelect,
|
|
340
|
+
areAllRowsSelected,
|
|
341
|
+
toggleRowSelect,
|
|
342
|
+
setSortFields,
|
|
343
|
+
fetchData,
|
|
344
|
+
isDataLoading,
|
|
345
|
+
onRowClicked,
|
|
346
|
+
isRowSelected,
|
|
347
|
+
getSortableState,
|
|
348
|
+
|
|
349
|
+
localPagination,
|
|
350
|
+
onPaginationChange,
|
|
351
|
+
rowMenuOpened,
|
|
352
|
+
settings
|
|
224
353
|
}
|
|
225
|
-
}
|
|
354
|
+
},
|
|
355
|
+
|
|
356
|
+
// methods: {
|
|
357
|
+
// // formatPagination(pagination) {
|
|
358
|
+
// // return {
|
|
359
|
+
// // page: pagination.page,
|
|
360
|
+
// // rowsPerPage: pagination.rowsPerPage,
|
|
361
|
+
// // sortBy: pagination.sortBy
|
|
362
|
+
// // }
|
|
363
|
+
// // },
|
|
364
|
+
//
|
|
365
|
+
//
|
|
366
|
+
//
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
//
|
|
370
|
+
//
|
|
371
|
+
//
|
|
372
|
+
// },
|
|
373
|
+
|
|
374
|
+
// watch: {
|
|
375
|
+
// filter: {
|
|
376
|
+
// handler: function (newValue, oldValue) {
|
|
377
|
+
// this.fetchData()
|
|
378
|
+
// },
|
|
379
|
+
// deep: true,
|
|
380
|
+
// }
|
|
381
|
+
// },
|
|
382
|
+
|
|
383
|
+
}
|
|
226
384
|
</script>
|
|
227
385
|
|
|
228
386
|
<style lang="scss">
|
|
229
|
-
|
|
387
|
+
@import "./ViGridBuilder.scss";
|
|
388
|
+
|
|
389
|
+
|
|
230
390
|
</style>
|
package/src/ViGridField.scss
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
}
|
|
1
|
+
|
package/src/ViGridField.vue
CHANGED
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
:value="filedValueFormatted"
|
|
8
8
|
:original-value="fieldValue"
|
|
9
9
|
:row="rowValue"
|
|
10
|
+
:row-key="rowKey"
|
|
11
|
+
:row-menu-opened="rowMenuOpened"
|
|
12
|
+
@update:rowMenuOpened="$emit('update:rowMenuOpened',$event)"
|
|
10
13
|
@actionClicked="$action => $emit(`action-clicked`, $action)"
|
|
11
14
|
|
|
12
15
|
/>
|
|
@@ -14,9 +17,9 @@
|
|
|
14
17
|
:field="field"
|
|
15
18
|
:value="fieldValue"
|
|
16
19
|
:original-value="fieldValue"
|
|
17
|
-
:row="rowValue"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
:row="rowValue"
|
|
21
|
+
:row-key="rowKey"
|
|
22
|
+
/>
|
|
20
23
|
</div>
|
|
21
24
|
</template>
|
|
22
25
|
|
|
@@ -54,6 +57,8 @@
|
|
|
54
57
|
},
|
|
55
58
|
fieldValue: {},
|
|
56
59
|
rowValue: {},
|
|
60
|
+
rowKey: String,
|
|
61
|
+
rowMenuOpened: {},
|
|
57
62
|
noDataLabel: {
|
|
58
63
|
type: String,
|
|
59
64
|
default: '/'
|
|
@@ -64,12 +69,14 @@
|
|
|
64
69
|
return this.fieldValue ?? this.noDataLabel
|
|
65
70
|
},
|
|
66
71
|
fieldComponent() {
|
|
67
|
-
let
|
|
72
|
+
let type = this.field.type ? `vi-grid-${this.field.type}` : 'vi-grid-text'
|
|
73
|
+
|
|
74
|
+
let component = uppercaseFirstLetter(snakeToCamel(type))
|
|
68
75
|
|
|
69
76
|
if (this.$options.components[component]) {
|
|
70
|
-
return
|
|
77
|
+
return type
|
|
71
78
|
} else {
|
|
72
|
-
return
|
|
79
|
+
return false;
|
|
73
80
|
}
|
|
74
81
|
}
|
|
75
82
|
},
|