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