atom-nuxt 1.0.138 → 1.0.140
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.json +3 -3
- package/dist/runtime/components/AlertDisplay.vue +11 -18
- package/dist/runtime/components/AlertDisplay.vue.d.ts +2 -0
- package/dist/runtime/components/CrudAddressSearchField.vue +16 -63
- package/dist/runtime/components/CrudAddressSearchField.vue.d.ts +2 -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 +31 -45
- 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 +4 -12
- package/dist/runtime/components/CrudFormDialog.vue.d.ts +28 -0
- package/dist/runtime/components/CrudFormLoader.vue +98 -121
- package/dist/runtime/components/CrudFormLoader.vue.d.ts +41 -0
- package/dist/runtime/components/CrudListLoader.vue +15 -26
- package/dist/runtime/components/CrudListLoader.vue.d.ts +36 -0
- package/dist/runtime/components/CrudPaginatedLoader.vue +53 -83
- package/dist/runtime/components/CrudPaginatedLoader.vue.d.ts +70 -0
- package/dist/runtime/components/CrudUploadField.vue +9 -26
- package/dist/runtime/components/CrudUploadField.vue.d.ts +23 -0
- package/dist/runtime/components/CrudUploadFieldSelection.vue +16 -24
- package/dist/runtime/components/CrudUploadFieldSelection.vue.d.ts +18 -0
- package/dist/types.d.mts +4 -2
- package/package.json +17 -18
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -23
- package/dist/types.d.ts +0 -7
|
@@ -1,8 +1,7 @@
|
|
|
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";
|
|
6
5
|
const props = defineProps({
|
|
7
6
|
action: {
|
|
8
7
|
type: String,
|
|
@@ -77,16 +76,13 @@ const props = defineProps({
|
|
|
77
76
|
}
|
|
78
77
|
});
|
|
79
78
|
const item = defineModel();
|
|
80
|
-
const dialogOpen = defineModel(
|
|
79
|
+
const dialogOpen = defineModel("dialog");
|
|
81
80
|
const hasItem = computed(() => item.value && Object.keys(item.value).length > 0);
|
|
82
|
-
|
|
83
81
|
const buttonTitle = computed(() => {
|
|
84
|
-
return props.btnText ? props.btnText :
|
|
82
|
+
return props.btnText ? props.btnText : props.action === "create" ? props.createTitle : props.action === "update" ? props.updateTitle : props.action === "delete" ? props.deleteTitle : "";
|
|
85
83
|
});
|
|
86
|
-
|
|
87
84
|
const display = useDisplay();
|
|
88
85
|
const isLarge = computed(() => display.lgAndUp.value);
|
|
89
|
-
|
|
90
86
|
</script>
|
|
91
87
|
|
|
92
88
|
<template>
|
|
@@ -163,7 +159,3 @@ const isLarge = computed(() => display.lgAndUp.value);
|
|
|
163
159
|
</v-card>
|
|
164
160
|
</v-dialog>
|
|
165
161
|
</template>
|
|
166
|
-
|
|
167
|
-
<style scoped>
|
|
168
|
-
|
|
169
|
-
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
saveAction: Function;
|
|
17
|
+
fullScreen: boolean;
|
|
18
|
+
originalItem: Record<string, any>;
|
|
19
|
+
btnText?: string | undefined;
|
|
20
|
+
$props: any;
|
|
21
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
22
|
+
type __VLS_Slots = {
|
|
23
|
+
default?: ((props: {
|
|
24
|
+
action: any;
|
|
25
|
+
item: any;
|
|
26
|
+
errors: any;
|
|
27
|
+
}) => any) | undefined;
|
|
28
|
+
};
|
|
@@ -1,102 +1,99 @@
|
|
|
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: () => []
|
|
98
|
-
}
|
|
99
|
-
})
|
|
94
|
+
default: () => []
|
|
95
|
+
}
|
|
96
|
+
});
|
|
100
97
|
const {
|
|
101
98
|
getItem,
|
|
102
99
|
updateItem,
|
|
@@ -106,122 +103,106 @@ const {
|
|
|
106
103
|
formErrors,
|
|
107
104
|
formPending,
|
|
108
105
|
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
|
-
|
|
106
|
+
itemPending
|
|
107
|
+
} = useCrudApi(props.path, false, props.transformItem, props.transformItems);
|
|
108
|
+
const route = useRoute();
|
|
109
|
+
const router = useRouter();
|
|
110
|
+
const action = computed(() => route.query[(props.loaderKey ?? "") + "action"]);
|
|
111
|
+
const actionId = computed(() => route.query[(props.loaderKey ?? "") + "actionId"]);
|
|
118
112
|
const dialogOpen = computed({
|
|
119
|
-
get: () => !!(action.value ===
|
|
113
|
+
get: () => !!(action.value === "create" || action.value === "update" && actionId.value || action.value === "delete" && actionId.value),
|
|
120
114
|
set: (value) => {
|
|
121
115
|
if (!value) {
|
|
122
116
|
if (router.options.history.state.back) {
|
|
123
|
-
router.back()
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const currentQuery = route.query
|
|
117
|
+
router.back();
|
|
118
|
+
} else {
|
|
119
|
+
const currentQuery = route.query;
|
|
127
120
|
if (props.loaderKey) {
|
|
128
|
-
delete
|
|
129
|
-
delete
|
|
121
|
+
delete currentQuery[(props.loaderKey ?? "") + "action"];
|
|
122
|
+
delete currentQuery[(props.loaderKey ?? "") + "actionId"];
|
|
123
|
+
} else {
|
|
124
|
+
delete currentQuery.action;
|
|
125
|
+
delete currentQuery.actionId;
|
|
130
126
|
}
|
|
131
|
-
|
|
132
|
-
delete currentQuery.action
|
|
133
|
-
delete currentQuery.actionId
|
|
134
|
-
}
|
|
135
|
-
router.replace({ ...route, query: currentQuery })
|
|
127
|
+
router.replace({ ...route, query: currentQuery });
|
|
136
128
|
}
|
|
137
129
|
}
|
|
138
|
-
}
|
|
139
|
-
})
|
|
130
|
+
}
|
|
131
|
+
});
|
|
140
132
|
const updateForm = async (id) => {
|
|
141
|
-
const newQuery = { query: { ...route.query } }
|
|
133
|
+
const newQuery = { query: { ...route.query } };
|
|
142
134
|
if (props.loaderKey) {
|
|
143
|
-
newQuery.query[(props.loaderKey ??
|
|
144
|
-
newQuery.query[(props.loaderKey ??
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
newQuery.query.
|
|
148
|
-
newQuery.query.actionId = id
|
|
135
|
+
newQuery.query[(props.loaderKey ?? "") + "action"] = "update";
|
|
136
|
+
newQuery.query[(props.loaderKey ?? "") + "actionId"] = id;
|
|
137
|
+
} else {
|
|
138
|
+
newQuery.query.action = "update";
|
|
139
|
+
newQuery.query.actionId = id;
|
|
149
140
|
}
|
|
150
|
-
await router.push(newQuery)
|
|
151
|
-
}
|
|
141
|
+
await router.push(newQuery);
|
|
142
|
+
};
|
|
152
143
|
const deleteForm = async (id) => {
|
|
153
|
-
const newQuery = { query: { ...route.query } }
|
|
144
|
+
const newQuery = { query: { ...route.query } };
|
|
154
145
|
if (props.loaderKey) {
|
|
155
|
-
newQuery.query[(props.loaderKey ??
|
|
156
|
-
newQuery.query[(props.loaderKey ??
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
newQuery.query.
|
|
160
|
-
newQuery.query.actionId = id
|
|
146
|
+
newQuery.query[(props.loaderKey ?? "") + "action"] = "delete";
|
|
147
|
+
newQuery.query[(props.loaderKey ?? "") + "actionId"] = id;
|
|
148
|
+
} else {
|
|
149
|
+
newQuery.query.action = "delete";
|
|
150
|
+
newQuery.query.actionId = id;
|
|
161
151
|
}
|
|
162
|
-
await router.push(newQuery)
|
|
163
|
-
}
|
|
152
|
+
await router.push(newQuery);
|
|
153
|
+
};
|
|
164
154
|
const createForm = () => {
|
|
165
|
-
item.value = props.initialItem ? cloneDeep(props.initialItem) : {}
|
|
166
|
-
const newQuery = { query: { ...route.query } }
|
|
155
|
+
item.value = props.initialItem ? cloneDeep(props.initialItem) : {};
|
|
156
|
+
const newQuery = { query: { ...route.query } };
|
|
167
157
|
if (props.loaderKey) {
|
|
168
|
-
newQuery.query[(props.loaderKey ??
|
|
158
|
+
newQuery.query[(props.loaderKey ?? "") + "action"] = "create";
|
|
159
|
+
} else {
|
|
160
|
+
newQuery.query.action = "create";
|
|
169
161
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
router.push(newQuery)
|
|
174
|
-
}
|
|
175
|
-
|
|
162
|
+
router.push(newQuery);
|
|
163
|
+
};
|
|
176
164
|
const saveAction = async () => {
|
|
177
|
-
formPending.value = true
|
|
178
|
-
let itemToSave = JSON.parse(JSON.stringify(item.value))
|
|
165
|
+
formPending.value = true;
|
|
166
|
+
let itemToSave = JSON.parse(JSON.stringify(item.value));
|
|
179
167
|
if (props.beforeSave != null) {
|
|
180
|
-
itemToSave = await props.beforeSave(itemToSave)
|
|
168
|
+
itemToSave = await props.beforeSave(itemToSave);
|
|
181
169
|
}
|
|
182
|
-
if (action.value ===
|
|
170
|
+
if (action.value === "create") {
|
|
183
171
|
if (props.beforeCreate != null) {
|
|
184
|
-
itemToSave = await props.beforeCreate(itemToSave)
|
|
172
|
+
itemToSave = await props.beforeCreate(itemToSave);
|
|
185
173
|
}
|
|
186
|
-
await createItem(itemToSave)
|
|
187
|
-
}
|
|
188
|
-
else if (action.value === 'update') {
|
|
174
|
+
await createItem(itemToSave);
|
|
175
|
+
} else if (action.value === "update") {
|
|
189
176
|
if (props.beforeUpdate != null) {
|
|
190
|
-
itemToSave = await props.beforeUpdate(itemToSave)
|
|
177
|
+
itemToSave = await props.beforeUpdate(itemToSave);
|
|
191
178
|
}
|
|
192
|
-
await updateItem(itemToSave.id, itemToSave)
|
|
193
|
-
}
|
|
194
|
-
else if (action.value === 'delete') {
|
|
179
|
+
await updateItem(itemToSave.id, itemToSave);
|
|
180
|
+
} else if (action.value === "delete") {
|
|
195
181
|
if (props.beforeDelete != null) {
|
|
196
|
-
itemToSave = await props.beforeDelete(itemToSave)
|
|
182
|
+
itemToSave = await props.beforeDelete(itemToSave);
|
|
197
183
|
}
|
|
198
|
-
await deleteItem(itemToSave.id)
|
|
184
|
+
await deleteItem(itemToSave.id);
|
|
199
185
|
}
|
|
200
186
|
if (formErrors.value == null || Object.keys(formErrors.value).length === 0) {
|
|
201
|
-
emits(action.value,itemToSave);
|
|
202
|
-
notify(props.path +
|
|
203
|
-
dialogOpen.value = false
|
|
187
|
+
emits(action.value, itemToSave);
|
|
188
|
+
notify(props.path + ":" + action.value, itemToSave);
|
|
189
|
+
dialogOpen.value = false;
|
|
204
190
|
}
|
|
205
|
-
}
|
|
206
|
-
|
|
191
|
+
};
|
|
207
192
|
watch(action, () => {
|
|
208
193
|
try {
|
|
209
|
-
if (action.value ===
|
|
210
|
-
getItem(actionId.value)
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
else if (action.value === 'delete' && actionId.value) {
|
|
216
|
-
getItem(actionId.value)
|
|
194
|
+
if (action.value === "update" && actionId.value) {
|
|
195
|
+
getItem(actionId.value);
|
|
196
|
+
} else if (action.value === "create") {
|
|
197
|
+
item.value = props.initialItem ? cloneDeep(props.initialItem) : {};
|
|
198
|
+
} else if (action.value === "delete" && actionId.value) {
|
|
199
|
+
getItem(actionId.value);
|
|
217
200
|
}
|
|
201
|
+
} catch (error) {
|
|
202
|
+
console.error("Error in actionId watcher:", error);
|
|
218
203
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
}, { immediate: true })
|
|
223
|
-
|
|
224
|
-
const { notify } = useListenerService()
|
|
204
|
+
}, { immediate: true });
|
|
205
|
+
const { notify } = useListenerService();
|
|
225
206
|
</script>
|
|
226
207
|
|
|
227
208
|
<template>
|
|
@@ -255,7 +236,3 @@ const { notify } = useListenerService()
|
|
|
255
236
|
</crud-form-dialog>
|
|
256
237
|
</div>
|
|
257
238
|
</template>
|
|
258
|
-
|
|
259
|
-
<style scoped>
|
|
260
|
-
|
|
261
|
-
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
allowCreate: boolean;
|
|
16
|
+
hideFilters: boolean;
|
|
17
|
+
title?: string | undefined;
|
|
18
|
+
loaderKey?: string | undefined;
|
|
19
|
+
initialItem?: Record<string, any> | undefined;
|
|
20
|
+
transformItem?: Function | undefined;
|
|
21
|
+
transformItems?: Function | undefined;
|
|
22
|
+
beforeSave?: Function | undefined;
|
|
23
|
+
beforeCreate?: Function | undefined;
|
|
24
|
+
beforeUpdate?: Function | undefined;
|
|
25
|
+
beforeDelete?: Function | undefined;
|
|
26
|
+
$props: any;
|
|
27
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
28
|
+
type __VLS_Slots = {
|
|
29
|
+
default?: ((props: {
|
|
30
|
+
createAction: any;
|
|
31
|
+
updateAction: any;
|
|
32
|
+
deleteAction: any;
|
|
33
|
+
formPending: any;
|
|
34
|
+
}) => any) | undefined;
|
|
35
|
+
} & {
|
|
36
|
+
form?: ((props: {
|
|
37
|
+
action: any;
|
|
38
|
+
item: any;
|
|
39
|
+
errors: any;
|
|
40
|
+
}) => any) | undefined;
|
|
41
|
+
};
|
|
@@ -1,14 +1,13 @@
|
|
|
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
12
|
path: {
|
|
14
13
|
type: String,
|
|
@@ -33,7 +32,7 @@ const props = defineProps({
|
|
|
33
32
|
required: false,
|
|
34
33
|
default: false
|
|
35
34
|
},
|
|
36
|
-
listeners
|
|
35
|
+
listeners: {
|
|
37
36
|
type: Array,
|
|
38
37
|
required: false,
|
|
39
38
|
default: () => []
|
|
@@ -60,20 +59,16 @@ const {
|
|
|
60
59
|
totalPages,
|
|
61
60
|
hasListErrors
|
|
62
61
|
} = useCrudApi(props.path);
|
|
63
|
-
|
|
64
62
|
const debouncedGet = useDebounceFn(getItems, 500);
|
|
65
|
-
|
|
66
63
|
const lastRequest = ref(null);
|
|
67
|
-
|
|
68
64
|
const setLastRequest = () => {
|
|
69
|
-
lastRequest.value = JSON.stringify({page: props.page, perPage: props.perPage, customFilters: props.customFilters});
|
|
70
|
-
}
|
|
71
|
-
|
|
65
|
+
lastRequest.value = JSON.stringify({ page: props.page, perPage: props.perPage, customFilters: props.customFilters });
|
|
66
|
+
};
|
|
72
67
|
watch(() => props.customFilters, () => {
|
|
73
|
-
if (lastRequest.value === JSON.stringify({page: props.page, perPage: props.perPage, customFilters: props.customFilters})) {
|
|
68
|
+
if (lastRequest.value === JSON.stringify({ page: props.page, perPage: props.perPage, customFilters: props.customFilters })) {
|
|
74
69
|
return;
|
|
75
70
|
}
|
|
76
|
-
if(props.debounced) {
|
|
71
|
+
if (props.debounced) {
|
|
77
72
|
debouncedGet(props.page, props.perPage, props.customFilters);
|
|
78
73
|
} else {
|
|
79
74
|
getItems(props.page, props.perPage, props.customFilters);
|
|
@@ -83,27 +78,25 @@ watch(() => props.customFilters, () => {
|
|
|
83
78
|
watch(() => props.page, () => {
|
|
84
79
|
getItems(props.page, props.perPage, props.customFilters);
|
|
85
80
|
});
|
|
86
|
-
if(props.await) {
|
|
81
|
+
if (props.await) {
|
|
87
82
|
await getItems(props.page, props.perPage, props.customFilters);
|
|
88
83
|
} else {
|
|
89
84
|
getItems(props.page, props.perPage, props.customFilters);
|
|
90
85
|
}
|
|
91
86
|
setLastRequest();
|
|
92
|
-
|
|
93
|
-
const {addListener, removeLocalListenersWithEvent, notify} = useListenerService();
|
|
87
|
+
const { addListener, removeLocalListenersWithEvent, notify } = useListenerService();
|
|
94
88
|
onMounted(() => {
|
|
95
89
|
props.listeners.forEach((listener) => {
|
|
96
90
|
addListener(listener, (data) => {
|
|
97
91
|
getItems(props.page, null, props.customFilters);
|
|
98
92
|
});
|
|
99
93
|
});
|
|
100
|
-
})
|
|
94
|
+
});
|
|
101
95
|
onBeforeUnmount(() => {
|
|
102
96
|
props.listeners.forEach((listener) => {
|
|
103
97
|
removeLocalListenersWithEvent(listener);
|
|
104
98
|
});
|
|
105
|
-
})
|
|
106
|
-
|
|
99
|
+
});
|
|
107
100
|
</script>
|
|
108
101
|
|
|
109
102
|
<template>
|
|
@@ -131,7 +124,3 @@ onBeforeUnmount(() => {
|
|
|
131
124
|
</slot>
|
|
132
125
|
</div>
|
|
133
126
|
</template>
|
|
134
|
-
|
|
135
|
-
<style scoped>
|
|
136
|
-
|
|
137
|
-
</style>
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
path: string;
|
|
10
|
+
perPage: number;
|
|
11
|
+
await: boolean;
|
|
12
|
+
listeners: unknown[];
|
|
13
|
+
noResultsText: string;
|
|
14
|
+
useQueryParams: boolean;
|
|
15
|
+
customFilters?: Record<string, any> | undefined;
|
|
16
|
+
$props: any;
|
|
17
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
18
|
+
type __VLS_Slots = {
|
|
19
|
+
errors?: ((props: {}) => any) | undefined;
|
|
20
|
+
} & {
|
|
21
|
+
empty?: ((props: {}) => any) | undefined;
|
|
22
|
+
} & {
|
|
23
|
+
loader?: ((props: {
|
|
24
|
+
empty: boolean;
|
|
25
|
+
}) => any) | undefined;
|
|
26
|
+
} & {
|
|
27
|
+
default?: ((props: {
|
|
28
|
+
items: any;
|
|
29
|
+
pending: any;
|
|
30
|
+
totalItems: any;
|
|
31
|
+
totalPages: any;
|
|
32
|
+
currentPage: any;
|
|
33
|
+
perPage: any;
|
|
34
|
+
filters: any;
|
|
35
|
+
}) => any) | undefined;
|
|
36
|
+
};
|