@sidekick-coder/zenith-kit 0.5.1 → 0.5.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/dist/client/{Icon-C-SaxixA.mjs → Icon-CV9WhwVm.js} +1 -1
- package/dist/client/client/components.d.ts +0 -2
- package/dist/client/client/composables/useLayoutOptions.d.ts +1 -1
- package/dist/client/client/contracts/events.d.ts +3 -1
- package/dist/client/client/facades/layout.d.ts +2 -1
- package/dist/client/client/facades/router.d.ts +2 -2
- package/dist/client/client/index.d.ts +2 -2
- package/dist/client/client/services/LayoutService.d.ts +15 -2
- package/dist/client/client/services/MenuService.d.ts +5 -0
- package/dist/client/client/services/RouterService.d.ts +24 -14
- package/dist/client/index.es.js +2832 -2850
- package/dist/client/styles.css +1 -1
- package/dist/components/client/components.d.ts +0 -2
- package/dist/components/client/composables/useLayoutOptions.d.ts +1 -1
- package/dist/components/client/contracts/events.d.ts +3 -1
- package/dist/components/client/facades/layout.d.ts +2 -1
- package/dist/components/client/facades/router.d.ts +2 -2
- package/dist/components/client/index.d.ts +2 -2
- package/dist/components/client/services/LayoutService.d.ts +15 -2
- package/dist/components/client/services/MenuService.d.ts +5 -0
- package/dist/components/client/services/RouterService.d.ts +24 -14
- package/dist/components/index.es.js +8683 -8840
- package/dist/components/styles.css +1 -1
- package/dist/shared/schemas/dashboardMetaSchema.d.mts +18 -18
- package/dist/shared/schemas/userSchema.d.mts +16 -16
- package/package.json +8 -13
- package/src/client/components/DataTable.vue +0 -2
- package/src/client/components/FormFileUploader.vue +6 -1
- package/src/client/components.ts +0 -2
- package/src/client/contracts/events.ts +3 -1
- package/src/client/css/styles.css +68 -38
- package/src/client/css/theme.css +2 -70
- package/src/client/facades/layout.ts +3 -6
- package/src/client/facades/router.ts +2 -2
- package/src/client/index.ts +2 -2
- package/src/client/services/LayoutService.ts +24 -8
- package/src/client/services/MenuService.ts +6 -0
- package/src/client/services/RouterService.ts +105 -91
- package/vite.client.config.ts +2 -1
- package/vite.components.config.ts +1 -1
- package/dist/client/client/components/PageCrud.vue.d.ts +0 -78
- package/dist/client/client/entities/PluginEntity.d.ts +0 -8
- package/dist/components/client/components/PageCrud.vue.d.ts +0 -78
- package/dist/components/client/entities/PluginEntity.d.ts +0 -8
- package/src/client/components/PageCrud.vue +0 -197
- package/src/client/entities/PluginEntity.ts +0 -14
|
@@ -3,134 +3,148 @@ import {
|
|
|
3
3
|
createMemoryHistory,
|
|
4
4
|
createWebHistory
|
|
5
5
|
} from 'vue-router'
|
|
6
|
-
import type { NavigationGuard, Router
|
|
6
|
+
import type { NavigationGuard, Router } from 'vue-router'
|
|
7
7
|
import type { RouteRecordRaw } from 'vue-router'
|
|
8
8
|
import type { DefineComponent } from 'vue'
|
|
9
9
|
import setupGuard from '#client/guards/setupGuard.ts'
|
|
10
|
+
import set from 'lodash-es/set.js'
|
|
10
11
|
|
|
11
|
-
export interface
|
|
12
|
-
|
|
12
|
+
export interface RouterEvents {
|
|
13
|
+
'router:registered': {
|
|
14
|
+
router: RouterService
|
|
15
|
+
}
|
|
16
|
+
'router:loaded': {
|
|
17
|
+
router: RouterService
|
|
18
|
+
}
|
|
13
19
|
}
|
|
14
20
|
|
|
15
|
-
export interface
|
|
21
|
+
export interface RouterSource {
|
|
22
|
+
files: Record<string, any>
|
|
23
|
+
prefix?: string
|
|
24
|
+
layout?: string
|
|
16
25
|
guards?: NavigationGuard[] | ((record: RouteRecordRaw) => NavigationGuard[]);
|
|
17
26
|
strip?: (string | RegExp)[];
|
|
18
27
|
exclude?: (string | RegExp)[];
|
|
19
|
-
prefix?: string;
|
|
20
28
|
refine?: (records: RouteRecordRaw[]) => RouteRecordRaw[];
|
|
21
29
|
}
|
|
22
30
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
'router:loaded': {
|
|
28
|
-
router: Router
|
|
29
|
-
}
|
|
31
|
+
interface RouterServiceOptions {
|
|
32
|
+
ssr?: boolean
|
|
33
|
+
debug?: boolean
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
export
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
for (const [filename, component] of Object.entries(imports)) {
|
|
36
|
+
export default class RouterService {
|
|
37
|
+
public static __container_entry_key = 'RouterClientService'
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
typeof rule === 'string'
|
|
39
|
-
? filename.includes(rule)
|
|
40
|
-
: rule.test(filename)
|
|
41
|
-
)) {
|
|
42
|
-
continue
|
|
43
|
-
}
|
|
39
|
+
public vueRouter: Router
|
|
44
40
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
.split('/')
|
|
48
|
-
.filter(p => p && !p.startsWith('.'))
|
|
49
|
-
.map(part => {
|
|
50
|
-
let p = part
|
|
41
|
+
constructor(options: RouterServiceOptions = {}) {
|
|
42
|
+
const ssr = options.ssr ?? false
|
|
51
43
|
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
const router = createVueRouter({
|
|
45
|
+
history: ssr ? createMemoryHistory() : createWebHistory(),
|
|
46
|
+
routes: [],
|
|
47
|
+
scrollBehavior(_to, _from, savedPosition) {
|
|
48
|
+
if (savedPosition) {
|
|
49
|
+
return savedPosition
|
|
54
50
|
}
|
|
55
51
|
|
|
56
|
-
return
|
|
57
|
-
}
|
|
52
|
+
return { top: 0 }
|
|
53
|
+
},
|
|
54
|
+
})
|
|
58
55
|
|
|
56
|
+
router.beforeEach(setupGuard)
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
parts = parts.filter(p =>
|
|
63
|
-
!options.strip!.some(rule =>
|
|
64
|
-
typeof rule === 'string'
|
|
65
|
-
? p === rule
|
|
66
|
-
: rule.test(p)
|
|
67
|
-
)
|
|
68
|
-
)
|
|
69
|
-
}
|
|
58
|
+
this.vueRouter = router
|
|
59
|
+
}
|
|
70
60
|
|
|
71
|
-
|
|
61
|
+
public addSource(source: RouterSource) {
|
|
62
|
+
const strip = source.strip || []
|
|
63
|
+
const exclude = source.exclude || []
|
|
64
|
+
const imports = source.files
|
|
72
65
|
|
|
73
|
-
|
|
74
|
-
path = options.prefix + '/' + path
|
|
75
|
-
}
|
|
66
|
+
let routes: RouteRecordRaw[] = []
|
|
76
67
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
const match = (filename: string, rule: string | RegExp) => {
|
|
69
|
+
if (typeof rule === 'string') {
|
|
70
|
+
return filename.includes(rule)
|
|
71
|
+
}
|
|
80
72
|
|
|
81
|
-
|
|
82
|
-
path = path.slice(0, -1)
|
|
73
|
+
return rule.test(filename)
|
|
83
74
|
}
|
|
84
75
|
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (options.guards && Array.isArray(options.guards)) {
|
|
92
|
-
record.beforeEnter = options.guards
|
|
93
|
-
}
|
|
76
|
+
for (const [filename, component] of Object.entries(imports)) {
|
|
77
|
+
if (exclude.some(rule => match(filename, rule))) {
|
|
78
|
+
continue
|
|
79
|
+
}
|
|
94
80
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
81
|
+
let parts = filename
|
|
82
|
+
.replace(/\.vue$/, '')
|
|
83
|
+
.split('/')
|
|
84
|
+
.filter(p => p && !p.startsWith('.'))
|
|
85
|
+
.map(part => {
|
|
86
|
+
let p = part
|
|
98
87
|
|
|
99
|
-
|
|
100
|
-
|
|
88
|
+
if (p.startsWith('[') && p.endsWith(']')) {
|
|
89
|
+
p = ':' + p.slice(1, -1)
|
|
90
|
+
}
|
|
101
91
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
92
|
+
return p
|
|
93
|
+
})
|
|
105
94
|
|
|
106
|
-
return routes
|
|
107
|
-
}
|
|
108
95
|
|
|
109
|
-
|
|
110
|
-
|
|
96
|
+
// Strip specific segments
|
|
97
|
+
if (source.strip?.length) {
|
|
98
|
+
parts = parts.filter(p => !strip.some(rule => match(p, rule)))
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let path = parts.join('/').replace(/index$/, '')
|
|
111
102
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
103
|
+
if (source.prefix) {
|
|
104
|
+
path = source.prefix + '/' + path
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!path.startsWith('/')) {
|
|
108
|
+
path = '/' + path
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (path.endsWith('/')) {
|
|
112
|
+
path = path.slice(0, -1)
|
|
120
113
|
}
|
|
121
|
-
},
|
|
122
|
-
}) as any as Router
|
|
123
114
|
|
|
124
|
-
|
|
115
|
+
const record = {
|
|
116
|
+
path: path,
|
|
117
|
+
component: component as DefineComponent,
|
|
118
|
+
beforeEnter: [] as NavigationGuard[],
|
|
119
|
+
}
|
|
125
120
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
autoRoutes.forEach(route => router.addRoute(route))
|
|
121
|
+
if (source.guards && Array.isArray(source.guards)) {
|
|
122
|
+
record.beforeEnter = source.guards
|
|
123
|
+
}
|
|
130
124
|
|
|
131
|
-
|
|
125
|
+
if (source.guards && typeof source.guards === 'function') {
|
|
126
|
+
record.beforeEnter = source.guards(record)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (source.layout) {
|
|
130
|
+
set(record, 'meta.layout', source.layout)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
routes.push(record)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (source.refine) {
|
|
137
|
+
routes = source.refine(routes)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
routes.forEach(route => this.vueRouter.addRoute(route))
|
|
132
141
|
}
|
|
133
142
|
|
|
134
|
-
|
|
135
|
-
|
|
143
|
+
public push(path: string) {
|
|
144
|
+
return this.vueRouter.push(path)
|
|
145
|
+
}
|
|
136
146
|
|
|
147
|
+
public isReady() {
|
|
148
|
+
return this.vueRouter.isReady()
|
|
149
|
+
}
|
|
150
|
+
}
|
package/vite.client.config.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLogger, defineConfig, mergeConfig } from 'vite'
|
|
2
2
|
import { generateIndexFile } from '#server/utils/generateIndexFile.ts'
|
|
3
|
-
import viteCommonConfig from './vite.common.config'
|
|
3
|
+
import viteCommonConfig from './vite.common.config.ts'
|
|
4
4
|
|
|
5
5
|
const logger = createLogger()
|
|
6
6
|
|
|
@@ -12,6 +12,7 @@ const prebuild = () => ({
|
|
|
12
12
|
folders: [
|
|
13
13
|
'src/client/services',
|
|
14
14
|
'src/client/composables',
|
|
15
|
+
'src/client/contracts',
|
|
15
16
|
'src/client/repositories',
|
|
16
17
|
'src/client/mixins',
|
|
17
18
|
'src/client/facades',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineConfig, mergeConfig } from 'vite'
|
|
2
2
|
import { generateIndexFile } from '#server/utils/generateIndexFile.ts'
|
|
3
|
-
import viteCommonConfig, { logger } from './vite.common.config'
|
|
3
|
+
import viteCommonConfig, { logger } from './vite.common.config.ts'
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
const prebuild = () => ({
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { PropType, PublicProps, ExtractPublicPropTypes, ShallowUnwrapRef, VNode } from 'vue';
|
|
2
|
-
import { DataTableColumn } from '..';
|
|
3
|
-
declare const __VLS_export: <T extends Record<string, any>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
-
props: PublicProps & __VLS_PrettifyLocal<{
|
|
5
|
-
fetchQuery?: Record<string, any> | null;
|
|
6
|
-
loading?: boolean;
|
|
7
|
-
columns?: any[];
|
|
8
|
-
fields?: any;
|
|
9
|
-
fieldsEdit?: any;
|
|
10
|
-
} & ExtractPublicPropTypes<{
|
|
11
|
-
title: {
|
|
12
|
-
type: StringConstructor;
|
|
13
|
-
default: () => string;
|
|
14
|
-
};
|
|
15
|
-
description: {
|
|
16
|
-
type: StringConstructor;
|
|
17
|
-
default: string;
|
|
18
|
-
};
|
|
19
|
-
serialize: {
|
|
20
|
-
type: PropType<(row: any) => T>;
|
|
21
|
-
default: (row: any) => T;
|
|
22
|
-
};
|
|
23
|
-
fetch: {
|
|
24
|
-
type: StringConstructor;
|
|
25
|
-
default: null;
|
|
26
|
-
};
|
|
27
|
-
fetchDestroy: {
|
|
28
|
-
type: StringConstructor;
|
|
29
|
-
default: null;
|
|
30
|
-
};
|
|
31
|
-
fetchUpdateMethod: {
|
|
32
|
-
type: StringConstructor;
|
|
33
|
-
default: string;
|
|
34
|
-
};
|
|
35
|
-
viewTo: {
|
|
36
|
-
type: StringConstructor;
|
|
37
|
-
default: null;
|
|
38
|
-
};
|
|
39
|
-
actions: {
|
|
40
|
-
type: PropType<Array<"create" | "edit" | "destroy">>;
|
|
41
|
-
default: () => string[];
|
|
42
|
-
};
|
|
43
|
-
}> & {
|
|
44
|
-
"onUpdate:loading"?: ((value: boolean) => any) | undefined;
|
|
45
|
-
"onUpdate:columns"?: ((value: any[]) => any) | undefined;
|
|
46
|
-
"onUpdate:fetchQuery"?: ((value: Record<string, any> | null) => any) | undefined;
|
|
47
|
-
"onUpdate:fields"?: ((value: any) => any) | undefined;
|
|
48
|
-
"onUpdate:fieldsEdit"?: ((value: any) => any) | undefined;
|
|
49
|
-
}> & (typeof globalThis extends {
|
|
50
|
-
__VLS_PROPS_FALLBACK: infer P;
|
|
51
|
-
} ? P : {});
|
|
52
|
-
expose: (exposed: ShallowUnwrapRef<{
|
|
53
|
-
load: () => void;
|
|
54
|
-
}>) => void;
|
|
55
|
-
attrs: any;
|
|
56
|
-
slots: {
|
|
57
|
-
[x: `row-${any}`]: ((props: {
|
|
58
|
-
column: DataTableColumn<Record<string, any>>;
|
|
59
|
-
row: Record<string, any>;
|
|
60
|
-
}) => any) | undefined;
|
|
61
|
-
} & {
|
|
62
|
-
'header-append'?: (props: {}) => any;
|
|
63
|
-
} & {
|
|
64
|
-
'prepend-actions'?: (props: {
|
|
65
|
-
row: Record<string, any>;
|
|
66
|
-
}) => any;
|
|
67
|
-
};
|
|
68
|
-
emit: ((event: "update:loading", value: boolean) => void) & ((event: "update:columns", value: any[]) => void) & ((event: "update:fetchQuery", value: Record<string, any> | null) => void) & ((event: "update:fields", value: any) => void) & ((event: "update:fieldsEdit", value: any) => void);
|
|
69
|
-
}>) => VNode & {
|
|
70
|
-
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
71
|
-
};
|
|
72
|
-
declare const _default: typeof __VLS_export;
|
|
73
|
-
export default _default;
|
|
74
|
-
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
75
|
-
[K in keyof T]: T[K];
|
|
76
|
-
} : {
|
|
77
|
-
[K in keyof T as K]: T[K];
|
|
78
|
-
}) & {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { default as Base } from '../../shared/entities/PluginEntity.ts';
|
|
2
|
-
import { AutoOptions } from '../services/RouterService.ts';
|
|
3
|
-
declare const PluginEntity_base: typeof Base;
|
|
4
|
-
export default class PluginEntity extends PluginEntity_base {
|
|
5
|
-
addPagesFolder(imports: any, options?: AutoOptions): void;
|
|
6
|
-
load(): Promise<void>;
|
|
7
|
-
}
|
|
8
|
-
export {};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { PropType, PublicProps, ExtractPublicPropTypes, ShallowUnwrapRef, VNode } from 'vue';
|
|
2
|
-
import { DataTableColumn } from '..';
|
|
3
|
-
declare const __VLS_export: <T extends Record<string, any>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
-
props: PublicProps & __VLS_PrettifyLocal<{
|
|
5
|
-
fetchQuery?: Record<string, any> | null;
|
|
6
|
-
loading?: boolean;
|
|
7
|
-
columns?: any[];
|
|
8
|
-
fields?: any;
|
|
9
|
-
fieldsEdit?: any;
|
|
10
|
-
} & ExtractPublicPropTypes<{
|
|
11
|
-
title: {
|
|
12
|
-
type: StringConstructor;
|
|
13
|
-
default: () => string;
|
|
14
|
-
};
|
|
15
|
-
description: {
|
|
16
|
-
type: StringConstructor;
|
|
17
|
-
default: string;
|
|
18
|
-
};
|
|
19
|
-
serialize: {
|
|
20
|
-
type: PropType<(row: any) => T>;
|
|
21
|
-
default: (row: any) => T;
|
|
22
|
-
};
|
|
23
|
-
fetch: {
|
|
24
|
-
type: StringConstructor;
|
|
25
|
-
default: null;
|
|
26
|
-
};
|
|
27
|
-
fetchDestroy: {
|
|
28
|
-
type: StringConstructor;
|
|
29
|
-
default: null;
|
|
30
|
-
};
|
|
31
|
-
fetchUpdateMethod: {
|
|
32
|
-
type: StringConstructor;
|
|
33
|
-
default: string;
|
|
34
|
-
};
|
|
35
|
-
viewTo: {
|
|
36
|
-
type: StringConstructor;
|
|
37
|
-
default: null;
|
|
38
|
-
};
|
|
39
|
-
actions: {
|
|
40
|
-
type: PropType<Array<"create" | "edit" | "destroy">>;
|
|
41
|
-
default: () => string[];
|
|
42
|
-
};
|
|
43
|
-
}> & {
|
|
44
|
-
"onUpdate:loading"?: ((value: boolean) => any) | undefined;
|
|
45
|
-
"onUpdate:columns"?: ((value: any[]) => any) | undefined;
|
|
46
|
-
"onUpdate:fetchQuery"?: ((value: Record<string, any> | null) => any) | undefined;
|
|
47
|
-
"onUpdate:fields"?: ((value: any) => any) | undefined;
|
|
48
|
-
"onUpdate:fieldsEdit"?: ((value: any) => any) | undefined;
|
|
49
|
-
}> & (typeof globalThis extends {
|
|
50
|
-
__VLS_PROPS_FALLBACK: infer P;
|
|
51
|
-
} ? P : {});
|
|
52
|
-
expose: (exposed: ShallowUnwrapRef<{
|
|
53
|
-
load: () => void;
|
|
54
|
-
}>) => void;
|
|
55
|
-
attrs: any;
|
|
56
|
-
slots: {
|
|
57
|
-
[x: `row-${any}`]: ((props: {
|
|
58
|
-
column: DataTableColumn<Record<string, any>>;
|
|
59
|
-
row: Record<string, any>;
|
|
60
|
-
}) => any) | undefined;
|
|
61
|
-
} & {
|
|
62
|
-
'header-append'?: (props: {}) => any;
|
|
63
|
-
} & {
|
|
64
|
-
'prepend-actions'?: (props: {
|
|
65
|
-
row: Record<string, any>;
|
|
66
|
-
}) => any;
|
|
67
|
-
};
|
|
68
|
-
emit: ((event: "update:loading", value: boolean) => void) & ((event: "update:columns", value: any[]) => void) & ((event: "update:fetchQuery", value: Record<string, any> | null) => void) & ((event: "update:fields", value: any) => void) & ((event: "update:fieldsEdit", value: any) => void);
|
|
69
|
-
}>) => VNode & {
|
|
70
|
-
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
71
|
-
};
|
|
72
|
-
declare const _default: typeof __VLS_export;
|
|
73
|
-
export default _default;
|
|
74
|
-
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
75
|
-
[K in keyof T]: T[K];
|
|
76
|
-
} : {
|
|
77
|
-
[K in keyof T as K]: T[K];
|
|
78
|
-
}) & {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { default as Base } from '../../shared/entities/PluginEntity.ts';
|
|
2
|
-
import { AutoOptions } from '../services/RouterService.ts';
|
|
3
|
-
declare const PluginEntity_base: typeof Base;
|
|
4
|
-
export default class PluginEntity extends PluginEntity_base {
|
|
5
|
-
addPagesFolder(imports: any, options?: AutoOptions): void;
|
|
6
|
-
load(): Promise<void>;
|
|
7
|
-
}
|
|
8
|
-
export {};
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts" generic="T extends Record<string, any>">
|
|
2
|
-
import { ref } from 'vue'
|
|
3
|
-
import type { PropType } from 'vue'
|
|
4
|
-
import DataTable from '#client/components/DataTable.vue'
|
|
5
|
-
import ClientOnly from '#client/components/ClientOnly.vue'
|
|
6
|
-
import ZButton from '#client/components/ZButton.vue'
|
|
7
|
-
import Icon from '#client/components/Icon.vue'
|
|
8
|
-
import ZAlertButton from '#client/components/ZAlertButton.vue'
|
|
9
|
-
import DialogForm from '#client/components/DialogForm.vue'
|
|
10
|
-
import PageTitle from '#client/components/PageTitle.vue'
|
|
11
|
-
import PageSubtitle from '#client/components/PageSubtitle.vue'
|
|
12
|
-
|
|
13
|
-
defineProps({
|
|
14
|
-
title: {
|
|
15
|
-
type: String,
|
|
16
|
-
default: () => $t('Items')
|
|
17
|
-
},
|
|
18
|
-
description: {
|
|
19
|
-
type: String,
|
|
20
|
-
default: ''
|
|
21
|
-
},
|
|
22
|
-
serialize: {
|
|
23
|
-
type: Function as PropType<(row: any) => T>,
|
|
24
|
-
default: (row: any) => row as T,
|
|
25
|
-
},
|
|
26
|
-
fetch: {
|
|
27
|
-
type: String,
|
|
28
|
-
default: null
|
|
29
|
-
},
|
|
30
|
-
fetchDestroy: {
|
|
31
|
-
type: String,
|
|
32
|
-
default: null
|
|
33
|
-
},
|
|
34
|
-
fetchUpdateMethod: {
|
|
35
|
-
type: String,
|
|
36
|
-
default: 'PUT'
|
|
37
|
-
},
|
|
38
|
-
viewTo: {
|
|
39
|
-
type: String,
|
|
40
|
-
default: null
|
|
41
|
-
},
|
|
42
|
-
actions: {
|
|
43
|
-
type: Array as PropType<Array<'create' | 'edit' | 'destroy'>> ,
|
|
44
|
-
default: () => ['create', 'edit', 'destroy'],
|
|
45
|
-
},
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
const tableRef = ref()
|
|
49
|
-
|
|
50
|
-
const fetchQuery = defineModel('fetchQuery', {
|
|
51
|
-
type: Object as PropType<Record<string, any>>,
|
|
52
|
-
default: null
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const loading = defineModel('loading', {
|
|
56
|
-
type: Boolean,
|
|
57
|
-
default: false,
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
const columns = defineModel('columns', {
|
|
61
|
-
type: Array as PropType<Array<any>>,
|
|
62
|
-
default: () => [],
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
const fields = defineModel('fields', {
|
|
66
|
-
type: Object,
|
|
67
|
-
default: () => ({}),
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
const fieldsEdit = defineModel('fieldsEdit', {
|
|
71
|
-
type: Object,
|
|
72
|
-
default: null,
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
function parse(url: string, row: any): string {
|
|
76
|
-
return url.replace(/:([a-zA-Z_]+)/g, (_, key) => row[key]) as string
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function load(){
|
|
80
|
-
tableRef.value?.load()
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
defineExpose({
|
|
84
|
-
load,
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
</script>
|
|
88
|
-
|
|
89
|
-
<template>
|
|
90
|
-
<div>
|
|
91
|
-
<div class="flex mb-4 justify-between items-center gap-4">
|
|
92
|
-
<div class="flex-1">
|
|
93
|
-
<PageTitle>
|
|
94
|
-
{{ title }}
|
|
95
|
-
</PageTitle>
|
|
96
|
-
<PageSubtitle v-if="description">
|
|
97
|
-
{{ description }}
|
|
98
|
-
</PageSubtitle>
|
|
99
|
-
</div>
|
|
100
|
-
<div class="flex items-center gap-2">
|
|
101
|
-
<ZButton
|
|
102
|
-
variant="outline"
|
|
103
|
-
size="icon"
|
|
104
|
-
:disabled="loading"
|
|
105
|
-
@click="load"
|
|
106
|
-
>
|
|
107
|
-
<Icon
|
|
108
|
-
name="RotateCcw"
|
|
109
|
-
:class="{ 'animate-spin': loading }"
|
|
110
|
-
/>
|
|
111
|
-
</ZButton>
|
|
112
|
-
<ClientOnly v-if="actions.includes('create')">
|
|
113
|
-
<DialogForm
|
|
114
|
-
:fetch
|
|
115
|
-
:title="$t('Add new')"
|
|
116
|
-
:description="$t('Fill in the details below to add a new repository')"
|
|
117
|
-
:fields="fields"
|
|
118
|
-
@submit="load"
|
|
119
|
-
>
|
|
120
|
-
<ZButton>
|
|
121
|
-
{{ $t('Add new') }}
|
|
122
|
-
</ZButton>
|
|
123
|
-
</DialogForm>
|
|
124
|
-
</ClientOnly>
|
|
125
|
-
</div>
|
|
126
|
-
</div>
|
|
127
|
-
|
|
128
|
-
<slot name="header-append" />
|
|
129
|
-
|
|
130
|
-
<DataTable
|
|
131
|
-
v-if="fetch"
|
|
132
|
-
ref="tableRef"
|
|
133
|
-
v-model:fetch-query="fetchQuery"
|
|
134
|
-
v-model:loading="loading"
|
|
135
|
-
v-model:columns="columns"
|
|
136
|
-
:fetch="fetch"
|
|
137
|
-
>
|
|
138
|
-
<template
|
|
139
|
-
v-for="c in columns.filter((c: any) => c.id !== 'actions')"
|
|
140
|
-
#[`row-${c.id}`]="slotProps"
|
|
141
|
-
:key="c.id"
|
|
142
|
-
>
|
|
143
|
-
<slot
|
|
144
|
-
:name="`row-${c.id}`"
|
|
145
|
-
v-bind="slotProps"
|
|
146
|
-
/>
|
|
147
|
-
</template>
|
|
148
|
-
|
|
149
|
-
<template #row-actions="{ row }">
|
|
150
|
-
<div class="flex items-center gap-2 justify-end">
|
|
151
|
-
<slot
|
|
152
|
-
name="prepend-actions"
|
|
153
|
-
:row="row"
|
|
154
|
-
/>
|
|
155
|
-
|
|
156
|
-
<ZButton
|
|
157
|
-
v-if="viewTo"
|
|
158
|
-
size="icon"
|
|
159
|
-
variant="ghost"
|
|
160
|
-
:to="parse(viewTo, row)"
|
|
161
|
-
>
|
|
162
|
-
<Icon name="Eye" />
|
|
163
|
-
</ZButton>
|
|
164
|
-
|
|
165
|
-
<DialogForm
|
|
166
|
-
v-if="actions.includes('edit')"
|
|
167
|
-
:fetch="parse(fetch + '/:id', row)"
|
|
168
|
-
:method="fetchUpdateMethod"
|
|
169
|
-
:title="$t('Edit')"
|
|
170
|
-
:description="$t('Fill in the details below to edit')"
|
|
171
|
-
:fields="fieldsEdit || fields"
|
|
172
|
-
:values="row"
|
|
173
|
-
@submit="load"
|
|
174
|
-
>
|
|
175
|
-
<ZButton
|
|
176
|
-
size="icon"
|
|
177
|
-
variant="ghost"
|
|
178
|
-
>
|
|
179
|
-
<Icon name="Edit" />
|
|
180
|
-
</ZButton>
|
|
181
|
-
</DialogForm>
|
|
182
|
-
|
|
183
|
-
<ZAlertButton
|
|
184
|
-
v-if="actions.includes('destroy')"
|
|
185
|
-
variant="ghost"
|
|
186
|
-
size="sm"
|
|
187
|
-
:fetch="parse(fetchDestroy || fetch, row)"
|
|
188
|
-
fetch-method="DELETE"
|
|
189
|
-
@fetched="load"
|
|
190
|
-
>
|
|
191
|
-
<Icon name="trash" />
|
|
192
|
-
</ZAlertButton>
|
|
193
|
-
</div>
|
|
194
|
-
</template>
|
|
195
|
-
</DataTable>
|
|
196
|
-
</div>
|
|
197
|
-
</template>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import Base from '#shared/entities/PluginEntity.ts'
|
|
2
|
-
import router from '#client/facades/router.ts'
|
|
3
|
-
import { composeWith } from '#shared/utils/compose.ts'
|
|
4
|
-
import type { AutoOptions } from '#client/services/RouterService.ts'
|
|
5
|
-
|
|
6
|
-
export default class PluginEntity extends composeWith(Base) {
|
|
7
|
-
public addPagesFolder(imports: any, options?: AutoOptions) {
|
|
8
|
-
router.auto(imports, options)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
public async load() {
|
|
12
|
-
// This method can be used to load additional data from the plugin's directory if needed
|
|
13
|
-
}
|
|
14
|
-
}
|