@mapomodule/uikit 2.0.0-beta.8 → 2.0.0-experimental.2
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/README.md +47 -174
- package/dist/__tests__/MapoConfirmDialog.component.test.d.ts +2 -0
- package/dist/__tests__/MapoConfirmDialog.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoDetail.component.test.d.ts +2 -0
- package/dist/__tests__/MapoDetail.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoDetailLangSwitch.component.test.d.ts +2 -0
- package/dist/__tests__/MapoDetailLangSwitch.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoListActions.component.test.d.ts +2 -0
- package/dist/__tests__/MapoListActions.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoListTable.component.test.d.ts +2 -0
- package/dist/__tests__/MapoListTable.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoSnackBar.component.test.d.ts +2 -0
- package/dist/__tests__/MapoSnackBar.component.test.d.ts.map +1 -0
- package/dist/__tests__/__mocks__/nuxt-app.d.ts +9 -0
- package/dist/__tests__/__mocks__/nuxt-app.d.ts.map +1 -0
- package/dist/__tests__/formValues.test.d.ts +2 -0
- package/dist/__tests__/formValues.test.d.ts.map +1 -0
- package/dist/__tests__/langInfo.test.d.ts +2 -0
- package/dist/__tests__/langInfo.test.d.ts.map +1 -0
- package/dist/__tests__/listTable.test.d.ts +2 -0
- package/dist/__tests__/listTable.test.d.ts.map +1 -0
- package/dist/__tests__/mediaLanguages.test.d.ts +2 -0
- package/dist/__tests__/mediaLanguages.test.d.ts.map +1 -0
- package/dist/__tests__/runtimePages.test.d.ts +2 -0
- package/dist/__tests__/runtimePages.test.d.ts.map +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/module.d.mts +1 -0
- package/dist/module.d.ts.map +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +10 -0
- package/dist/runtime/assets/main.css +1 -1
- package/dist/runtime/components/MapoConfirmDialog.vue +18 -1
- package/dist/runtime/components/MapoConfirmDialog.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoDetail.vue +263 -33
- package/dist/runtime/components/MapoDetail.vue.d.ts +191 -9
- package/dist/runtime/components/MapoDetail.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoDetailExtensions.vue +24 -0
- package/dist/runtime/components/MapoDetailExtensions.vue.d.ts +15 -0
- package/dist/runtime/components/MapoDetailExtensions.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoDetailLangSwitch.vue +21 -25
- package/dist/runtime/components/MapoDetailLangSwitch.vue.d.ts +4 -3
- package/dist/runtime/components/MapoDetailLangSwitch.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoDropArea.vue.d.ts +1 -1
- package/dist/runtime/components/MapoDropArea.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoList.vue +7 -3
- package/dist/runtime/components/MapoList.vue.d.ts +14 -4
- package/dist/runtime/components/MapoList.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoListActions.vue +12 -5
- package/dist/runtime/components/MapoListActions.vue.d.ts +4 -0
- package/dist/runtime/components/MapoListActions.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoListQuickEdit.vue +1 -1
- package/dist/runtime/components/MapoListTable.vue +99 -33
- package/dist/runtime/components/MapoListTable.vue.d.ts +11 -6
- package/dist/runtime/components/MapoListTable.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaEditor.vue +10 -4
- package/dist/runtime/components/MapoMediaEditor.vue.d.ts +1 -0
- package/dist/runtime/components/MapoMediaEditor.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaFileChanger.vue +1 -1
- package/dist/runtime/components/MapoMediaManager.vue +1 -1
- package/dist/runtime/components/MapoMediaManagerDialog.vue +1 -1
- package/dist/runtime/components/MapoMediaPreview.vue +1 -1
- package/dist/runtime/components/MapoMediaUploader.vue +21 -21
- package/dist/runtime/components/MapoMediaUploader.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMenuManager.vue +23 -3
- package/dist/runtime/components/MapoMenuManager.vue.d.ts +2 -2
- package/dist/runtime/components/MapoMenuManager.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMenuTreeview.vue.d.ts +1 -1
- package/dist/runtime/components/MapoMenuTreeview.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMenuTreeviewNode.vue.d.ts +2 -2
- package/dist/runtime/components/MapoSnackBar.vue +11 -0
- package/dist/runtime/components/MapoSnackBar.vue.d.ts.map +1 -1
- package/dist/runtime/composables/defineDetailExtension.d.ts +32 -0
- package/dist/runtime/composables/defineDetailExtension.d.ts.map +1 -0
- package/dist/runtime/composables/defineDetailExtension.js +34 -0
- package/dist/runtime/composables/useMapoDetail.d.ts +18 -0
- package/dist/runtime/composables/useMapoDetail.d.ts.map +1 -0
- package/dist/runtime/composables/useMapoDetail.js +5 -0
- package/dist/runtime/page-meta.nuxt.d.ts +4 -0
- package/dist/runtime/stores/media.d.ts +8 -2
- package/dist/runtime/stores/media.d.ts.map +1 -1
- package/dist/runtime/stores/media.js +16 -0
- package/dist/runtime/types/detail.d.ts +167 -0
- package/dist/runtime/types/detail.d.ts.map +1 -0
- package/dist/runtime/types/detail.js +0 -0
- package/dist/runtime/types/list.d.ts +10 -2
- package/dist/runtime/types/list.d.ts.map +1 -1
- package/dist/runtime/utils/formValues.d.ts +8 -0
- package/dist/runtime/utils/formValues.d.ts.map +1 -0
- package/dist/runtime/utils/formValues.js +19 -0
- package/dist/runtime/utils/langInfo.d.ts +30 -0
- package/dist/runtime/utils/langInfo.d.ts.map +1 -0
- package/dist/runtime/utils/langInfo.js +8 -0
- package/dist/runtime/utils/listTable.d.ts +29 -0
- package/dist/runtime/utils/listTable.d.ts.map +1 -0
- package/dist/runtime/utils/listTable.js +21 -0
- package/package.json +7 -8
- package/src/__tests__/MapoConfirmDialog.component.test.ts +165 -0
- package/src/__tests__/MapoDetail.component.test.ts +1107 -0
- package/src/__tests__/MapoDetailLangSwitch.component.test.ts +145 -0
- package/src/__tests__/MapoListActions.component.test.ts +175 -0
- package/src/__tests__/MapoListTable.component.test.ts +504 -0
- package/src/__tests__/MapoSnackBar.component.test.ts +79 -0
- package/src/__tests__/__mocks__/nuxt-app.ts +8 -0
- package/src/__tests__/formValues.test.ts +31 -0
- package/src/__tests__/langInfo.test.ts +48 -0
- package/src/__tests__/listTable.test.ts +82 -0
- package/src/__tests__/mediaLanguages.test.ts +66 -0
- package/src/__tests__/runtimePages.test.ts +17 -0
- package/src/index.ts +8 -0
- package/src/module.ts +12 -0
- package/src/runtime/assets/main.css +13 -0
- package/src/runtime/components/MapoConfirmDialog.vue +28 -1
- package/src/runtime/components/MapoDetail.vue +481 -53
- package/src/runtime/components/MapoDetailExtensions.vue +39 -0
- package/src/runtime/components/MapoDetailLangSwitch.vue +26 -27
- package/src/runtime/components/MapoList.vue +20 -5
- package/src/runtime/components/MapoListActions.vue +16 -4
- package/src/runtime/components/MapoListTable.vue +128 -41
- package/src/runtime/components/MapoMediaEditor.vue +17 -4
- package/src/runtime/components/MapoMediaUploader.vue +25 -21
- package/src/runtime/components/MapoMenuManager.vue +38 -3
- package/src/runtime/components/MapoSnackBar.vue +12 -0
- package/src/runtime/composables/defineDetailExtension.ts +78 -0
- package/src/runtime/composables/useMapoDetail.ts +24 -0
- package/src/runtime/page-meta.nuxt.d.ts +4 -0
- package/src/runtime/stores/media.ts +32 -0
- package/src/runtime/types/detail.ts +178 -0
- package/src/runtime/types/list.ts +10 -2
- package/src/runtime/utils/formValues.ts +28 -0
- package/src/runtime/utils/langInfo.ts +38 -0
- package/src/runtime/utils/listTable.ts +54 -0
|
@@ -39,6 +39,7 @@ function onSelectChange(v) {
|
|
|
39
39
|
const lang = typeof v === "object" && v !== null ? v.value : v;
|
|
40
40
|
if (lang) selectLang(lang);
|
|
41
41
|
}
|
|
42
|
+
const showSelect = computed(() => props.langs.length > props.langThreshold);
|
|
42
43
|
const selectItems = computed(
|
|
43
44
|
() => props.langs.map((lang) => ({
|
|
44
45
|
label: lang.toUpperCase(),
|
|
@@ -68,26 +69,21 @@ watch(
|
|
|
68
69
|
<div
|
|
69
70
|
class="flex items-end gap-0 border-b border-gray-200 dark:border-gray-700 mt-2 mb-4"
|
|
70
71
|
>
|
|
71
|
-
<!-- Language select —
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
:trailing-icon="
|
|
87
|
-
open ? 'i-lucide-chevron-up' : 'i-lucide-chevron-down'
|
|
88
|
-
"
|
|
89
|
-
class="w-full justify-between font-medium"
|
|
90
|
-
>
|
|
72
|
+
<!-- Language select — above langThreshold only, aligned at bottom of row -->
|
|
73
|
+
<template v-if="showSelect">
|
|
74
|
+
<USelectMenu
|
|
75
|
+
:model-value="modelValue"
|
|
76
|
+
:items="selectItems"
|
|
77
|
+
value-key="value"
|
|
78
|
+
label-key="label"
|
|
79
|
+
size="sm"
|
|
80
|
+
variant="ghost"
|
|
81
|
+
class="w-28 shrink-0 mb-px font-medium"
|
|
82
|
+
@update:model-value="onSelectChange"
|
|
83
|
+
>
|
|
84
|
+
<!-- The trigger is already a button with its own chevron: the slot
|
|
85
|
+
holds only what it shows, never another button. -->
|
|
86
|
+
<template #default>
|
|
91
87
|
<span class="flex items-center gap-1">
|
|
92
88
|
<span
|
|
93
89
|
v-if="hasErrors(modelValue)"
|
|
@@ -95,12 +91,12 @@ watch(
|
|
|
95
91
|
/>
|
|
96
92
|
{{ modelValue.toUpperCase() }}
|
|
97
93
|
</span>
|
|
98
|
-
</
|
|
99
|
-
</
|
|
100
|
-
</USelectMenu>
|
|
94
|
+
</template>
|
|
95
|
+
</USelectMenu>
|
|
101
96
|
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
<!-- Divider -->
|
|
98
|
+
<div class="h-5 w-px bg-gray-200 dark:bg-gray-700 mx-2 shrink-0" />
|
|
99
|
+
</template>
|
|
104
100
|
|
|
105
101
|
<!-- Tab bar — always shown, scrollable -->
|
|
106
102
|
<div class="flex gap-1 overflow-x-auto scrollbar-none flex-1">
|
|
@@ -4,8 +4,9 @@ type __VLS_Props = {
|
|
|
4
4
|
errors?: Record<string, string[]>;
|
|
5
5
|
noRouteChange?: boolean;
|
|
6
6
|
/**
|
|
7
|
-
* Number of languages above which
|
|
8
|
-
*
|
|
7
|
+
* Number of languages above which a searchable select appears next to the
|
|
8
|
+
* tab bar, for quick navigation. Default: `8`. `0` always shows it,
|
|
9
|
+
* `Infinity` never does.
|
|
9
10
|
*/
|
|
10
11
|
langThreshold?: number;
|
|
11
12
|
};
|
|
@@ -15,8 +16,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
15
16
|
"onUpdate:modelValue"?: ((lang: string) => any) | undefined;
|
|
16
17
|
}>, {
|
|
17
18
|
errors: Record<string, string[]>;
|
|
18
|
-
noRouteChange: boolean;
|
|
19
19
|
langThreshold: number;
|
|
20
|
+
noRouteChange: boolean;
|
|
20
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
21
22
|
declare const _default: typeof __VLS_export;
|
|
22
23
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoDetailLangSwitch.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoDetailLangSwitch.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoDetailLangSwitch.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoDetailLangSwitch.vue"],"names":[],"mappings":"AA2KA,KAAK,WAAW,GAAG;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAClC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAkQJ,QAAA,MAAM,YAAY;;;;;YA1QL,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;mBAOjB,MAAM;mBANN,OAAO;6EA6QzB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -18,8 +18,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
|
18
18
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
19
19
|
onFiles?: ((files: File[]) => any) | undefined;
|
|
20
20
|
}>, {
|
|
21
|
-
accept: string;
|
|
22
21
|
multiple: boolean;
|
|
22
|
+
accept: string;
|
|
23
23
|
disabled: boolean;
|
|
24
24
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
25
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoDropArea.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoDropArea.vue"],"names":[],"mappings":"AAuIA,KAAK,WAAW,GAAG;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAiDJ,iBAAS,WAAW,SAEnB;AAgJD,QAAA,IAAI,OAAO;;;CAAW,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAO/C,QAAA,MAAM,UAAU;;;;;;;
|
|
1
|
+
{"version":3,"file":"MapoDropArea.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoDropArea.vue"],"names":[],"mappings":"AAuIA,KAAK,WAAW,GAAG;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAiDJ,iBAAS,WAAW,SAEnB;AAgJD,QAAA,IAAI,OAAO;;;CAAW,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAO/C,QAAA,MAAM,UAAU;;;;;;;cA9MD,OAAO;YADT,MAAM;cAEJ,OAAO;6EAkNpB,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { ref, computed, watch, useSlots } from "vue";
|
|
2
|
+
import { ref, computed, watch, useSlots, onBeforeUnmount } from "vue";
|
|
3
3
|
import { debounce } from "@mapomodule/utils";
|
|
4
4
|
import { useRoute, useRouter } from "#app";
|
|
5
5
|
const props = defineProps({
|
|
@@ -18,10 +18,11 @@ const props = defineProps({
|
|
|
18
18
|
positionField: { type: String, required: false, default: "position" },
|
|
19
19
|
editFields: { type: Array, required: false, default: () => [] },
|
|
20
20
|
languages: { type: Array, required: false },
|
|
21
|
-
registry: { type:
|
|
21
|
+
registry: { type: Object, required: false },
|
|
22
22
|
detailBase: { type: String, required: false },
|
|
23
23
|
permissionModel: { type: String, required: false },
|
|
24
|
-
|
|
24
|
+
defaultActions: { type: Boolean, required: false },
|
|
25
|
+
defaultPageSize: { type: [Number, String], required: false, default: 20 },
|
|
25
26
|
pageSizeOptions: { type: Array, required: false, default: () => [10, 20, 50, 100] },
|
|
26
27
|
responseAdapter: { type: Function, required: false },
|
|
27
28
|
paginationParams: { type: Function, required: false }
|
|
@@ -81,6 +82,7 @@ const writeUrlState = debounce(() => {
|
|
|
81
82
|
router.replace({ query });
|
|
82
83
|
}, 150);
|
|
83
84
|
watch([activeTab, activeFilters], writeUrlState, { deep: true });
|
|
85
|
+
onBeforeUnmount(() => writeUrlState.cancel());
|
|
84
86
|
const crudEndpoint = computed(
|
|
85
87
|
() => (props.endpoint ?? "").split("?")[0] || (props.endpoint ?? "")
|
|
86
88
|
);
|
|
@@ -148,6 +150,8 @@ watch([activeTab, activeFilters], () => {
|
|
|
148
150
|
:selection-query="selectionQuery"
|
|
149
151
|
:endpoint="crudEndpoint"
|
|
150
152
|
:lookup="lookup"
|
|
153
|
+
:permission-model="permissionModel"
|
|
154
|
+
:default-actions="defaultActions"
|
|
151
155
|
@action-completed="refresh"
|
|
152
156
|
/>
|
|
153
157
|
</div>
|
|
@@ -17,6 +17,7 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
17
17
|
* Ignored when `items` is provided.
|
|
18
18
|
*/
|
|
19
19
|
clientSide?: boolean;
|
|
20
|
+
/** Column definitions. A dotted `key` (`category.name`) reads a field of a related object. */
|
|
20
21
|
columns: ListColumn<T>[];
|
|
21
22
|
lookup?: string;
|
|
22
23
|
filters?: FilterDescriptor[];
|
|
@@ -38,10 +39,19 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
38
39
|
* hides the trash unless the user has `delete_article`. Omit to always show both.
|
|
39
40
|
*/
|
|
40
41
|
permissionModel?: string;
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Whether to include the built-in permanent delete bulk action.
|
|
44
|
+
* Defaults to `true`; custom `actions` are unaffected.
|
|
45
|
+
*/
|
|
46
|
+
defaultActions?: boolean;
|
|
47
|
+
/** Initial page size: a number, or `"all"`. Default: 20. */
|
|
48
|
+
defaultPageSize?: number | "all";
|
|
49
|
+
/**
|
|
50
|
+
* Options of the per-page selector. `"all"` adds an option that requests
|
|
51
|
+
* the list without pagination params, like `clientSide` does: the backend
|
|
52
|
+
* has to return the whole collection then. Default: [10, 20, 50, 100].
|
|
53
|
+
*/
|
|
54
|
+
pageSizeOptions?: (number | "all")[];
|
|
45
55
|
/**
|
|
46
56
|
* Custom response parser. Replaces the built-in DRF / flat-array detection.
|
|
47
57
|
* Return `{ items, total }` from any shape your backend returns.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoList.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoList.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoList.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoList.vue"],"names":[],"mappings":"AAuWA,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,YAAY,EAEZ,gBAAgB,EAChB,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIhF,QAAA,MAAM,YAAY,GAAK,CAAC,SAAS,MAAM,EACtC,aAAa,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,EAC9D,YAAY,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,EAC3G,gBAAgB,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EAClE;WAyhBO,OAAO,KAAK,EAAE,WAAW,GAAG,mBAAmB,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K,IAAI,CAAC;YACxE,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;YAClD,cAAc,CAAC,EAAE,CACf,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,YAAY,KACjB,OAAO,CAAC;SACd,KAAK,OAAO;QAvBb,uFAAuF;gBAC/E,OAAO;QACf,8EAA8E;4BAC1D,OAAO;QAC3B,qEAAqE;0BACnD,OAAO;QACzB,+EAA+E;4BAC3D,OAAO;QAiB3B;;;WAGG;uBACY,CAAC,KAAK,EAAE;YAAE,KAAK,EAAE,CAAC,CAAA;SAAE,KAAK,OAAO;WAK9C,CAAC,8CAA8C;QAC9C,IAAI,EAAE,CAAC,CAAC;QACR,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;KACb,KAAK,OAAO;;EA8Sb,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAI,CAAC;wBACvD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,CAAC,GAAG,EAAE,CAAC"}
|
|
@@ -11,16 +11,19 @@ const props = defineProps({
|
|
|
11
11
|
selection: { type: [Array, String], required: true },
|
|
12
12
|
selectionQuery: { type: null, required: true },
|
|
13
13
|
endpoint: { type: String, required: true },
|
|
14
|
-
lookup: { type: String, required: false, default: "id" }
|
|
14
|
+
lookup: { type: String, required: false, default: "id" },
|
|
15
|
+
permissionModel: { type: String, required: false, default: void 0 },
|
|
16
|
+
defaultActions: { type: Boolean, required: false, default: true }
|
|
15
17
|
});
|
|
16
18
|
const emit = defineEmits(["actionCompleted"]);
|
|
17
19
|
defineSlots();
|
|
18
20
|
const { t } = useI18n();
|
|
19
21
|
const snack = useSnackStore();
|
|
20
22
|
const confirm = useConfirmStore();
|
|
23
|
+
const { canDelete, checkPermission } = usePermissions();
|
|
21
24
|
const crud = useCrud(props.endpoint);
|
|
22
25
|
const isRunning = ref(false);
|
|
23
|
-
const
|
|
26
|
+
const builtInActions = computed(() => [
|
|
24
27
|
{
|
|
25
28
|
label: t("mapo.listActions.permanentDelete"),
|
|
26
29
|
handler: async ({ selection }) => {
|
|
@@ -33,12 +36,14 @@ const defaultActions = computed(() => [
|
|
|
33
36
|
)
|
|
34
37
|
);
|
|
35
38
|
},
|
|
36
|
-
permissions: "delete",
|
|
37
39
|
handleMultiple: true,
|
|
38
40
|
handleAll: false
|
|
39
41
|
}
|
|
40
42
|
]);
|
|
41
|
-
const allActions = computed(() => [
|
|
43
|
+
const allActions = computed(() => [
|
|
44
|
+
...props.defaultActions ? builtInActions.value : [],
|
|
45
|
+
...props.actions
|
|
46
|
+
]);
|
|
42
47
|
const visibleActions = computed(
|
|
43
48
|
() => allActions.value.filter(
|
|
44
49
|
(a) => props.selection === "all" ? a.handleAll ?? false : a.handleMultiple ?? true
|
|
@@ -52,9 +57,11 @@ const applyButtonColor = computed(
|
|
|
52
57
|
() => selectedAction.value?.dangerous ? "error" : "primary"
|
|
53
58
|
);
|
|
54
59
|
function canRun(action) {
|
|
60
|
+
if (builtInActions.value.includes(action)) {
|
|
61
|
+
return !props.permissionModel || canDelete(props.permissionModel);
|
|
62
|
+
}
|
|
55
63
|
const perms = action.permissions ? Array.isArray(action.permissions) ? action.permissions : [action.permissions] : [];
|
|
56
64
|
if (!perms.length) return true;
|
|
57
|
-
const { checkPermission } = usePermissions();
|
|
58
65
|
return perms.every((p) => checkPermission(p));
|
|
59
66
|
}
|
|
60
67
|
async function runAction() {
|
|
@@ -6,6 +6,10 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
6
6
|
selectionQuery: URLSearchParams;
|
|
7
7
|
endpoint: string;
|
|
8
8
|
lookup?: string;
|
|
9
|
+
/** Django model label used to gate the built-in permanent delete action. */
|
|
10
|
+
permissionModel?: string;
|
|
11
|
+
/** Whether to include the built-in permanent delete action. */
|
|
12
|
+
defaultActions?: boolean;
|
|
9
13
|
} & {
|
|
10
14
|
onActionCompleted?: (() => any) | undefined;
|
|
11
15
|
}> & (typeof globalThis extends {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoListActions.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoListActions.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoListActions.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoListActions.vue"],"names":[],"mappings":"AA+KA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAOzD,QAAA,MAAM,YAAY,GAAK,CAAC,SAAS,MAAM,EACtC,aAAa,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,EAC9D,YAAY,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,EAC3G,gBAAgB,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EAClE;WAkPO,OAAO,KAAK,EAAE,WAAW,GAAG,mBAAmB,CAAC;kBAhP1C,gBAAgB,CAAC,CAAC,CAAC,EAAE;mBACpB,CAAC,EAAE,GAAG,KAAK;wBACN,eAAe;kBACrB,MAAM;iBACP,MAAM;QACf,4EAA4E;0BAC1D,MAAM;QACxB,+DAA+D;yBAC9C,OAAO;;;KAwO+D,CAAC,GAAG,CAAC,OAAO,UAAU,SAAS;QAAE,oBAAoB,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG,CAAC,GAAG,EAAE,CAAC;YAC5J,CAAC,OAAO,EAAE,EAAE,KAAK,IAAI;WACtB,GAAG;;QA1NT,qFAAqF;mBAC1E,GAAG;QACd,qDAAqD;kBAC3C,GAAG;;;EA2NX,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAI,CAAC;wBACvD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,CAAC,GAAG,EAAE,CAAC"}
|
|
@@ -11,7 +11,7 @@ const props = defineProps({
|
|
|
11
11
|
editFields: { type: Array, required: false, default: () => [] },
|
|
12
12
|
lookup: { type: String, required: false, default: "id" },
|
|
13
13
|
languages: { type: Array, required: false },
|
|
14
|
-
registry: { type:
|
|
14
|
+
registry: { type: Object, required: false },
|
|
15
15
|
offline: { type: Boolean, required: false, default: false },
|
|
16
16
|
localItem: { type: null, required: false, default: null }
|
|
17
17
|
});
|
|
@@ -6,21 +6,34 @@ import {
|
|
|
6
6
|
watch,
|
|
7
7
|
h,
|
|
8
8
|
resolveComponent,
|
|
9
|
-
useSlots
|
|
9
|
+
useSlots,
|
|
10
|
+
onBeforeUnmount
|
|
10
11
|
} from "vue";
|
|
11
12
|
import { useI18n } from "vue-i18n";
|
|
12
13
|
import { useSnackStore } from "@mapomodule/store/runtime/stores/snack";
|
|
13
14
|
import { useConfirmStore } from "@mapomodule/store/runtime/stores/confirm";
|
|
14
15
|
import { usePermissions } from "@mapomodule/store/runtime/composables/usePermissions";
|
|
15
16
|
import { useCrud } from "@mapomodule/core/runtime/api/crud";
|
|
16
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
debounce,
|
|
19
|
+
getNestedValue,
|
|
20
|
+
splitEndpointParams
|
|
21
|
+
} from "@mapomodule/utils";
|
|
17
22
|
import { useRoute, useRouter } from "#app";
|
|
23
|
+
import {
|
|
24
|
+
ALL_ROWS,
|
|
25
|
+
formatPageSize,
|
|
26
|
+
nextSorting,
|
|
27
|
+
orderingParam,
|
|
28
|
+
parsePageSize,
|
|
29
|
+
toPageSize
|
|
30
|
+
} from "../utils/listTable.js";
|
|
18
31
|
const props = defineProps({
|
|
19
32
|
endpoint: { type: String, required: false, default: "" },
|
|
20
33
|
items: { type: Array, required: false, default: void 0 },
|
|
21
34
|
crudEndpoint: { type: String, required: false },
|
|
22
35
|
filterParams: { type: Object, required: false },
|
|
23
|
-
defaultPageSize: { type: Number, required: false, default: 20 },
|
|
36
|
+
defaultPageSize: { type: [Number, String], required: false, default: 20 },
|
|
24
37
|
pageSizeOptions: { type: Array, required: false, default: () => [10, 20, 50, 100] },
|
|
25
38
|
responseAdapter: { type: Function, required: false },
|
|
26
39
|
paginationParams: { type: Function, required: false },
|
|
@@ -32,7 +45,7 @@ const props = defineProps({
|
|
|
32
45
|
positionField: { type: String, required: false, default: "position" },
|
|
33
46
|
editFields: { type: Array, required: false, default: () => [] },
|
|
34
47
|
languages: { type: Array, required: false },
|
|
35
|
-
registry: { type:
|
|
48
|
+
registry: { type: Object, required: false },
|
|
36
49
|
detailBase: { type: String, required: false },
|
|
37
50
|
permissionModel: { type: String, required: false }
|
|
38
51
|
});
|
|
@@ -42,7 +55,7 @@ const emit = defineEmits(["update:selection", "update:selectionQuery", "update:i
|
|
|
42
55
|
defineExpose({ refresh });
|
|
43
56
|
defineSlots();
|
|
44
57
|
const slots = useSlots();
|
|
45
|
-
const atKey = (item, key) => item
|
|
58
|
+
const atKey = (item, key) => getNestedValue(item, key);
|
|
46
59
|
const { t } = useI18n();
|
|
47
60
|
const snack = useSnackStore();
|
|
48
61
|
const confirm = useConfirmStore();
|
|
@@ -66,10 +79,17 @@ function toPositiveNumber(value, fallback) {
|
|
|
66
79
|
const n = Number(value);
|
|
67
80
|
return Number.isFinite(n) && n > 0 ? n : fallback;
|
|
68
81
|
}
|
|
82
|
+
const defaultPageSize = toPageSize(props.defaultPageSize);
|
|
69
83
|
const pagination = ref({
|
|
70
84
|
pageIndex: route.query.page ? Math.max(0, toPositiveNumber(route.query.page, 1) - 1) : 0,
|
|
71
|
-
pageSize: route.query.page_size ?
|
|
85
|
+
pageSize: route.query.page_size ? parsePageSize(route.query.page_size, defaultPageSize) : defaultPageSize
|
|
72
86
|
});
|
|
87
|
+
const showsAllRows = computed(() => pagination.value.pageSize === ALL_ROWS);
|
|
88
|
+
const pageSizeItems = computed(
|
|
89
|
+
() => props.pageSizeOptions.map(
|
|
90
|
+
(option) => option === "all" ? { label: t("mapo.listTable.allRows"), value: ALL_ROWS } : { label: t("mapo.listTable.perPage", { n: option }), value: option }
|
|
91
|
+
)
|
|
92
|
+
);
|
|
73
93
|
const sorting = ref(
|
|
74
94
|
route.query.ordering ? String(route.query.ordering).split(",").map((o) => ({
|
|
75
95
|
id: o.startsWith("-") ? o.slice(1) : o,
|
|
@@ -88,8 +108,8 @@ const writeUrlState = debounce(() => {
|
|
|
88
108
|
const page = pagination.value.pageIndex + 1;
|
|
89
109
|
if (page > 1) query.page = String(page);
|
|
90
110
|
else delete query.page;
|
|
91
|
-
if (pagination.value.pageSize !==
|
|
92
|
-
query.page_size =
|
|
111
|
+
if (pagination.value.pageSize !== defaultPageSize)
|
|
112
|
+
query.page_size = formatPageSize(pagination.value.pageSize);
|
|
93
113
|
else delete query.page_size;
|
|
94
114
|
if (search.value) query.search = search.value;
|
|
95
115
|
else delete query.search;
|
|
@@ -99,6 +119,10 @@ const writeUrlState = debounce(() => {
|
|
|
99
119
|
router.replace({ query });
|
|
100
120
|
}, 150);
|
|
101
121
|
watch([pagination, search, sorting], writeUrlState, { deep: true });
|
|
122
|
+
onBeforeUnmount(() => {
|
|
123
|
+
onSearchInput.cancel();
|
|
124
|
+
writeUrlState.cancel();
|
|
125
|
+
});
|
|
102
126
|
const rowSelection = ref({});
|
|
103
127
|
const pkOf = (row) => String(atKey(row, props.lookup));
|
|
104
128
|
const isAllSelected = computed(
|
|
@@ -117,11 +141,11 @@ watch(selectedRows, (rows2) => {
|
|
|
117
141
|
});
|
|
118
142
|
function buildSelectionQuery() {
|
|
119
143
|
const params = new URLSearchParams();
|
|
120
|
-
|
|
144
|
+
if (!showsAllRows.value)
|
|
145
|
+
params.set("page_size", String(pagination.value.pageSize));
|
|
121
146
|
if (search.value) params.set("search", search.value);
|
|
122
|
-
sorting.value.
|
|
123
|
-
|
|
124
|
-
);
|
|
147
|
+
if (sorting.value.length)
|
|
148
|
+
params.set("ordering", orderingParam(sorting.value));
|
|
125
149
|
return params;
|
|
126
150
|
}
|
|
127
151
|
function toggleAll() {
|
|
@@ -288,7 +312,7 @@ function applyOffline(source) {
|
|
|
288
312
|
const q = search.value.toLowerCase();
|
|
289
313
|
arr = arr.filter(
|
|
290
314
|
(row) => props.columns.some(
|
|
291
|
-
(c) => String(row
|
|
315
|
+
(c) => String(atKey(row, c.key) ?? "").toLowerCase().includes(q)
|
|
292
316
|
)
|
|
293
317
|
);
|
|
294
318
|
}
|
|
@@ -377,11 +401,11 @@ async function refresh() {
|
|
|
377
401
|
const params = {
|
|
378
402
|
...endpointParams,
|
|
379
403
|
...props.filterParams ?? {},
|
|
380
|
-
|
|
404
|
+
// "All rows" sends no pagination params: the backend returns the whole collection.
|
|
405
|
+
...showsAllRows.value ? {} : paginationP
|
|
381
406
|
};
|
|
382
407
|
if (search.value) params.search = search.value;
|
|
383
|
-
if (sorting.value.length)
|
|
384
|
-
params.ordering = sorting.value.map((s) => `${s.desc ? "-" : ""}${s.id}`).join(",");
|
|
408
|
+
if (sorting.value.length) params.ordering = orderingParam(sorting.value);
|
|
385
409
|
const res = await crud.list(params);
|
|
386
410
|
let nextItems = [];
|
|
387
411
|
let nextTotal = 0;
|
|
@@ -425,18 +449,51 @@ watch(
|
|
|
425
449
|
search
|
|
426
450
|
],
|
|
427
451
|
([newEndpoint, , newFilters], [oldEndpoint, , oldFilters]) => {
|
|
428
|
-
const
|
|
429
|
-
if (
|
|
430
|
-
pagination.value = { ...pagination.value, pageIndex: 0 };
|
|
431
|
-
} else {
|
|
452
|
+
const isFirstRun = oldFilters === void 0;
|
|
453
|
+
if (isFirstRun) {
|
|
432
454
|
refresh();
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
const endpointChanged = newEndpoint !== oldEndpoint;
|
|
458
|
+
const filtersChanged = newFilters !== oldFilters;
|
|
459
|
+
const contextChanged = endpointChanged || filtersChanged;
|
|
460
|
+
const isOnFirstPage = pagination.value.pageIndex === 0;
|
|
461
|
+
if (contextChanged && !isOnFirstPage) {
|
|
462
|
+
pagination.value = { ...pagination.value, pageIndex: 0 };
|
|
463
|
+
return;
|
|
433
464
|
}
|
|
465
|
+
refresh();
|
|
434
466
|
},
|
|
435
467
|
{ immediate: true, deep: true }
|
|
436
468
|
);
|
|
437
469
|
const UCheckbox = resolveComponent("UCheckbox");
|
|
438
470
|
const UButton = resolveComponent("UButton");
|
|
439
471
|
const UIcon = resolveComponent("UIcon");
|
|
472
|
+
const SORT_ICONS = {
|
|
473
|
+
none: "i-lucide-arrow-up-down",
|
|
474
|
+
asc: "i-lucide-arrow-up-narrow-wide",
|
|
475
|
+
desc: "i-lucide-arrow-down-wide-narrow"
|
|
476
|
+
};
|
|
477
|
+
const SORT_NEXT_ACTION = {
|
|
478
|
+
none: "mapo.listTable.sortAscending",
|
|
479
|
+
asc: "mapo.listTable.sortDescending",
|
|
480
|
+
desc: "mapo.listTable.clearSorting"
|
|
481
|
+
};
|
|
482
|
+
function sortHeader(col) {
|
|
483
|
+
const sort = sorting.value.find((s) => s.id === col.key);
|
|
484
|
+
const direction = !sort ? "none" : sort.desc ? "desc" : "asc";
|
|
485
|
+
return h(UButton, {
|
|
486
|
+
color: "neutral",
|
|
487
|
+
variant: "ghost",
|
|
488
|
+
label: col.label,
|
|
489
|
+
icon: SORT_ICONS[direction],
|
|
490
|
+
class: "-mx-2.5",
|
|
491
|
+
"aria-label": t(SORT_NEXT_ACTION[direction], { column: col.label }),
|
|
492
|
+
onClick: () => {
|
|
493
|
+
sorting.value = nextSorting(sorting.value, col.key);
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
}
|
|
440
497
|
const tableColumns = computed(() => {
|
|
441
498
|
const cols = [];
|
|
442
499
|
cols.push({
|
|
@@ -482,8 +539,11 @@ const tableColumns = computed(() => {
|
|
|
482
539
|
const col = props.columns[i];
|
|
483
540
|
const isFirst = i === 0 && !!props.detailBase;
|
|
484
541
|
cols.push({
|
|
542
|
+
// TanStack would turn a dotted key into `category_name`; the sorting
|
|
543
|
+
// state uses the column key, so the id must be the key itself.
|
|
544
|
+
id: col.key,
|
|
485
545
|
accessorKey: col.key,
|
|
486
|
-
header: col.label,
|
|
546
|
+
header: col.sortable ? () => sortHeader(col) : col.label,
|
|
487
547
|
cell: ({ row }) => {
|
|
488
548
|
const cellSlot = slots[`cell.${col.key}`];
|
|
489
549
|
if (cellSlot)
|
|
@@ -519,6 +579,7 @@ const tableColumns = computed(() => {
|
|
|
519
579
|
variant: "ghost",
|
|
520
580
|
color: "neutral",
|
|
521
581
|
icon: "i-lucide-pencil",
|
|
582
|
+
"aria-label": t("mapo.edit"),
|
|
522
583
|
onClick: () => openQuickEdit(
|
|
523
584
|
atKey(row.original, props.lookup)
|
|
524
585
|
)
|
|
@@ -532,6 +593,7 @@ const tableColumns = computed(() => {
|
|
|
532
593
|
variant: "ghost",
|
|
533
594
|
color: "error",
|
|
534
595
|
icon: "i-lucide-trash-2",
|
|
596
|
+
"aria-label": t("mapo.delete"),
|
|
535
597
|
onClick: () => deleteRow(row.original)
|
|
536
598
|
})
|
|
537
599
|
);
|
|
@@ -546,6 +608,15 @@ const tableColumns = computed(() => {
|
|
|
546
608
|
});
|
|
547
609
|
return cols;
|
|
548
610
|
});
|
|
611
|
+
const emptyText = computed(() => {
|
|
612
|
+
const isSearching = !!search.value;
|
|
613
|
+
const isFiltering = Object.values(props.filterParams ?? {}).some(
|
|
614
|
+
(value) => value != null && value !== ""
|
|
615
|
+
);
|
|
616
|
+
return t(
|
|
617
|
+
isSearching || isFiltering ? "mapo.listTable.noResults" : "mapo.listTable.noItems"
|
|
618
|
+
);
|
|
619
|
+
});
|
|
549
620
|
const paginationOptions = computed(() => ({
|
|
550
621
|
manualPagination: true,
|
|
551
622
|
rowCount: total.value
|
|
@@ -585,7 +656,7 @@ const sortingOptions = computed(() => ({
|
|
|
585
656
|
:pagination-options="paginationOptions"
|
|
586
657
|
:sorting="sorting"
|
|
587
658
|
:sorting-options="sortingOptions"
|
|
588
|
-
:empty="
|
|
659
|
+
:empty="emptyText"
|
|
589
660
|
@update:pagination="pagination = $event ?? pagination"
|
|
590
661
|
@update:sorting="sorting = $event ?? sorting"
|
|
591
662
|
>
|
|
@@ -593,7 +664,7 @@ const sortingOptions = computed(() => ({
|
|
|
593
664
|
<slot name="dtable.empty">
|
|
594
665
|
<div class="flex flex-col items-center gap-2 py-8 text-muted">
|
|
595
666
|
<UIcon name="i-lucide-inbox" class="h-8 w-8" />
|
|
596
|
-
<span class="text-sm">{{
|
|
667
|
+
<span class="text-sm">{{ emptyText }}</span>
|
|
597
668
|
</div>
|
|
598
669
|
</slot>
|
|
599
670
|
</template>
|
|
@@ -614,23 +685,18 @@ const sortingOptions = computed(() => ({
|
|
|
614
685
|
<!-- Pagination controls -->
|
|
615
686
|
<div class="flex items-center justify-between text-sm text-muted">
|
|
616
687
|
<span>{{ t("mapo.listTable.totalItems", { total }) }}</span>
|
|
688
|
+
<!-- Nuxt UI 4's UPagination models `page`: with `modelValue` it runs uncontrolled. -->
|
|
617
689
|
<UPagination
|
|
618
|
-
|
|
690
|
+
v-if="!showsAllRows"
|
|
691
|
+
:page="pagination.pageIndex + 1"
|
|
619
692
|
:total="total"
|
|
620
693
|
:items-per-page="pagination.pageSize"
|
|
621
694
|
size="sm"
|
|
622
|
-
@update:
|
|
623
|
-
pagination = { ...pagination, pageIndex: $event - 1 }
|
|
624
|
-
"
|
|
695
|
+
@update:page="pagination = { ...pagination, pageIndex: $event - 1 }"
|
|
625
696
|
/>
|
|
626
697
|
<USelect
|
|
627
698
|
:model-value="pagination.pageSize"
|
|
628
|
-
:items="
|
|
629
|
-
pageSizeOptions.map((n) => ({
|
|
630
|
-
label: t('mapo.listTable.perPage', { n }),
|
|
631
|
-
value: n
|
|
632
|
-
}))
|
|
633
|
-
"
|
|
699
|
+
:items="pageSizeItems"
|
|
634
700
|
size="xs"
|
|
635
701
|
class="w-28"
|
|
636
702
|
@update:model-value="
|
|
@@ -23,10 +23,14 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
23
23
|
* and tab params without baking them into the endpoint string.
|
|
24
24
|
*/
|
|
25
25
|
filterParams?: Record<string, unknown>;
|
|
26
|
-
/** Initial page size
|
|
27
|
-
defaultPageSize?: number;
|
|
28
|
-
/**
|
|
29
|
-
|
|
26
|
+
/** Initial page size: a number, or `"all"`. Default: 20. */
|
|
27
|
+
defaultPageSize?: number | "all";
|
|
28
|
+
/**
|
|
29
|
+
* Options of the per-page selector. `"all"` adds an option that requests
|
|
30
|
+
* the list without pagination params, like `clientSide` does: the backend
|
|
31
|
+
* has to return the whole collection then. Default: [10, 20, 50, 100].
|
|
32
|
+
*/
|
|
33
|
+
pageSizeOptions?: (number | "all")[];
|
|
30
34
|
/**
|
|
31
35
|
* Custom response parser. When provided it replaces the built-in DRF / flat-array
|
|
32
36
|
* detection. Return `{ items, total }` from any shape your backend returns.
|
|
@@ -52,6 +56,7 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
52
56
|
* still hit the backend, then re-fetch. Ignored when `items` is provided.
|
|
53
57
|
*/
|
|
54
58
|
clientSide?: boolean;
|
|
59
|
+
/** Column definitions. A dotted `key` (`category.name`) reads a field of a related object. */
|
|
55
60
|
columns: ListColumn<T>[];
|
|
56
61
|
lookup?: string;
|
|
57
62
|
searchable?: boolean;
|
|
@@ -69,9 +74,9 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
69
74
|
*/
|
|
70
75
|
permissionModel?: string;
|
|
71
76
|
} & {
|
|
72
|
-
"onUpdate:items"?: ((value: T[]) => any) | undefined;
|
|
73
77
|
"onUpdate:selection"?: ((value: "all" | T[]) => any) | undefined;
|
|
74
78
|
"onUpdate:selectionQuery"?: ((value: URLSearchParams) => any) | undefined;
|
|
79
|
+
"onUpdate:items"?: ((value: T[]) => any) | undefined;
|
|
75
80
|
}> & (typeof globalThis extends {
|
|
76
81
|
__VLS_PROPS_FALLBACK: infer P;
|
|
77
82
|
} ? P : {});
|
|
@@ -91,7 +96,7 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
91
96
|
item: T;
|
|
92
97
|
value: T[K];
|
|
93
98
|
}) => any; };
|
|
94
|
-
emit: ((evt: "update:
|
|
99
|
+
emit: ((evt: "update:selection", value: "all" | T[]) => void) & ((evt: "update:selectionQuery", value: URLSearchParams) => void) & ((evt: "update:items", value: T[]) => void);
|
|
95
100
|
}>) => import("vue").VNode & {
|
|
96
101
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
97
102
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoListTable.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoListTable.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoListTable.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoListTable.vue"],"names":[],"mappings":"AA2gCA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAKnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAgBhF,QAAA,MAAM,YAAY,GAAK,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