atom-nuxt 1.3.1 → 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 +16 -27
- package/dist/runtime/components/CrudListLoader.vue.d.ts +37 -0
- package/dist/runtime/components/CrudPaginatedLoader.vue +118 -99
- 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
package/dist/module.d.mts
CHANGED
|
@@ -16,7 +16,9 @@ interface AtomCrudModuleOptions {
|
|
|
16
16
|
azureAdB2C?: azureAdB2COptions;
|
|
17
17
|
googleMapsApiKey?: string;
|
|
18
18
|
debug?: boolean;
|
|
19
|
+
defaultDialogStyle?: 'default' | 'leaf';
|
|
19
20
|
}
|
|
20
21
|
declare const _default: _nuxt_schema.NuxtModule<AtomCrudModuleOptions, AtomCrudModuleOptions, false>;
|
|
21
22
|
|
|
22
|
-
export {
|
|
23
|
+
export { _default as default };
|
|
24
|
+
export type { AtomCrudModuleOptions, azureAdB2COptions };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -10,7 +10,8 @@ const module = defineNuxtModule({
|
|
|
10
10
|
additionalHeaders: {
|
|
11
11
|
"Content-Type": "application/json",
|
|
12
12
|
"Accept": "application/json"
|
|
13
|
-
}
|
|
13
|
+
},
|
|
14
|
+
defaultDialogStyle: "default"
|
|
14
15
|
},
|
|
15
16
|
async setup(options, nuxt) {
|
|
16
17
|
const resolver = createResolver(import.meta.url);
|
|
@@ -1,46 +1,43 @@
|
|
|
1
|
-
<script setup
|
|
2
|
-
import {useAlertService} from
|
|
3
|
-
import {computed} from
|
|
4
|
-
|
|
5
|
-
const {alertMessage, alertActive} = useAlertService();
|
|
6
|
-
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useAlertService } from "../composables/useAlertService";
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
const { alertMessage, alertActive } = useAlertService();
|
|
7
5
|
const message = computed(() => {
|
|
8
6
|
if (!alertMessage.value || !alertActive.value) {
|
|
9
7
|
return null;
|
|
10
8
|
}
|
|
11
|
-
return typeof alertMessage.value ===
|
|
9
|
+
return typeof alertMessage.value === "string" ? alertMessage.value : alertMessage.value.message;
|
|
12
10
|
});
|
|
13
11
|
const color = computed(() => {
|
|
14
12
|
if (!alertMessage.value || !alertActive.value) {
|
|
15
13
|
return null;
|
|
16
14
|
}
|
|
17
|
-
return typeof alertMessage.value ===
|
|
15
|
+
return typeof alertMessage.value === "string" ? "success" : alertMessage.value.color || "success";
|
|
18
16
|
});
|
|
19
17
|
const location = computed(() => {
|
|
20
18
|
if (!alertMessage.value || !alertActive.value) {
|
|
21
19
|
return "";
|
|
22
20
|
}
|
|
23
|
-
return typeof alertMessage.value ===
|
|
21
|
+
return typeof alertMessage.value === "string" ? "" : alertMessage.value.location || "";
|
|
24
22
|
});
|
|
25
23
|
const icon = computed(() => {
|
|
26
24
|
if (!alertMessage.value || !alertActive.value) {
|
|
27
25
|
return null;
|
|
28
26
|
}
|
|
29
|
-
return typeof alertMessage.value ===
|
|
27
|
+
return typeof alertMessage.value === "string" ? null : alertMessage.value.icon || null;
|
|
30
28
|
});
|
|
31
|
-
|
|
32
29
|
const clickable = computed(() => {
|
|
33
|
-
if (!alertMessage.value || !alertActive.value || typeof alertMessage.value ===
|
|
30
|
+
if (!alertMessage.value || !alertActive.value || typeof alertMessage.value === "string" || !alertMessage.value.onClick) {
|
|
34
31
|
return false;
|
|
35
32
|
}
|
|
36
33
|
return true;
|
|
37
|
-
})
|
|
34
|
+
});
|
|
38
35
|
const onClick = () => {
|
|
39
36
|
if (!clickable.value) {
|
|
40
37
|
return;
|
|
41
38
|
}
|
|
42
39
|
alertMessage.value.onClick();
|
|
43
|
-
}
|
|
40
|
+
};
|
|
44
41
|
</script>
|
|
45
42
|
|
|
46
43
|
<template>
|
|
@@ -56,7 +53,3 @@ const onClick = () => {
|
|
|
56
53
|
</div>
|
|
57
54
|
</v-snackbar>
|
|
58
55
|
</template>
|
|
59
|
-
|
|
60
|
-
<style scoped>
|
|
61
|
-
|
|
62
|
-
</style>
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
export default _default;
|
|
@@ -1,36 +1,33 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import {ref, watch} from
|
|
3
|
-
import {useRuntimeConfig} from "nuxt/app";
|
|
4
|
-
import {useDebounceFn} from
|
|
5
|
-
|
|
2
|
+
import { ref, watch } from "vue";
|
|
3
|
+
import { useRuntimeConfig } from "nuxt/app";
|
|
4
|
+
import { useDebounceFn } from "@vueuse/core";
|
|
6
5
|
const atomNuxtConfig = useRuntimeConfig().public.atomNuxt;
|
|
7
6
|
const props = defineProps({
|
|
8
7
|
hint: {
|
|
9
8
|
type: String,
|
|
10
|
-
default:
|
|
9
|
+
default: "Search by postcode, city or country. You must select an option from the list."
|
|
11
10
|
},
|
|
12
11
|
label: {
|
|
13
12
|
type: String,
|
|
14
|
-
default:
|
|
13
|
+
default: "Address search"
|
|
15
14
|
},
|
|
16
15
|
placeholder: {
|
|
17
16
|
type: String,
|
|
18
|
-
default:
|
|
17
|
+
default: "Start typing address"
|
|
19
18
|
},
|
|
20
19
|
countries: {
|
|
21
20
|
type: Array,
|
|
22
|
-
default: () => []
|
|
21
|
+
default: () => []
|
|
22
|
+
// Example: ['gb', 'fr', 'us']
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
|
|
26
|
-
const searchText = ref('');
|
|
25
|
+
const searchText = ref("");
|
|
27
26
|
const addressSearchResults = ref([]);
|
|
28
27
|
const loading = ref(false);
|
|
29
28
|
const selectedPlaceId = ref(null);
|
|
30
29
|
const model = defineModel();
|
|
31
|
-
const placeModel = defineModel("place")
|
|
32
|
-
|
|
33
|
-
// Function to get autocomplete suggestions using fetch
|
|
30
|
+
const placeModel = defineModel("place");
|
|
34
31
|
const fetchAutocompleteSuggestions = async (query) => {
|
|
35
32
|
if (!query || loading.value) return;
|
|
36
33
|
loading.value = true;
|
|
@@ -41,23 +38,21 @@ const fetchAutocompleteSuggestions = async (query) => {
|
|
|
41
38
|
params: {
|
|
42
39
|
input: query,
|
|
43
40
|
key: atomNuxtConfig.googleMapsApiKey,
|
|
44
|
-
components: props.countries.length
|
|
45
|
-
? props.countries.map(c => `country:${c}`).join('|')
|
|
46
|
-
: undefined
|
|
41
|
+
components: props.countries.length ? props.countries.map((c) => `country:${c}`).join("|") : void 0
|
|
47
42
|
},
|
|
48
|
-
method:
|
|
43
|
+
method: "GET"
|
|
49
44
|
}
|
|
50
45
|
);
|
|
51
|
-
if (result.status ===
|
|
52
|
-
addressSearchResults.value = result.predictions.map(prediction => ({
|
|
46
|
+
if (result.status === "OK") {
|
|
47
|
+
addressSearchResults.value = result.predictions.map((prediction) => ({
|
|
53
48
|
text: prediction.description,
|
|
54
49
|
place_id: prediction.place_id
|
|
55
50
|
}));
|
|
56
51
|
} else {
|
|
57
|
-
console.error(
|
|
52
|
+
console.error("Error fetching autocomplete suggestions:", result.status);
|
|
58
53
|
}
|
|
59
54
|
} catch (error) {
|
|
60
|
-
console.error(
|
|
55
|
+
console.error("Error fetching autocomplete suggestions:", error);
|
|
61
56
|
} finally {
|
|
62
57
|
loading.value = false;
|
|
63
58
|
}
|
|
@@ -73,37 +68,29 @@ const fetchPlaceId = async (placeId) => {
|
|
|
73
68
|
`/api/maps/places`,
|
|
74
69
|
{
|
|
75
70
|
params: {
|
|
76
|
-
placeId
|
|
77
|
-
key: atomNuxtConfig.googleMapsApiKey
|
|
71
|
+
placeId,
|
|
72
|
+
key: atomNuxtConfig.googleMapsApiKey
|
|
78
73
|
},
|
|
79
|
-
method:
|
|
74
|
+
method: "GET"
|
|
80
75
|
}
|
|
81
76
|
);
|
|
82
|
-
|
|
83
|
-
if (result.status === 'OK') {
|
|
77
|
+
if (result.status === "OK") {
|
|
84
78
|
placeModel.value = result.result;
|
|
85
79
|
model.value = `${result.result.geometry.location.lat},${result.result.geometry.location.lng}`;
|
|
86
80
|
} else {
|
|
87
|
-
console.error(
|
|
81
|
+
console.error("Error fetching place details:", result.status);
|
|
88
82
|
}
|
|
89
83
|
} catch (error) {
|
|
90
|
-
console.error(
|
|
84
|
+
console.error("Error fetching place details:", error);
|
|
91
85
|
}
|
|
92
86
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// Debounce the search text updates to avoid excessive API calls
|
|
96
87
|
const debouncedFetchAutocompleteSuggestions = useDebounceFn(fetchAutocompleteSuggestions, 500);
|
|
97
|
-
|
|
98
|
-
// Watch for changes to searchText and trigger debounced API calls
|
|
99
88
|
watch(searchText, (newQuery) => {
|
|
100
89
|
debouncedFetchAutocompleteSuggestions(newQuery);
|
|
101
90
|
});
|
|
102
|
-
|
|
103
91
|
watch(selectedPlaceId, (newPlaceId) => {
|
|
104
92
|
fetchPlaceId(newPlaceId);
|
|
105
93
|
});
|
|
106
|
-
|
|
107
94
|
</script>
|
|
108
95
|
|
|
109
96
|
<template>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {
|
|
2
|
+
hint: string;
|
|
3
|
+
label: string;
|
|
4
|
+
placeholder: string;
|
|
5
|
+
countries: unknown[];
|
|
6
|
+
$props: any;
|
|
7
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
export default _default;
|
|
@@ -1,44 +1,31 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import CrudListLoader from "./CrudListLoader.vue";
|
|
3
|
-
import {defineModel, ref, computed} from "vue";
|
|
4
|
-
|
|
3
|
+
import { defineModel, ref, computed } from "vue";
|
|
5
4
|
const props = defineProps({
|
|
6
|
-
path: {type: String, required: true},
|
|
7
|
-
multiple: {type: Boolean, default: false},
|
|
8
|
-
endpointDisplayKey: {type: String, default: "name"},
|
|
9
|
-
endpointFilterKey: {type: String, default: "keywords"},
|
|
10
|
-
endpointResponseKey: {type: String, default: "id"},
|
|
11
|
-
additionalFilters: {type: Object, default: () => ({})},
|
|
12
|
-
disableUpdate: {type: Boolean, default: false},
|
|
13
|
-
createBtnText: {type: String, default: "Select"},
|
|
14
|
-
updateBtnText: {type: String, default: "Update"}
|
|
5
|
+
path: { type: String, required: true },
|
|
6
|
+
multiple: { type: Boolean, default: false },
|
|
7
|
+
endpointDisplayKey: { type: String, default: "name" },
|
|
8
|
+
endpointFilterKey: { type: String, default: "keywords" },
|
|
9
|
+
endpointResponseKey: { type: String, default: "id" },
|
|
10
|
+
additionalFilters: { type: Object, default: () => ({}) },
|
|
11
|
+
disableUpdate: { type: Boolean, default: false },
|
|
12
|
+
createBtnText: { type: String, default: "Select" },
|
|
13
|
+
updateBtnText: { type: String, default: "Update" }
|
|
15
14
|
});
|
|
16
|
-
|
|
17
15
|
const selectionModel = defineModel();
|
|
18
16
|
const search = ref("");
|
|
19
17
|
const searchDialog = ref(false);
|
|
20
18
|
const searchDialogSelectedValue = ref(null);
|
|
21
|
-
|
|
22
19
|
const hasSelection = computed(() => props.multiple ? selectionModel.value !== null && Array.isArray(selectionModel.value) && selectionModel.value.length > 0 : selectionModel.value !== null);
|
|
23
|
-
|
|
24
20
|
const onAction = () => {
|
|
25
|
-
|
|
26
|
-
searchDialogSelectedValue.value = selectionModel.value
|
|
27
|
-
? Array.isArray(selectionModel.value)
|
|
28
|
-
? [...selectionModel.value]
|
|
29
|
-
: selectionModel.value
|
|
30
|
-
: null;
|
|
21
|
+
searchDialogSelectedValue.value = selectionModel.value ? Array.isArray(selectionModel.value) ? [...selectionModel.value] : selectionModel.value : null;
|
|
31
22
|
searchDialog.value = true;
|
|
32
23
|
};
|
|
33
|
-
|
|
34
24
|
const onDone = () => {
|
|
35
|
-
// Update selectionModel only when clicking "Done"
|
|
36
25
|
selectionModel.value = searchDialogSelectedValue.value;
|
|
37
26
|
searchDialog.value = false;
|
|
38
27
|
};
|
|
39
|
-
|
|
40
28
|
const onCancel = () => {
|
|
41
|
-
// Close the dialog without saving changes
|
|
42
29
|
searchDialog.value = false;
|
|
43
30
|
};
|
|
44
31
|
</script>
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
multiple: boolean;
|
|
9
|
+
endpointDisplayKey: string;
|
|
10
|
+
endpointFilterKey: string;
|
|
11
|
+
endpointResponseKey: string;
|
|
12
|
+
additionalFilters: Record<string, any>;
|
|
13
|
+
disableUpdate: boolean;
|
|
14
|
+
createBtnText: string;
|
|
15
|
+
updateBtnText: string;
|
|
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
|
+
items?: ((props: {
|
|
20
|
+
items: any;
|
|
21
|
+
}) => any) | undefined;
|
|
22
|
+
} & {
|
|
23
|
+
action?: ((props: {
|
|
24
|
+
action: any;
|
|
25
|
+
}) => any) | undefined;
|
|
26
|
+
} & {
|
|
27
|
+
dialogListTitle?: ((props: {
|
|
28
|
+
item: any;
|
|
29
|
+
}) => any) | undefined;
|
|
30
|
+
};
|
|
@@ -1,41 +1,40 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { ref, defineProps, defineEmits } from
|
|
2
|
+
import { ref, defineProps, defineEmits } from "vue";
|
|
3
3
|
defineProps({
|
|
4
4
|
title: {
|
|
5
5
|
type: String,
|
|
6
6
|
default() {
|
|
7
|
-
return "Delete item"
|
|
7
|
+
return "Delete item";
|
|
8
8
|
}
|
|
9
9
|
},
|
|
10
10
|
message: {
|
|
11
11
|
type: String,
|
|
12
12
|
default() {
|
|
13
|
-
return "Are you sure you want to delete this item?"
|
|
13
|
+
return "Are you sure you want to delete this item?";
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
cancelText: {
|
|
17
17
|
type: String,
|
|
18
18
|
default() {
|
|
19
|
-
return "Cancel"
|
|
19
|
+
return "Cancel";
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
confirmText: {
|
|
23
23
|
type: String,
|
|
24
24
|
default() {
|
|
25
|
-
return "OK"
|
|
25
|
+
return "OK";
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
})
|
|
29
|
-
const emit = defineEmits([
|
|
30
|
-
const dialog = ref(false)
|
|
28
|
+
});
|
|
29
|
+
const emit = defineEmits(["confirm"]);
|
|
30
|
+
const dialog = ref(false);
|
|
31
31
|
const open = () => {
|
|
32
|
-
dialog.value = true
|
|
33
|
-
}
|
|
32
|
+
dialog.value = true;
|
|
33
|
+
};
|
|
34
34
|
const handleConfirm = () => {
|
|
35
|
-
emit(
|
|
35
|
+
emit("confirm");
|
|
36
36
|
dialog.value = false;
|
|
37
37
|
};
|
|
38
|
-
|
|
39
38
|
</script>
|
|
40
39
|
|
|
41
40
|
<template>
|
|
@@ -79,11 +78,6 @@ const handleConfirm = () => {
|
|
|
79
78
|
</v-btn>
|
|
80
79
|
</v-card-actions>
|
|
81
80
|
|
|
82
|
-
|
|
83
81
|
</v-card>
|
|
84
82
|
</v-dialog>
|
|
85
83
|
</template>
|
|
86
|
-
|
|
87
|
-
<style scoped>
|
|
88
|
-
|
|
89
|
-
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
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: "confirm", ...args: any[]) => void;
|
|
8
|
+
message: string;
|
|
9
|
+
title: string;
|
|
10
|
+
cancelText: string;
|
|
11
|
+
confirmText: string;
|
|
12
|
+
$props: any;
|
|
13
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
14
|
+
type __VLS_Slots = {
|
|
15
|
+
default?: ((props: {
|
|
16
|
+
click: any;
|
|
17
|
+
}) => any) | undefined;
|
|
18
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import {computed} from
|
|
3
|
-
import {defineProps} from
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { defineProps } from "vue";
|
|
4
4
|
const props = defineProps({
|
|
5
5
|
errors: Object,
|
|
6
6
|
errorKey: {
|
|
@@ -8,9 +8,9 @@ const props = defineProps({
|
|
|
8
8
|
default: null
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
|
|
12
11
|
const random = computed(() => Math.random());
|
|
13
12
|
</script>
|
|
13
|
+
|
|
14
14
|
<template>
|
|
15
15
|
<v-alert
|
|
16
16
|
v-if="errors != null && errors[errorKey ?? 'global'] != null"
|
|
@@ -26,4 +26,3 @@ const random = computed(() => Math.random());
|
|
|
26
26
|
</div>
|
|
27
27
|
</v-alert>
|
|
28
28
|
</template>
|
|
29
|
-
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {
|
|
2
|
+
errorKey: string;
|
|
3
|
+
errors?: Record<string, any> | undefined;
|
|
4
|
+
$props: any;
|
|
5
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
6
|
+
export default _default;
|
|
@@ -1,121 +1,103 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import CrudListLoader from "./CrudListLoader.vue";
|
|
3
|
-
import {ref, computed, watch, onMounted, onBeforeUnmount} from "vue";
|
|
4
|
-
import {useDebounceFn} from "@vueuse/core";
|
|
3
|
+
import { ref, computed, watch, onMounted, onBeforeUnmount } from "vue";
|
|
4
|
+
import { useDebounceFn } from "@vueuse/core";
|
|
5
5
|
import CrudAddressSearchField from "./CrudAddressSearchField.vue";
|
|
6
|
-
import {useCrudConverters} from "../composables/useCrudConverters";
|
|
7
|
-
import {useCrudApi} from "../composables/useCrudApi";
|
|
8
|
-
|
|
6
|
+
import { useCrudConverters } from "../composables/useCrudConverters";
|
|
7
|
+
import { useCrudApi } from "../composables/useCrudApi";
|
|
9
8
|
const props = defineProps({
|
|
10
9
|
filter: {
|
|
11
10
|
type: Object,
|
|
12
|
-
required: true
|
|
11
|
+
required: true
|
|
13
12
|
},
|
|
14
13
|
modelValue: null,
|
|
15
|
-
disabled: Boolean
|
|
14
|
+
disabled: Boolean
|
|
16
15
|
});
|
|
17
16
|
const model = ref();
|
|
18
|
-
const emit = defineEmits([
|
|
19
|
-
// Watch for changes in the prop and update the internal model
|
|
17
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
20
18
|
watch(() => props.modelValue, (newValue) => {
|
|
21
|
-
model.value = newValue;
|
|
19
|
+
model.value = newValue;
|
|
22
20
|
});
|
|
23
|
-
// Debounced emit function
|
|
24
|
-
|
|
25
21
|
const filter = ref(props.filter);
|
|
26
|
-
|
|
27
|
-
// Watch for changes in the filter prop and update the internal filter
|
|
28
22
|
watch(() => props.filter, (newValue) => {
|
|
29
|
-
filter.value = newValue;
|
|
23
|
+
filter.value = newValue;
|
|
30
24
|
});
|
|
31
|
-
|
|
32
25
|
const searchDialogSelectedValue = ref(null);
|
|
33
26
|
const search = ref(null);
|
|
34
27
|
const searchDialog = ref(false);
|
|
35
28
|
const datePickerValue = ref(null);
|
|
36
29
|
const datePicker = ref(false);
|
|
37
|
-
|
|
38
30
|
const emitUpdate = () => {
|
|
39
|
-
emit(
|
|
40
|
-
}
|
|
31
|
+
emit("update:modelValue", model.value);
|
|
32
|
+
};
|
|
41
33
|
const debouncedUpdate = useDebounceFn(emitUpdate, 700);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const {inputDateForDb, outputDateFromDb, cloneDeep, localDateForDb} = useCrudConverters();
|
|
45
|
-
|
|
34
|
+
const { inputDateForDb, outputDateFromDb, cloneDeep, localDateForDb } = useCrudConverters();
|
|
46
35
|
const datePickerDisplayValue = computed(() => {
|
|
47
36
|
if (!selectedValue.value || selectedValue.value.length !== 2) {
|
|
48
37
|
return null;
|
|
49
38
|
}
|
|
50
|
-
const startDate = outputDateFromDb(selectedValue.value[0],
|
|
51
|
-
const endDate = outputDateFromDb(selectedValue.value[1],
|
|
39
|
+
const startDate = outputDateFromDb(selectedValue.value[0], "dd LLL");
|
|
40
|
+
const endDate = outputDateFromDb(selectedValue.value[1], "dd LLL");
|
|
52
41
|
return `${startDate} - ${endDate}`;
|
|
53
42
|
});
|
|
54
|
-
|
|
55
43
|
const selectedValue = computed({
|
|
56
44
|
get() {
|
|
57
45
|
if (model.value != null) {
|
|
58
|
-
if (props.filter.optionType ===
|
|
46
|
+
if (props.filter.optionType === "DateTimeRange") {
|
|
59
47
|
if (!model.value || model.value.length !== 2) {
|
|
60
48
|
return null;
|
|
61
49
|
}
|
|
62
50
|
return model.value;
|
|
63
51
|
}
|
|
64
52
|
return model.value;
|
|
65
|
-
} else if (props.filter.type ===
|
|
53
|
+
} else if (props.filter.type === "multiOption" || props.filter.type === "multiSearch") {
|
|
66
54
|
return [];
|
|
67
55
|
} else {
|
|
68
56
|
return null;
|
|
69
57
|
}
|
|
70
58
|
},
|
|
71
59
|
set(val) {
|
|
72
|
-
if (props.filter.optionType ===
|
|
60
|
+
if (props.filter.optionType === "DateTimeRange" && val && val[0]) {
|
|
73
61
|
let start = val[0];
|
|
74
62
|
let end = val[1];
|
|
75
63
|
model.value = [start, end];
|
|
76
64
|
} else {
|
|
77
65
|
model.value = val;
|
|
78
66
|
}
|
|
79
|
-
if (props.filter.type ===
|
|
67
|
+
if (props.filter.type === "search" || props.filter.type === "multiSearch" || props.filter.type === "option" || props.filter.type === "multiOption" || props.filter.type === "multiOptionTree") {
|
|
80
68
|
emitUpdate();
|
|
81
69
|
} else {
|
|
82
70
|
debouncedUpdate();
|
|
83
71
|
}
|
|
84
|
-
}
|
|
72
|
+
}
|
|
85
73
|
});
|
|
86
|
-
|
|
87
74
|
const {
|
|
88
75
|
getItems: searchGetItems,
|
|
89
76
|
items: searchListItems,
|
|
90
77
|
listPending: searchLoading
|
|
91
78
|
} = useCrudApi(props.filter.endpoint);
|
|
92
|
-
|
|
93
|
-
|
|
94
79
|
async function getSearchListValue() {
|
|
95
80
|
if (!selectedValue.value || selectedValue.value.length === 0) {
|
|
96
81
|
return;
|
|
97
82
|
}
|
|
98
|
-
const filters = {ids: selectedValue.value};
|
|
83
|
+
const filters = { ids: selectedValue.value };
|
|
99
84
|
await searchGetItems(1, selectedValue.value.length, filters);
|
|
100
85
|
}
|
|
101
|
-
|
|
102
86
|
const validateDateRange = () => {
|
|
103
87
|
datePicker.value = false;
|
|
104
|
-
|
|
105
88
|
if (!datePickerValue.value || datePickerValue.value.length < 2) {
|
|
106
89
|
return;
|
|
107
90
|
}
|
|
108
91
|
let startDate = localDateForDb(datePickerValue.value[0]);
|
|
109
92
|
let endDate = localDateForDb(datePickerValue.value[datePickerValue.value.length - 1]);
|
|
110
93
|
selectedValue.value = [startDate, endDate];
|
|
111
|
-
}
|
|
112
|
-
|
|
94
|
+
};
|
|
113
95
|
const closeDatePicker = (clear = false) => {
|
|
114
96
|
if (clear) {
|
|
115
97
|
selectedValue.value = null;
|
|
116
98
|
}
|
|
117
99
|
datePicker.value = false;
|
|
118
|
-
}
|
|
100
|
+
};
|
|
119
101
|
watch(searchDialog, (newValue, oldValue) => {
|
|
120
102
|
if (!newValue && searchDialogSelectedValue.value != null) {
|
|
121
103
|
selectedValue.value = cloneDeep(searchDialogSelectedValue.value);
|
|
@@ -126,22 +108,19 @@ watch(searchDialog, (newValue, oldValue) => {
|
|
|
126
108
|
searchDialogSelectedValue.value = cloneDeep(model.value);
|
|
127
109
|
}
|
|
128
110
|
});
|
|
129
|
-
|
|
130
111
|
onMounted(() => {
|
|
131
112
|
model.value = props.modelValue;
|
|
132
|
-
if (props.filter.type ===
|
|
113
|
+
if (props.filter.type === "search" || props.filter.type === "multiSearch") {
|
|
133
114
|
getSearchListValue();
|
|
134
115
|
}
|
|
135
116
|
});
|
|
136
|
-
|
|
137
117
|
const displayForChip = (item) => {
|
|
138
|
-
var searchItem = searchListItems.value.find(inlineItem => inlineItem[props.filter.endpointResponseKey] === item.raw);
|
|
118
|
+
var searchItem = searchListItems.value.find((inlineItem) => inlineItem[props.filter.endpointResponseKey] === item.raw);
|
|
139
119
|
if (!searchItem) {
|
|
140
120
|
return "Loading";
|
|
141
121
|
}
|
|
142
122
|
return searchItem[props.filter.endpointDisplayKey] ?? "Loading";
|
|
143
|
-
}
|
|
144
|
-
|
|
123
|
+
};
|
|
145
124
|
</script>
|
|
146
125
|
|
|
147
126
|
<template>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {
|
|
2
|
+
$emit: (event: "update:modelValue", ...args: any[]) => void;
|
|
3
|
+
filter: Record<string, any>;
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
modelValue?: any;
|
|
6
|
+
$props: any;
|
|
7
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
export default _default;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import CrudFilter from "../components/CrudFilter.vue";
|
|
3
|
-
|
|
4
3
|
const model = defineModel();
|
|
5
4
|
const props = defineProps({
|
|
6
5
|
filters: {
|
|
@@ -10,7 +9,6 @@ const props = defineProps({
|
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
11
|
});
|
|
13
|
-
|
|
14
12
|
</script>
|
|
15
13
|
|
|
16
14
|
<template>
|
|
@@ -20,7 +18,3 @@ const props = defineProps({
|
|
|
20
18
|
</div>
|
|
21
19
|
</div>
|
|
22
20
|
</template>
|
|
23
|
-
|
|
24
|
-
<style scoped>
|
|
25
|
-
|
|
26
|
-
</style>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {
|
|
2
|
+
filters: unknown[];
|
|
3
|
+
$props: any;
|
|
4
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
5
|
+
export default _default;
|