vi-grid-builder 0.0.9 → 1.0.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/ViGridBuilderPlugin.js +10 -1
- package/package.json +2 -1
- package/src/ViGridBuilder.scss +3 -0
- package/src/ViGridBuilder.vue +10 -1
- package/src/ViGridField.vue +1 -1
- package/src/composables/useGridActions.js +1 -1
- package/src/fields/ViGridActions.vue +12 -7
- package/src/fields/ViGridBadge.vue +0 -4
- package/src/fields/ViGridDate.vue +18 -20
- package/src/fields/ViGridImage.vue +0 -5
- package/src/fields/ViGridLink.vue +3 -3
- package/src/fields/ViGridText.vue +0 -4
- package/src/settings/DateSettings.js +7 -0
package/ViGridBuilderPlugin.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import ViGridBuilder from "./src/ViGridBuilder.vue"
|
|
2
|
+
import DateSettings from "./src/settings/DateSettings.js"
|
|
2
3
|
import ViPaginationPlugin from 'vi-pagination'
|
|
3
4
|
import fieldMixin from "./src/mixins/field-mixin.js"
|
|
4
5
|
import {useGridActions} from "./src/composables/useGridActions.js"
|
|
5
6
|
export default {
|
|
6
|
-
install(app, options ={pagination:{}, fieldComponents:{}, defaultSlots:{}}) {
|
|
7
|
+
install(app, options ={pagination:{}, fieldComponents:{}, defaultSlots:{}, dateFormats: {}}) {
|
|
7
8
|
|
|
8
9
|
// if (options?.fieldComponents) {
|
|
9
10
|
// Object.keys(options.fieldComponents).forEach(key => {
|
|
10
11
|
// ViGridBuilder.components[key] = options.fieldComponents[key]
|
|
11
12
|
// });
|
|
12
13
|
// }
|
|
14
|
+
app.provide('ViDateSettings', {
|
|
15
|
+
...DateSettings,
|
|
16
|
+
format:{
|
|
17
|
+
...DateSettings.format,
|
|
18
|
+
...options?.dateFormats
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
13
22
|
app.use(ViPaginationPlugin, options?.pagination);
|
|
14
23
|
app.component('ViGridBuilder', {
|
|
15
24
|
extends:ViGridBuilder,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vi-grid-builder",
|
|
3
3
|
"main": "ViGridBuilderPlugin",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"preview": "vite preview"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
+
"date-fns": "^2.30.0",
|
|
12
13
|
"vi-pagination": "^0.0.5",
|
|
13
14
|
"vue": "^3.3.4"
|
|
14
15
|
},
|
package/src/ViGridBuilder.scss
CHANGED
package/src/ViGridBuilder.vue
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
</slot>
|
|
34
34
|
</td>
|
|
35
35
|
</tr>
|
|
36
|
-
<tr v-for="row in currentVisibleRows" :key="row[rowKey]">
|
|
36
|
+
<tr v-for="row in currentVisibleRows" :key="row[rowKey]" @click="$ev => onRowClicked(row)" :class="{'clickable': clickableRow}">
|
|
37
37
|
|
|
38
38
|
<td v-for="column in columns" :key="column.name">
|
|
39
39
|
<vi-grid-field
|
|
@@ -132,6 +132,10 @@
|
|
|
132
132
|
noCellDataLabel: {
|
|
133
133
|
type: String,
|
|
134
134
|
default:'/'
|
|
135
|
+
},
|
|
136
|
+
clickableRow:{
|
|
137
|
+
type: Boolean,
|
|
138
|
+
default: false
|
|
135
139
|
}
|
|
136
140
|
},
|
|
137
141
|
data: () => ({search: null, isFetchingData: false}),
|
|
@@ -186,6 +190,11 @@
|
|
|
186
190
|
if (this.isServerSide) {
|
|
187
191
|
this.fetchData({pagination: newPagination})
|
|
188
192
|
}
|
|
193
|
+
},
|
|
194
|
+
onRowClicked(row){
|
|
195
|
+
if (this.clickableRow) {
|
|
196
|
+
this.$emit('rowClicked',row)
|
|
197
|
+
}
|
|
189
198
|
}
|
|
190
199
|
},
|
|
191
200
|
created() {
|
package/src/ViGridField.vue
CHANGED
|
@@ -2,7 +2,7 @@ import {computed } from 'vue';
|
|
|
2
2
|
|
|
3
3
|
export function useGridActions(props) {
|
|
4
4
|
|
|
5
|
-
const visibleActions = computed(() => props.
|
|
5
|
+
const visibleActions = computed(() => props.actions.filter((action ) => {
|
|
6
6
|
if (action.isVisible === undefined) {
|
|
7
7
|
return true
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div class="vi-grid-actions">
|
|
3
3
|
|
|
4
4
|
<vi-grid-kebab-menu
|
|
5
|
-
v-if="
|
|
5
|
+
v-if="kebab"
|
|
6
6
|
:actions="visibleActions"
|
|
7
7
|
@actionClicked="$action => $emit(`action-clicked`, {action:$action, row})"
|
|
8
8
|
/>
|
|
@@ -21,18 +21,23 @@
|
|
|
21
21
|
import ViGridBuilderActions from "./partials/ViGridBuilderActions.vue";
|
|
22
22
|
|
|
23
23
|
import {useGridActions} from "../composables/useGridActions.js"
|
|
24
|
-
import fieldMixin from "../mixins/field-mixin.js"
|
|
25
24
|
|
|
26
25
|
export default {
|
|
27
26
|
name: "ViGridActions",
|
|
28
|
-
mixins: [fieldMixin],
|
|
29
27
|
components: {ViGridBuilderActions, ViGridKebabMenu},
|
|
30
28
|
props: {
|
|
31
|
-
|
|
32
|
-
type:
|
|
33
|
-
|
|
29
|
+
kebab:{
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false,
|
|
34
32
|
},
|
|
35
|
-
row: {}
|
|
33
|
+
row: {},
|
|
34
|
+
actions:{
|
|
35
|
+
type: Array,
|
|
36
|
+
default: function () {
|
|
37
|
+
|
|
38
|
+
return []
|
|
39
|
+
}
|
|
40
|
+
}
|
|
36
41
|
},
|
|
37
42
|
|
|
38
43
|
setup() {
|
|
@@ -5,33 +5,31 @@
|
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script>
|
|
8
|
+
|
|
9
|
+
import { format, parseISO } from 'date-fns';
|
|
10
|
+
|
|
8
11
|
export default {
|
|
9
12
|
name: "ViGridDate",
|
|
13
|
+
inject: ['ViDateSettings'],
|
|
10
14
|
props: {
|
|
11
|
-
field: {
|
|
12
|
-
type: Object,
|
|
13
|
-
required: true
|
|
14
|
-
},
|
|
15
15
|
value: {},
|
|
16
|
+
mode:{
|
|
17
|
+
type: String,
|
|
18
|
+
validator: function (value) {
|
|
19
|
+
|
|
20
|
+
return ['date','dateTime','time'].includes(value)
|
|
21
|
+
},
|
|
22
|
+
default:'dateTime'
|
|
23
|
+
},
|
|
24
|
+
format:{
|
|
25
|
+
type: String,
|
|
26
|
+
}
|
|
16
27
|
},
|
|
28
|
+
|
|
17
29
|
computed: {
|
|
18
30
|
dateFormatted() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// if (!this.value) {
|
|
22
|
-
// return this.value;
|
|
23
|
-
// }
|
|
24
|
-
// switch (this.field.format) {
|
|
25
|
-
// case 'date':
|
|
26
|
-
// return this.$options.filters.viFormatDate(this.value);
|
|
27
|
-
//
|
|
28
|
-
// case 'time':
|
|
29
|
-
// return this.$options.filters.viFormatTime(this.value);
|
|
30
|
-
//
|
|
31
|
-
// default:
|
|
32
|
-
// return this.$options.filters.viFormatDateTime(this.value);
|
|
33
|
-
//
|
|
34
|
-
// }
|
|
31
|
+
const formatString = this.format ?? this.ViDateSettings.format[this.mode];
|
|
32
|
+
return format(parseISO(this.value), formatString);
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="vi-grid-link">
|
|
3
|
-
<a :href="row[
|
|
3
|
+
<a :href="row[link]" target="_blank" v-if="row[link]">{{value}}</a>
|
|
4
4
|
<div v-else>{{value}}</div>
|
|
5
5
|
</div>
|
|
6
6
|
</template>
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
export default {
|
|
10
10
|
name: "ViGridLink",
|
|
11
11
|
props: {
|
|
12
|
-
|
|
13
|
-
type:
|
|
12
|
+
link: {
|
|
13
|
+
type: String,
|
|
14
14
|
required: true
|
|
15
15
|
},
|
|
16
16
|
row: {
|