atom-nuxt 1.3.1 → 1.3.4
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 +16 -27
- package/dist/runtime/components/CrudListLoader.vue.d.ts +37 -0
- package/dist/runtime/components/CrudPaginatedLoader.vue +138 -99
- package/dist/runtime/components/CrudPaginatedLoader.vue.d.ts +89 -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,16 +1,15 @@
|
|
|
1
1
|
<script setup async>
|
|
2
|
-
import {useCrudApi} from "../composables/useCrudApi";
|
|
2
|
+
import { useCrudApi } from "../composables/useCrudApi";
|
|
3
3
|
import CrudErrorDisplay from "./CrudErrorDisplay.vue";
|
|
4
|
-
import {useListenerService} from "../composables/useListenerService";
|
|
5
|
-
import {watch, onMounted, onBeforeUnmount, ref} from "vue";
|
|
6
|
-
import {useDebounceFn} from "@vueuse/core";
|
|
7
|
-
|
|
4
|
+
import { useListenerService } from "../composables/useListenerService";
|
|
5
|
+
import { watch, onMounted, onBeforeUnmount, ref } from "vue";
|
|
6
|
+
import { useDebounceFn } from "@vueuse/core";
|
|
8
7
|
const props = defineProps({
|
|
9
|
-
debounced
|
|
8
|
+
debounced: {
|
|
10
9
|
type: Boolean,
|
|
11
|
-
default
|
|
10
|
+
default: false
|
|
12
11
|
},
|
|
13
|
-
disableNoResults
|
|
12
|
+
disableNoResults: {
|
|
14
13
|
type: Boolean,
|
|
15
14
|
default: false
|
|
16
15
|
},
|
|
@@ -37,7 +36,7 @@ const props = defineProps({
|
|
|
37
36
|
required: false,
|
|
38
37
|
default: false
|
|
39
38
|
},
|
|
40
|
-
listeners
|
|
39
|
+
listeners: {
|
|
41
40
|
type: Array,
|
|
42
41
|
required: false,
|
|
43
42
|
default: () => []
|
|
@@ -64,20 +63,16 @@ const {
|
|
|
64
63
|
totalPages,
|
|
65
64
|
hasListErrors
|
|
66
65
|
} = useCrudApi(props.path);
|
|
67
|
-
|
|
68
66
|
const debouncedGet = useDebounceFn(getItems, 500);
|
|
69
|
-
|
|
70
67
|
const lastRequest = ref(null);
|
|
71
|
-
|
|
72
68
|
const setLastRequest = () => {
|
|
73
|
-
lastRequest.value = JSON.stringify({page: props.page, perPage: props.perPage, customFilters: props.customFilters});
|
|
74
|
-
}
|
|
75
|
-
|
|
69
|
+
lastRequest.value = JSON.stringify({ page: props.page, perPage: props.perPage, customFilters: props.customFilters });
|
|
70
|
+
};
|
|
76
71
|
watch(() => props.customFilters, () => {
|
|
77
|
-
if (lastRequest.value === JSON.stringify({page: props.page, perPage: props.perPage, customFilters: props.customFilters})) {
|
|
72
|
+
if (lastRequest.value === JSON.stringify({ page: props.page, perPage: props.perPage, customFilters: props.customFilters })) {
|
|
78
73
|
return;
|
|
79
74
|
}
|
|
80
|
-
if(props.debounced) {
|
|
75
|
+
if (props.debounced) {
|
|
81
76
|
debouncedGet(props.page, props.perPage, props.customFilters);
|
|
82
77
|
} else {
|
|
83
78
|
getItems(props.page, props.perPage, props.customFilters);
|
|
@@ -87,27 +82,25 @@ watch(() => props.customFilters, () => {
|
|
|
87
82
|
watch(() => props.page, () => {
|
|
88
83
|
getItems(props.page, props.perPage, props.customFilters);
|
|
89
84
|
});
|
|
90
|
-
if(props.await) {
|
|
85
|
+
if (props.await) {
|
|
91
86
|
await getItems(props.page, props.perPage, props.customFilters);
|
|
92
87
|
} else {
|
|
93
88
|
getItems(props.page, props.perPage, props.customFilters);
|
|
94
89
|
}
|
|
95
90
|
setLastRequest();
|
|
96
|
-
|
|
97
|
-
const {addListener, removeLocalListenersWithEvent, notify} = useListenerService();
|
|
91
|
+
const { addListener, removeLocalListenersWithEvent, notify } = useListenerService();
|
|
98
92
|
onMounted(() => {
|
|
99
93
|
props.listeners.forEach((listener) => {
|
|
100
94
|
addListener(listener, (data) => {
|
|
101
95
|
getItems(props.page, null, props.customFilters);
|
|
102
96
|
});
|
|
103
97
|
});
|
|
104
|
-
})
|
|
98
|
+
});
|
|
105
99
|
onBeforeUnmount(() => {
|
|
106
100
|
props.listeners.forEach((listener) => {
|
|
107
101
|
removeLocalListenersWithEvent(listener);
|
|
108
102
|
});
|
|
109
|
-
})
|
|
110
|
-
|
|
103
|
+
});
|
|
111
104
|
</script>
|
|
112
105
|
|
|
113
106
|
<template>
|
|
@@ -135,7 +128,3 @@ onBeforeUnmount(() => {
|
|
|
135
128
|
</slot>
|
|
136
129
|
</div>
|
|
137
130
|
</template>
|
|
138
|
-
|
|
139
|
-
<style scoped>
|
|
140
|
-
|
|
141
|
-
</style>
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
page: number;
|
|
8
|
+
debounced: boolean;
|
|
9
|
+
disableNoResults: boolean;
|
|
10
|
+
path: string;
|
|
11
|
+
perPage: number;
|
|
12
|
+
await: boolean;
|
|
13
|
+
listeners: unknown[];
|
|
14
|
+
noResultsText: string;
|
|
15
|
+
useQueryParams: boolean;
|
|
16
|
+
customFilters?: Record<string, any> | undefined;
|
|
17
|
+
$props: any;
|
|
18
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
19
|
+
type __VLS_Slots = {
|
|
20
|
+
errors?: ((props: {}) => any) | undefined;
|
|
21
|
+
} & {
|
|
22
|
+
empty?: ((props: {}) => any) | undefined;
|
|
23
|
+
} & {
|
|
24
|
+
loader?: ((props: {
|
|
25
|
+
empty: boolean;
|
|
26
|
+
}) => any) | undefined;
|
|
27
|
+
} & {
|
|
28
|
+
default?: ((props: {
|
|
29
|
+
items: any;
|
|
30
|
+
pending: any;
|
|
31
|
+
totalItems: any;
|
|
32
|
+
totalPages: any;
|
|
33
|
+
currentPage: any;
|
|
34
|
+
perPage: any;
|
|
35
|
+
filters: any;
|
|
36
|
+
}) => any) | undefined;
|
|
37
|
+
};
|
|
@@ -1,17 +1,40 @@
|
|
|
1
1
|
<script setup async>
|
|
2
|
-
import {useCrudApi} from "../composables/useCrudApi";
|
|
3
|
-
import {useCrudConverters} from "../composables/useCrudConverters";
|
|
4
|
-
import {usePreviousRoute} from "../composables/usePreviousRoute";
|
|
5
|
-
import {useRoute, useRouter} from
|
|
2
|
+
import { useCrudApi } from "../composables/useCrudApi";
|
|
3
|
+
import { useCrudConverters } from "../composables/useCrudConverters";
|
|
4
|
+
import { usePreviousRoute } from "../composables/usePreviousRoute";
|
|
5
|
+
import { useRoute, useRouter } from "#app";
|
|
6
6
|
import CrudFilterList from "./CrudFilterList.vue";
|
|
7
|
-
import {computed, ref, watch, onMounted, onBeforeUnmount} from "vue";
|
|
8
|
-
import {useDebounceFn} from
|
|
9
|
-
import {useListenerService} from "../composables/useListenerService";
|
|
7
|
+
import { computed, ref, watch, onMounted, onBeforeUnmount } from "vue";
|
|
8
|
+
import { useDebounceFn } from "@vueuse/core";
|
|
9
|
+
import { useListenerService } from "../composables/useListenerService";
|
|
10
10
|
import CrudFormDialog from "./CrudFormDialog.vue";
|
|
11
11
|
import CrudErrorDisplay from "./CrudErrorDisplay.vue";
|
|
12
|
-
|
|
13
|
-
const {parseQuery, stringifyQuery, cloneDeep} = useCrudConverters();
|
|
12
|
+
const { parseQuery, stringifyQuery, cloneDeep } = useCrudConverters();
|
|
14
13
|
const props = defineProps({
|
|
14
|
+
filtersTitle: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: false,
|
|
17
|
+
default() {
|
|
18
|
+
return "Filters";
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
resultsTitle: {
|
|
22
|
+
type: String,
|
|
23
|
+
required: false,
|
|
24
|
+
default() {
|
|
25
|
+
return "Results";
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
filterClasses: {
|
|
29
|
+
type: String,
|
|
30
|
+
required: false,
|
|
31
|
+
default: ""
|
|
32
|
+
},
|
|
33
|
+
resultClasses: {
|
|
34
|
+
type: String,
|
|
35
|
+
required: false,
|
|
36
|
+
default: ""
|
|
37
|
+
},
|
|
15
38
|
fullScreenDialog: {
|
|
16
39
|
type: Boolean,
|
|
17
40
|
required: false,
|
|
@@ -123,6 +146,36 @@ const props = defineProps({
|
|
|
123
146
|
type: String,
|
|
124
147
|
required: false,
|
|
125
148
|
default: ""
|
|
149
|
+
},
|
|
150
|
+
dialogStyle: {
|
|
151
|
+
type: String,
|
|
152
|
+
required: false,
|
|
153
|
+
default: null
|
|
154
|
+
},
|
|
155
|
+
dialogSize: {
|
|
156
|
+
type: [String, Number],
|
|
157
|
+
required: false,
|
|
158
|
+
default: null
|
|
159
|
+
},
|
|
160
|
+
createDialogSize: {
|
|
161
|
+
type: [String, Number],
|
|
162
|
+
required: false,
|
|
163
|
+
default: null
|
|
164
|
+
},
|
|
165
|
+
updateDialogSize: {
|
|
166
|
+
type: [String, Number],
|
|
167
|
+
required: false,
|
|
168
|
+
default: null
|
|
169
|
+
},
|
|
170
|
+
deleteDialogSize: {
|
|
171
|
+
type: [String, Number],
|
|
172
|
+
required: false,
|
|
173
|
+
default: null
|
|
174
|
+
},
|
|
175
|
+
viewDialogSize: {
|
|
176
|
+
type: [String, Number],
|
|
177
|
+
required: false,
|
|
178
|
+
default: null
|
|
126
179
|
}
|
|
127
180
|
});
|
|
128
181
|
const {
|
|
@@ -152,40 +205,29 @@ const {
|
|
|
152
205
|
hasExportErrors,
|
|
153
206
|
hasListErrors
|
|
154
207
|
} = useCrudApi(props.path, false, props.transformItem, props.transformItems);
|
|
155
|
-
|
|
156
208
|
perPage.value = props.perPage;
|
|
157
|
-
|
|
158
209
|
const route = useRoute();
|
|
159
210
|
const router = useRouter();
|
|
160
211
|
const previousRoute = usePreviousRoute();
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
const actionId = computed(() => route.query[(props.loaderKey ?? '') + 'actionId']);
|
|
164
|
-
|
|
212
|
+
const action = computed(() => route.query[(props.loaderKey ?? "") + "action"]);
|
|
213
|
+
const actionId = computed(() => route.query[(props.loaderKey ?? "") + "actionId"]);
|
|
165
214
|
const dialogOpen = computed({
|
|
166
|
-
get: () => !!(action.value === "create" ||
|
|
215
|
+
get: () => !!(action.value === "create" || action.value === "update" && actionId.value || action.value === "delete" && actionId.value || action.value === "view" && actionId.value),
|
|
167
216
|
set: (value) => {
|
|
168
217
|
if (!value) {
|
|
169
|
-
const hasBackState = router.options.history.state.back
|
|
170
|
-
|
|
171
|
-
console.log(
|
|
172
|
-
console.log(
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
console.log('currentRouteName', currentRouteName)
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (hasBackState && previousRouteName === currentRouteName) { // Only go back if there's a back state AND the previous route is the same
|
|
183
|
-
console.log('going back')
|
|
218
|
+
const hasBackState = router.options.history.state.back;
|
|
219
|
+
console.log("hasBackState", hasBackState);
|
|
220
|
+
console.log("previousRoute", previousRoute.value);
|
|
221
|
+
console.log("route", route);
|
|
222
|
+
const previousRouteName = previousRoute.value?.name;
|
|
223
|
+
const currentRouteName = route.name;
|
|
224
|
+
console.log("previousRouteName", previousRouteName);
|
|
225
|
+
console.log("currentRouteName", currentRouteName);
|
|
226
|
+
if (hasBackState && previousRouteName === currentRouteName) {
|
|
227
|
+
console.log("going back");
|
|
184
228
|
router.back();
|
|
185
229
|
} else {
|
|
186
|
-
|
|
187
|
-
const currentQuery = {...route.query};
|
|
188
|
-
|
|
230
|
+
const currentQuery = { ...route.query };
|
|
189
231
|
if (props.loaderKey) {
|
|
190
232
|
delete currentQuery[`${props.loaderKey}action`];
|
|
191
233
|
delete currentQuery[`${props.loaderKey}actionId`];
|
|
@@ -193,40 +235,35 @@ const dialogOpen = computed({
|
|
|
193
235
|
delete currentQuery.action;
|
|
194
236
|
delete currentQuery.actionId;
|
|
195
237
|
}
|
|
196
|
-
|
|
197
238
|
const finalRoute = {
|
|
198
239
|
path: route.path,
|
|
199
|
-
query: currentQuery
|
|
240
|
+
query: currentQuery
|
|
200
241
|
};
|
|
201
242
|
router.replace(finalRoute);
|
|
202
243
|
}
|
|
203
244
|
}
|
|
204
245
|
}
|
|
205
246
|
});
|
|
206
|
-
|
|
207
|
-
|
|
208
247
|
const page = computed(() => props.loaderKey ? parseQuery(route.query[props.loaderKey])?.page ?? 1 : route.query.page ?? 1);
|
|
209
|
-
const filterValues = props.loaderKey ? ref({...props.customFilters, ...parseQuery(route.query[props.loaderKey])}
|
|
210
|
-
const onQueryChange = (
|
|
248
|
+
const filterValues = props.loaderKey ? ref({ ...props.customFilters, ...parseQuery(route.query[props.loaderKey]) }) : ref({ ...props.customFilters, ...route.query });
|
|
249
|
+
const onQueryChange = (page2) => {
|
|
211
250
|
console.error("QUERY CHANGED");
|
|
212
|
-
const newQuery = {}
|
|
251
|
+
const newQuery = {};
|
|
213
252
|
const existingQuery = parseQuery(route.query);
|
|
214
|
-
|
|
215
253
|
for (const key in filterValues.value) {
|
|
216
254
|
if (filterValues.value[key] !== null && filterValues.value[key] !== "") {
|
|
217
255
|
newQuery[key] = filterValues.value[key];
|
|
218
256
|
}
|
|
219
257
|
}
|
|
220
|
-
newQuery.page =
|
|
258
|
+
newQuery.page = page2;
|
|
221
259
|
let finalQuery = {
|
|
222
|
-
...existingQuery
|
|
223
|
-
}
|
|
260
|
+
...existingQuery
|
|
261
|
+
};
|
|
224
262
|
if (props.loaderKey) {
|
|
225
263
|
finalQuery[props.loaderKey] = stringifyQuery(newQuery);
|
|
226
264
|
} else {
|
|
227
265
|
finalQuery = newQuery;
|
|
228
266
|
}
|
|
229
|
-
//Delete action and actionId from query when filters or page change
|
|
230
267
|
if (props.loaderKey) {
|
|
231
268
|
delete finalQuery[`${props.loaderKey}action`];
|
|
232
269
|
delete finalQuery[`${props.loaderKey}actionId`];
|
|
@@ -235,76 +272,70 @@ const onQueryChange = (page) => {
|
|
|
235
272
|
delete finalQuery.actionId;
|
|
236
273
|
}
|
|
237
274
|
console.error("Setting query", finalQuery);
|
|
238
|
-
router.replace({path: route.path, query: finalQuery, force: true})
|
|
239
|
-
}
|
|
275
|
+
router.replace({ path: route.path, query: finalQuery, force: true });
|
|
276
|
+
};
|
|
240
277
|
watch(currentPage, (newVal, oldValue) => {
|
|
241
278
|
onQueryChange(currentPage.value);
|
|
242
279
|
});
|
|
243
280
|
watch(filterValues, (newVal, oldValue) => {
|
|
244
281
|
console.error("FILTERS CHANGED");
|
|
245
282
|
onQueryChange(1);
|
|
246
|
-
}, {deep: true});
|
|
247
|
-
|
|
248
|
-
|
|
283
|
+
}, { deep: true });
|
|
249
284
|
watch(() => page, () => {
|
|
250
285
|
console.error("ROUTE CHANGED");
|
|
251
286
|
debouncedGet();
|
|
252
|
-
}, {deep: true});
|
|
287
|
+
}, { deep: true });
|
|
253
288
|
watch(() => filterValues, () => {
|
|
254
289
|
console.error("ROUTE CHANGED");
|
|
255
290
|
debouncedGet();
|
|
256
|
-
}, {deep: true});
|
|
257
|
-
|
|
291
|
+
}, { deep: true });
|
|
258
292
|
const debouncedGet = useDebounceFn(() => {
|
|
259
293
|
console.error("DEBOUNCED GET");
|
|
260
294
|
getItems(Number.parseInt(page.value) ?? null, null, filterValues.value);
|
|
261
|
-
}, 200)
|
|
262
|
-
|
|
295
|
+
}, 200);
|
|
263
296
|
const updateForm = async (id) => {
|
|
264
|
-
const newQuery = {query: {...route.query}};
|
|
297
|
+
const newQuery = { query: { ...route.query } };
|
|
265
298
|
if (props.loaderKey) {
|
|
266
|
-
newQuery.query[(props.loaderKey ??
|
|
267
|
-
newQuery.query[(props.loaderKey ??
|
|
299
|
+
newQuery.query[(props.loaderKey ?? "") + "action"] = "update";
|
|
300
|
+
newQuery.query[(props.loaderKey ?? "") + "actionId"] = id;
|
|
268
301
|
} else {
|
|
269
302
|
newQuery.query.action = "update";
|
|
270
303
|
newQuery.query.actionId = id;
|
|
271
304
|
}
|
|
272
305
|
await router.push(newQuery);
|
|
273
|
-
}
|
|
306
|
+
};
|
|
274
307
|
const deleteForm = async (id) => {
|
|
275
|
-
|
|
276
|
-
const newQuery = {query: {...route.query}};
|
|
308
|
+
const newQuery = { query: { ...route.query } };
|
|
277
309
|
if (props.loaderKey) {
|
|
278
|
-
newQuery.query[(props.loaderKey ??
|
|
279
|
-
newQuery.query[(props.loaderKey ??
|
|
310
|
+
newQuery.query[(props.loaderKey ?? "") + "action"] = "delete";
|
|
311
|
+
newQuery.query[(props.loaderKey ?? "") + "actionId"] = id;
|
|
280
312
|
} else {
|
|
281
313
|
newQuery.query.action = "delete";
|
|
282
314
|
newQuery.query.actionId = id;
|
|
283
315
|
}
|
|
284
316
|
await router.push(newQuery);
|
|
285
|
-
}
|
|
317
|
+
};
|
|
286
318
|
const viewForm = async (id) => {
|
|
287
|
-
const newQuery = {query: {...route.query}};
|
|
319
|
+
const newQuery = { query: { ...route.query } };
|
|
288
320
|
if (props.loaderKey) {
|
|
289
|
-
newQuery.query[(props.loaderKey ??
|
|
290
|
-
newQuery.query[(props.loaderKey ??
|
|
321
|
+
newQuery.query[(props.loaderKey ?? "") + "action"] = "view";
|
|
322
|
+
newQuery.query[(props.loaderKey ?? "") + "actionId"] = id;
|
|
291
323
|
} else {
|
|
292
324
|
newQuery.query.action = "view";
|
|
293
325
|
newQuery.query.actionId = id;
|
|
294
326
|
}
|
|
295
327
|
await router.push(newQuery);
|
|
296
|
-
}
|
|
328
|
+
};
|
|
297
329
|
const createForm = () => {
|
|
298
330
|
item.value = props.initialItem ? cloneDeep(props.initialItem) : {};
|
|
299
|
-
const newQuery = {query: {...route.query}};
|
|
331
|
+
const newQuery = { query: { ...route.query } };
|
|
300
332
|
if (props.loaderKey) {
|
|
301
|
-
newQuery.query[(props.loaderKey ??
|
|
333
|
+
newQuery.query[(props.loaderKey ?? "") + "action"] = "create";
|
|
302
334
|
} else {
|
|
303
335
|
newQuery.query.action = "create";
|
|
304
336
|
}
|
|
305
337
|
router.push(newQuery);
|
|
306
|
-
}
|
|
307
|
-
|
|
338
|
+
};
|
|
308
339
|
const saveAction = async () => {
|
|
309
340
|
formPending.value = true;
|
|
310
341
|
let itemToSave = JSON.parse(JSON.stringify(item.value));
|
|
@@ -335,14 +366,12 @@ const saveAction = async () => {
|
|
|
335
366
|
await getItems(Number.parseInt(page.value) ?? null, null, filterValues.value);
|
|
336
367
|
notify(savedPath + ":" + savedAction, savedItem);
|
|
337
368
|
}
|
|
338
|
-
}
|
|
339
|
-
|
|
369
|
+
};
|
|
340
370
|
if (props.await) {
|
|
341
371
|
await getItems(page.value ?? null, null, filterValues.value);
|
|
342
372
|
} else {
|
|
343
373
|
getItems(page.value ?? null, null, filterValues.value);
|
|
344
374
|
}
|
|
345
|
-
|
|
346
375
|
watch(action, (newVal, oldValue) => {
|
|
347
376
|
try {
|
|
348
377
|
if (action.value === "update" && actionId.value) {
|
|
@@ -357,28 +386,26 @@ watch(action, (newVal, oldValue) => {
|
|
|
357
386
|
} catch (error) {
|
|
358
387
|
console.error("Error in actionId watcher:", error);
|
|
359
388
|
}
|
|
360
|
-
}, {immediate: true});
|
|
361
|
-
|
|
362
|
-
const {addListener, removeLocalListenersWithEvent, notify} = useListenerService();
|
|
389
|
+
}, { immediate: true });
|
|
390
|
+
const { addListener, removeLocalListenersWithEvent, notify } = useListenerService();
|
|
363
391
|
onMounted(() => {
|
|
364
392
|
props.listeners.forEach((listener) => {
|
|
365
393
|
addListener(listener, (data) => {
|
|
366
394
|
getItems(Number.parseInt(page.value) ?? null, null, filterValues.value);
|
|
367
395
|
});
|
|
368
396
|
});
|
|
369
|
-
})
|
|
397
|
+
});
|
|
370
398
|
onBeforeUnmount(() => {
|
|
371
399
|
props.listeners.forEach((listener) => {
|
|
372
400
|
removeLocalListenersWithEvent(listener);
|
|
373
401
|
});
|
|
374
|
-
})
|
|
402
|
+
});
|
|
375
403
|
const exportAction = async () => {
|
|
376
404
|
await exportItems(filterValues.value);
|
|
377
405
|
if (!hasExportErrors.value) {
|
|
378
|
-
window.open(exportUrl.value,
|
|
406
|
+
window.open(exportUrl.value, "_blank");
|
|
379
407
|
}
|
|
380
|
-
}
|
|
381
|
-
|
|
408
|
+
};
|
|
382
409
|
</script>
|
|
383
410
|
|
|
384
411
|
<template>
|
|
@@ -404,13 +431,21 @@ const exportAction = async () => {
|
|
|
404
431
|
<v-row>
|
|
405
432
|
<v-col v-if="!hideFilters && filters.length > 0" cols="12" md="3">
|
|
406
433
|
<div>
|
|
434
|
+
<slot name="filtersTitle">
|
|
435
|
+
<h3 v-if="filtersTitle" class="mb-2">{{ filtersTitle }}</h3>
|
|
436
|
+
</slot>
|
|
407
437
|
<slot name="filters" :filters="filters">
|
|
408
|
-
<
|
|
438
|
+
<div :class="filterClasses">
|
|
439
|
+
<crud-filter-list v-model="filterValues" :filters="filters"></crud-filter-list>
|
|
440
|
+
</div>
|
|
409
441
|
</slot>
|
|
410
442
|
</div>
|
|
411
443
|
</v-col>
|
|
412
444
|
<v-col cols="12" :md="hideFilters || filters.length === 0 ? '12' : '9'">
|
|
413
445
|
<div class="">
|
|
446
|
+
<slot name="resultsTitle">
|
|
447
|
+
<h3 v-if="resultsTitle" class="mb-2">{{ resultsTitle }}</h3>
|
|
448
|
+
</slot>
|
|
414
449
|
<slot v-if="!listPending && totalItems === 0 && !hasListErrors" name="empty" :create-action="createForm">
|
|
415
450
|
<v-alert icon="mdi-playlist-remove" type="info" class="pa-5">
|
|
416
451
|
{{ noResultsText }}
|
|
@@ -419,16 +454,18 @@ const exportAction = async () => {
|
|
|
419
454
|
<slot v-if="hasListErrors" name="error" :errors="listErrors">
|
|
420
455
|
<crud-error-display :errors="listErrors"></crud-error-display>
|
|
421
456
|
</slot>
|
|
422
|
-
<
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
457
|
+
<div :class="resultClasses">
|
|
458
|
+
<slot
|
|
459
|
+
v-if="totalItems > 0"
|
|
460
|
+
:items="items"
|
|
461
|
+
:pending="listPending"
|
|
462
|
+
:update-action="updateForm"
|
|
463
|
+
:view-action="viewForm"
|
|
464
|
+
:delete-action="deleteForm"
|
|
465
|
+
:form-pending="formPending"
|
|
466
|
+
>
|
|
467
|
+
</slot>
|
|
468
|
+
</div>
|
|
432
469
|
</div>
|
|
433
470
|
<div v-if="totalItems > 0 && totalPages > 1" class="pa-3">
|
|
434
471
|
<span class="d-none d-md-block pa-3">Page {{ currentPage }} of {{ totalPages }} pages with {{ totalItems }} items</span>
|
|
@@ -457,6 +494,12 @@ const exportAction = async () => {
|
|
|
457
494
|
:view-title="viewTitle"
|
|
458
495
|
:save-action="saveAction"
|
|
459
496
|
:full-screen="fullScreenDialog"
|
|
497
|
+
:dialog-style="dialogStyle"
|
|
498
|
+
:dialog-size="dialogSize"
|
|
499
|
+
:create-dialog-size="createDialogSize"
|
|
500
|
+
:update-dialog-size="updateDialogSize"
|
|
501
|
+
:delete-dialog-size="deleteDialogSize"
|
|
502
|
+
:view-dialog-size="viewDialogSize"
|
|
460
503
|
>
|
|
461
504
|
<slot
|
|
462
505
|
name="form" :action="action"
|
|
@@ -469,7 +512,3 @@ const exportAction = async () => {
|
|
|
469
512
|
|
|
470
513
|
</div>
|
|
471
514
|
</template>
|
|
472
|
-
|
|
473
|
-
<style scoped>
|
|
474
|
-
|
|
475
|
-
</style>
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
path: string;
|
|
8
|
+
customFilters: Record<string, any>;
|
|
9
|
+
perPage: number;
|
|
10
|
+
await: boolean;
|
|
11
|
+
listeners: unknown[];
|
|
12
|
+
noResultsText: string;
|
|
13
|
+
createTitle: string;
|
|
14
|
+
updateTitle: string;
|
|
15
|
+
deleteTitle: string;
|
|
16
|
+
viewTitle: string;
|
|
17
|
+
dialogStyle: string;
|
|
18
|
+
dialogSize: string | number;
|
|
19
|
+
createDialogSize: string | number;
|
|
20
|
+
updateDialogSize: string | number;
|
|
21
|
+
deleteDialogSize: string | number;
|
|
22
|
+
viewDialogSize: string | number;
|
|
23
|
+
allowCreate: boolean;
|
|
24
|
+
hideFilters: boolean;
|
|
25
|
+
filtersTitle: string;
|
|
26
|
+
resultsTitle: string;
|
|
27
|
+
filterClasses: string;
|
|
28
|
+
resultClasses: string;
|
|
29
|
+
fullScreenDialog: boolean;
|
|
30
|
+
contentClasses: string;
|
|
31
|
+
title?: string | undefined;
|
|
32
|
+
loaderKey?: string | undefined;
|
|
33
|
+
initialItem?: Record<string, any> | undefined;
|
|
34
|
+
transformItem?: Function | undefined;
|
|
35
|
+
transformItems?: Function | undefined;
|
|
36
|
+
beforeSave?: Function | undefined;
|
|
37
|
+
beforeCreate?: Function | undefined;
|
|
38
|
+
beforeUpdate?: Function | undefined;
|
|
39
|
+
beforeDelete?: Function | undefined;
|
|
40
|
+
$props: any;
|
|
41
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
42
|
+
type __VLS_Slots = {
|
|
43
|
+
before?: ((props: {
|
|
44
|
+
items: any;
|
|
45
|
+
totalItems: any;
|
|
46
|
+
totalPages: any;
|
|
47
|
+
pending: any;
|
|
48
|
+
createAction: any;
|
|
49
|
+
updateAction: any;
|
|
50
|
+
viewAction: any;
|
|
51
|
+
deleteAction: any;
|
|
52
|
+
formPending: any;
|
|
53
|
+
exportAction: any;
|
|
54
|
+
exportPending: any;
|
|
55
|
+
exportErrors: any;
|
|
56
|
+
}) => any) | undefined;
|
|
57
|
+
} & {
|
|
58
|
+
filtersTitle?: ((props: {}) => any) | undefined;
|
|
59
|
+
} & {
|
|
60
|
+
filters?: ((props: {
|
|
61
|
+
filters: any;
|
|
62
|
+
}) => any) | undefined;
|
|
63
|
+
} & {
|
|
64
|
+
resultsTitle?: ((props: {}) => any) | undefined;
|
|
65
|
+
} & {
|
|
66
|
+
empty?: ((props: {
|
|
67
|
+
createAction: any;
|
|
68
|
+
}) => any) | undefined;
|
|
69
|
+
} & {
|
|
70
|
+
error?: ((props: {
|
|
71
|
+
errors: any;
|
|
72
|
+
}) => any) | undefined;
|
|
73
|
+
} & {
|
|
74
|
+
default?: ((props: {
|
|
75
|
+
items: any;
|
|
76
|
+
pending: any;
|
|
77
|
+
updateAction: any;
|
|
78
|
+
viewAction: any;
|
|
79
|
+
deleteAction: any;
|
|
80
|
+
formPending: any;
|
|
81
|
+
}) => any) | undefined;
|
|
82
|
+
} & {
|
|
83
|
+
form?: ((props: {
|
|
84
|
+
action: any;
|
|
85
|
+
item: any;
|
|
86
|
+
originalItem: any;
|
|
87
|
+
errors: any;
|
|
88
|
+
}) => any) | undefined;
|
|
89
|
+
};
|