vi-grid-builder 2.0.2 → 2.0.3
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 +14 -6
- package/package.json +2 -2
- package/playground/src/App.vue +4 -0
- package/playground/src/components/FieldTypes.vue +138 -0
- package/playground/src/main.js +3 -1
- package/src/ViGridBuilder.vue +1 -1
- package/src/composables/useRowHelper.js +3 -0
- package/src/fields/ViGridImage.scss +4 -0
- package/src/fields/ViGridLink.vue +2 -2
- package/src/fields/ViGridNumber.vue +0 -18
package/README.md
CHANGED
|
@@ -59,15 +59,23 @@ const app = createApp(App).use(ViGridBuilder)
|
|
|
59
59
|
| name | String | Name of the field for which data will be presented | / |
|
|
60
60
|
| sortable | Boolean | Is the column sortable? | false |
|
|
61
61
|
| isVisible | Boolean | Is the column visible? | true |
|
|
62
|
-
|
|
|
62
|
+
| render | Function | Function to cange| format the data before display | / |
|
|
63
63
|
| align | centre, left, right | How to align the content in the cells for this column | / |
|
|
64
64
|
| sort | Function | Compare function for sorting data in this column | / |
|
|
65
|
-
mode| date, dateTime, time| Option for date field | dateTime|
|
|
66
|
-
format| String| Option for formatting the date field | yyyy-MM-dd HH:mm:ss
|
|
67
|
-
actions |Array| Option for field of type action | /|
|
|
68
|
-
link |String| Option for field of type link, this will be name of the field from which we need to get the link, and name attribute is for the text of the link| /
|
|
69
65
|
|
|
70
|
-
##
|
|
66
|
+
##Aditional columsn options for sepcific fields
|
|
67
|
+
|
|
68
|
+
field type| option | type | description | default value |
|
|
69
|
+
|------------|------------|-----------------------------|--------------------------------------------------------|---------------|
|
|
70
|
+
|date | mode| date,time, dateTime| what part of the date shoudl be displayed| dateTime
|
|
71
|
+
|date | format| object | format of date field| {date:"yyyy-MM-dd",dateTime:"yyyy-MM-dd HH:mm:ss",time:"HH:mm:ss",}|
|
|
72
|
+
|actions |actions|Array of object| Option for field of type action | every object should have unique action field and name for the text displayed for the action |
|
|
73
|
+
|actions |kebab|boolean| should action menu be 'kebab type'| false |
|
|
74
|
+
|link |String| link field| If the link field is provided, it is used as the URL, and name is used as the link text. If the link field is not provided, both the URL and link text default to the name field value.| /
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
## Example config for columns
|
|
71
79
|
|
|
72
80
|
```js
|
|
73
81
|
columns: [
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vi-grid-builder",
|
|
3
3
|
"main": "ViGridBuilderPlugin",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@fortawesome/free-solid-svg-icons": "^6.7.1",
|
|
15
15
|
"@fortawesome/vue-fontawesome": "^3.0.8",
|
|
16
16
|
"date-fns": "^2.30.0",
|
|
17
|
-
"vi-pagination": "^1.0.
|
|
17
|
+
"vi-pagination": "^1.0.1",
|
|
18
18
|
"vue": "^3.3.4"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
package/playground/src/App.vue
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
<div>
|
|
4
4
|
<h1> Examples</h1>
|
|
5
5
|
</div>
|
|
6
|
+
|
|
7
|
+
<field-types/>
|
|
6
8
|
<custom-header/>
|
|
7
9
|
|
|
8
10
|
|
|
@@ -49,10 +51,12 @@ import TableStyle from "@/components/TableStyle.vue";
|
|
|
49
51
|
import PaginationOptions from "@/components/PaginationOptions.vue";
|
|
50
52
|
import CustomField from "@/components/CustomField.vue";
|
|
51
53
|
import GlobalOptions from "@/components/GlobalOptions.vue";
|
|
54
|
+
import FieldTypes from "@/components/FieldTypes.vue";
|
|
52
55
|
|
|
53
56
|
|
|
54
57
|
export default {
|
|
55
58
|
components: {
|
|
59
|
+
FieldTypes,
|
|
56
60
|
GlobalOptions,
|
|
57
61
|
CustomField,
|
|
58
62
|
PaginationOptions,
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="example-container">
|
|
3
|
+
|
|
4
|
+
<h3 id="custom-header">Defautl field types</h3>
|
|
5
|
+
<div class="example-body">
|
|
6
|
+
|
|
7
|
+
<vi-grid-builder
|
|
8
|
+
stripped
|
|
9
|
+
v-bind="config"
|
|
10
|
+
v-model:pagination="config.pagination"
|
|
11
|
+
:rows="rows"
|
|
12
|
+
:server-mode="false"
|
|
13
|
+
/>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
import axios from "axios";
|
|
20
|
+
|
|
21
|
+
function getRandomDate(startDate, endDate) {
|
|
22
|
+
const start = new Date(startDate).getTime();
|
|
23
|
+
const end = new Date(endDate).getTime();
|
|
24
|
+
const randomTimestamp = Math.floor(Math.random() * (end - start + 1)) + start;
|
|
25
|
+
return new Date(randomTimestamp).toISOString();
|
|
26
|
+
}
|
|
27
|
+
const posts = Array.from({ length: 25 }, (_, index) => ({
|
|
28
|
+
id: index + 1,
|
|
29
|
+
title: `Post Title ${index + 1}`,
|
|
30
|
+
link: `https://example.com/post-${index + 1}`,
|
|
31
|
+
image: "https://images.pexels.com/photos/2325447/pexels-photo-2325447.jpeg",
|
|
32
|
+
status: Math.random() > 0.5 ? "published" : "unpublished",
|
|
33
|
+
date:getRandomDate("2020-01-01", "2024-12-31")
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
console.log(posts);
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
export default {
|
|
40
|
+
|
|
41
|
+
data: () => ({
|
|
42
|
+
|
|
43
|
+
loading: true,
|
|
44
|
+
rows:posts,
|
|
45
|
+
config: {
|
|
46
|
+
rowKey: 'id',
|
|
47
|
+
columns: [{
|
|
48
|
+
label: 'ID',
|
|
49
|
+
name: 'id',
|
|
50
|
+
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
label: 'Title',
|
|
54
|
+
name: 'title',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: 'Link',
|
|
58
|
+
name: 'link',
|
|
59
|
+
type:'link',
|
|
60
|
+
// link:'link'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
label: 'Link with title',
|
|
64
|
+
name: 'title',
|
|
65
|
+
type:'link',
|
|
66
|
+
link:'link'
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
label: 'Image',
|
|
70
|
+
name: 'image',
|
|
71
|
+
type:'image'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
label: 'Status',
|
|
75
|
+
name: 'status',
|
|
76
|
+
type:'badge'
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
label: 'Date',
|
|
80
|
+
name: 'date',
|
|
81
|
+
type:'date',
|
|
82
|
+
mode:'date'
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
label: 'Time',
|
|
86
|
+
name: 'date',
|
|
87
|
+
type:'date',
|
|
88
|
+
mode:'time'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
label: 'Simple actions',
|
|
92
|
+
name: 'actions',
|
|
93
|
+
type:'actions',
|
|
94
|
+
actions:[
|
|
95
|
+
{
|
|
96
|
+
action:'edit',
|
|
97
|
+
name:'Edit post'
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
action:'remove',
|
|
101
|
+
name:'Remove post'
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
label: 'Kebap type actions',
|
|
107
|
+
name: 'actions',
|
|
108
|
+
type:'actions',
|
|
109
|
+
kebab:true,
|
|
110
|
+
actions:[
|
|
111
|
+
{
|
|
112
|
+
action:'edit',
|
|
113
|
+
name:'Edit post'
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
action:'remove',
|
|
117
|
+
name:'Remove post'
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
|
|
123
|
+
pagination: {page: 1, rowsPerPage:15},
|
|
124
|
+
|
|
125
|
+
},
|
|
126
|
+
compact: false,
|
|
127
|
+
|
|
128
|
+
}),
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
<style scoped lang="scss">
|
|
137
|
+
|
|
138
|
+
</style>
|
package/playground/src/main.js
CHANGED
package/src/ViGridBuilder.vue
CHANGED
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
<vi-grid-field
|
|
102
102
|
:class="column.align ?? settings.align"
|
|
103
103
|
:field="column"
|
|
104
|
-
:field-value="column.
|
|
104
|
+
:field-value="column.render ? column.render(row) : row[column.name]"
|
|
105
105
|
:row-value="row"
|
|
106
106
|
:row-key="rowKey"
|
|
107
107
|
v-model:row-menu-opened="rowMenuOpened"
|
|
@@ -17,6 +17,9 @@ export default function useRowHelper(props, emit) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
let rowsPerPage = props.pagination?.rowsPerPage ?? globalGridSettings.value.rowsPerPage
|
|
20
|
+
if (rowsPerPage === 0) {
|
|
21
|
+
return sortedRows.value;
|
|
22
|
+
}
|
|
20
23
|
const startIndex = (props.pagination.page - 1) * rowsPerPage;
|
|
21
24
|
const endIndex = startIndex + rowsPerPage;
|
|
22
25
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="vi-grid-link">
|
|
3
|
-
<a :href="row[link]" target="_blank" v-if="row[link]">{{value}}</a>
|
|
3
|
+
<a :href="row[link] ?? value" target="_blank" v-if="(link && row[link]) || (!link && value)">{{value}}</a>
|
|
4
4
|
<div v-else>{{value}}</div>
|
|
5
5
|
</div>
|
|
6
6
|
</template>
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
props: {
|
|
12
12
|
link: {
|
|
13
13
|
type: String,
|
|
14
|
-
required: true
|
|
14
|
+
// required: true
|
|
15
15
|
},
|
|
16
16
|
row: {
|
|
17
17
|
type: Object,
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="vi-grid-number">
|
|
3
|
-
{{value}}
|
|
4
|
-
</div>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script>
|
|
8
|
-
export default {
|
|
9
|
-
name: "ViGridNumber",
|
|
10
|
-
props: {
|
|
11
|
-
value: {},
|
|
12
|
-
},
|
|
13
|
-
}
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
<style lang="scss">
|
|
17
|
-
@import "ViGridNumber";
|
|
18
|
-
</style>
|