atom-nuxt 1.3.0 → 1.3.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/dist/module.d.mts +3 -1
- package/dist/module.json +3 -3
- package/dist/module.mjs +2 -1
- package/dist/runtime/components/AlertDisplay.vue +11 -18
- package/dist/runtime/components/AlertDisplay.vue.d.ts +2 -0
- package/dist/runtime/components/CrudAddressSearchField.vue +22 -35
- package/dist/runtime/components/CrudAddressSearchField.vue.d.ts +8 -0
- package/dist/runtime/components/CrudApiSelectorField.vue +11 -24
- package/dist/runtime/components/CrudApiSelectorField.vue.d.ts +30 -0
- package/dist/runtime/components/CrudConfirmDialog.vue +11 -17
- package/dist/runtime/components/CrudConfirmDialog.vue.d.ts +18 -0
- package/dist/runtime/components/CrudErrorDisplay.vue +3 -4
- package/dist/runtime/components/CrudErrorDisplay.vue.d.ts +6 -0
- package/dist/runtime/components/CrudFilter.vue +25 -46
- package/dist/runtime/components/CrudFilter.vue.d.ts +8 -0
- package/dist/runtime/components/CrudFilterList.vue +0 -6
- package/dist/runtime/components/CrudFilterList.vue.d.ts +5 -0
- package/dist/runtime/components/CrudFormDialog.vue +82 -24
- package/dist/runtime/components/CrudFormDialog.vue.d.ts +39 -0
- package/dist/runtime/components/CrudFormLoader.vue +127 -120
- package/dist/runtime/components/CrudFormLoader.vue.d.ts +46 -0
- package/dist/runtime/components/CrudListLoader.vue +17 -28
- package/dist/runtime/components/CrudListLoader.vue.d.ts +37 -0
- package/dist/runtime/components/CrudPaginatedLoader.vue +118 -104
- package/dist/runtime/components/CrudPaginatedLoader.vue.d.ts +83 -0
- package/dist/runtime/components/CrudUploadField.vue +6 -28
- package/dist/runtime/components/CrudUploadField.vue.d.ts +23 -0
- package/dist/runtime/components/CrudUploadFieldSelection.vue +19 -27
- package/dist/runtime/components/CrudUploadFieldSelection.vue.d.ts +18 -0
- package/dist/types.d.mts +4 -2
- package/package.json +1 -1
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -22
- package/dist/types.d.ts +0 -7
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import CrudErrorDisplay from "../components/CrudErrorDisplay.vue";
|
|
3
|
-
import {computed} from "vue";
|
|
4
|
-
import {useDisplay} from "vuetify";
|
|
5
|
-
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
import { useDisplay } from "vuetify";
|
|
5
|
+
import { useRuntimeConfig } from "#app";
|
|
6
6
|
const props = defineProps({
|
|
7
7
|
action: {
|
|
8
8
|
type: String,
|
|
@@ -94,25 +94,72 @@ const props = defineProps({
|
|
|
94
94
|
default: () => {
|
|
95
95
|
return {};
|
|
96
96
|
}
|
|
97
|
+
},
|
|
98
|
+
dialogStyle: {
|
|
99
|
+
type: String,
|
|
100
|
+
required: false,
|
|
101
|
+
default: null
|
|
102
|
+
},
|
|
103
|
+
dialogSize: {
|
|
104
|
+
type: [String, Number],
|
|
105
|
+
required: false,
|
|
106
|
+
default: null
|
|
107
|
+
},
|
|
108
|
+
createDialogSize: {
|
|
109
|
+
type: [String, Number],
|
|
110
|
+
required: false,
|
|
111
|
+
default: null
|
|
112
|
+
},
|
|
113
|
+
updateDialogSize: {
|
|
114
|
+
type: [String, Number],
|
|
115
|
+
required: false,
|
|
116
|
+
default: null
|
|
117
|
+
},
|
|
118
|
+
deleteDialogSize: {
|
|
119
|
+
type: [String, Number],
|
|
120
|
+
required: false,
|
|
121
|
+
default: null
|
|
122
|
+
},
|
|
123
|
+
viewDialogSize: {
|
|
124
|
+
type: [String, Number],
|
|
125
|
+
required: false,
|
|
126
|
+
default: null
|
|
97
127
|
}
|
|
98
128
|
});
|
|
99
129
|
const item = defineModel();
|
|
100
|
-
const dialogOpen = defineModel(
|
|
130
|
+
const dialogOpen = defineModel("dialog");
|
|
101
131
|
const hasItem = computed(() => item.value && Object.keys(item.value).length > 0);
|
|
102
|
-
|
|
103
132
|
const buttonTitle = computed(() => {
|
|
104
|
-
return props.btnText ? props.btnText :
|
|
133
|
+
return props.btnText ? props.btnText : props.action === "create" ? props.createTitle : props.action === "update" ? props.updateTitle : props.action === "delete" ? props.deleteTitle : props.action === "view" ? props.viewTitle : "";
|
|
105
134
|
});
|
|
106
|
-
|
|
107
135
|
const buttonIcon = computed(() => {
|
|
108
|
-
return props.btnIcon ? props.btnIcon :
|
|
136
|
+
return props.btnIcon ? props.btnIcon : props.action === "create" ? "mdi-plus" : props.action === "update" ? "mdi-pencil" : props.action === "delete" ? "mdi-delete" : props.action === "view" ? "mdi-eye" : "mdi-timer-sand";
|
|
109
137
|
});
|
|
110
|
-
|
|
111
138
|
const display = useDisplay();
|
|
112
139
|
const isLarge = computed(() => display.lgAndUp.value);
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
140
|
+
const readonly = computed(() => props.action === "view");
|
|
141
|
+
const atomNuxtConfig = useRuntimeConfig().public.atomNuxt;
|
|
142
|
+
const effectiveDialogStyle = computed(() => {
|
|
143
|
+
return props.dialogStyle ?? atomNuxtConfig?.defaultDialogStyle ?? "default";
|
|
144
|
+
});
|
|
145
|
+
const effectiveDialogSize = computed(() => {
|
|
146
|
+
const actionSize = props.action === "create" ? props.createDialogSize : props.action === "update" ? props.updateDialogSize : props.action === "delete" ? props.deleteDialogSize : props.action === "view" ? props.viewDialogSize : null;
|
|
147
|
+
if (actionSize) return actionSize;
|
|
148
|
+
if (props.dialogSize) return props.dialogSize;
|
|
149
|
+
return effectiveDialogStyle.value === "leaf" ? "400" : "1200";
|
|
150
|
+
});
|
|
151
|
+
const shouldUseFullscreen = computed(() => {
|
|
152
|
+
if (props.fullScreen) return true;
|
|
153
|
+
if (effectiveDialogStyle.value === "leaf") {
|
|
154
|
+
if (!isLarge.value) return true;
|
|
155
|
+
const sizeNum = typeof effectiveDialogSize.value === "string" ? parseInt(effectiveDialogSize.value) : effectiveDialogSize.value;
|
|
156
|
+
return sizeNum >= display.width.value * 0.9;
|
|
157
|
+
}
|
|
158
|
+
return !isLarge.value;
|
|
159
|
+
});
|
|
160
|
+
const dialogTransition = computed(() => {
|
|
161
|
+
return effectiveDialogStyle.value === "leaf" ? "dialog-right-transition" : "dialog-bottom-transition";
|
|
162
|
+
});
|
|
116
163
|
</script>
|
|
117
164
|
|
|
118
165
|
<template>
|
|
@@ -121,15 +168,26 @@ const readonly = computed(() => props.action === 'view');
|
|
|
121
168
|
:persistent="true"
|
|
122
169
|
:close-on-back="false"
|
|
123
170
|
v-model="dialogOpen"
|
|
124
|
-
:fullscreen="
|
|
171
|
+
:fullscreen="shouldUseFullscreen"
|
|
125
172
|
z-index="2000"
|
|
126
|
-
:max-width="isLarge && !
|
|
127
|
-
|
|
173
|
+
:max-width="effectiveDialogStyle === 'default' && isLarge && !shouldUseFullscreen ? effectiveDialogSize : ''"
|
|
174
|
+
:width="effectiveDialogStyle === 'leaf' && !shouldUseFullscreen ? effectiveDialogSize : ''"
|
|
175
|
+
:transition="dialogTransition"
|
|
176
|
+
:content-class="effectiveDialogStyle === 'leaf' ? 'leaf-dialog' : ''"
|
|
128
177
|
>
|
|
129
|
-
<v-card class="bg-white d-flex flex-column pa-0">
|
|
130
|
-
<v-toolbar>
|
|
131
|
-
<v-toolbar-items>
|
|
178
|
+
<v-card :class="['bg-white d-flex flex-column pa-0', effectiveDialogStyle === 'leaf' ? 'leaf-card' : '']">
|
|
179
|
+
<v-toolbar :class="effectiveDialogStyle === 'leaf' ? 'leaf-toolbar' : ''">
|
|
180
|
+
<v-toolbar-items :class="effectiveDialogStyle === 'leaf' ? 'leaf-toolbar-items' : ''">
|
|
132
181
|
<v-btn
|
|
182
|
+
v-if="effectiveDialogStyle === 'leaf'"
|
|
183
|
+
icon="mdi-close"
|
|
184
|
+
variant="flat"
|
|
185
|
+
color="light"
|
|
186
|
+
class="leaf-close-btn"
|
|
187
|
+
@click="dialogOpen = false"
|
|
188
|
+
></v-btn>
|
|
189
|
+
<v-btn
|
|
190
|
+
v-else
|
|
133
191
|
color="error"
|
|
134
192
|
variant="flat"
|
|
135
193
|
@click="dialogOpen = false"
|
|
@@ -137,15 +195,15 @@ const readonly = computed(() => props.action === 'view');
|
|
|
137
195
|
<v-icon color="white" icon="mdi-close"></v-icon>
|
|
138
196
|
</v-btn>
|
|
139
197
|
</v-toolbar-items>
|
|
140
|
-
<v-toolbar-title v-if="itemPending">
|
|
198
|
+
<v-toolbar-title v-if="itemPending" :class="effectiveDialogStyle === 'leaf' ? 'font-weight-bold' : ''">
|
|
141
199
|
Loading
|
|
142
200
|
</v-toolbar-title>
|
|
143
|
-
<v-toolbar-title v-else>{{
|
|
201
|
+
<v-toolbar-title v-else :class="effectiveDialogStyle === 'leaf' ? 'font-weight-bold' : ''">{{
|
|
144
202
|
action === 'create' ? createTitle : (action === 'update' ? updateTitle : (action === 'delete' ? deleteTitle : (action === 'view' ? viewTitle : '')))
|
|
145
203
|
}}
|
|
146
204
|
</v-toolbar-title>
|
|
147
205
|
</v-toolbar>
|
|
148
|
-
<div class="pa-5 d-flex flex-column flex-
|
|
206
|
+
<div :class="['pa-5 d-flex flex-column justify-start', effectiveDialogStyle === 'leaf' ? 'flex-grow-1 overflow-y-auto' : 'flex-fill overflow-scroll']">
|
|
149
207
|
<div>
|
|
150
208
|
<crud-error-display class="mb-5" :errors="formErrors"></crud-error-display>
|
|
151
209
|
<crud-error-display class="mb-5" :errors="itemErrors"></crud-error-display>
|
|
@@ -172,7 +230,7 @@ const readonly = computed(() => props.action === 'view');
|
|
|
172
230
|
</suspense>
|
|
173
231
|
</div>
|
|
174
232
|
</div>
|
|
175
|
-
<v-card-actions v-if="!hideActions && action !== 'view'" class="pa-0 border-t pa-4 elevation-5">
|
|
233
|
+
<v-card-actions v-if="!hideActions && action !== 'view'" :class="['pa-0 border-t pa-4 elevation-5', effectiveDialogStyle === 'leaf' ? 'flex-shrink-0' : '']">
|
|
176
234
|
<v-btn
|
|
177
235
|
size="large"
|
|
178
236
|
class="px-5"
|
|
@@ -192,6 +250,6 @@ const readonly = computed(() => props.action === 'view');
|
|
|
192
250
|
</v-dialog>
|
|
193
251
|
</template>
|
|
194
252
|
|
|
195
|
-
<style
|
|
196
|
-
|
|
253
|
+
<style>
|
|
254
|
+
.leaf-dialog,.leaf-dialog .v-overlay__content{align-items:stretch!important;bottom:0!important;display:flex!important;height:100vh!important;margin:0!important;max-height:100vh!important;position:fixed!important;right:0!important;top:0!important}.leaf-card{border-radius:0!important;height:100vh!important;max-height:100vh!important}.leaf-toolbar{background-color:#fff!important;border-bottom:1px solid rgba(0,0,0,.08)!important;box-shadow:0 1px 3px rgba(0,0,0,.04)!important}.leaf-toolbar-items{align-items:center!important;display:flex!important;padding:8px 4px 8px 8px!important}.leaf-close-btn{border-radius:50%!important;height:40px!important;min-height:40px!important;min-width:40px!important;transition:background-color .2s ease,color .2s ease;width:40px!important}.leaf-close-btn .v-icon{color:rgb(var(--v-theme-error))!important;transition:color .2s ease}.leaf-close-btn:hover{background-color:rgb(var(--v-theme-error))!important}.leaf-close-btn:hover .v-icon{color:#fff!important}.dialog-right-transition-enter-active,.dialog-right-transition-leave-active{transition:transform .3s cubic-bezier(.25,.8,.25,1)}.dialog-right-transition-enter-from,.dialog-right-transition-leave-to{transform:translateX(100%)}.dialog-right-transition-enter-to,.dialog-right-transition-leave-from{transform:translateX(0)}
|
|
197
255
|
</style>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
2
|
+
export default _default;
|
|
3
|
+
type __VLS_WithSlots<T, S> = T & (new () => {
|
|
4
|
+
$slots: S;
|
|
5
|
+
});
|
|
6
|
+
declare const __VLS_component: import("vue").DefineComponent<{}, {
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
action: string;
|
|
9
|
+
formErrors: Record<string, any>;
|
|
10
|
+
itemErrors: Record<string, any>;
|
|
11
|
+
formPending: boolean;
|
|
12
|
+
itemPending: boolean;
|
|
13
|
+
createTitle: string;
|
|
14
|
+
updateTitle: string;
|
|
15
|
+
deleteTitle: string;
|
|
16
|
+
viewTitle: string;
|
|
17
|
+
saveAction: Function;
|
|
18
|
+
btnIcon: string;
|
|
19
|
+
btnColor: string;
|
|
20
|
+
fullScreen: boolean;
|
|
21
|
+
hideActions: boolean;
|
|
22
|
+
originalItem: Record<string, any>;
|
|
23
|
+
dialogStyle: string;
|
|
24
|
+
dialogSize: string | number;
|
|
25
|
+
createDialogSize: string | number;
|
|
26
|
+
updateDialogSize: string | number;
|
|
27
|
+
deleteDialogSize: string | number;
|
|
28
|
+
viewDialogSize: string | number;
|
|
29
|
+
btnText?: string | undefined;
|
|
30
|
+
$props: any;
|
|
31
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
32
|
+
type __VLS_Slots = {
|
|
33
|
+
default?: ((props: {
|
|
34
|
+
action: any;
|
|
35
|
+
readonly: any;
|
|
36
|
+
item: any;
|
|
37
|
+
errors: any;
|
|
38
|
+
}) => any) | undefined;
|
|
39
|
+
};
|
|
@@ -1,102 +1,124 @@
|
|
|
1
1
|
<script setup async>
|
|
2
|
-
import { computed, watch } from
|
|
3
|
-
import { useCrudConverters } from
|
|
4
|
-
import { useCrudApi } from
|
|
5
|
-
import { useListenerService } from
|
|
6
|
-
import CrudFormDialog from
|
|
7
|
-
import { useRoute, useRouter } from
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const emits = defineEmits(['update', 'delete', 'create'])
|
|
12
|
-
|
|
2
|
+
import { computed, watch } from "vue";
|
|
3
|
+
import { useCrudConverters } from "../composables/useCrudConverters";
|
|
4
|
+
import { useCrudApi } from "../composables/useCrudApi";
|
|
5
|
+
import { useListenerService } from "../composables/useListenerService";
|
|
6
|
+
import CrudFormDialog from "./CrudFormDialog.vue";
|
|
7
|
+
import { useRoute, useRouter } from "#app";
|
|
8
|
+
const { cloneDeep } = useCrudConverters();
|
|
9
|
+
const emits = defineEmits(["update", "delete", "create"]);
|
|
13
10
|
const props = defineProps({
|
|
14
11
|
loaderKey: {
|
|
15
12
|
type: String,
|
|
16
|
-
required: false
|
|
13
|
+
required: false
|
|
17
14
|
},
|
|
18
15
|
initialItem: {
|
|
19
16
|
type: Object,
|
|
20
|
-
required: false
|
|
17
|
+
required: false
|
|
21
18
|
},
|
|
22
19
|
path: {
|
|
23
20
|
type: String,
|
|
24
|
-
required: true
|
|
21
|
+
required: true
|
|
25
22
|
},
|
|
26
23
|
allowCreate: {
|
|
27
24
|
type: Boolean,
|
|
28
|
-
default: false
|
|
25
|
+
default: false
|
|
29
26
|
},
|
|
30
27
|
hideFilters: {
|
|
31
28
|
type: Boolean,
|
|
32
|
-
default: false
|
|
29
|
+
default: false
|
|
33
30
|
},
|
|
34
31
|
title: {
|
|
35
32
|
type: String,
|
|
36
|
-
required: false
|
|
33
|
+
required: false
|
|
37
34
|
},
|
|
38
35
|
transformItem: {
|
|
39
36
|
type: Function,
|
|
40
|
-
required: false
|
|
37
|
+
required: false
|
|
41
38
|
},
|
|
42
39
|
transformItems: {
|
|
43
40
|
type: Function,
|
|
44
|
-
required: false
|
|
41
|
+
required: false
|
|
45
42
|
},
|
|
46
43
|
beforeSave: {
|
|
47
44
|
type: Function,
|
|
48
|
-
required: false
|
|
45
|
+
required: false
|
|
49
46
|
},
|
|
50
47
|
beforeCreate: {
|
|
51
48
|
type: Function,
|
|
52
|
-
required: false
|
|
49
|
+
required: false
|
|
53
50
|
},
|
|
54
51
|
beforeUpdate: {
|
|
55
52
|
type: Function,
|
|
56
|
-
required: false
|
|
53
|
+
required: false
|
|
57
54
|
},
|
|
58
55
|
beforeDelete: {
|
|
59
56
|
type: Function,
|
|
60
|
-
required: false
|
|
57
|
+
required: false
|
|
61
58
|
},
|
|
62
59
|
updateTitle: {
|
|
63
60
|
type: String,
|
|
64
61
|
required: false,
|
|
65
62
|
default() {
|
|
66
|
-
return
|
|
67
|
-
}
|
|
63
|
+
return "Update item";
|
|
64
|
+
}
|
|
68
65
|
},
|
|
69
66
|
deleteTitle: {
|
|
70
67
|
type: String,
|
|
71
68
|
required: false,
|
|
72
69
|
default() {
|
|
73
|
-
return
|
|
74
|
-
}
|
|
70
|
+
return "Delete item";
|
|
71
|
+
}
|
|
75
72
|
},
|
|
76
73
|
createTitle: {
|
|
77
74
|
type: String,
|
|
78
75
|
required: false,
|
|
79
76
|
default() {
|
|
80
|
-
return
|
|
81
|
-
}
|
|
77
|
+
return "Create item";
|
|
78
|
+
}
|
|
82
79
|
},
|
|
83
80
|
customFilters: {
|
|
84
81
|
type: Object,
|
|
85
82
|
required: false,
|
|
86
83
|
default: () => {
|
|
87
|
-
}
|
|
84
|
+
}
|
|
88
85
|
},
|
|
89
86
|
await: {
|
|
90
87
|
type: Boolean,
|
|
91
88
|
required: false,
|
|
92
|
-
default: false
|
|
89
|
+
default: false
|
|
93
90
|
},
|
|
94
91
|
listeners: {
|
|
95
92
|
type: Array,
|
|
96
93
|
required: false,
|
|
97
|
-
default: () => []
|
|
94
|
+
default: () => []
|
|
95
|
+
},
|
|
96
|
+
dialogStyle: {
|
|
97
|
+
type: String,
|
|
98
|
+
required: false,
|
|
99
|
+
default: null
|
|
100
|
+
},
|
|
101
|
+
dialogSize: {
|
|
102
|
+
type: [String, Number],
|
|
103
|
+
required: false,
|
|
104
|
+
default: null
|
|
98
105
|
},
|
|
99
|
-
|
|
106
|
+
createDialogSize: {
|
|
107
|
+
type: [String, Number],
|
|
108
|
+
required: false,
|
|
109
|
+
default: null
|
|
110
|
+
},
|
|
111
|
+
updateDialogSize: {
|
|
112
|
+
type: [String, Number],
|
|
113
|
+
required: false,
|
|
114
|
+
default: null
|
|
115
|
+
},
|
|
116
|
+
deleteDialogSize: {
|
|
117
|
+
type: [String, Number],
|
|
118
|
+
required: false,
|
|
119
|
+
default: null
|
|
120
|
+
}
|
|
121
|
+
});
|
|
100
122
|
const {
|
|
101
123
|
getItem,
|
|
102
124
|
updateItem,
|
|
@@ -106,122 +128,106 @@ const {
|
|
|
106
128
|
formErrors,
|
|
107
129
|
formPending,
|
|
108
130
|
itemErrors,
|
|
109
|
-
itemPending
|
|
110
|
-
} = useCrudApi(props.path, false, props.transformItem, props.transformItems)
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
const action = computed(() => route.query[(props.loaderKey ?? '') + 'action'])
|
|
116
|
-
const actionId = computed(() => route.query[(props.loaderKey ?? '') + 'actionId'])
|
|
117
|
-
|
|
131
|
+
itemPending
|
|
132
|
+
} = useCrudApi(props.path, false, props.transformItem, props.transformItems);
|
|
133
|
+
const route = useRoute();
|
|
134
|
+
const router = useRouter();
|
|
135
|
+
const action = computed(() => route.query[(props.loaderKey ?? "") + "action"]);
|
|
136
|
+
const actionId = computed(() => route.query[(props.loaderKey ?? "") + "actionId"]);
|
|
118
137
|
const dialogOpen = computed({
|
|
119
|
-
get: () => !!(action.value ===
|
|
138
|
+
get: () => !!(action.value === "create" || action.value === "update" && actionId.value || action.value === "delete" && actionId.value),
|
|
120
139
|
set: (value) => {
|
|
121
140
|
if (!value) {
|
|
122
141
|
if (router.options.history.state.back) {
|
|
123
|
-
router.back()
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const currentQuery = route.query
|
|
142
|
+
router.back();
|
|
143
|
+
} else {
|
|
144
|
+
const currentQuery = route.query;
|
|
127
145
|
if (props.loaderKey) {
|
|
128
|
-
delete
|
|
129
|
-
delete
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
delete currentQuery.
|
|
133
|
-
delete currentQuery.actionId
|
|
146
|
+
delete currentQuery[(props.loaderKey ?? "") + "action"];
|
|
147
|
+
delete currentQuery[(props.loaderKey ?? "") + "actionId"];
|
|
148
|
+
} else {
|
|
149
|
+
delete currentQuery.action;
|
|
150
|
+
delete currentQuery.actionId;
|
|
134
151
|
}
|
|
135
|
-
router.replace({ ...route, query: currentQuery })
|
|
152
|
+
router.replace({ ...route, query: currentQuery });
|
|
136
153
|
}
|
|
137
154
|
}
|
|
138
|
-
}
|
|
139
|
-
})
|
|
155
|
+
}
|
|
156
|
+
});
|
|
140
157
|
const updateForm = async (id) => {
|
|
141
|
-
const newQuery = { query: { ...route.query } }
|
|
158
|
+
const newQuery = { query: { ...route.query } };
|
|
142
159
|
if (props.loaderKey) {
|
|
143
|
-
newQuery.query[(props.loaderKey ??
|
|
144
|
-
newQuery.query[(props.loaderKey ??
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
newQuery.query.
|
|
148
|
-
newQuery.query.actionId = id
|
|
160
|
+
newQuery.query[(props.loaderKey ?? "") + "action"] = "update";
|
|
161
|
+
newQuery.query[(props.loaderKey ?? "") + "actionId"] = id;
|
|
162
|
+
} else {
|
|
163
|
+
newQuery.query.action = "update";
|
|
164
|
+
newQuery.query.actionId = id;
|
|
149
165
|
}
|
|
150
|
-
await router.push(newQuery)
|
|
151
|
-
}
|
|
166
|
+
await router.push(newQuery);
|
|
167
|
+
};
|
|
152
168
|
const deleteForm = async (id) => {
|
|
153
|
-
const newQuery = { query: { ...route.query } }
|
|
169
|
+
const newQuery = { query: { ...route.query } };
|
|
154
170
|
if (props.loaderKey) {
|
|
155
|
-
newQuery.query[(props.loaderKey ??
|
|
156
|
-
newQuery.query[(props.loaderKey ??
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
newQuery.query.
|
|
160
|
-
newQuery.query.actionId = id
|
|
171
|
+
newQuery.query[(props.loaderKey ?? "") + "action"] = "delete";
|
|
172
|
+
newQuery.query[(props.loaderKey ?? "") + "actionId"] = id;
|
|
173
|
+
} else {
|
|
174
|
+
newQuery.query.action = "delete";
|
|
175
|
+
newQuery.query.actionId = id;
|
|
161
176
|
}
|
|
162
|
-
await router.push(newQuery)
|
|
163
|
-
}
|
|
177
|
+
await router.push(newQuery);
|
|
178
|
+
};
|
|
164
179
|
const createForm = () => {
|
|
165
|
-
item.value = props.initialItem ? cloneDeep(props.initialItem) : {}
|
|
166
|
-
const newQuery = { query: { ...route.query } }
|
|
180
|
+
item.value = props.initialItem ? cloneDeep(props.initialItem) : {};
|
|
181
|
+
const newQuery = { query: { ...route.query } };
|
|
167
182
|
if (props.loaderKey) {
|
|
168
|
-
newQuery.query[(props.loaderKey ??
|
|
183
|
+
newQuery.query[(props.loaderKey ?? "") + "action"] = "create";
|
|
184
|
+
} else {
|
|
185
|
+
newQuery.query.action = "create";
|
|
169
186
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
router.push(newQuery)
|
|
174
|
-
}
|
|
175
|
-
|
|
187
|
+
router.push(newQuery);
|
|
188
|
+
};
|
|
176
189
|
const saveAction = async () => {
|
|
177
|
-
formPending.value = true
|
|
178
|
-
let itemToSave = JSON.parse(JSON.stringify(item.value))
|
|
190
|
+
formPending.value = true;
|
|
191
|
+
let itemToSave = JSON.parse(JSON.stringify(item.value));
|
|
179
192
|
if (props.beforeSave != null) {
|
|
180
|
-
itemToSave = await props.beforeSave(itemToSave)
|
|
193
|
+
itemToSave = await props.beforeSave(itemToSave);
|
|
181
194
|
}
|
|
182
|
-
if (action.value ===
|
|
195
|
+
if (action.value === "create") {
|
|
183
196
|
if (props.beforeCreate != null) {
|
|
184
|
-
itemToSave = await props.beforeCreate(itemToSave)
|
|
197
|
+
itemToSave = await props.beforeCreate(itemToSave);
|
|
185
198
|
}
|
|
186
|
-
await createItem(itemToSave)
|
|
187
|
-
}
|
|
188
|
-
else if (action.value === 'update') {
|
|
199
|
+
await createItem(itemToSave);
|
|
200
|
+
} else if (action.value === "update") {
|
|
189
201
|
if (props.beforeUpdate != null) {
|
|
190
|
-
itemToSave = await props.beforeUpdate(itemToSave)
|
|
202
|
+
itemToSave = await props.beforeUpdate(itemToSave);
|
|
191
203
|
}
|
|
192
|
-
await updateItem(itemToSave.id, itemToSave)
|
|
193
|
-
}
|
|
194
|
-
else if (action.value === 'delete') {
|
|
204
|
+
await updateItem(itemToSave.id, itemToSave);
|
|
205
|
+
} else if (action.value === "delete") {
|
|
195
206
|
if (props.beforeDelete != null) {
|
|
196
|
-
itemToSave = await props.beforeDelete(itemToSave)
|
|
207
|
+
itemToSave = await props.beforeDelete(itemToSave);
|
|
197
208
|
}
|
|
198
|
-
await deleteItem(itemToSave.id)
|
|
209
|
+
await deleteItem(itemToSave.id);
|
|
199
210
|
}
|
|
200
211
|
if (formErrors.value == null || Object.keys(formErrors.value).length === 0) {
|
|
201
|
-
emits(action.value,itemToSave);
|
|
202
|
-
notify(props.path +
|
|
203
|
-
dialogOpen.value = false
|
|
212
|
+
emits(action.value, itemToSave);
|
|
213
|
+
notify(props.path + ":" + action.value, itemToSave);
|
|
214
|
+
dialogOpen.value = false;
|
|
204
215
|
}
|
|
205
|
-
}
|
|
206
|
-
|
|
216
|
+
};
|
|
207
217
|
watch(action, () => {
|
|
208
218
|
try {
|
|
209
|
-
if (action.value ===
|
|
210
|
-
getItem(actionId.value)
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
219
|
+
if (action.value === "update" && actionId.value) {
|
|
220
|
+
getItem(actionId.value);
|
|
221
|
+
} else if (action.value === "create") {
|
|
222
|
+
item.value = props.initialItem ? cloneDeep(props.initialItem) : {};
|
|
223
|
+
} else if (action.value === "delete" && actionId.value) {
|
|
224
|
+
getItem(actionId.value);
|
|
214
225
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
catch (error) {
|
|
220
|
-
console.error('Error in actionId watcher:', error)
|
|
226
|
+
} catch (error) {
|
|
227
|
+
console.error("Error in actionId watcher:", error);
|
|
221
228
|
}
|
|
222
|
-
}, { immediate: true })
|
|
223
|
-
|
|
224
|
-
const { notify } = useListenerService()
|
|
229
|
+
}, { immediate: true });
|
|
230
|
+
const { notify } = useListenerService();
|
|
225
231
|
</script>
|
|
226
232
|
|
|
227
233
|
<template>
|
|
@@ -245,6 +251,11 @@ const { notify } = useListenerService()
|
|
|
245
251
|
:update-title="updateTitle"
|
|
246
252
|
:delete-title="deleteTitle"
|
|
247
253
|
:save-action="saveAction"
|
|
254
|
+
:dialog-style="dialogStyle"
|
|
255
|
+
:dialog-size="dialogSize"
|
|
256
|
+
:create-dialog-size="createDialogSize"
|
|
257
|
+
:update-dialog-size="updateDialogSize"
|
|
258
|
+
:delete-dialog-size="deleteDialogSize"
|
|
248
259
|
>
|
|
249
260
|
<slot
|
|
250
261
|
name="form"
|
|
@@ -255,7 +266,3 @@ const { notify } = useListenerService()
|
|
|
255
266
|
</crud-form-dialog>
|
|
256
267
|
</div>
|
|
257
268
|
</template>
|
|
258
|
-
|
|
259
|
-
<style scoped>
|
|
260
|
-
|
|
261
|
-
</style>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
2
|
+
export default _default;
|
|
3
|
+
type __VLS_WithSlots<T, S> = T & (new () => {
|
|
4
|
+
$slots: S;
|
|
5
|
+
});
|
|
6
|
+
declare const __VLS_component: import("vue").DefineComponent<{}, {
|
|
7
|
+
$emit: (event: "delete" | "create" | "update", ...args: any[]) => void;
|
|
8
|
+
path: string;
|
|
9
|
+
customFilters: Record<string, any>;
|
|
10
|
+
await: boolean;
|
|
11
|
+
listeners: unknown[];
|
|
12
|
+
createTitle: string;
|
|
13
|
+
updateTitle: string;
|
|
14
|
+
deleteTitle: string;
|
|
15
|
+
dialogStyle: string;
|
|
16
|
+
dialogSize: string | number;
|
|
17
|
+
createDialogSize: string | number;
|
|
18
|
+
updateDialogSize: string | number;
|
|
19
|
+
deleteDialogSize: string | number;
|
|
20
|
+
allowCreate: boolean;
|
|
21
|
+
hideFilters: boolean;
|
|
22
|
+
title?: string | undefined;
|
|
23
|
+
loaderKey?: string | undefined;
|
|
24
|
+
initialItem?: Record<string, any> | undefined;
|
|
25
|
+
transformItem?: Function | undefined;
|
|
26
|
+
transformItems?: Function | undefined;
|
|
27
|
+
beforeSave?: Function | undefined;
|
|
28
|
+
beforeCreate?: Function | undefined;
|
|
29
|
+
beforeUpdate?: Function | undefined;
|
|
30
|
+
beforeDelete?: Function | undefined;
|
|
31
|
+
$props: any;
|
|
32
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
33
|
+
type __VLS_Slots = {
|
|
34
|
+
default?: ((props: {
|
|
35
|
+
createAction: any;
|
|
36
|
+
updateAction: any;
|
|
37
|
+
deleteAction: any;
|
|
38
|
+
formPending: any;
|
|
39
|
+
}) => any) | undefined;
|
|
40
|
+
} & {
|
|
41
|
+
form?: ((props: {
|
|
42
|
+
action: any;
|
|
43
|
+
item: any;
|
|
44
|
+
errors: any;
|
|
45
|
+
}) => any) | undefined;
|
|
46
|
+
};
|