@mapomodule/uikit 2.0.0-beta.2 → 2.0.0-beta.20
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 +46 -142
- 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__/MapoList.component.test.d.ts +2 -0
- package/dist/__tests__/MapoList.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__/MapoMediaEditor.component.test.d.ts +2 -0
- package/dist/__tests__/MapoMediaEditor.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoMediaFolderPicker.component.test.d.ts +2 -0
- package/dist/__tests__/MapoMediaFolderPicker.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoMediaFolders.component.test.d.ts +2 -0
- package/dist/__tests__/MapoMediaFolders.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoMediaGallery.component.test.d.ts +2 -0
- package/dist/__tests__/MapoMediaGallery.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoMediaUploadHandover.component.test.d.ts +2 -0
- package/dist/__tests__/MapoMediaUploadHandover.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoMenuManager.component.test.d.ts +2 -0
- package/dist/__tests__/MapoMenuManager.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__/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__/mediaDrag.test.d.ts +2 -0
- package/dist/__tests__/mediaDrag.test.d.ts.map +1 -0
- package/dist/__tests__/mediaFolders.test.d.ts +2 -0
- package/dist/__tests__/mediaFolders.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__/mediaMetadata.test.d.ts +2 -0
- package/dist/__tests__/mediaMetadata.test.d.ts.map +1 -0
- package/dist/__tests__/mediaStore.test.d.ts +2 -0
- package/dist/__tests__/mediaStore.test.d.ts.map +1 -0
- package/dist/__tests__/mediaUrl.test.d.ts +2 -0
- package/dist/__tests__/mediaUrl.test.d.ts.map +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/module.d.mts +48 -1
- package/dist/module.d.ts +44 -0
- package/dist/module.d.ts.map +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +71 -2
- package/dist/runtime/adapters/defaultMediaAdapter.d.ts +15 -0
- package/dist/runtime/adapters/defaultMediaAdapter.d.ts.map +1 -0
- package/dist/runtime/adapters/defaultMediaAdapter.js +35 -0
- package/dist/runtime/assets/main.css +1 -1
- package/dist/runtime/components/MapoConfirmDialog.vue +23 -4
- package/dist/runtime/components/MapoConfirmDialog.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoDetail.vue +127 -55
- package/dist/runtime/components/MapoDetail.vue.d.ts +102 -5
- package/dist/runtime/components/MapoDetail.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoDetailLangSwitch.vue +22 -26
- 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 +110 -0
- package/dist/runtime/components/MapoDropArea.vue.d.ts +33 -0
- package/dist/runtime/components/MapoDropArea.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoLangSwitcher.vue +39 -0
- package/dist/runtime/components/MapoLangSwitcher.vue.d.ts +18 -0
- package/dist/runtime/components/MapoLangSwitcher.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoList.vue +45 -31
- package/dist/runtime/components/MapoList.vue.d.ts +18 -5
- package/dist/runtime/components/MapoList.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoListActions.vue +27 -13
- 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/MapoListFilters.vue +4 -2
- package/dist/runtime/components/MapoListFilters.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoListQuickEdit.vue +20 -10
- package/dist/runtime/components/MapoListQuickEdit.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoListTable.vue +125 -49
- package/dist/runtime/components/MapoListTable.vue.d.ts +13 -5
- package/dist/runtime/components/MapoListTable.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoLogin.vue +13 -10
- package/dist/runtime/components/MapoLogin.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoLogoutButton.vue +4 -2
- package/dist/runtime/components/MapoLogoutButton.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaBreadcrumbs.vue +47 -0
- package/dist/runtime/components/MapoMediaBreadcrumbs.vue.d.ts +4 -0
- package/dist/runtime/components/MapoMediaBreadcrumbs.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaEditor.vue +382 -0
- package/dist/runtime/components/MapoMediaEditor.vue.d.ts +13 -0
- package/dist/runtime/components/MapoMediaEditor.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaFileChanger.vue +112 -0
- package/dist/runtime/components/MapoMediaFileChanger.vue.d.ts +15 -0
- package/dist/runtime/components/MapoMediaFileChanger.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaFolderPicker.vue +129 -0
- package/dist/runtime/components/MapoMediaFolderPicker.vue.d.ts +33 -0
- package/dist/runtime/components/MapoMediaFolderPicker.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaFolders.vue +402 -0
- package/dist/runtime/components/MapoMediaFolders.vue.d.ts +4 -0
- package/dist/runtime/components/MapoMediaFolders.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaGallery.vue +304 -0
- package/dist/runtime/components/MapoMediaGallery.vue.d.ts +8 -0
- package/dist/runtime/components/MapoMediaGallery.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaManager.vue +144 -0
- package/dist/runtime/components/MapoMediaManager.vue.d.ts +44 -0
- package/dist/runtime/components/MapoMediaManager.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaManagerDialog.vue +116 -0
- package/dist/runtime/components/MapoMediaManagerDialog.vue.d.ts +41 -0
- package/dist/runtime/components/MapoMediaManagerDialog.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaPreview.vue +94 -0
- package/dist/runtime/components/MapoMediaPreview.vue.d.ts +19 -0
- package/dist/runtime/components/MapoMediaPreview.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaUploader.vue +294 -0
- package/dist/runtime/components/MapoMediaUploader.vue.d.ts +8 -0
- package/dist/runtime/components/MapoMediaUploader.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMenuManager.vue +301 -0
- package/dist/runtime/components/MapoMenuManager.vue.d.ts +92 -0
- package/dist/runtime/components/MapoMenuManager.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMenuNodeEditor.vue +201 -0
- package/dist/runtime/components/MapoMenuNodeEditor.vue.d.ts +61 -0
- package/dist/runtime/components/MapoMenuNodeEditor.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMenuTreeview.vue +181 -0
- package/dist/runtime/components/MapoMenuTreeview.vue.d.ts +57 -0
- package/dist/runtime/components/MapoMenuTreeview.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMenuTreeviewNode.vue +175 -0
- package/dist/runtime/components/MapoMenuTreeviewNode.vue.d.ts +27 -0
- package/dist/runtime/components/MapoMenuTreeviewNode.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoSidebar.vue +3 -1
- package/dist/runtime/components/MapoSidebar.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoSidebarList.vue +1 -1
- package/dist/runtime/components/MapoSidebarProfile.vue +6 -2
- package/dist/runtime/components/MapoSidebarProfile.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoSnackBar.vue +11 -0
- package/dist/runtime/components/MapoSnackBar.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoThemeToggle.vue +5 -1
- package/dist/runtime/components/MapoThemeToggle.vue.d.ts.map +1 -1
- package/dist/runtime/components/menuDndContext.d.ts +19 -0
- package/dist/runtime/components/menuDndContext.d.ts.map +1 -0
- package/dist/runtime/components/menuDndContext.js +3 -0
- package/dist/runtime/page-meta.nuxt.d.ts +4 -0
- package/dist/runtime/pages/index.vue +4 -3
- package/dist/runtime/pages/index.vue.d.ts.map +1 -1
- package/dist/runtime/pages/login.vue +0 -4
- package/dist/runtime/pages/login.vue.d.ts.map +1 -1
- package/dist/runtime/plugins/media-adapter.d.ts +18 -0
- package/dist/runtime/plugins/media-adapter.d.ts.map +1 -0
- package/dist/runtime/plugins/media-adapter.js +8 -0
- package/dist/runtime/stores/media.d.ts +505 -0
- package/dist/runtime/stores/media.d.ts.map +1 -0
- package/dist/runtime/stores/media.js +545 -0
- package/dist/runtime/types/list.d.ts +10 -2
- package/dist/runtime/types/list.d.ts.map +1 -1
- package/dist/runtime/types/media.d.ts +131 -0
- package/dist/runtime/types/media.d.ts.map +1 -0
- package/dist/runtime/types/media.js +0 -0
- package/dist/runtime/types/menu.d.ts +66 -0
- package/dist/runtime/types/menu.d.ts.map +1 -0
- package/dist/runtime/types/menu.js +30 -0
- package/dist/runtime/utils/contentLanguages.d.ts +9 -0
- package/dist/runtime/utils/contentLanguages.d.ts.map +1 -0
- package/dist/runtime/utils/contentLanguages.js +8 -0
- package/dist/runtime/utils/langInfo.d.ts +43 -0
- package/dist/runtime/utils/langInfo.d.ts.map +1 -0
- package/dist/runtime/utils/langInfo.js +17 -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/dist/runtime/utils/mediaDrag.d.ts +21 -0
- package/dist/runtime/utils/mediaDrag.d.ts.map +1 -0
- package/dist/runtime/utils/mediaDrag.js +11 -0
- package/dist/runtime/utils/mediaFolders.d.ts +65 -0
- package/dist/runtime/utils/mediaFolders.d.ts.map +1 -0
- package/dist/runtime/utils/mediaFolders.js +97 -0
- package/dist/runtime/utils/mediaMetadata.d.ts +39 -0
- package/dist/runtime/utils/mediaMetadata.d.ts.map +1 -0
- package/dist/runtime/utils/mediaMetadata.js +97 -0
- package/dist/runtime/utils/mediaUrl.d.ts +16 -0
- package/dist/runtime/utils/mediaUrl.d.ts.map +1 -0
- package/dist/runtime/utils/mediaUrl.js +12 -0
- package/dist/types.d.mts +1 -1
- package/package.json +15 -11
- package/src/__tests__/MapoConfirmDialog.component.test.ts +165 -0
- package/src/__tests__/MapoDetail.component.test.ts +393 -0
- package/src/__tests__/MapoDetailLangSwitch.component.test.ts +145 -0
- package/src/__tests__/MapoList.component.test.ts +166 -0
- package/src/__tests__/MapoListActions.component.test.ts +175 -0
- package/src/__tests__/MapoListTable.component.test.ts +545 -0
- package/src/__tests__/MapoMediaEditor.component.test.ts +447 -0
- package/src/__tests__/MapoMediaFolderPicker.component.test.ts +220 -0
- package/src/__tests__/MapoMediaFolders.component.test.ts +519 -0
- package/src/__tests__/MapoMediaGallery.component.test.ts +211 -0
- package/src/__tests__/MapoMediaUploadHandover.component.test.ts +241 -0
- package/src/__tests__/MapoMenuManager.component.test.ts +175 -0
- package/src/__tests__/MapoSnackBar.component.test.ts +79 -0
- package/src/__tests__/__mocks__/nuxt-app.ts +8 -0
- package/src/__tests__/langInfo.test.ts +85 -0
- package/src/__tests__/listTable.test.ts +82 -0
- package/src/__tests__/mediaDrag.test.ts +42 -0
- package/src/__tests__/mediaFolders.test.ts +204 -0
- package/src/__tests__/mediaLanguages.test.ts +66 -0
- package/src/__tests__/mediaMetadata.test.ts +169 -0
- package/src/__tests__/mediaStore.test.ts +569 -0
- package/src/__tests__/mediaUrl.test.ts +44 -0
- package/src/index.ts +21 -0
- package/src/module.ts +155 -0
- package/src/runtime/adapters/defaultMediaAdapter.ts +67 -0
- package/src/runtime/assets/main.css +9 -0
- package/src/runtime/components/MapoConfirmDialog.vue +33 -4
- package/src/runtime/components/MapoDetail.vue +229 -73
- package/src/runtime/components/MapoDetailLangSwitch.vue +27 -28
- package/src/runtime/components/MapoDropArea.vue +145 -0
- package/src/runtime/components/MapoLangSwitcher.vue +74 -0
- package/src/runtime/components/MapoList.vue +65 -34
- package/src/runtime/components/MapoListActions.vue +32 -14
- package/src/runtime/components/MapoListFilters.vue +5 -2
- package/src/runtime/components/MapoListQuickEdit.vue +22 -10
- package/src/runtime/components/MapoListTable.vue +159 -59
- package/src/runtime/components/MapoLogin.vue +13 -10
- package/src/runtime/components/MapoLogoutButton.vue +4 -2
- package/src/runtime/components/MapoMediaBreadcrumbs.vue +53 -0
- package/src/runtime/components/MapoMediaEditor.vue +447 -0
- package/src/runtime/components/MapoMediaFileChanger.vue +136 -0
- package/src/runtime/components/MapoMediaFolderPicker.vue +176 -0
- package/src/runtime/components/MapoMediaFolders.vue +478 -0
- package/src/runtime/components/MapoMediaGallery.vue +350 -0
- package/src/runtime/components/MapoMediaManager.vue +194 -0
- package/src/runtime/components/MapoMediaManagerDialog.vue +148 -0
- package/src/runtime/components/MapoMediaPreview.vue +116 -0
- package/src/runtime/components/MapoMediaUploader.vue +362 -0
- package/src/runtime/components/MapoMenuManager.vue +454 -0
- package/src/runtime/components/MapoMenuNodeEditor.vue +282 -0
- package/src/runtime/components/MapoMenuTreeview.vue +264 -0
- package/src/runtime/components/MapoMenuTreeviewNode.vue +234 -0
- package/src/runtime/components/MapoSidebar.vue +3 -1
- package/src/runtime/components/MapoSidebarList.vue +1 -1
- package/src/runtime/components/MapoSidebarProfile.vue +6 -2
- package/src/runtime/components/MapoSnackBar.vue +12 -0
- package/src/runtime/components/MapoThemeToggle.vue +5 -1
- package/src/runtime/components/menuDndContext.ts +22 -0
- package/src/runtime/page-meta.nuxt.d.ts +4 -0
- package/src/runtime/pages/index.vue +4 -3
- package/src/runtime/pages/login.vue +0 -4
- package/src/runtime/plugins/media-adapter.ts +33 -0
- package/src/runtime/stores/media.ts +820 -0
- package/src/runtime/types/list.ts +10 -2
- package/src/runtime/types/media.ts +144 -0
- package/src/runtime/types/menu.ts +105 -0
- package/src/runtime/utils/contentLanguages.ts +18 -0
- package/src/runtime/utils/langInfo.ts +63 -0
- package/src/runtime/utils/listTable.ts +54 -0
- package/src/runtime/utils/mediaDrag.ts +29 -0
- package/src/runtime/utils/mediaFolders.ts +182 -0
- package/src/runtime/utils/mediaMetadata.ts +165 -0
- package/src/runtime/utils/mediaUrl.ts +30 -0
|
@@ -7,8 +7,10 @@ import {
|
|
|
7
7
|
h,
|
|
8
8
|
resolveComponent,
|
|
9
9
|
useSlots,
|
|
10
|
+
onBeforeUnmount,
|
|
10
11
|
} from "vue";
|
|
11
12
|
import type { Ref } from "vue";
|
|
13
|
+
import { useI18n } from "vue-i18n";
|
|
12
14
|
import type { TableColumn } from "@nuxt/ui";
|
|
13
15
|
import type { SortingState, PaginationState } from "@tanstack/vue-table";
|
|
14
16
|
import type { ListColumn } from "../types/list.js";
|
|
@@ -17,8 +19,20 @@ import { useConfirmStore } from "@mapomodule/store/runtime/stores/confirm";
|
|
|
17
19
|
import { usePermissions } from "@mapomodule/store/runtime/composables/usePermissions";
|
|
18
20
|
import { useCrud } from "@mapomodule/core/runtime/api/crud";
|
|
19
21
|
import type { AnyFieldDescriptor, FieldRegistry } from "@mapomodule/form/types";
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
+
import {
|
|
23
|
+
debounce,
|
|
24
|
+
getNestedValue,
|
|
25
|
+
splitEndpointParams,
|
|
26
|
+
} from "@mapomodule/utils";
|
|
27
|
+
import { useRoute, useRouter } from "#app";
|
|
28
|
+
import {
|
|
29
|
+
ALL_ROWS,
|
|
30
|
+
formatPageSize,
|
|
31
|
+
nextSorting,
|
|
32
|
+
orderingParam,
|
|
33
|
+
parsePageSize,
|
|
34
|
+
toPageSize,
|
|
35
|
+
} from "../utils/listTable.js";
|
|
22
36
|
|
|
23
37
|
const props = withDefaults(
|
|
24
38
|
defineProps<{
|
|
@@ -43,10 +57,14 @@ const props = withDefaults(
|
|
|
43
57
|
* and tab params without baking them into the endpoint string.
|
|
44
58
|
*/
|
|
45
59
|
filterParams?: Record<string, unknown>;
|
|
46
|
-
/** Initial page size
|
|
47
|
-
defaultPageSize?: number;
|
|
48
|
-
/**
|
|
49
|
-
|
|
60
|
+
/** Initial page size: a number, or `"all"`. Default: 20. */
|
|
61
|
+
defaultPageSize?: number | "all";
|
|
62
|
+
/**
|
|
63
|
+
* Options of the per-page selector. `"all"` adds an option that requests
|
|
64
|
+
* the list without pagination params, like `clientSide` does: the backend
|
|
65
|
+
* has to return the whole collection then. Default: [10, 20, 50, 100].
|
|
66
|
+
*/
|
|
67
|
+
pageSizeOptions?: (number | "all")[];
|
|
50
68
|
/**
|
|
51
69
|
* Custom response parser. When provided it replaces the built-in DRF / flat-array
|
|
52
70
|
* detection. Return `{ items, total }` from any shape your backend returns.
|
|
@@ -69,6 +87,7 @@ const props = withDefaults(
|
|
|
69
87
|
* still hit the backend, then re-fetch. Ignored when `items` is provided.
|
|
70
88
|
*/
|
|
71
89
|
clientSide?: boolean;
|
|
90
|
+
/** Column definitions. A dotted `key` (`category.name`) reads a field of a related object. */
|
|
72
91
|
columns: ListColumn<T>[];
|
|
73
92
|
lookup?: string;
|
|
74
93
|
searchable?: boolean;
|
|
@@ -113,7 +132,10 @@ defineExpose({ refresh });
|
|
|
113
132
|
|
|
114
133
|
defineSlots<
|
|
115
134
|
{
|
|
116
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* Content of the toolbar row, after the search input; the row shows it
|
|
137
|
+
* without the search too. `MapoList` puts its bulk actions here.
|
|
138
|
+
*/
|
|
117
139
|
"dtable.toolbar"(): any;
|
|
118
140
|
/** Override for the empty state displayed when no rows are found. */
|
|
119
141
|
"dtable.empty"(): any;
|
|
@@ -134,11 +156,13 @@ defineSlots<
|
|
|
134
156
|
|
|
135
157
|
const slots = useSlots();
|
|
136
158
|
|
|
137
|
-
//
|
|
138
|
-
//
|
|
139
|
-
//
|
|
140
|
-
const atKey = (item: T, key: string): T[keyof T] =>
|
|
159
|
+
// A key can be a dotted path into a related object (`category.name`). The cast to
|
|
160
|
+
// T[keyof T] gives the call sites the union of the row's property types rather
|
|
161
|
+
// than `unknown`.
|
|
162
|
+
const atKey = (item: T, key: string): T[keyof T] =>
|
|
163
|
+
getNestedValue(item, key) as T[keyof T];
|
|
141
164
|
|
|
165
|
+
const { t } = useI18n();
|
|
142
166
|
const snack = useSnackStore();
|
|
143
167
|
const confirm = useConfirmStore();
|
|
144
168
|
|
|
@@ -185,14 +209,24 @@ function toPositiveNumber(value: unknown, fallback: number): number {
|
|
|
185
209
|
}
|
|
186
210
|
|
|
187
211
|
// --- Pagination (restored from URL) ---
|
|
212
|
+
// "All rows" is stored as the ALL_ROWS page size and written as `page_size=all`.
|
|
213
|
+
const defaultPageSize = toPageSize(props.defaultPageSize);
|
|
188
214
|
const pagination = ref<PaginationState>({
|
|
189
215
|
pageIndex: route.query.page
|
|
190
216
|
? Math.max(0, toPositiveNumber(route.query.page, 1) - 1)
|
|
191
217
|
: 0,
|
|
192
218
|
pageSize: route.query.page_size
|
|
193
|
-
?
|
|
194
|
-
:
|
|
219
|
+
? parsePageSize(route.query.page_size, defaultPageSize)
|
|
220
|
+
: defaultPageSize,
|
|
195
221
|
});
|
|
222
|
+
const showsAllRows = computed(() => pagination.value.pageSize === ALL_ROWS);
|
|
223
|
+
const pageSizeItems = computed(() =>
|
|
224
|
+
props.pageSizeOptions.map((option) =>
|
|
225
|
+
option === "all"
|
|
226
|
+
? { label: t("mapo.listTable.allRows"), value: ALL_ROWS }
|
|
227
|
+
: { label: t("mapo.listTable.perPage", { n: option }), value: option },
|
|
228
|
+
),
|
|
229
|
+
);
|
|
196
230
|
|
|
197
231
|
// --- Sorting (restored from URL) ---
|
|
198
232
|
const sorting = ref<SortingState>(
|
|
@@ -224,8 +258,8 @@ const writeUrlState = debounce(() => {
|
|
|
224
258
|
const page = pagination.value.pageIndex + 1;
|
|
225
259
|
if (page > 1) query.page = String(page);
|
|
226
260
|
else delete query.page;
|
|
227
|
-
if (pagination.value.pageSize !==
|
|
228
|
-
query.page_size =
|
|
261
|
+
if (pagination.value.pageSize !== defaultPageSize)
|
|
262
|
+
query.page_size = formatPageSize(pagination.value.pageSize);
|
|
229
263
|
else delete query.page_size;
|
|
230
264
|
if (search.value) query.search = search.value;
|
|
231
265
|
else delete query.search;
|
|
@@ -239,6 +273,13 @@ const writeUrlState = debounce(() => {
|
|
|
239
273
|
|
|
240
274
|
watch([pagination, search, sorting], writeUrlState, { deep: true });
|
|
241
275
|
|
|
276
|
+
// A debounced call still pending when the list goes away would act on the next
|
|
277
|
+
// page: the URL write would put this list's query on it.
|
|
278
|
+
onBeforeUnmount(() => {
|
|
279
|
+
onSearchInput.cancel();
|
|
280
|
+
writeUrlState.cancel();
|
|
281
|
+
});
|
|
282
|
+
|
|
242
283
|
// --- Row selection ---
|
|
243
284
|
// Selection is keyed by primary key (lookup), not by row index, so pagination/sort/refresh
|
|
244
285
|
// changes do not affect which rows are marked as selected.
|
|
@@ -264,11 +305,12 @@ watch(selectedRows, (rows) => {
|
|
|
264
305
|
|
|
265
306
|
function buildSelectionQuery(): URLSearchParams {
|
|
266
307
|
const params = new URLSearchParams();
|
|
267
|
-
|
|
308
|
+
if (!showsAllRows.value)
|
|
309
|
+
params.set("page_size", String(pagination.value.pageSize));
|
|
268
310
|
if (search.value) params.set("search", search.value);
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
311
|
+
// The same ordering the list request sends.
|
|
312
|
+
if (sorting.value.length)
|
|
313
|
+
params.set("ordering", orderingParam(sorting.value));
|
|
272
314
|
return params;
|
|
273
315
|
}
|
|
274
316
|
|
|
@@ -328,9 +370,9 @@ const quickEditLocalItem = computed<T | null>(() => {
|
|
|
328
370
|
// --- Delete ---
|
|
329
371
|
async function deleteRow(item: T) {
|
|
330
372
|
const ok = await confirm.ask({
|
|
331
|
-
title: "
|
|
332
|
-
message: "
|
|
333
|
-
confirmText: "
|
|
373
|
+
title: t("mapo.listTable.deleteItemTitle"),
|
|
374
|
+
message: t("mapo.confirmDelete"),
|
|
375
|
+
confirmText: t("mapo.delete"),
|
|
334
376
|
dangerous: true,
|
|
335
377
|
});
|
|
336
378
|
if (!ok) return;
|
|
@@ -340,16 +382,16 @@ async function deleteRow(item: T) {
|
|
|
340
382
|
String(atKey(r, props.lookup)) !== String(atKey(item, props.lookup)),
|
|
341
383
|
);
|
|
342
384
|
emit("update:items", next);
|
|
343
|
-
snack.show("
|
|
385
|
+
snack.show(t("mapo.listTable.itemDeleted"), "success");
|
|
344
386
|
return;
|
|
345
387
|
}
|
|
346
388
|
try {
|
|
347
389
|
await crud.delete(atKey(item, props.lookup) as string | number);
|
|
348
|
-
snack.show("
|
|
390
|
+
snack.show(t("mapo.listTable.itemDeleted"), "success");
|
|
349
391
|
if (hybridMode.value) hybridLoaded.value = false;
|
|
350
392
|
refresh();
|
|
351
393
|
} catch {
|
|
352
|
-
snack.show("
|
|
394
|
+
snack.show(t("mapo.listTable.deleteItemError"), "error");
|
|
353
395
|
}
|
|
354
396
|
}
|
|
355
397
|
|
|
@@ -454,13 +496,13 @@ async function onDrop(fromIdx: number, toIdx: number) {
|
|
|
454
496
|
atKey(moved, props.lookup) as string | number,
|
|
455
497
|
atKey(target, props.lookup) as string | number,
|
|
456
498
|
);
|
|
457
|
-
snack.show("
|
|
499
|
+
snack.show(t("mapo.listTable.orderSaved"), "success");
|
|
458
500
|
if (hybridMode.value) {
|
|
459
501
|
hybridLoaded.value = false;
|
|
460
502
|
refresh();
|
|
461
503
|
}
|
|
462
504
|
} catch {
|
|
463
|
-
snack.show("
|
|
505
|
+
snack.show(t("mapo.listTable.orderError"), "error");
|
|
464
506
|
refresh();
|
|
465
507
|
}
|
|
466
508
|
}
|
|
@@ -474,7 +516,7 @@ function applyOffline(source: T[]) {
|
|
|
474
516
|
const q = search.value.toLowerCase();
|
|
475
517
|
arr = arr.filter((row) =>
|
|
476
518
|
props.columns.some((c) =>
|
|
477
|
-
String(row
|
|
519
|
+
String(atKey(row, c.key) ?? "")
|
|
478
520
|
.toLowerCase()
|
|
479
521
|
.includes(q),
|
|
480
522
|
),
|
|
@@ -554,7 +596,7 @@ async function fetchAll() {
|
|
|
554
596
|
fullDataset.value = nextItems;
|
|
555
597
|
hybridLoaded.value = true;
|
|
556
598
|
} catch {
|
|
557
|
-
snack.show("
|
|
599
|
+
snack.show(t("mapo.loadError"), "error");
|
|
558
600
|
} finally {
|
|
559
601
|
loading.value = false;
|
|
560
602
|
}
|
|
@@ -587,13 +629,11 @@ async function refresh() {
|
|
|
587
629
|
const params: Record<string, unknown> = {
|
|
588
630
|
...endpointParams,
|
|
589
631
|
...(props.filterParams ?? {}),
|
|
590
|
-
|
|
632
|
+
// "All rows" sends no pagination params: the backend returns the whole collection.
|
|
633
|
+
...(showsAllRows.value ? {} : paginationP),
|
|
591
634
|
};
|
|
592
635
|
if (search.value) params.search = search.value;
|
|
593
|
-
if (sorting.value.length)
|
|
594
|
-
params.ordering = sorting.value
|
|
595
|
-
.map((s) => `${s.desc ? "-" : ""}${s.id}`)
|
|
596
|
-
.join(",");
|
|
636
|
+
if (sorting.value.length) params.ordering = orderingParam(sorting.value);
|
|
597
637
|
|
|
598
638
|
const res = await crud.list(params as Record<string, string>);
|
|
599
639
|
|
|
@@ -626,7 +666,7 @@ async function refresh() {
|
|
|
626
666
|
rows.value = nextItems;
|
|
627
667
|
total.value = nextTotal;
|
|
628
668
|
} catch {
|
|
629
|
-
snack.show("
|
|
669
|
+
snack.show(t("mapo.loadError"), "error");
|
|
630
670
|
} finally {
|
|
631
671
|
loading.value = false;
|
|
632
672
|
}
|
|
@@ -655,13 +695,23 @@ watch(
|
|
|
655
695
|
search,
|
|
656
696
|
],
|
|
657
697
|
([newEndpoint, , newFilters], [oldEndpoint, , oldFilters]) => {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
} else {
|
|
698
|
+
// The immediate first run has no old values: it is the initial load, so it
|
|
699
|
+
// fetches the page restored from the URL.
|
|
700
|
+
const isFirstRun = oldFilters === undefined;
|
|
701
|
+
if (isFirstRun) {
|
|
663
702
|
refresh();
|
|
703
|
+
return;
|
|
664
704
|
}
|
|
705
|
+
const endpointChanged = newEndpoint !== oldEndpoint;
|
|
706
|
+
const filtersChanged = newFilters !== oldFilters;
|
|
707
|
+
const contextChanged = endpointChanged || filtersChanged;
|
|
708
|
+
const isOnFirstPage = pagination.value.pageIndex === 0;
|
|
709
|
+
// Moving to the first page runs this watcher again, and that run fetches.
|
|
710
|
+
if (contextChanged && !isOnFirstPage) {
|
|
711
|
+
pagination.value = { ...pagination.value, pageIndex: 0 };
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
refresh();
|
|
665
715
|
},
|
|
666
716
|
{ immediate: true, deep: true },
|
|
667
717
|
);
|
|
@@ -671,6 +721,35 @@ const UCheckbox = resolveComponent("UCheckbox");
|
|
|
671
721
|
const UButton = resolveComponent("UButton");
|
|
672
722
|
const UIcon = resolveComponent("UIcon");
|
|
673
723
|
|
|
724
|
+
// A sortable header is a button: the icon shows the current direction, the
|
|
725
|
+
// accessible name says what the next click does (UTable sets no `aria-sort`).
|
|
726
|
+
const SORT_ICONS = {
|
|
727
|
+
none: "i-lucide-arrow-up-down",
|
|
728
|
+
asc: "i-lucide-arrow-up-narrow-wide",
|
|
729
|
+
desc: "i-lucide-arrow-down-wide-narrow",
|
|
730
|
+
};
|
|
731
|
+
const SORT_NEXT_ACTION = {
|
|
732
|
+
none: "mapo.listTable.sortAscending",
|
|
733
|
+
asc: "mapo.listTable.sortDescending",
|
|
734
|
+
desc: "mapo.listTable.clearSorting",
|
|
735
|
+
};
|
|
736
|
+
|
|
737
|
+
function sortHeader(col: ListColumn<T>) {
|
|
738
|
+
const sort = sorting.value.find((s) => s.id === col.key);
|
|
739
|
+
const direction = !sort ? "none" : sort.desc ? "desc" : "asc";
|
|
740
|
+
return h(UButton, {
|
|
741
|
+
color: "neutral",
|
|
742
|
+
variant: "ghost",
|
|
743
|
+
label: col.label,
|
|
744
|
+
icon: SORT_ICONS[direction],
|
|
745
|
+
class: "-mx-2.5",
|
|
746
|
+
"aria-label": t(SORT_NEXT_ACTION[direction], { column: col.label }),
|
|
747
|
+
onClick: () => {
|
|
748
|
+
sorting.value = nextSorting(sorting.value, col.key);
|
|
749
|
+
},
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
|
|
674
753
|
const tableColumns = computed<TableColumn<T>[]>(() => {
|
|
675
754
|
const cols: TableColumn<T>[] = [];
|
|
676
755
|
|
|
@@ -682,14 +761,14 @@ const tableColumns = computed<TableColumn<T>[]>(() => {
|
|
|
682
761
|
modelValue: isAllSelected.value,
|
|
683
762
|
indeterminate: isIndeterminate.value,
|
|
684
763
|
"onUpdate:modelValue": toggleAll,
|
|
685
|
-
ariaLabel: "
|
|
764
|
+
ariaLabel: t("mapo.listTable.selectAllRows"),
|
|
686
765
|
}),
|
|
687
766
|
cell: ({ row }: { row: { original: T } }) => {
|
|
688
767
|
const k = pkOf(row.original);
|
|
689
768
|
return h(UCheckbox, {
|
|
690
769
|
modelValue: !!rowSelection.value[k],
|
|
691
770
|
"onUpdate:modelValue": () => toggleRowByKey(k),
|
|
692
|
-
ariaLabel: "
|
|
771
|
+
ariaLabel: t("mapo.listTable.selectRow"),
|
|
693
772
|
});
|
|
694
773
|
},
|
|
695
774
|
meta: { class: { th: "w-10", td: "w-10" } },
|
|
@@ -709,8 +788,8 @@ const tableColumns = computed<TableColumn<T>[]>(() => {
|
|
|
709
788
|
: "cursor-not-allowed text-muted opacity-30",
|
|
710
789
|
draggable: canReorder.value,
|
|
711
790
|
title: canReorder.value
|
|
712
|
-
? "
|
|
713
|
-
: "
|
|
791
|
+
? t("mapo.listTable.dragToReorder")
|
|
792
|
+
: t("mapo.listTable.clearToReorder"),
|
|
714
793
|
onDragstart: (e: DragEvent) => {
|
|
715
794
|
e.dataTransfer?.setData("text/plain", "");
|
|
716
795
|
onDragStart(row.index);
|
|
@@ -729,8 +808,11 @@ const tableColumns = computed<TableColumn<T>[]>(() => {
|
|
|
729
808
|
const col = props.columns[i]!;
|
|
730
809
|
const isFirst = i === 0 && !!props.detailBase;
|
|
731
810
|
cols.push({
|
|
811
|
+
// TanStack would turn a dotted key into `category_name`; the sorting
|
|
812
|
+
// state uses the column key, so the id must be the key itself.
|
|
813
|
+
id: col.key,
|
|
732
814
|
accessorKey: col.key,
|
|
733
|
-
header: col.label,
|
|
815
|
+
header: col.sortable ? () => sortHeader(col) : col.label,
|
|
734
816
|
cell: ({ row }: { row: { original: T } }) => {
|
|
735
817
|
const cellSlot = slots[`cell.${col.key}`];
|
|
736
818
|
if (cellSlot)
|
|
@@ -768,6 +850,7 @@ const tableColumns = computed<TableColumn<T>[]>(() => {
|
|
|
768
850
|
variant: "ghost",
|
|
769
851
|
color: "neutral",
|
|
770
852
|
icon: "i-lucide-pencil",
|
|
853
|
+
"aria-label": t("mapo.edit"),
|
|
771
854
|
onClick: () =>
|
|
772
855
|
openQuickEdit(
|
|
773
856
|
atKey(row.original, props.lookup) as string | number,
|
|
@@ -782,6 +865,7 @@ const tableColumns = computed<TableColumn<T>[]>(() => {
|
|
|
782
865
|
variant: "ghost",
|
|
783
866
|
color: "error",
|
|
784
867
|
icon: "i-lucide-trash-2",
|
|
868
|
+
"aria-label": t("mapo.delete"),
|
|
785
869
|
onClick: () => deleteRow(row.original),
|
|
786
870
|
}),
|
|
787
871
|
);
|
|
@@ -798,6 +882,19 @@ const tableColumns = computed<TableColumn<T>[]>(() => {
|
|
|
798
882
|
return cols;
|
|
799
883
|
});
|
|
800
884
|
|
|
885
|
+
// A search or a filter with no match reads differently from an empty list.
|
|
886
|
+
const emptyText = computed(() => {
|
|
887
|
+
const isSearching = !!search.value;
|
|
888
|
+
const isFiltering = Object.values(props.filterParams ?? {}).some(
|
|
889
|
+
(value) => value != null && value !== "",
|
|
890
|
+
);
|
|
891
|
+
return t(
|
|
892
|
+
isSearching || isFiltering
|
|
893
|
+
? "mapo.listTable.noResults"
|
|
894
|
+
: "mapo.listTable.noItems",
|
|
895
|
+
);
|
|
896
|
+
});
|
|
897
|
+
|
|
801
898
|
// --- Pagination for UTable ---
|
|
802
899
|
const paginationOptions = computed(() => ({
|
|
803
900
|
manualPagination: true,
|
|
@@ -811,11 +908,16 @@ const sortingOptions = computed(() => ({
|
|
|
811
908
|
|
|
812
909
|
<template>
|
|
813
910
|
<div class="mapo-list-table space-y-3">
|
|
814
|
-
<!--
|
|
815
|
-
|
|
911
|
+
<!-- Toolbar: the search and the `dtable.toolbar` content (in MapoList,
|
|
912
|
+
the bulk actions), also without the search -->
|
|
913
|
+
<div
|
|
914
|
+
v-if="searchable || $slots['dtable.toolbar']"
|
|
915
|
+
class="flex flex-wrap items-center gap-2"
|
|
916
|
+
>
|
|
816
917
|
<UInput
|
|
918
|
+
v-if="searchable"
|
|
817
919
|
:model-value="search"
|
|
818
|
-
placeholder="
|
|
920
|
+
:placeholder="t('mapo.search')"
|
|
819
921
|
icon="i-lucide-search"
|
|
820
922
|
size="sm"
|
|
821
923
|
class="max-w-xs"
|
|
@@ -839,7 +941,7 @@ const sortingOptions = computed(() => ({
|
|
|
839
941
|
:pagination-options="paginationOptions"
|
|
840
942
|
:sorting="sorting"
|
|
841
943
|
:sorting-options="sortingOptions"
|
|
842
|
-
empty="
|
|
944
|
+
:empty="emptyText"
|
|
843
945
|
@update:pagination="pagination = $event ?? pagination"
|
|
844
946
|
@update:sorting="sorting = $event ?? sorting"
|
|
845
947
|
>
|
|
@@ -847,7 +949,7 @@ const sortingOptions = computed(() => ({
|
|
|
847
949
|
<slot name="dtable.empty">
|
|
848
950
|
<div class="flex flex-col items-center gap-2 py-8 text-muted">
|
|
849
951
|
<UIcon name="i-lucide-inbox" class="h-8 w-8" />
|
|
850
|
-
<span class="text-sm">
|
|
952
|
+
<span class="text-sm">{{ emptyText }}</span>
|
|
851
953
|
</div>
|
|
852
954
|
</slot>
|
|
853
955
|
</template>
|
|
@@ -867,21 +969,19 @@ const sortingOptions = computed(() => ({
|
|
|
867
969
|
|
|
868
970
|
<!-- Pagination controls -->
|
|
869
971
|
<div class="flex items-center justify-between text-sm text-muted">
|
|
870
|
-
<span>{{ total }}
|
|
972
|
+
<span>{{ t("mapo.listTable.totalItems", { total }) }}</span>
|
|
973
|
+
<!-- Nuxt UI 4's UPagination models `page`: with `modelValue` it runs uncontrolled. -->
|
|
871
974
|
<UPagination
|
|
872
|
-
|
|
975
|
+
v-if="!showsAllRows"
|
|
976
|
+
:page="pagination.pageIndex + 1"
|
|
873
977
|
:total="total"
|
|
874
|
-
:page
|
|
978
|
+
:items-per-page="pagination.pageSize"
|
|
875
979
|
size="sm"
|
|
876
|
-
@update:
|
|
877
|
-
pagination = { ...pagination, pageIndex: $event - 1 }
|
|
878
|
-
"
|
|
980
|
+
@update:page="pagination = { ...pagination, pageIndex: $event - 1 }"
|
|
879
981
|
/>
|
|
880
982
|
<USelect
|
|
881
983
|
:model-value="pagination.pageSize"
|
|
882
|
-
:items="
|
|
883
|
-
pageSizeOptions.map((n) => ({ label: `${n} / page`, value: n }))
|
|
884
|
-
"
|
|
984
|
+
:items="pageSizeItems"
|
|
885
985
|
size="xs"
|
|
886
986
|
class="w-28"
|
|
887
987
|
@update:model-value="
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { reactive, ref } from "vue";
|
|
3
|
+
import { useI18n } from "vue-i18n";
|
|
3
4
|
import { useMapoAuth } from "@mapomodule/core/runtime/auth/useMapoAuth";
|
|
4
|
-
import { useRoute } from "
|
|
5
|
-
import { navigateTo } from "#app";
|
|
5
|
+
import { useRoute, navigateTo } from "#app";
|
|
6
6
|
|
|
7
7
|
defineSlots<{
|
|
8
8
|
/** Left decorative panel (shown lg+). Replace with your own branding. */
|
|
@@ -17,6 +17,7 @@ defineSlots<{
|
|
|
17
17
|
footer(): unknown;
|
|
18
18
|
}>();
|
|
19
19
|
|
|
20
|
+
const { t } = useI18n();
|
|
20
21
|
const { login } = useMapoAuth();
|
|
21
22
|
const route = useRoute();
|
|
22
23
|
|
|
@@ -41,7 +42,7 @@ async function submit() {
|
|
|
41
42
|
if (data.username?.length) fieldErrors.username = data.username[0];
|
|
42
43
|
if (data.password?.length) fieldErrors.password = data.password[0];
|
|
43
44
|
} else {
|
|
44
|
-
error.value = "
|
|
45
|
+
error.value = t("mapo.login.invalidCredentials");
|
|
45
46
|
}
|
|
46
47
|
} finally {
|
|
47
48
|
loading.value = false;
|
|
@@ -77,9 +78,11 @@ async function submit() {
|
|
|
77
78
|
<UIcon name="i-lucide-layers" class="size-10 text-white" />
|
|
78
79
|
</div>
|
|
79
80
|
<div class="space-y-2">
|
|
80
|
-
<h2 class="text-3xl font-bold tracking-tight">
|
|
81
|
+
<h2 class="text-3xl font-bold tracking-tight">
|
|
82
|
+
{{ t("mapo.login.welcome") }}
|
|
83
|
+
</h2>
|
|
81
84
|
<p class="text-white/70 text-sm leading-relaxed max-w-xs">
|
|
82
|
-
|
|
85
|
+
{{ t("mapo.login.tagline") }}
|
|
83
86
|
</p>
|
|
84
87
|
</div>
|
|
85
88
|
<div class="flex gap-2 flex-wrap justify-center">
|
|
@@ -125,10 +128,10 @@ async function submit() {
|
|
|
125
128
|
</div>
|
|
126
129
|
<div>
|
|
127
130
|
<h1 class="text-2xl font-bold text-highlighted tracking-tight">
|
|
128
|
-
|
|
131
|
+
{{ t("mapo.signIn") }}
|
|
129
132
|
</h1>
|
|
130
133
|
<p class="text-sm text-muted mt-1">
|
|
131
|
-
|
|
134
|
+
{{ t("mapo.login.subtitle") }}
|
|
132
135
|
</p>
|
|
133
136
|
</div>
|
|
134
137
|
</div>
|
|
@@ -139,7 +142,7 @@ async function submit() {
|
|
|
139
142
|
<UCard class="shadow-xl ring-1 ring-default/60">
|
|
140
143
|
<form class="space-y-5" @submit.prevent="submit">
|
|
141
144
|
<UFormField
|
|
142
|
-
label="
|
|
145
|
+
:label="t('mapo.username')"
|
|
143
146
|
name="username"
|
|
144
147
|
:error="fieldErrors.username"
|
|
145
148
|
>
|
|
@@ -156,7 +159,7 @@ async function submit() {
|
|
|
156
159
|
</UFormField>
|
|
157
160
|
|
|
158
161
|
<UFormField
|
|
159
|
-
label="
|
|
162
|
+
:label="t('mapo.password')"
|
|
160
163
|
name="password"
|
|
161
164
|
:error="fieldErrors.password"
|
|
162
165
|
>
|
|
@@ -195,7 +198,7 @@ async function submit() {
|
|
|
195
198
|
:disabled="!form.username || !form.password"
|
|
196
199
|
block
|
|
197
200
|
>
|
|
198
|
-
|
|
201
|
+
{{ t("mapo.signIn") }}
|
|
199
202
|
</UButton>
|
|
200
203
|
</form>
|
|
201
204
|
</UCard>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { useI18n } from "vue-i18n";
|
|
2
3
|
import { useMapoAuth } from "@mapomodule/core/runtime/auth/useMapoAuth";
|
|
3
4
|
|
|
4
5
|
withDefaults(
|
|
@@ -27,6 +28,7 @@ withDefaults(
|
|
|
27
28
|
},
|
|
28
29
|
);
|
|
29
30
|
|
|
31
|
+
const { t } = useI18n();
|
|
30
32
|
const { logout } = useMapoAuth();
|
|
31
33
|
</script>
|
|
32
34
|
|
|
@@ -36,11 +38,11 @@ const { logout } = useMapoAuth();
|
|
|
36
38
|
:color="color"
|
|
37
39
|
:size="size"
|
|
38
40
|
icon="i-lucide-log-out"
|
|
39
|
-
:aria-label="iconOnly ? '
|
|
41
|
+
:aria-label="iconOnly ? t('mapo.logout') : undefined"
|
|
40
42
|
@click="logout()"
|
|
41
43
|
>
|
|
42
44
|
<span v-if="!iconOnly">
|
|
43
|
-
<slot>
|
|
45
|
+
<slot>{{ t("mapo.logout") }}</slot>
|
|
44
46
|
</span>
|
|
45
47
|
</UButton>
|
|
46
48
|
</template>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { useI18n } from "vue-i18n";
|
|
4
|
+
import { useMediaStore } from "../stores/media.js";
|
|
5
|
+
import type { MediaFolder } from "../types/media.js";
|
|
6
|
+
|
|
7
|
+
const { t } = useI18n();
|
|
8
|
+
const store = useMediaStore();
|
|
9
|
+
|
|
10
|
+
const items = computed(() => [
|
|
11
|
+
{
|
|
12
|
+
label: t("mapo.mediaManager.root"),
|
|
13
|
+
icon: "i-lucide-folder-open",
|
|
14
|
+
folder: null as MediaFolder | null,
|
|
15
|
+
},
|
|
16
|
+
...store.parentFolders.map((f) => ({
|
|
17
|
+
label: f.name,
|
|
18
|
+
icon: "i-lucide-folder",
|
|
19
|
+
folder: f,
|
|
20
|
+
})),
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
function navigate(folder: MediaFolder | null) {
|
|
24
|
+
store.navigateToFolder(folder);
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<nav class="flex items-center gap-1 overflow-x-auto py-1 text-sm">
|
|
30
|
+
<template v-for="(item, i) in items" :key="i">
|
|
31
|
+
<UButton
|
|
32
|
+
variant="ghost"
|
|
33
|
+
color="neutral"
|
|
34
|
+
size="xs"
|
|
35
|
+
:icon="item.icon"
|
|
36
|
+
:disabled="i === items.length - 1"
|
|
37
|
+
:class="
|
|
38
|
+
i === items.length - 1
|
|
39
|
+
? 'font-semibold text-highlighted'
|
|
40
|
+
: 'text-muted hover:text-highlighted'
|
|
41
|
+
"
|
|
42
|
+
@click="navigate(item.folder)"
|
|
43
|
+
>
|
|
44
|
+
{{ item.label }}
|
|
45
|
+
</UButton>
|
|
46
|
+
<UIcon
|
|
47
|
+
v-if="i < items.length - 1"
|
|
48
|
+
name="i-lucide-chevron-right"
|
|
49
|
+
class="size-3 shrink-0 text-dimmed"
|
|
50
|
+
/>
|
|
51
|
+
</template>
|
|
52
|
+
</nav>
|
|
53
|
+
</template>
|