@mapomodule/uikit 2.0.0-beta.7 → 2.0.0-experimental.1
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 +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/module.d.mts +2 -0
- package/dist/module.d.ts.map +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +23 -2
- 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 +301 -63
- 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 +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 +5 -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/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 +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 +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 +12 -8
- package/dist/runtime/components/MapoListQuickEdit.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoListTable.vue +116 -45
- 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/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 +3 -1
- package/dist/runtime/components/MapoMediaBreadcrumbs.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaEditor.vue +36 -20
- 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 +7 -3
- package/dist/runtime/components/MapoMediaFileChanger.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaFolders.vue +36 -14
- package/dist/runtime/components/MapoMediaFolders.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaGallery.vue +15 -5
- package/dist/runtime/components/MapoMediaGallery.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaManager.vue +17 -7
- package/dist/runtime/components/MapoMediaManager.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaManagerDialog.vue +8 -4
- package/dist/runtime/components/MapoMediaManagerDialog.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaUploader.vue +53 -29
- package/dist/runtime/components/MapoMediaUploader.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMenuManager.vue +293 -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/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/pages/index.vue +4 -2
- package/dist/runtime/pages/index.vue.d.ts.map +1 -1
- package/dist/runtime/plugins/media-adapter.d.ts.map +1 -1
- package/dist/runtime/plugins/media-adapter.js +2 -1
- 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 +45 -13
- 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/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/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 +12 -10
- 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 +20 -0
- package/src/module.ts +29 -0
- package/src/runtime/assets/main.css +13 -0
- package/src/runtime/components/MapoConfirmDialog.vue +33 -4
- package/src/runtime/components/MapoDetail.vue +520 -89
- package/src/runtime/components/MapoDetailExtensions.vue +39 -0
- package/src/runtime/components/MapoDetailLangSwitch.vue +27 -28
- package/src/runtime/components/MapoDropArea.vue +6 -1
- package/src/runtime/components/MapoLangSwitcher.vue +74 -0
- package/src/runtime/components/MapoList.vue +21 -6
- package/src/runtime/components/MapoListActions.vue +32 -14
- package/src/runtime/components/MapoListFilters.vue +5 -2
- package/src/runtime/components/MapoListQuickEdit.vue +12 -9
- package/src/runtime/components/MapoListTable.vue +147 -55
- package/src/runtime/components/MapoLogin.vue +13 -10
- package/src/runtime/components/MapoLogoutButton.vue +4 -2
- package/src/runtime/components/MapoMediaBreadcrumbs.vue +3 -1
- package/src/runtime/components/MapoMediaEditor.vue +43 -20
- package/src/runtime/components/MapoMediaFileChanger.vue +8 -3
- package/src/runtime/components/MapoMediaFolders.vue +37 -15
- package/src/runtime/components/MapoMediaGallery.vue +17 -5
- package/src/runtime/components/MapoMediaManager.vue +17 -7
- package/src/runtime/components/MapoMediaManagerDialog.vue +10 -4
- package/src/runtime/components/MapoMediaUploader.vue +60 -29
- package/src/runtime/components/MapoMenuManager.vue +437 -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/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/pages/index.vue +5 -2
- package/src/runtime/plugins/media-adapter.ts +9 -5
- package/src/runtime/stores/media.ts +61 -13
- package/src/runtime/types/detail.ts +178 -0
- package/src/runtime/types/list.ts +10 -2
- package/src/runtime/types/menu.ts +105 -0
- package/src/runtime/utils/formValues.ts +28 -0
- package/src/runtime/utils/langInfo.ts +38 -0
- package/src/runtime/utils/listTable.ts +54 -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;
|
|
@@ -134,11 +153,13 @@ defineSlots<
|
|
|
134
153
|
|
|
135
154
|
const slots = useSlots();
|
|
136
155
|
|
|
137
|
-
//
|
|
138
|
-
//
|
|
139
|
-
//
|
|
140
|
-
const atKey = (item: T, key: string): T[keyof T] =>
|
|
156
|
+
// A key can be a dotted path into a related object (`category.name`). The cast to
|
|
157
|
+
// T[keyof T] gives the call sites the union of the row's property types rather
|
|
158
|
+
// than `unknown`.
|
|
159
|
+
const atKey = (item: T, key: string): T[keyof T] =>
|
|
160
|
+
getNestedValue(item, key) as T[keyof T];
|
|
141
161
|
|
|
162
|
+
const { t } = useI18n();
|
|
142
163
|
const snack = useSnackStore();
|
|
143
164
|
const confirm = useConfirmStore();
|
|
144
165
|
|
|
@@ -185,14 +206,24 @@ function toPositiveNumber(value: unknown, fallback: number): number {
|
|
|
185
206
|
}
|
|
186
207
|
|
|
187
208
|
// --- Pagination (restored from URL) ---
|
|
209
|
+
// "All rows" is stored as the ALL_ROWS page size and written as `page_size=all`.
|
|
210
|
+
const defaultPageSize = toPageSize(props.defaultPageSize);
|
|
188
211
|
const pagination = ref<PaginationState>({
|
|
189
212
|
pageIndex: route.query.page
|
|
190
213
|
? Math.max(0, toPositiveNumber(route.query.page, 1) - 1)
|
|
191
214
|
: 0,
|
|
192
215
|
pageSize: route.query.page_size
|
|
193
|
-
?
|
|
194
|
-
:
|
|
216
|
+
? parsePageSize(route.query.page_size, defaultPageSize)
|
|
217
|
+
: defaultPageSize,
|
|
195
218
|
});
|
|
219
|
+
const showsAllRows = computed(() => pagination.value.pageSize === ALL_ROWS);
|
|
220
|
+
const pageSizeItems = computed(() =>
|
|
221
|
+
props.pageSizeOptions.map((option) =>
|
|
222
|
+
option === "all"
|
|
223
|
+
? { label: t("mapo.listTable.allRows"), value: ALL_ROWS }
|
|
224
|
+
: { label: t("mapo.listTable.perPage", { n: option }), value: option },
|
|
225
|
+
),
|
|
226
|
+
);
|
|
196
227
|
|
|
197
228
|
// --- Sorting (restored from URL) ---
|
|
198
229
|
const sorting = ref<SortingState>(
|
|
@@ -224,8 +255,8 @@ const writeUrlState = debounce(() => {
|
|
|
224
255
|
const page = pagination.value.pageIndex + 1;
|
|
225
256
|
if (page > 1) query.page = String(page);
|
|
226
257
|
else delete query.page;
|
|
227
|
-
if (pagination.value.pageSize !==
|
|
228
|
-
query.page_size =
|
|
258
|
+
if (pagination.value.pageSize !== defaultPageSize)
|
|
259
|
+
query.page_size = formatPageSize(pagination.value.pageSize);
|
|
229
260
|
else delete query.page_size;
|
|
230
261
|
if (search.value) query.search = search.value;
|
|
231
262
|
else delete query.search;
|
|
@@ -239,6 +270,13 @@ const writeUrlState = debounce(() => {
|
|
|
239
270
|
|
|
240
271
|
watch([pagination, search, sorting], writeUrlState, { deep: true });
|
|
241
272
|
|
|
273
|
+
// A debounced call still pending when the list goes away would act on the next
|
|
274
|
+
// page: the URL write would put this list's query on it.
|
|
275
|
+
onBeforeUnmount(() => {
|
|
276
|
+
onSearchInput.cancel();
|
|
277
|
+
writeUrlState.cancel();
|
|
278
|
+
});
|
|
279
|
+
|
|
242
280
|
// --- Row selection ---
|
|
243
281
|
// Selection is keyed by primary key (lookup), not by row index, so pagination/sort/refresh
|
|
244
282
|
// changes do not affect which rows are marked as selected.
|
|
@@ -264,11 +302,12 @@ watch(selectedRows, (rows) => {
|
|
|
264
302
|
|
|
265
303
|
function buildSelectionQuery(): URLSearchParams {
|
|
266
304
|
const params = new URLSearchParams();
|
|
267
|
-
|
|
305
|
+
if (!showsAllRows.value)
|
|
306
|
+
params.set("page_size", String(pagination.value.pageSize));
|
|
268
307
|
if (search.value) params.set("search", search.value);
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
308
|
+
// The same ordering the list request sends.
|
|
309
|
+
if (sorting.value.length)
|
|
310
|
+
params.set("ordering", orderingParam(sorting.value));
|
|
272
311
|
return params;
|
|
273
312
|
}
|
|
274
313
|
|
|
@@ -328,9 +367,9 @@ const quickEditLocalItem = computed<T | null>(() => {
|
|
|
328
367
|
// --- Delete ---
|
|
329
368
|
async function deleteRow(item: T) {
|
|
330
369
|
const ok = await confirm.ask({
|
|
331
|
-
title: "
|
|
332
|
-
message: "
|
|
333
|
-
confirmText: "
|
|
370
|
+
title: t("mapo.listTable.deleteItemTitle"),
|
|
371
|
+
message: t("mapo.confirmDelete"),
|
|
372
|
+
confirmText: t("mapo.delete"),
|
|
334
373
|
dangerous: true,
|
|
335
374
|
});
|
|
336
375
|
if (!ok) return;
|
|
@@ -340,16 +379,16 @@ async function deleteRow(item: T) {
|
|
|
340
379
|
String(atKey(r, props.lookup)) !== String(atKey(item, props.lookup)),
|
|
341
380
|
);
|
|
342
381
|
emit("update:items", next);
|
|
343
|
-
snack.show("
|
|
382
|
+
snack.show(t("mapo.listTable.itemDeleted"), "success");
|
|
344
383
|
return;
|
|
345
384
|
}
|
|
346
385
|
try {
|
|
347
386
|
await crud.delete(atKey(item, props.lookup) as string | number);
|
|
348
|
-
snack.show("
|
|
387
|
+
snack.show(t("mapo.listTable.itemDeleted"), "success");
|
|
349
388
|
if (hybridMode.value) hybridLoaded.value = false;
|
|
350
389
|
refresh();
|
|
351
390
|
} catch {
|
|
352
|
-
snack.show("
|
|
391
|
+
snack.show(t("mapo.listTable.deleteItemError"), "error");
|
|
353
392
|
}
|
|
354
393
|
}
|
|
355
394
|
|
|
@@ -454,13 +493,13 @@ async function onDrop(fromIdx: number, toIdx: number) {
|
|
|
454
493
|
atKey(moved, props.lookup) as string | number,
|
|
455
494
|
atKey(target, props.lookup) as string | number,
|
|
456
495
|
);
|
|
457
|
-
snack.show("
|
|
496
|
+
snack.show(t("mapo.listTable.orderSaved"), "success");
|
|
458
497
|
if (hybridMode.value) {
|
|
459
498
|
hybridLoaded.value = false;
|
|
460
499
|
refresh();
|
|
461
500
|
}
|
|
462
501
|
} catch {
|
|
463
|
-
snack.show("
|
|
502
|
+
snack.show(t("mapo.listTable.orderError"), "error");
|
|
464
503
|
refresh();
|
|
465
504
|
}
|
|
466
505
|
}
|
|
@@ -474,7 +513,7 @@ function applyOffline(source: T[]) {
|
|
|
474
513
|
const q = search.value.toLowerCase();
|
|
475
514
|
arr = arr.filter((row) =>
|
|
476
515
|
props.columns.some((c) =>
|
|
477
|
-
String(row
|
|
516
|
+
String(atKey(row, c.key) ?? "")
|
|
478
517
|
.toLowerCase()
|
|
479
518
|
.includes(q),
|
|
480
519
|
),
|
|
@@ -554,7 +593,7 @@ async function fetchAll() {
|
|
|
554
593
|
fullDataset.value = nextItems;
|
|
555
594
|
hybridLoaded.value = true;
|
|
556
595
|
} catch {
|
|
557
|
-
snack.show("
|
|
596
|
+
snack.show(t("mapo.loadError"), "error");
|
|
558
597
|
} finally {
|
|
559
598
|
loading.value = false;
|
|
560
599
|
}
|
|
@@ -587,13 +626,11 @@ async function refresh() {
|
|
|
587
626
|
const params: Record<string, unknown> = {
|
|
588
627
|
...endpointParams,
|
|
589
628
|
...(props.filterParams ?? {}),
|
|
590
|
-
|
|
629
|
+
// "All rows" sends no pagination params: the backend returns the whole collection.
|
|
630
|
+
...(showsAllRows.value ? {} : paginationP),
|
|
591
631
|
};
|
|
592
632
|
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(",");
|
|
633
|
+
if (sorting.value.length) params.ordering = orderingParam(sorting.value);
|
|
597
634
|
|
|
598
635
|
const res = await crud.list(params as Record<string, string>);
|
|
599
636
|
|
|
@@ -626,7 +663,7 @@ async function refresh() {
|
|
|
626
663
|
rows.value = nextItems;
|
|
627
664
|
total.value = nextTotal;
|
|
628
665
|
} catch {
|
|
629
|
-
snack.show("
|
|
666
|
+
snack.show(t("mapo.loadError"), "error");
|
|
630
667
|
} finally {
|
|
631
668
|
loading.value = false;
|
|
632
669
|
}
|
|
@@ -655,13 +692,23 @@ watch(
|
|
|
655
692
|
search,
|
|
656
693
|
],
|
|
657
694
|
([newEndpoint, , newFilters], [oldEndpoint, , oldFilters]) => {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
} else {
|
|
695
|
+
// The immediate first run has no old values: it is the initial load, so it
|
|
696
|
+
// fetches the page restored from the URL.
|
|
697
|
+
const isFirstRun = oldFilters === undefined;
|
|
698
|
+
if (isFirstRun) {
|
|
663
699
|
refresh();
|
|
700
|
+
return;
|
|
664
701
|
}
|
|
702
|
+
const endpointChanged = newEndpoint !== oldEndpoint;
|
|
703
|
+
const filtersChanged = newFilters !== oldFilters;
|
|
704
|
+
const contextChanged = endpointChanged || filtersChanged;
|
|
705
|
+
const isOnFirstPage = pagination.value.pageIndex === 0;
|
|
706
|
+
// Moving to the first page runs this watcher again, and that run fetches.
|
|
707
|
+
if (contextChanged && !isOnFirstPage) {
|
|
708
|
+
pagination.value = { ...pagination.value, pageIndex: 0 };
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
refresh();
|
|
665
712
|
},
|
|
666
713
|
{ immediate: true, deep: true },
|
|
667
714
|
);
|
|
@@ -671,6 +718,35 @@ const UCheckbox = resolveComponent("UCheckbox");
|
|
|
671
718
|
const UButton = resolveComponent("UButton");
|
|
672
719
|
const UIcon = resolveComponent("UIcon");
|
|
673
720
|
|
|
721
|
+
// A sortable header is a button: the icon shows the current direction, the
|
|
722
|
+
// accessible name says what the next click does (UTable sets no `aria-sort`).
|
|
723
|
+
const SORT_ICONS = {
|
|
724
|
+
none: "i-lucide-arrow-up-down",
|
|
725
|
+
asc: "i-lucide-arrow-up-narrow-wide",
|
|
726
|
+
desc: "i-lucide-arrow-down-wide-narrow",
|
|
727
|
+
};
|
|
728
|
+
const SORT_NEXT_ACTION = {
|
|
729
|
+
none: "mapo.listTable.sortAscending",
|
|
730
|
+
asc: "mapo.listTable.sortDescending",
|
|
731
|
+
desc: "mapo.listTable.clearSorting",
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
function sortHeader(col: ListColumn<T>) {
|
|
735
|
+
const sort = sorting.value.find((s) => s.id === col.key);
|
|
736
|
+
const direction = !sort ? "none" : sort.desc ? "desc" : "asc";
|
|
737
|
+
return h(UButton, {
|
|
738
|
+
color: "neutral",
|
|
739
|
+
variant: "ghost",
|
|
740
|
+
label: col.label,
|
|
741
|
+
icon: SORT_ICONS[direction],
|
|
742
|
+
class: "-mx-2.5",
|
|
743
|
+
"aria-label": t(SORT_NEXT_ACTION[direction], { column: col.label }),
|
|
744
|
+
onClick: () => {
|
|
745
|
+
sorting.value = nextSorting(sorting.value, col.key);
|
|
746
|
+
},
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
|
|
674
750
|
const tableColumns = computed<TableColumn<T>[]>(() => {
|
|
675
751
|
const cols: TableColumn<T>[] = [];
|
|
676
752
|
|
|
@@ -682,14 +758,14 @@ const tableColumns = computed<TableColumn<T>[]>(() => {
|
|
|
682
758
|
modelValue: isAllSelected.value,
|
|
683
759
|
indeterminate: isIndeterminate.value,
|
|
684
760
|
"onUpdate:modelValue": toggleAll,
|
|
685
|
-
ariaLabel: "
|
|
761
|
+
ariaLabel: t("mapo.listTable.selectAllRows"),
|
|
686
762
|
}),
|
|
687
763
|
cell: ({ row }: { row: { original: T } }) => {
|
|
688
764
|
const k = pkOf(row.original);
|
|
689
765
|
return h(UCheckbox, {
|
|
690
766
|
modelValue: !!rowSelection.value[k],
|
|
691
767
|
"onUpdate:modelValue": () => toggleRowByKey(k),
|
|
692
|
-
ariaLabel: "
|
|
768
|
+
ariaLabel: t("mapo.listTable.selectRow"),
|
|
693
769
|
});
|
|
694
770
|
},
|
|
695
771
|
meta: { class: { th: "w-10", td: "w-10" } },
|
|
@@ -709,8 +785,8 @@ const tableColumns = computed<TableColumn<T>[]>(() => {
|
|
|
709
785
|
: "cursor-not-allowed text-muted opacity-30",
|
|
710
786
|
draggable: canReorder.value,
|
|
711
787
|
title: canReorder.value
|
|
712
|
-
? "
|
|
713
|
-
: "
|
|
788
|
+
? t("mapo.listTable.dragToReorder")
|
|
789
|
+
: t("mapo.listTable.clearToReorder"),
|
|
714
790
|
onDragstart: (e: DragEvent) => {
|
|
715
791
|
e.dataTransfer?.setData("text/plain", "");
|
|
716
792
|
onDragStart(row.index);
|
|
@@ -729,8 +805,11 @@ const tableColumns = computed<TableColumn<T>[]>(() => {
|
|
|
729
805
|
const col = props.columns[i]!;
|
|
730
806
|
const isFirst = i === 0 && !!props.detailBase;
|
|
731
807
|
cols.push({
|
|
808
|
+
// TanStack would turn a dotted key into `category_name`; the sorting
|
|
809
|
+
// state uses the column key, so the id must be the key itself.
|
|
810
|
+
id: col.key,
|
|
732
811
|
accessorKey: col.key,
|
|
733
|
-
header: col.label,
|
|
812
|
+
header: col.sortable ? () => sortHeader(col) : col.label,
|
|
734
813
|
cell: ({ row }: { row: { original: T } }) => {
|
|
735
814
|
const cellSlot = slots[`cell.${col.key}`];
|
|
736
815
|
if (cellSlot)
|
|
@@ -768,6 +847,7 @@ const tableColumns = computed<TableColumn<T>[]>(() => {
|
|
|
768
847
|
variant: "ghost",
|
|
769
848
|
color: "neutral",
|
|
770
849
|
icon: "i-lucide-pencil",
|
|
850
|
+
"aria-label": t("mapo.edit"),
|
|
771
851
|
onClick: () =>
|
|
772
852
|
openQuickEdit(
|
|
773
853
|
atKey(row.original, props.lookup) as string | number,
|
|
@@ -782,6 +862,7 @@ const tableColumns = computed<TableColumn<T>[]>(() => {
|
|
|
782
862
|
variant: "ghost",
|
|
783
863
|
color: "error",
|
|
784
864
|
icon: "i-lucide-trash-2",
|
|
865
|
+
"aria-label": t("mapo.delete"),
|
|
785
866
|
onClick: () => deleteRow(row.original),
|
|
786
867
|
}),
|
|
787
868
|
);
|
|
@@ -798,6 +879,19 @@ const tableColumns = computed<TableColumn<T>[]>(() => {
|
|
|
798
879
|
return cols;
|
|
799
880
|
});
|
|
800
881
|
|
|
882
|
+
// A search or a filter with no match reads differently from an empty list.
|
|
883
|
+
const emptyText = computed(() => {
|
|
884
|
+
const isSearching = !!search.value;
|
|
885
|
+
const isFiltering = Object.values(props.filterParams ?? {}).some(
|
|
886
|
+
(value) => value != null && value !== "",
|
|
887
|
+
);
|
|
888
|
+
return t(
|
|
889
|
+
isSearching || isFiltering
|
|
890
|
+
? "mapo.listTable.noResults"
|
|
891
|
+
: "mapo.listTable.noItems",
|
|
892
|
+
);
|
|
893
|
+
});
|
|
894
|
+
|
|
801
895
|
// --- Pagination for UTable ---
|
|
802
896
|
const paginationOptions = computed(() => ({
|
|
803
897
|
manualPagination: true,
|
|
@@ -815,7 +909,7 @@ const sortingOptions = computed(() => ({
|
|
|
815
909
|
<div v-if="searchable" class="flex items-center gap-2">
|
|
816
910
|
<UInput
|
|
817
911
|
:model-value="search"
|
|
818
|
-
placeholder="
|
|
912
|
+
:placeholder="t('mapo.search')"
|
|
819
913
|
icon="i-lucide-search"
|
|
820
914
|
size="sm"
|
|
821
915
|
class="max-w-xs"
|
|
@@ -839,7 +933,7 @@ const sortingOptions = computed(() => ({
|
|
|
839
933
|
:pagination-options="paginationOptions"
|
|
840
934
|
:sorting="sorting"
|
|
841
935
|
:sorting-options="sortingOptions"
|
|
842
|
-
empty="
|
|
936
|
+
:empty="emptyText"
|
|
843
937
|
@update:pagination="pagination = $event ?? pagination"
|
|
844
938
|
@update:sorting="sorting = $event ?? sorting"
|
|
845
939
|
>
|
|
@@ -847,7 +941,7 @@ const sortingOptions = computed(() => ({
|
|
|
847
941
|
<slot name="dtable.empty">
|
|
848
942
|
<div class="flex flex-col items-center gap-2 py-8 text-muted">
|
|
849
943
|
<UIcon name="i-lucide-inbox" class="h-8 w-8" />
|
|
850
|
-
<span class="text-sm">
|
|
944
|
+
<span class="text-sm">{{ emptyText }}</span>
|
|
851
945
|
</div>
|
|
852
946
|
</slot>
|
|
853
947
|
</template>
|
|
@@ -867,21 +961,19 @@ const sortingOptions = computed(() => ({
|
|
|
867
961
|
|
|
868
962
|
<!-- Pagination controls -->
|
|
869
963
|
<div class="flex items-center justify-between text-sm text-muted">
|
|
870
|
-
<span>{{ total }}
|
|
964
|
+
<span>{{ t("mapo.listTable.totalItems", { total }) }}</span>
|
|
965
|
+
<!-- Nuxt UI 4's UPagination models `page`: with `modelValue` it runs uncontrolled. -->
|
|
871
966
|
<UPagination
|
|
872
|
-
|
|
967
|
+
v-if="!showsAllRows"
|
|
968
|
+
:page="pagination.pageIndex + 1"
|
|
873
969
|
:total="total"
|
|
874
970
|
:items-per-page="pagination.pageSize"
|
|
875
971
|
size="sm"
|
|
876
|
-
@update:
|
|
877
|
-
pagination = { ...pagination, pageIndex: $event - 1 }
|
|
878
|
-
"
|
|
972
|
+
@update:page="pagination = { ...pagination, pageIndex: $event - 1 }"
|
|
879
973
|
/>
|
|
880
974
|
<USelect
|
|
881
975
|
:model-value="pagination.pageSize"
|
|
882
|
-
:items="
|
|
883
|
-
pageSizeOptions.map((n) => ({ label: `${n} / page`, value: n }))
|
|
884
|
-
"
|
|
976
|
+
:items="pageSizeItems"
|
|
885
977
|
size="xs"
|
|
886
978
|
class="w-28"
|
|
887
979
|
@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>
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed } from "vue";
|
|
3
|
+
import { useI18n } from "vue-i18n";
|
|
3
4
|
import { useMediaStore } from "../stores/media.js";
|
|
4
5
|
import type { MediaFolder } from "../types/media.js";
|
|
5
6
|
|
|
7
|
+
const { t } = useI18n();
|
|
6
8
|
const store = useMediaStore();
|
|
7
9
|
|
|
8
10
|
const items = computed(() => [
|
|
9
11
|
{
|
|
10
|
-
label: "
|
|
12
|
+
label: t("mapo.mediaManager.root"),
|
|
11
13
|
icon: "i-lucide-folder-open",
|
|
12
14
|
folder: null as MediaFolder | null,
|
|
13
15
|
},
|