@weconstudio/nuxt 0.0.0-stage → 1.72.0
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/LICENSE +1 -0
- package/README.md +115 -2
- package/dist/module.d.mts +7 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +250 -0
- package/dist/runtime/components/We/Autocomplete.d.vue.ts +13 -0
- package/dist/runtime/components/We/Autocomplete.vue +91 -0
- package/dist/runtime/components/We/Autocomplete.vue.d.ts +13 -0
- package/dist/runtime/components/We/BoldText.d.vue.ts +17 -0
- package/dist/runtime/components/We/BoldText.vue +29 -0
- package/dist/runtime/components/We/BoldText.vue.d.ts +17 -0
- package/dist/runtime/components/We/ColorPicker.d.vue.ts +11 -0
- package/dist/runtime/components/We/ColorPicker.vue +199 -0
- package/dist/runtime/components/We/ColorPicker.vue.d.ts +11 -0
- package/dist/runtime/components/We/ConfirmDialog.d.vue.ts +104 -0
- package/dist/runtime/components/We/ConfirmDialog.vue +143 -0
- package/dist/runtime/components/We/ConfirmDialog.vue.d.ts +104 -0
- package/dist/runtime/components/We/Datatable.d.vue.ts +40 -0
- package/dist/runtime/components/We/Datatable.vue +87 -0
- package/dist/runtime/components/We/Datatable.vue.d.ts +40 -0
- package/dist/runtime/components/We/DatatableInternal.d.vue.ts +194 -0
- package/dist/runtime/components/We/DatatableInternal.vue +638 -0
- package/dist/runtime/components/We/DatatableInternal.vue.d.ts +194 -0
- package/dist/runtime/components/We/DatePicker.d.vue.ts +51 -0
- package/dist/runtime/components/We/DatePicker.vue +901 -0
- package/dist/runtime/components/We/DatePicker.vue.d.ts +51 -0
- package/dist/runtime/components/We/Dt/Actions.d.vue.ts +51 -0
- package/dist/runtime/components/We/Dt/Actions.vue +106 -0
- package/dist/runtime/components/We/Dt/Actions.vue.d.ts +51 -0
- package/dist/runtime/components/We/Dt/BooleanFormatter.d.vue.ts +8 -0
- package/dist/runtime/components/We/Dt/BooleanFormatter.vue +26 -0
- package/dist/runtime/components/We/Dt/BooleanFormatter.vue.d.ts +8 -0
- package/dist/runtime/components/We/Dt/CardFilterContainer.d.vue.ts +17 -0
- package/dist/runtime/components/We/Dt/CardFilterContainer.vue +60 -0
- package/dist/runtime/components/We/Dt/CardFilterContainer.vue.d.ts +17 -0
- package/dist/runtime/components/We/Dt/CheckboxFilter.d.vue.ts +16 -0
- package/dist/runtime/components/We/Dt/CheckboxFilter.vue +47 -0
- package/dist/runtime/components/We/Dt/CheckboxFilter.vue.d.ts +16 -0
- package/dist/runtime/components/We/Dt/ChipGroupSelect.d.vue.ts +7 -0
- package/dist/runtime/components/We/Dt/ChipGroupSelect.vue +35 -0
- package/dist/runtime/components/We/Dt/ChipGroupSelect.vue.d.ts +7 -0
- package/dist/runtime/components/We/Dt/ClusterFilter.d.vue.ts +18 -0
- package/dist/runtime/components/We/Dt/ClusterFilter.vue +68 -0
- package/dist/runtime/components/We/Dt/ClusterFilter.vue.d.ts +18 -0
- package/dist/runtime/components/We/Dt/DatasetFormatter.d.vue.ts +19 -0
- package/dist/runtime/components/We/Dt/DatasetFormatter.vue +65 -0
- package/dist/runtime/components/We/Dt/DatasetFormatter.vue.d.ts +19 -0
- package/dist/runtime/components/We/Dt/DaterangeFilter.d.vue.ts +28 -0
- package/dist/runtime/components/We/Dt/DaterangeFilter.vue +140 -0
- package/dist/runtime/components/We/Dt/DaterangeFilter.vue.d.ts +28 -0
- package/dist/runtime/components/We/Dt/Filter.d.vue.ts +7 -0
- package/dist/runtime/components/We/Dt/Filter.vue +234 -0
- package/dist/runtime/components/We/Dt/Filter.vue.d.ts +7 -0
- package/dist/runtime/components/We/Dt/Filters.d.vue.ts +6 -0
- package/dist/runtime/components/We/Dt/Filters.vue +24 -0
- package/dist/runtime/components/We/Dt/Filters.vue.d.ts +6 -0
- package/dist/runtime/components/We/Dt/LuxonFormatter.d.vue.ts +12 -0
- package/dist/runtime/components/We/Dt/LuxonFormatter.vue +23 -0
- package/dist/runtime/components/We/Dt/LuxonFormatter.vue.d.ts +12 -0
- package/dist/runtime/components/We/Dt/SelectFilter.d.vue.ts +60 -0
- package/dist/runtime/components/We/Dt/SelectFilter.vue +333 -0
- package/dist/runtime/components/We/Dt/SelectFilter.vue.d.ts +60 -0
- package/dist/runtime/components/We/Dt/SelectResourceFilter.d.vue.ts +43 -0
- package/dist/runtime/components/We/Dt/SelectResourceFilter.vue +127 -0
- package/dist/runtime/components/We/Dt/SelectResourceFilter.vue.d.ts +43 -0
- package/dist/runtime/components/We/Dt/dt.types.d.ts +8 -0
- package/dist/runtime/components/We/EndpointSwitcher.d.vue.ts +12 -0
- package/dist/runtime/components/We/EndpointSwitcher.vue +256 -0
- package/dist/runtime/components/We/EndpointSwitcher.vue.d.ts +12 -0
- package/dist/runtime/components/We/Import.d.vue.ts +118 -0
- package/dist/runtime/components/We/Import.vue +730 -0
- package/dist/runtime/components/We/Import.vue.d.ts +118 -0
- package/dist/runtime/components/We/ImportDefaultValues.d.vue.ts +3666 -0
- package/dist/runtime/components/We/ImportDefaultValues.vue +115 -0
- package/dist/runtime/components/We/ImportDefaultValues.vue.d.ts +3666 -0
- package/dist/runtime/components/We/ImportMatchColumns.d.vue.ts +66 -0
- package/dist/runtime/components/We/ImportMatchColumns.vue +172 -0
- package/dist/runtime/components/We/ImportMatchColumns.vue.d.ts +66 -0
- package/dist/runtime/components/We/ImportPreviewResults.d.vue.ts +38 -0
- package/dist/runtime/components/We/ImportPreviewResults.vue +165 -0
- package/dist/runtime/components/We/ImportPreviewResults.vue.d.ts +38 -0
- package/dist/runtime/components/We/ImportSelectStart.d.vue.ts +47 -0
- package/dist/runtime/components/We/ImportSelectStart.vue +106 -0
- package/dist/runtime/components/We/ImportSelectStart.vue.d.ts +47 -0
- package/dist/runtime/components/We/Notification.d.vue.ts +7 -0
- package/dist/runtime/components/We/Notification.vue +49 -0
- package/dist/runtime/components/We/Notification.vue.d.ts +7 -0
- package/dist/runtime/components/We/S3Dropzone.d.vue.ts +17 -0
- package/dist/runtime/components/We/S3Dropzone.vue +527 -0
- package/dist/runtime/components/We/S3Dropzone.vue.d.ts +17 -0
- package/dist/runtime/components/We/Select.d.vue.ts +39 -0
- package/dist/runtime/components/We/Select.vue +354 -0
- package/dist/runtime/components/We/Select.vue.d.ts +39 -0
- package/dist/runtime/components/We/TipTap.d.vue.ts +26 -0
- package/dist/runtime/components/We/TipTap.vue +362 -0
- package/dist/runtime/components/We/TipTap.vue.d.ts +26 -0
- package/dist/runtime/components/We/datatable.props.d.ts +57 -0
- package/dist/runtime/components/We/datatable.props.js +60 -0
- package/dist/runtime/composables/datatable/useAutoFillHeight.d.ts +31 -0
- package/dist/runtime/composables/datatable/useAutoFillHeight.js +57 -0
- package/dist/runtime/composables/datatable/useDataTable.d.ts +33 -0
- package/dist/runtime/composables/datatable/useDataTable.js +161 -0
- package/dist/runtime/composables/datatable/useDatatableColumns.d.ts +12 -0
- package/dist/runtime/composables/datatable/useDatatableColumns.js +96 -0
- package/dist/runtime/composables/useApi.d.ts +56 -0
- package/dist/runtime/composables/useApi.js +230 -0
- package/dist/runtime/composables/useApiFetch.d.ts +2 -0
- package/dist/runtime/composables/useApiFetch.js +9 -0
- package/dist/runtime/composables/useApiUrl.d.ts +10 -0
- package/dist/runtime/composables/useApiUrl.js +37 -0
- package/dist/runtime/composables/useAuth.d.ts +9 -0
- package/dist/runtime/composables/useAuth.js +22 -0
- package/dist/runtime/composables/useBus.d.ts +8 -0
- package/dist/runtime/composables/useBus.js +18 -0
- package/dist/runtime/composables/useDateRangePresets.d.ts +21 -0
- package/dist/runtime/composables/useDateRangePresets.js +90 -0
- package/dist/runtime/composables/useForm.d.ts +29 -0
- package/dist/runtime/composables/useForm.js +74 -0
- package/dist/runtime/composables/useFormLock.d.ts +11 -0
- package/dist/runtime/composables/useFormLock.js +8 -0
- package/dist/runtime/composables/useFormWrapper.d.ts +16 -0
- package/dist/runtime/composables/useFormWrapper.js +36 -0
- package/dist/runtime/composables/useImportJob.d.ts +55 -0
- package/dist/runtime/composables/useImportJob.js +94 -0
- package/dist/runtime/composables/useLux.d.ts +1 -0
- package/dist/runtime/composables/useLux.js +8 -0
- package/dist/runtime/composables/useNotify.d.ts +12 -0
- package/dist/runtime/composables/useNotify.js +24 -0
- package/dist/runtime/composables/usePaginatedFetch.d.ts +24 -0
- package/dist/runtime/composables/usePaginatedFetch.js +154 -0
- package/dist/runtime/composables/useServerErrors.d.ts +16 -0
- package/dist/runtime/composables/useServerErrors.js +60 -0
- package/dist/runtime/composables/useValidators.d.ts +18 -0
- package/dist/runtime/composables/useValidators.js +56 -0
- package/dist/runtime/generator/code/dt.d.ts +8 -0
- package/dist/runtime/generator/code/dt.js +97 -0
- package/dist/runtime/generator/code/edit.d.ts +4 -0
- package/dist/runtime/generator/code/edit.js +41 -0
- package/dist/runtime/generator/code/form.d.ts +6 -0
- package/dist/runtime/generator/code/form.js +229 -0
- package/dist/runtime/generator/code/i18n.d.ts +5 -0
- package/dist/runtime/generator/code/i18n.js +43 -0
- package/dist/runtime/generator/code/index.d.ts +11 -0
- package/dist/runtime/generator/code/index.js +90 -0
- package/dist/runtime/generator/components/CodeSnippet.d.vue.ts +14 -0
- package/dist/runtime/generator/components/CodeSnippet.vue +49 -0
- package/dist/runtime/generator/components/CodeSnippet.vue.d.ts +14 -0
- package/dist/runtime/generator/components/Configuration.d.vue.ts +16 -0
- package/dist/runtime/generator/components/Configuration.vue +154 -0
- package/dist/runtime/generator/components/Configuration.vue.d.ts +16 -0
- package/dist/runtime/generator/components/GeneratorPage.d.vue.ts +50 -0
- package/dist/runtime/generator/components/GeneratorPage.vue +226 -0
- package/dist/runtime/generator/components/GeneratorPage.vue.d.ts +50 -0
- package/dist/runtime/generator/fs.d.ts +16 -0
- package/dist/runtime/generator/fs.js +79 -0
- package/dist/runtime/generator/index.d.vue.ts +52 -0
- package/dist/runtime/generator/index.vue +17 -0
- package/dist/runtime/generator/index.vue.d.ts +52 -0
- package/dist/runtime/internals/api.d.ts +3 -0
- package/dist/runtime/internals/api.js +16 -0
- package/dist/runtime/internals/bus.d.ts +1 -0
- package/dist/runtime/internals/bus.js +2 -0
- package/dist/runtime/internals/dt.d.ts +24 -0
- package/dist/runtime/internals/dt.js +57 -0
- package/dist/runtime/lang/en.json +211 -0
- package/dist/runtime/lang/it.json +211 -0
- package/dist/runtime/mixins/formValidator.d.ts +38 -0
- package/dist/runtime/mixins/formValidator.js +118 -0
- package/dist/runtime/plugins/api-legacy.d.ts +76 -0
- package/dist/runtime/plugins/api-legacy.js +11 -0
- package/dist/runtime/plugins/auth-legacy.d.ts +22 -0
- package/dist/runtime/plugins/auth-legacy.js +14 -0
- package/dist/runtime/plugins/bus-legacy.d.ts +6 -0
- package/dist/runtime/plugins/bus-legacy.js +9 -0
- package/dist/runtime/plugins/notify-legacy.d.ts +25 -0
- package/dist/runtime/plugins/notify-legacy.js +35 -0
- package/dist/runtime/plugins/portal.d.ts +2 -0
- package/dist/runtime/plugins/portal.js +5 -0
- package/dist/runtime/plugins/update-sanctum-app-config.d.ts +2 -0
- package/dist/runtime/plugins/update-sanctum-app-config.js +44 -0
- package/dist/runtime/plugins/vuetify-nuxt-icon.d.ts +4 -0
- package/dist/runtime/plugins/vuetify-nuxt-icon.js +30 -0
- package/dist/runtime/types/app-config.d.ts +24 -0
- package/dist/runtime/types/app-config.js +1 -0
- package/dist/runtime/types/icons.d.ts +82 -0
- package/dist/runtime/types/icons.js +84 -0
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/index.js +2 -0
- package/dist/runtime/types/module-options.d.ts +29 -0
- package/dist/runtime/types/module-options.js +0 -0
- package/dist/runtime/types/runtime-hooks.d.ts +17 -0
- package/dist/runtime/types/runtime-hooks.js +1 -0
- package/dist/runtime/utils/color.d.ts +10 -0
- package/dist/runtime/utils/color.js +38 -0
- package/dist/runtime/utils/file.d.ts +17 -0
- package/dist/runtime/utils/file.js +108 -0
- package/dist/runtime/utils/format.d.ts +1 -0
- package/dist/runtime/utils/format.js +14 -0
- package/dist/runtime/utils/make-enum.d.ts +15 -0
- package/dist/runtime/utils/make-enum.js +27 -0
- package/dist/runtime/utils/mergeDefaults.d.ts +1 -0
- package/dist/runtime/utils/mergeDefaults.js +18 -0
- package/dist/runtime/utils/object-to-formdata.d.ts +10 -0
- package/dist/runtime/utils/object-to-formdata.js +82 -0
- package/dist/runtime/utils/uuid.d.ts +1 -0
- package/dist/runtime/utils/uuid.js +9 -0
- package/dist/types.d.mts +9 -0
- package/package.json +92 -4
|
@@ -0,0 +1,638 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { refDebounced, useResizeObserver, useScroll } from "@vueuse/core";
|
|
3
|
+
import { computed, normalizeClass, ref, toRef, useAttrs, useTemplateRef, watch } from "vue";
|
|
4
|
+
import { useI18n } from "vue-i18n";
|
|
5
|
+
import { useDefaults } from "vuetify";
|
|
6
|
+
import { useAutoFillHeight } from "../../composables/datatable/useAutoFillHeight";
|
|
7
|
+
import { useDataTable } from "../../composables/datatable/useDataTable";
|
|
8
|
+
import { useDatatableColumns } from "../../composables/datatable/useDatatableColumns";
|
|
9
|
+
import { formatError } from "../../internals/api";
|
|
10
|
+
import { isFilterComplete } from "../../internals/dt";
|
|
11
|
+
import { datatableProps } from "./datatable.props";
|
|
12
|
+
const _props = defineProps(datatableProps);
|
|
13
|
+
const emit = defineEmits(["action", "new", "update:filters"]);
|
|
14
|
+
const props = useDefaults(_props, "WeDatatable");
|
|
15
|
+
const { t } = useI18n();
|
|
16
|
+
const DEFAULT_ITEMS_PER_PAGE = 50;
|
|
17
|
+
const search = defineModel("search", {
|
|
18
|
+
type: String,
|
|
19
|
+
default: ""
|
|
20
|
+
});
|
|
21
|
+
const itemsPerPage = defineModel("itemsPerPage", {
|
|
22
|
+
type: Number,
|
|
23
|
+
default: DEFAULT_ITEMS_PER_PAGE
|
|
24
|
+
});
|
|
25
|
+
const itemsPerPageOptions = computed(() => {
|
|
26
|
+
const items2 = [10, 25, 50, 100, 250, 500, 1e3, itemsPerPage.value].filter(Boolean).sort((a, b) => a - b).filter((v, i, a) => a.indexOf(v) === i);
|
|
27
|
+
return items2.map((i) => ({ value: i, text: String(i), title: String(i) }));
|
|
28
|
+
});
|
|
29
|
+
const page = defineModel("page", {
|
|
30
|
+
type: Number,
|
|
31
|
+
default: 1
|
|
32
|
+
});
|
|
33
|
+
const sortBy = defineModel("sortBy", {
|
|
34
|
+
type: Array,
|
|
35
|
+
default: () => []
|
|
36
|
+
});
|
|
37
|
+
const columns = defineModel("columns", { type: [Array, null], ...{ default: null } });
|
|
38
|
+
const modelSelection = defineModel("selection", { type: Array });
|
|
39
|
+
const modelAggregates = defineModel("aggregates", {
|
|
40
|
+
type: Object,
|
|
41
|
+
default: void 0
|
|
42
|
+
});
|
|
43
|
+
const confirmDialog = ref(null);
|
|
44
|
+
const debouncedSearch = refDebounced(search, 500);
|
|
45
|
+
const showFilters = ref(false);
|
|
46
|
+
const allFilters = ref(props.filters);
|
|
47
|
+
const hasFilters = computed(() => {
|
|
48
|
+
return Object.values(allFilters.value).some(isFilterComplete);
|
|
49
|
+
});
|
|
50
|
+
watch(() => props.filters, (val) => allFilters.value = val);
|
|
51
|
+
watch(() => allFilters.value, (val) => emit("update:filters", val));
|
|
52
|
+
const {
|
|
53
|
+
// conf
|
|
54
|
+
headers,
|
|
55
|
+
pagination,
|
|
56
|
+
availableFilters,
|
|
57
|
+
optionalHeaders,
|
|
58
|
+
visibleColumns,
|
|
59
|
+
defaultColumns,
|
|
60
|
+
// aggregates
|
|
61
|
+
aggregates,
|
|
62
|
+
// data
|
|
63
|
+
totalItems,
|
|
64
|
+
items,
|
|
65
|
+
loading,
|
|
66
|
+
error,
|
|
67
|
+
// methods
|
|
68
|
+
load,
|
|
69
|
+
reloadData,
|
|
70
|
+
// actions
|
|
71
|
+
selectionKey,
|
|
72
|
+
actions,
|
|
73
|
+
selectedItems,
|
|
74
|
+
loadingExecuteAction,
|
|
75
|
+
clearSelection,
|
|
76
|
+
executeAction
|
|
77
|
+
} = useDataTable({
|
|
78
|
+
filters: allFilters,
|
|
79
|
+
// `resource` is required, but the shared (untyped) props object widens it to
|
|
80
|
+
// `string | undefined`; it is always present at runtime.
|
|
81
|
+
resource: toRef(props, "resource"),
|
|
82
|
+
requestParams: toRef(props, "requestParams"),
|
|
83
|
+
loadConfiguration: toRef(props, "loadConfiguration"),
|
|
84
|
+
columns
|
|
85
|
+
});
|
|
86
|
+
watch([visibleColumns, optionalHeaders], () => {
|
|
87
|
+
const hidden = optionalHeaders.value.map((h) => h.key).filter((key) => !visibleColumns.value.includes(key) && allFilters.value?.[key] !== void 0);
|
|
88
|
+
if (!hidden.length) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
allFilters.value = Object.fromEntries(Object.entries(allFilters.value).filter(([key]) => !hidden.includes(key)));
|
|
92
|
+
}, { flush: "sync" });
|
|
93
|
+
function toggleColumn(key) {
|
|
94
|
+
const current = visibleColumns.value;
|
|
95
|
+
const next = current.includes(key) ? current.filter((k) => k !== key) : [...current, key];
|
|
96
|
+
const isDefault = next.length === defaultColumns.value.length && next.every((k) => defaultColumns.value.includes(k));
|
|
97
|
+
columns.value = isDefault ? null : next;
|
|
98
|
+
}
|
|
99
|
+
const columnsSearch = ref("");
|
|
100
|
+
const filteredOptionalHeaders = computed(() => {
|
|
101
|
+
const q = columnsSearch.value?.toLowerCase();
|
|
102
|
+
return q ? optionalHeaders.value.filter((h) => String(h.title).toLowerCase().includes(q)) : optionalHeaders.value;
|
|
103
|
+
});
|
|
104
|
+
const aggregatesFields = computed(() => {
|
|
105
|
+
const arr = headers.value.map((h) => ({
|
|
106
|
+
...h,
|
|
107
|
+
aggregates: aggregates.value[h.key]
|
|
108
|
+
}));
|
|
109
|
+
return arr;
|
|
110
|
+
});
|
|
111
|
+
const hasAggregates = computed(() => {
|
|
112
|
+
if (props.hideAggregates) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
return aggregatesFields.value.filter((a) => a && a.aggregates).length > 0;
|
|
116
|
+
});
|
|
117
|
+
const aggregateTableRowItem = computed(() => {
|
|
118
|
+
const columnsData = aggregatesFields.value.reduce((acc, f) => {
|
|
119
|
+
const firstKey = f.aggregates ? Object.keys(f.aggregates)[0] : null;
|
|
120
|
+
acc[f.key] = firstKey ? f.aggregates[firstKey] : null;
|
|
121
|
+
return acc;
|
|
122
|
+
}, {});
|
|
123
|
+
return {
|
|
124
|
+
raw: columnsData,
|
|
125
|
+
columns: columnsData,
|
|
126
|
+
selectable: false
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
const clientPages = computed(() => {
|
|
130
|
+
const length = Math.ceil(totalItems.value / itemsPerPage.value);
|
|
131
|
+
return Array.from({ length }, (_, i) => i + 1);
|
|
132
|
+
});
|
|
133
|
+
watch(aggregates, (newVal) => {
|
|
134
|
+
modelAggregates.value = newVal;
|
|
135
|
+
}, { immediate: true });
|
|
136
|
+
async function userSelectedAction(action) {
|
|
137
|
+
if (action.extra) {
|
|
138
|
+
emit("action", { ...action, selection: selectedItems.value });
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (action.confirm && action.confirm_message) {
|
|
142
|
+
const resp = await confirmDialog.value.confirm({
|
|
143
|
+
title: action[selectedItems.value.length === 0 ? "bulk_label" : "label"],
|
|
144
|
+
text: action.confirm_message
|
|
145
|
+
});
|
|
146
|
+
if (!resp) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
return executeAction(action.id);
|
|
150
|
+
}
|
|
151
|
+
return executeAction(action.id);
|
|
152
|
+
}
|
|
153
|
+
const checkShowSelect = computed(() => {
|
|
154
|
+
return Boolean(selectionKey.value && selectionKey.value !== "");
|
|
155
|
+
});
|
|
156
|
+
const addButtonLabel = computed(() => {
|
|
157
|
+
if (props.addButton === true) {
|
|
158
|
+
return t("dt.addButton");
|
|
159
|
+
}
|
|
160
|
+
return props.addButton;
|
|
161
|
+
});
|
|
162
|
+
function btnAddPressed() {
|
|
163
|
+
emit("action", { id: "new" });
|
|
164
|
+
emit("new");
|
|
165
|
+
}
|
|
166
|
+
function paginationLabel(props2) {
|
|
167
|
+
return t("dt.pages", [(props2.page - 1) * props2.itemsPerPage + 1, Math.min(props2.page * props2.itemsPerPage, totalItems.value), totalItems.value]);
|
|
168
|
+
}
|
|
169
|
+
const componentAttrs = useAttrs();
|
|
170
|
+
const isFill = computed(() => {
|
|
171
|
+
return !!props.fill || normalizeClass(componentAttrs.class).split(" ").includes("we-datatable-card--fill");
|
|
172
|
+
});
|
|
173
|
+
const cardRef = useTemplateRef("cardRef");
|
|
174
|
+
const { height: fillHeight } = useAutoFillHeight(cardRef, () => props.fill);
|
|
175
|
+
const dtAttrs = computed(() => {
|
|
176
|
+
const { "onClick:row": onClickRow, ...otherAttrs } = componentAttrs;
|
|
177
|
+
return {
|
|
178
|
+
"fixed-header": isFill.value || void 0,
|
|
179
|
+
...otherAttrs,
|
|
180
|
+
"height": props.height,
|
|
181
|
+
// Only add the key when there is a listener: Vuetify builds a row click handler
|
|
182
|
+
// for every `on*:row` key, even an `undefined` one, and then marks every row as
|
|
183
|
+
// `v-data-table__tr--clickable` (pointer cursor).
|
|
184
|
+
...onClickRow && {
|
|
185
|
+
"onClick:row": (event, args) => {
|
|
186
|
+
onClickRow(args.item, args, event);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
});
|
|
191
|
+
const { allHeaders, autoSlots, userDefinedSlots } = useDatatableColumns(headers, toRef(props, "extraHeaders"), toRef(props, "actionsHeader"));
|
|
192
|
+
const isInitialLoading = computed(() => loading.value && allHeaders.value.length === 0);
|
|
193
|
+
function reset() {
|
|
194
|
+
clearSelection();
|
|
195
|
+
allFilters.value = {};
|
|
196
|
+
search.value = "";
|
|
197
|
+
page.value = 1;
|
|
198
|
+
sortBy.value = [];
|
|
199
|
+
}
|
|
200
|
+
const headersMap = computed(() => {
|
|
201
|
+
return availableFilters.value.reduce((acc, f) => {
|
|
202
|
+
acc[f.key] = f;
|
|
203
|
+
return acc;
|
|
204
|
+
}, {});
|
|
205
|
+
});
|
|
206
|
+
const tableRef = useTemplateRef("tableRef");
|
|
207
|
+
const scrollWrapper = computed(() => tableRef.value?.$el?.querySelector(".v-table__wrapper"));
|
|
208
|
+
const { arrivedState } = useScroll(scrollWrapper);
|
|
209
|
+
const isOverflowing = ref(false);
|
|
210
|
+
useResizeObserver(scrollWrapper, ([entry]) => {
|
|
211
|
+
const el = entry.target;
|
|
212
|
+
isOverflowing.value = el.scrollWidth > el.clientWidth;
|
|
213
|
+
arrivedState.right = el.scrollLeft + el.clientWidth >= el.scrollWidth - 1;
|
|
214
|
+
});
|
|
215
|
+
const hasContentUnderFixed = computed(() => isOverflowing.value && !arrivedState.right);
|
|
216
|
+
watch(selectedItems, (value) => {
|
|
217
|
+
if (value !== modelSelection.value) {
|
|
218
|
+
modelSelection.value = value;
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
watch(modelSelection, (value) => {
|
|
222
|
+
if (value !== void 0 && value !== selectedItems.value) {
|
|
223
|
+
selectedItems.value = value;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
defineExpose({ reloadData, clearSelection, executeAction, reset, headersMap, totalItems });
|
|
227
|
+
</script>
|
|
228
|
+
|
|
229
|
+
<template>
|
|
230
|
+
<v-card
|
|
231
|
+
ref="cardRef"
|
|
232
|
+
class="we-datatable-card pa-4"
|
|
233
|
+
:class="{ 'we-datatable-card--fill': isFill }"
|
|
234
|
+
:style="fillHeight ? { height: fillHeight } : void 0"
|
|
235
|
+
>
|
|
236
|
+
<v-row
|
|
237
|
+
v-if="!hideTopActions"
|
|
238
|
+
>
|
|
239
|
+
<v-col
|
|
240
|
+
cols="12"
|
|
241
|
+
md="8"
|
|
242
|
+
class="d-flex align-center"
|
|
243
|
+
>
|
|
244
|
+
<slot name="action-buttons">
|
|
245
|
+
<v-btn
|
|
246
|
+
v-if="addButtonLabel"
|
|
247
|
+
class="mr-2"
|
|
248
|
+
color="primary"
|
|
249
|
+
@click="btnAddPressed"
|
|
250
|
+
>
|
|
251
|
+
<v-icon start>
|
|
252
|
+
$plus
|
|
253
|
+
</v-icon> {{ addButtonLabel }}
|
|
254
|
+
</v-btn>
|
|
255
|
+
</slot>
|
|
256
|
+
|
|
257
|
+
<WeDtActions
|
|
258
|
+
:selection="selectedItems"
|
|
259
|
+
:loading="loadingExecuteAction"
|
|
260
|
+
:actions="actions"
|
|
261
|
+
:extra-actions="props.extraActions"
|
|
262
|
+
@action="userSelectedAction"
|
|
263
|
+
/>
|
|
264
|
+
</v-col>
|
|
265
|
+
<v-col
|
|
266
|
+
class="d-flex align-center"
|
|
267
|
+
md="4"
|
|
268
|
+
cols="12"
|
|
269
|
+
>
|
|
270
|
+
<v-btn
|
|
271
|
+
class="mr-2"
|
|
272
|
+
variant="tonal"
|
|
273
|
+
icon
|
|
274
|
+
size="small"
|
|
275
|
+
rounded="lg"
|
|
276
|
+
@click="reloadData()"
|
|
277
|
+
>
|
|
278
|
+
<v-icon icon="$refresh" />
|
|
279
|
+
</v-btn>
|
|
280
|
+
|
|
281
|
+
<v-text-field
|
|
282
|
+
v-model="search"
|
|
283
|
+
variant="filled"
|
|
284
|
+
flat
|
|
285
|
+
clearable
|
|
286
|
+
hide-details
|
|
287
|
+
prepend-inner-icon="$search"
|
|
288
|
+
density="compact"
|
|
289
|
+
class="we-datatable-search"
|
|
290
|
+
rounded="lg"
|
|
291
|
+
:placeholder="$t('dt.search.label')"
|
|
292
|
+
/>
|
|
293
|
+
<v-menu
|
|
294
|
+
v-if="optionalHeaders.length"
|
|
295
|
+
:close-on-content-click="false"
|
|
296
|
+
location="bottom end"
|
|
297
|
+
width="300px"
|
|
298
|
+
>
|
|
299
|
+
<template #activator="{ props: menuProps, isActive }">
|
|
300
|
+
<v-btn
|
|
301
|
+
v-bind="menuProps"
|
|
302
|
+
:icon="columns !== null ? '$columnsOn' : '$columns'"
|
|
303
|
+
rounded="lg"
|
|
304
|
+
variant="tonal"
|
|
305
|
+
:color="isActive || columns !== null ? 'primary' : void 0"
|
|
306
|
+
size="small"
|
|
307
|
+
class="ml-1"
|
|
308
|
+
:title="$t('dt.columns')"
|
|
309
|
+
/>
|
|
310
|
+
</template>
|
|
311
|
+
<!-- stesso layout del menu di WeDtSelectFilter -->
|
|
312
|
+
<v-card>
|
|
313
|
+
<v-card-title class="d-flex align-center pb-0 mt-2">
|
|
314
|
+
{{ $t("dt.columns") }}
|
|
315
|
+
<v-spacer />
|
|
316
|
+
<v-btn
|
|
317
|
+
v-if="columns !== null"
|
|
318
|
+
variant="text"
|
|
319
|
+
border="sm"
|
|
320
|
+
color="error"
|
|
321
|
+
size="small"
|
|
322
|
+
class="ml-1"
|
|
323
|
+
@click="columns = null"
|
|
324
|
+
>
|
|
325
|
+
{{ $t("reset") }}
|
|
326
|
+
</v-btn>
|
|
327
|
+
</v-card-title>
|
|
328
|
+
<v-text-field
|
|
329
|
+
v-if="optionalHeaders.length > 8"
|
|
330
|
+
v-model="columnsSearch"
|
|
331
|
+
prepend-inner-icon="$search"
|
|
332
|
+
:placeholder="$t('dt.search.label')"
|
|
333
|
+
class="mx-3 my-2"
|
|
334
|
+
rounded="we"
|
|
335
|
+
density="compact"
|
|
336
|
+
variant="solo-filled"
|
|
337
|
+
flat
|
|
338
|
+
hide-details
|
|
339
|
+
clearable
|
|
340
|
+
/>
|
|
341
|
+
<v-list class="py-1">
|
|
342
|
+
<v-list-item
|
|
343
|
+
v-for="h in filteredOptionalHeaders"
|
|
344
|
+
:key="h.key"
|
|
345
|
+
lines="one"
|
|
346
|
+
@click="toggleColumn(h.key)"
|
|
347
|
+
>
|
|
348
|
+
<template #prepend>
|
|
349
|
+
<v-list-item-action start>
|
|
350
|
+
<v-checkbox-btn
|
|
351
|
+
:model-value="visibleColumns.includes(h.key)"
|
|
352
|
+
@click.stop.prevent="toggleColumn(h.key)"
|
|
353
|
+
/>
|
|
354
|
+
</v-list-item-action>
|
|
355
|
+
</template>
|
|
356
|
+
<v-list-item-title>{{ h.title }}</v-list-item-title>
|
|
357
|
+
</v-list-item>
|
|
358
|
+
</v-list>
|
|
359
|
+
</v-card>
|
|
360
|
+
</v-menu>
|
|
361
|
+
<!-- primary = pannello aperto o filtri applicati, icona piena = filtri applicati -->
|
|
362
|
+
<v-btn
|
|
363
|
+
:icon="hasFilters ? '$filter' : '$filterOff'"
|
|
364
|
+
rounded="lg"
|
|
365
|
+
variant="tonal"
|
|
366
|
+
:color="showFilters || hasFilters ? 'primary' : void 0"
|
|
367
|
+
size="small"
|
|
368
|
+
class="ml-1"
|
|
369
|
+
@click="showFilters = !showFilters"
|
|
370
|
+
/>
|
|
371
|
+
</v-col>
|
|
372
|
+
<v-expand-transition>
|
|
373
|
+
<v-col
|
|
374
|
+
v-if="showFilters"
|
|
375
|
+
cols="12"
|
|
376
|
+
class="pa-0"
|
|
377
|
+
>
|
|
378
|
+
<v-col
|
|
379
|
+
cols="12"
|
|
380
|
+
class="mb-2 d-flex align-center flex-wrap ga-1"
|
|
381
|
+
>
|
|
382
|
+
<WeDtFilters
|
|
383
|
+
v-model="allFilters"
|
|
384
|
+
:available-filters="availableFilters"
|
|
385
|
+
/>
|
|
386
|
+
<v-btn
|
|
387
|
+
class="ml-auto"
|
|
388
|
+
variant="text"
|
|
389
|
+
text
|
|
390
|
+
|
|
391
|
+
@click="reset"
|
|
392
|
+
>
|
|
393
|
+
Reset
|
|
394
|
+
</v-btn>
|
|
395
|
+
</v-col>
|
|
396
|
+
</v-col>
|
|
397
|
+
</v-expand-transition>
|
|
398
|
+
<slot
|
|
399
|
+
name="above-table"
|
|
400
|
+
v-bind="{ headersMap }"
|
|
401
|
+
/>
|
|
402
|
+
</v-row>
|
|
403
|
+
|
|
404
|
+
<v-alert
|
|
405
|
+
v-if="error"
|
|
406
|
+
type="error"
|
|
407
|
+
variant="tonal"
|
|
408
|
+
class="my-4"
|
|
409
|
+
:title="$t('dt.error')"
|
|
410
|
+
:text="formatError(error)"
|
|
411
|
+
>
|
|
412
|
+
<template #append>
|
|
413
|
+
<v-btn
|
|
414
|
+
variant="tonal"
|
|
415
|
+
color="error"
|
|
416
|
+
size="small"
|
|
417
|
+
@click="reloadData()"
|
|
418
|
+
>
|
|
419
|
+
<v-icon start>
|
|
420
|
+
$refresh
|
|
421
|
+
</v-icon>
|
|
422
|
+
{{ $t("dt.reload") }}
|
|
423
|
+
</v-btn>
|
|
424
|
+
</template>
|
|
425
|
+
</v-alert>
|
|
426
|
+
|
|
427
|
+
<VDataTableServer
|
|
428
|
+
ref="tableRef"
|
|
429
|
+
v-bind="dtAttrs"
|
|
430
|
+
v-model:model-value="selectedItems"
|
|
431
|
+
v-model:items-per-page="itemsPerPage"
|
|
432
|
+
v-model:page="page"
|
|
433
|
+
v-model:sort-by="sortBy"
|
|
434
|
+
class="we-data-table"
|
|
435
|
+
:class="{
|
|
436
|
+
'we-data-table--has-hidden-content': hasContentUnderFixed,
|
|
437
|
+
'we-data-table--initial-loading': isInitialLoading
|
|
438
|
+
}"
|
|
439
|
+
:items-length="totalItems"
|
|
440
|
+
:search="debouncedSearch"
|
|
441
|
+
:loading="loading ? 'primary' : false"
|
|
442
|
+
:headers="allHeaders"
|
|
443
|
+
:items="items"
|
|
444
|
+
:multi-sort="multiSort"
|
|
445
|
+
hide-default-footer
|
|
446
|
+
:item-value="selectionKey"
|
|
447
|
+
:show-select="checkShowSelect"
|
|
448
|
+
:items-per-page-options="itemsPerPageOptions"
|
|
449
|
+
@update:options="load"
|
|
450
|
+
>
|
|
451
|
+
<template
|
|
452
|
+
v-for="slotName in userDefinedSlots"
|
|
453
|
+
#[slotName]="attrs"
|
|
454
|
+
>
|
|
455
|
+
<slot
|
|
456
|
+
:name="slotName"
|
|
457
|
+
v-bind="attrs"
|
|
458
|
+
:aggregates="hasAggregates ? aggregates : null"
|
|
459
|
+
/>
|
|
460
|
+
</template>
|
|
461
|
+
|
|
462
|
+
<template
|
|
463
|
+
v-for="s in autoSlots"
|
|
464
|
+
#[s.slot]="{ item }"
|
|
465
|
+
:key="s.key"
|
|
466
|
+
>
|
|
467
|
+
<component
|
|
468
|
+
:is="s.component"
|
|
469
|
+
:value="item[s.key]"
|
|
470
|
+
:field="s.field"
|
|
471
|
+
:item="item"
|
|
472
|
+
/>
|
|
473
|
+
</template>
|
|
474
|
+
<template
|
|
475
|
+
v-if="hasAggregates"
|
|
476
|
+
#[`body.append`]
|
|
477
|
+
>
|
|
478
|
+
<v-data-table-row
|
|
479
|
+
:item="aggregateTableRowItem"
|
|
480
|
+
density="comfortable"
|
|
481
|
+
class="dt-aggregate-table-row"
|
|
482
|
+
>
|
|
483
|
+
<template
|
|
484
|
+
v-for="slotName in userDefinedSlots"
|
|
485
|
+
#[slotName]="attrs"
|
|
486
|
+
>
|
|
487
|
+
<slot
|
|
488
|
+
v-if="slotName !== 'item.actions'"
|
|
489
|
+
:name="slotName"
|
|
490
|
+
v-bind="attrs"
|
|
491
|
+
:aggregates="hasAggregates ? aggregates : null"
|
|
492
|
+
/>
|
|
493
|
+
</template>
|
|
494
|
+
|
|
495
|
+
<template
|
|
496
|
+
v-for="s in autoSlots"
|
|
497
|
+
#[s.slot]="{ item }"
|
|
498
|
+
:key="s.key"
|
|
499
|
+
>
|
|
500
|
+
<component
|
|
501
|
+
:is="s.component"
|
|
502
|
+
:value="item[s.key]"
|
|
503
|
+
:field="s.field"
|
|
504
|
+
:item="item"
|
|
505
|
+
/>
|
|
506
|
+
</template>
|
|
507
|
+
</v-data-table-row>
|
|
508
|
+
</template>
|
|
509
|
+
<template
|
|
510
|
+
v-if="pagination"
|
|
511
|
+
#bottom="footerProps"
|
|
512
|
+
>
|
|
513
|
+
<div class="d-flex pt-2 align-center we-datatable-footer">
|
|
514
|
+
<v-select
|
|
515
|
+
v-model="itemsPerPage"
|
|
516
|
+
style="flex: 0 1 auto"
|
|
517
|
+
class="mr-5"
|
|
518
|
+
hide-details
|
|
519
|
+
flat
|
|
520
|
+
density="compact"
|
|
521
|
+
variant="solo-filled"
|
|
522
|
+
:items="itemsPerPageOptions"
|
|
523
|
+
/>
|
|
524
|
+
|
|
525
|
+
{{ paginationLabel(footerProps) }}
|
|
526
|
+
|
|
527
|
+
<v-spacer />
|
|
528
|
+
<v-btn
|
|
529
|
+
:disabled="page === 1"
|
|
530
|
+
icon
|
|
531
|
+
variant="text"
|
|
532
|
+
size="small"
|
|
533
|
+
@click="page--"
|
|
534
|
+
>
|
|
535
|
+
<v-icon size="x-large">
|
|
536
|
+
$prev
|
|
537
|
+
</v-icon>
|
|
538
|
+
</v-btn>
|
|
539
|
+
|
|
540
|
+
<v-select
|
|
541
|
+
v-model="page"
|
|
542
|
+
hide-details
|
|
543
|
+
style="flex: 0 1 auto;"
|
|
544
|
+
density="compact"
|
|
545
|
+
variant="solo-filled"
|
|
546
|
+
flat
|
|
547
|
+
class="mx-1"
|
|
548
|
+
:items="clientPages"
|
|
549
|
+
/>
|
|
550
|
+
|
|
551
|
+
<v-btn
|
|
552
|
+
:disabled="footerProps.page === footerProps.pageCount"
|
|
553
|
+
icon
|
|
554
|
+
variant="text"
|
|
555
|
+
size="small"
|
|
556
|
+
@click="page++"
|
|
557
|
+
>
|
|
558
|
+
<v-icon size="x-large">
|
|
559
|
+
$next
|
|
560
|
+
</v-icon>
|
|
561
|
+
</v-btn>
|
|
562
|
+
</div>
|
|
563
|
+
</template>
|
|
564
|
+
</VDataTableServer>
|
|
565
|
+
|
|
566
|
+
<WeConfirmDialog ref="confirmDialog" />
|
|
567
|
+
</v-card>
|
|
568
|
+
</template>
|
|
569
|
+
|
|
570
|
+
<style>
|
|
571
|
+
.we-datatable-search .v-field__outline::before,
|
|
572
|
+
.we-datatable-search .v-field__outline::after {
|
|
573
|
+
border: none !important;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/*
|
|
577
|
+
Fill mode (opt-in via `class="we-datatable-card--fill"` on <WeDatatable>):
|
|
578
|
+
the card fills its container, the header stays fixed (Vuetify's
|
|
579
|
+
fixed-header, enabled by the component when it detects this class) and
|
|
580
|
+
only the rows scroll. The consumer just needs to give the container a
|
|
581
|
+
bounded height. `min-height: 0` at every level lets each flex item
|
|
582
|
+
shrink below its content height, keeping the scroll on the rows wrapper
|
|
583
|
+
instead of the page.
|
|
584
|
+
*/
|
|
585
|
+
.we-datatable-card.we-datatable-card--fill {
|
|
586
|
+
height: 100%;
|
|
587
|
+
display: flex;
|
|
588
|
+
flex-direction: column;
|
|
589
|
+
}
|
|
590
|
+
.we-datatable-card.we-datatable-card--fill > .v-row {
|
|
591
|
+
flex: 0 0 auto;
|
|
592
|
+
}
|
|
593
|
+
.we-datatable-card.we-datatable-card--fill > .v-alert {
|
|
594
|
+
flex: 0 0 auto;
|
|
595
|
+
}
|
|
596
|
+
.we-datatable-card.we-datatable-card--fill > .we-data-table {
|
|
597
|
+
flex: 1 1 auto;
|
|
598
|
+
min-height: 0;
|
|
599
|
+
display: flex;
|
|
600
|
+
flex-direction: column;
|
|
601
|
+
}
|
|
602
|
+
.we-datatable-card.we-datatable-card--fill > .we-data-table > .v-table__wrapper {
|
|
603
|
+
flex: 1 1 0;
|
|
604
|
+
min-height: 0;
|
|
605
|
+
}
|
|
606
|
+
.we-datatable-card.we-datatable-card--fill > .we-data-table > :not(.v-table__wrapper) {
|
|
607
|
+
flex: 0 0 auto;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
.we-data-table .v-data-table__th--sticky,
|
|
611
|
+
.we-data-table .v-data-table-column--fixed,
|
|
612
|
+
.we-data-table .v-data-table-column--fixed-end {
|
|
613
|
+
background-color: rgb(var(--v-theme-surface)) !important;
|
|
614
|
+
}
|
|
615
|
+
.we-data-table .v-data-table-column--first-fixed-end {
|
|
616
|
+
border-left: none !important;
|
|
617
|
+
}
|
|
618
|
+
.we-data-table.we-data-table--has-hidden-content tbody td.v-data-table-column--first-fixed-end {
|
|
619
|
+
position: relative;
|
|
620
|
+
}
|
|
621
|
+
.we-data-table.we-data-table--has-hidden-content tbody td.v-data-table-column--first-fixed-end::before {
|
|
622
|
+
content: "";
|
|
623
|
+
position: absolute;
|
|
624
|
+
top: 0;
|
|
625
|
+
left: 0;
|
|
626
|
+
bottom: 0;
|
|
627
|
+
width: 10px;
|
|
628
|
+
transform: translateX(-100%);
|
|
629
|
+
background: linear-gradient(to right, transparent, rgba(var(--v-theme-on-surface), 0.06));
|
|
630
|
+
pointer-events: none;
|
|
631
|
+
}
|
|
632
|
+
.we-data-table .dt-aggregate-table-row .v-selection-control {
|
|
633
|
+
display: none;
|
|
634
|
+
}
|
|
635
|
+
.we-data-table.we-data-table--initial-loading > .v-table__wrapper {
|
|
636
|
+
padding-top: var(--we-datatable-initial-loading-height, 48px);
|
|
637
|
+
}
|
|
638
|
+
</style>
|