@drax/dashboard-vue 0.39.0 → 0.42.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 +4 -4
- package/src/components/DashboardView/DashboardView.vue +2 -3
- package/src/components/GroupByCard/GroupByCard.vue +12 -2
- package/src/components/GroupByCard/renders/GroupByBarsRender.vue +1 -1
- package/src/components/GroupByCard/renders/GroupByGalleryRender.vue +1 -1
- package/src/components/GroupByCard/renders/GroupByPieRender.vue +1 -1
- package/src/components/GroupByCard/renders/GroupByTableRender.vue +1 -1
- package/src/composables/UseDashboardCard.ts +10 -3
- package/src/cruds/DashboardCrud.ts +2 -2
- package/src/index.ts +5 -0
- package/src/stores/UseDashboardStore.ts +8 -8
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.42.2",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./src/index.ts",
|
|
9
9
|
"module": "./src/index.ts",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"format": "prettier --write src/"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@drax/crud-front": "^0.
|
|
28
|
-
"@drax/crud-share": "^0.
|
|
27
|
+
"@drax/crud-front": "^0.42.2",
|
|
28
|
+
"@drax/crud-share": "^0.42.2"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"pinia": "^2.2.2",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"vue-tsc": "^2.0.11",
|
|
63
63
|
"vuetify": "^3.7.1"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "6b4f9f50a8e3f0fbdaff7ec913356834a4e2c0b5"
|
|
66
66
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type {PropType} from "vue";
|
|
3
|
-
import type {
|
|
3
|
+
import type {IDashboardBase} from "@drax/dashboard-share";
|
|
4
4
|
import GroupByCard from "../GroupByCard/GroupByCard.vue";
|
|
5
5
|
import PaginateCard from "../PaginateCard/PaginateCard.vue";
|
|
6
6
|
|
|
7
7
|
const {dashboard} = defineProps({
|
|
8
|
-
dashboard: {type: Object as PropType<
|
|
8
|
+
dashboard: {type: Object as PropType<IDashboardBase>, required: true},
|
|
9
9
|
})
|
|
10
10
|
|
|
11
11
|
</script>
|
|
@@ -13,7 +13,6 @@ const {dashboard} = defineProps({
|
|
|
13
13
|
<template>
|
|
14
14
|
<v-card v-if="dashboard" class="mt-3" >
|
|
15
15
|
<v-card-title>{{dashboard.title}}</v-card-title>
|
|
16
|
-
<v-card-subtitle>{{dashboard.identifier}}</v-card-subtitle>
|
|
17
16
|
<v-card-text>
|
|
18
17
|
<v-row>
|
|
19
18
|
<v-col v-for="(card,i) in dashboard.cards" :key="i"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type
|
|
2
|
+
import {type PropType, watch} from "vue";
|
|
3
3
|
import type {IDashboardCard} from "@drax/dashboard-share";
|
|
4
4
|
import {useDashboardCard} from "../../composables/UseDashboardCard";
|
|
5
5
|
import GroupByTableRender from "./renders/GroupByTableRender.vue";
|
|
@@ -17,10 +17,20 @@ const {fetchGroupByData, groupByHeaders, cardEntityFields} = useDashboardCard(ca
|
|
|
17
17
|
|
|
18
18
|
const data = ref<any[]>()
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
const loadData = async () => {
|
|
21
21
|
data.value = await fetchGroupByData()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
onMounted(async ()=> {
|
|
25
|
+
await loadData()
|
|
22
26
|
})
|
|
23
27
|
|
|
28
|
+
watch(() => card, async () => {
|
|
29
|
+
await loadData()
|
|
30
|
+
}, { deep: true })
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
24
34
|
</script>
|
|
25
35
|
|
|
26
36
|
<template>
|
|
@@ -58,7 +58,7 @@ const chartData = computed(() => {
|
|
|
58
58
|
|
|
59
59
|
let formattedValue = ''
|
|
60
60
|
|
|
61
|
-
if (field.type
|
|
61
|
+
if (['ref','object'].includes(field.type) && field.refDisplay && value) {
|
|
62
62
|
formattedValue = value[field.refDisplay]
|
|
63
63
|
} else if (field.type === 'date' && value) {
|
|
64
64
|
formattedValue = formatDateByUnit(value, dateFormat)
|
|
@@ -49,7 +49,7 @@ const cardData = computed(() => {
|
|
|
49
49
|
|
|
50
50
|
let formattedValue = ''
|
|
51
51
|
|
|
52
|
-
if (field.type
|
|
52
|
+
if (['ref','object'].includes(field.type) && field.refDisplay && value) {
|
|
53
53
|
formattedValue = value[field.refDisplay]
|
|
54
54
|
} else if (field.type === 'date' && value) {
|
|
55
55
|
formattedValue = formatDateByUnit(value, dateFormat)
|
|
@@ -51,7 +51,7 @@ const chartData = computed(() => {
|
|
|
51
51
|
|
|
52
52
|
let formattedValue = ''
|
|
53
53
|
|
|
54
|
-
if (field.type
|
|
54
|
+
if (['ref','object'].includes(field.type) && field.refDisplay && value) {
|
|
55
55
|
formattedValue = value[field.refDisplay]
|
|
56
56
|
} else if (field.type === 'date' && value) {
|
|
57
57
|
formattedValue = formatDateByUnit(value, dateFormat)
|
|
@@ -45,7 +45,7 @@ const getPercentage = (count: number) => {
|
|
|
45
45
|
:key="field.name"
|
|
46
46
|
v-slot:[`item.${field.name}`]="{ value }"
|
|
47
47
|
>
|
|
48
|
-
<template v-if="field.type
|
|
48
|
+
<template v-if="['ref','object'].includes(field.type) && field.refDisplay">
|
|
49
49
|
{{value[field.refDisplay]}}
|
|
50
50
|
</template>
|
|
51
51
|
<template v-else-if="field.type === 'date'">
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {computed} from 'vue'
|
|
2
|
-
import {
|
|
2
|
+
import {useEntityStore} from "@drax/crud-vue";
|
|
3
3
|
import type {IDashboardCard} from "@drax/dashboard-share";
|
|
4
4
|
import type {IDraxCrudProvider, IEntityCrud, IEntityCrudField} from "@drax/crud-share";
|
|
5
5
|
import {useI18n} from "vue-i18n";
|
|
@@ -8,11 +8,18 @@ import {useI18n} from "vue-i18n";
|
|
|
8
8
|
export function useDashboardCard(card: IDashboardCard) {
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
const store =
|
|
11
|
+
const store = useEntityStore()
|
|
12
12
|
const {t, te} = useI18n()
|
|
13
13
|
|
|
14
14
|
const cardEntity = computed<IEntityCrud>(() => {
|
|
15
|
-
|
|
15
|
+
if(card.entityInstance){
|
|
16
|
+
return card.entityInstance
|
|
17
|
+
}
|
|
18
|
+
const entityInstance = store.getEntities.find((entity: IEntityCrud) => entity.name === card.entity)
|
|
19
|
+
if(!entityInstance){
|
|
20
|
+
throw new Error(`Entity "${card.entity}" not found in entities DashboardStore`)
|
|
21
|
+
}
|
|
22
|
+
return entityInstance
|
|
16
23
|
})
|
|
17
24
|
|
|
18
25
|
const cardEntityFields = computed<IEntityCrudField[]>(() => {
|
|
@@ -10,7 +10,7 @@ import type {
|
|
|
10
10
|
IEntityCrudRules
|
|
11
11
|
} from "@drax/crud-share";
|
|
12
12
|
import {DashboardProvider} from "@drax/dashboard-front";
|
|
13
|
-
import {
|
|
13
|
+
import {useEntityStore} from "@drax/crud-vue";
|
|
14
14
|
|
|
15
15
|
//Import EntityCrud Refs
|
|
16
16
|
|
|
@@ -81,7 +81,7 @@ class DashboardCrud extends EntityCrud implements IEntityCrud {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
get entities(){
|
|
84
|
-
const dashboardStore =
|
|
84
|
+
const dashboardStore = useEntityStore();
|
|
85
85
|
return dashboardStore.entities.map((entity: any) => entity.name)
|
|
86
86
|
}
|
|
87
87
|
|
package/src/index.ts
CHANGED
|
@@ -2,12 +2,15 @@ import {DashboardCrudRoute} from './routes/DashboardCrudRoute'
|
|
|
2
2
|
import DashboardCrudPage from './pages/crud/DashboardCrudPage.vue'
|
|
3
3
|
import DashboardViewPage from './pages/DashboardViewPage.vue'
|
|
4
4
|
import DashboardView from './components/DashboardView/DashboardView.vue'
|
|
5
|
+
import GroupByCard from './components/GroupByCard/GroupByCard.vue'
|
|
6
|
+
import PaginateCard from './components/PaginateCard/PaginateCard.vue'
|
|
5
7
|
import DashboardCombobox from './combobox/DashboardCombobox.vue'
|
|
6
8
|
import {useDashboardCard} from './composables/UseDashboardCard'
|
|
7
9
|
import {useDashboardStore} from './stores/UseDashboardStore'
|
|
8
10
|
import DashboardCrud from './cruds/DashboardCrud'
|
|
9
11
|
|
|
10
12
|
|
|
13
|
+
|
|
11
14
|
export {
|
|
12
15
|
//ROUTES
|
|
13
16
|
DashboardCrudRoute,
|
|
@@ -17,6 +20,8 @@ export {
|
|
|
17
20
|
//COMPONENTS
|
|
18
21
|
DashboardView,
|
|
19
22
|
DashboardCombobox,
|
|
23
|
+
GroupByCard,
|
|
24
|
+
PaginateCard,
|
|
20
25
|
//CRUD
|
|
21
26
|
DashboardCrud,
|
|
22
27
|
//STORES
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {defineStore} from "pinia";
|
|
2
|
-
import type {
|
|
2
|
+
import type { IDashboardBase} from "@drax/dashboard-share";
|
|
3
3
|
|
|
4
4
|
export const useDashboardStore = defineStore('DashboardStore', {
|
|
5
5
|
state: () => (
|
|
6
6
|
{
|
|
7
|
-
|
|
7
|
+
dashboards: [] as IDashboardBase[],
|
|
8
8
|
|
|
9
9
|
}
|
|
10
10
|
),
|
|
11
11
|
getters: {
|
|
12
|
-
|
|
13
|
-
return state.
|
|
12
|
+
getDashboards(state: any) {
|
|
13
|
+
return state.dashboards
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
actions: {
|
|
17
|
-
|
|
18
|
-
this.
|
|
17
|
+
setDashboards(dashboards: IDashboardBase[]) {
|
|
18
|
+
this.dashboards = dashboards
|
|
19
19
|
},
|
|
20
|
-
addEntity(
|
|
21
|
-
this.
|
|
20
|
+
addEntity(dashboard: IDashboardBase) {
|
|
21
|
+
this.dashboards.push(dashboard)
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|