@mapomodule/uikit 2.0.0-beta.13 → 2.0.0-beta.14
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 -184
- 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__/MapoListTable.component.test.d.ts +2 -0
- package/dist/__tests__/MapoListTable.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__/listTable.test.d.ts +2 -0
- package/dist/__tests__/listTable.test.d.ts.map +1 -0
- package/dist/module.json +1 -1
- 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 +43 -11
- package/dist/runtime/components/MapoDetail.vue.d.ts +76 -0
- package/dist/runtime/components/MapoDetail.vue.d.ts.map +1 -1
- 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/MapoList.vue +3 -2
- package/dist/runtime/components/MapoList.vue.d.ts +9 -4
- package/dist/runtime/components/MapoList.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoListTable.vue +98 -32
- 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/MapoMediaPreview.vue.d.ts +1 -1
- package/dist/runtime/components/MapoMediaPreview.vue.d.ts.map +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.d.ts +1 -1
- 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/stores/media.d.ts +2 -2
- package/dist/runtime/types/list.d.ts +10 -2
- package/dist/runtime/types/list.d.ts.map +1 -1
- 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 +6 -6
- package/src/__tests__/MapoConfirmDialog.component.test.ts +165 -0
- package/src/__tests__/MapoDetail.component.test.ts +293 -0
- package/src/__tests__/MapoDetailLangSwitch.component.test.ts +145 -0
- package/src/__tests__/MapoListTable.component.test.ts +504 -0
- package/src/__tests__/__mocks__/nuxt-app.ts +8 -0
- package/src/__tests__/listTable.test.ts +82 -0
- package/src/runtime/assets/main.css +9 -0
- package/src/runtime/components/MapoConfirmDialog.vue +28 -1
- package/src/runtime/components/MapoDetail.vue +78 -11
- package/src/runtime/components/MapoDetailLangSwitch.vue +26 -27
- package/src/runtime/components/MapoList.vue +13 -5
- package/src/runtime/components/MapoListTable.vue +128 -41
- package/src/runtime/components/MapoMediaUploader.vue +25 -21
- package/src/runtime/types/list.ts +10 -2
- package/src/runtime/utils/listTable.ts +54 -0
|
@@ -55,6 +55,15 @@ const pendingCount = computed(
|
|
|
55
55
|
() => entries.value.filter((e) => e.status === "pending").length,
|
|
56
56
|
);
|
|
57
57
|
|
|
58
|
+
// The text metadata of a pending file, labelled like MapoMediaEditor's fields.
|
|
59
|
+
// Labels, not placeholders: title and alt text start from the file name, so a
|
|
60
|
+
// placeholder would never show what they are.
|
|
61
|
+
const textFields = computed(() => [
|
|
62
|
+
{ key: "title" as const, label: t("mapo.title") },
|
|
63
|
+
{ key: "alt_text" as const, label: t("mapo.altTag") },
|
|
64
|
+
{ key: "description" as const, label: t("mapo.description") },
|
|
65
|
+
]);
|
|
66
|
+
|
|
58
67
|
// Destination options: the current folder plus its subfolders (legacy parity).
|
|
59
68
|
const folderOptions = computed(() => [
|
|
60
69
|
{
|
|
@@ -260,32 +269,27 @@ onUnmounted(clearAll);
|
|
|
260
269
|
</span>
|
|
261
270
|
</div>
|
|
262
271
|
|
|
263
|
-
<!-- Metadata inputs (only for pending)
|
|
272
|
+
<!-- Metadata inputs (only for pending). The inputs take their
|
|
273
|
+
size from UFormField. -->
|
|
264
274
|
<div
|
|
265
275
|
v-if="entry.status === 'pending'"
|
|
266
276
|
class="grid grid-cols-2 gap-1.5"
|
|
267
277
|
>
|
|
268
|
-
<
|
|
269
|
-
v-
|
|
270
|
-
|
|
271
|
-
:
|
|
272
|
-
/>
|
|
273
|
-
<UInput
|
|
274
|
-
v-model="entry.alt_text"
|
|
275
|
-
size="xs"
|
|
276
|
-
:placeholder="t('mapo.altTag')"
|
|
277
|
-
/>
|
|
278
|
-
<UInput
|
|
279
|
-
v-model="entry.description"
|
|
280
|
-
size="xs"
|
|
281
|
-
:placeholder="t('mapo.description')"
|
|
282
|
-
/>
|
|
283
|
-
<USelect
|
|
284
|
-
v-model="entry.folder"
|
|
285
|
-
:items="folderOptions"
|
|
278
|
+
<UFormField
|
|
279
|
+
v-for="field in textFields"
|
|
280
|
+
:key="field.key"
|
|
281
|
+
:label="field.label"
|
|
286
282
|
size="xs"
|
|
287
|
-
|
|
288
|
-
|
|
283
|
+
>
|
|
284
|
+
<UInput v-model="entry[field.key]" class="w-full" />
|
|
285
|
+
</UFormField>
|
|
286
|
+
<UFormField :label="t('mapo.folder')" size="xs">
|
|
287
|
+
<USelect
|
|
288
|
+
v-model="entry.folder"
|
|
289
|
+
:items="folderOptions"
|
|
290
|
+
class="w-full"
|
|
291
|
+
/>
|
|
292
|
+
</UFormField>
|
|
289
293
|
</div>
|
|
290
294
|
|
|
291
295
|
<!-- Progress bar -->
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
/** Defines a single column in the list table. */
|
|
2
2
|
export interface ListColumn<T = Record<string, unknown>> {
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Property of the row to show, a key of `T`. A dotted path (`category.name`)
|
|
5
|
+
* reads a field of a related object; it starts with a key of `T`.
|
|
6
|
+
*/
|
|
7
|
+
key: (keyof T & string) | `${keyof T & string}.${string}`;
|
|
5
8
|
label: string;
|
|
9
|
+
/**
|
|
10
|
+
* Turns the header into a button that cycles ascending, descending and
|
|
11
|
+
* unsorted. The list sends the order to the backend as `ordering`, or sorts
|
|
12
|
+
* in memory in offline and hybrid mode.
|
|
13
|
+
*/
|
|
6
14
|
sortable?: boolean;
|
|
7
15
|
/** CSS class applied to the `<td>` cell. */
|
|
8
16
|
class?: string;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** One sort key as `UTable` holds it: the column id and the direction. */
|
|
2
|
+
export interface TableSort {
|
|
3
|
+
id: string;
|
|
4
|
+
desc: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The page size that stands for "all rows". A plain number, so the paging
|
|
9
|
+
* arithmetic and the in-memory slicing keep working unchanged.
|
|
10
|
+
*/
|
|
11
|
+
export const ALL_ROWS = Number.MAX_SAFE_INTEGER;
|
|
12
|
+
|
|
13
|
+
/** A `pageSizeOptions` entry as the table stores it: `"all"` → {@link ALL_ROWS}. */
|
|
14
|
+
export function toPageSize(option: number | "all"): number {
|
|
15
|
+
return option === "all" ? ALL_ROWS : option;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Reads `page_size` from the URL: `all`, or a positive number, else `fallback`. */
|
|
19
|
+
export function parsePageSize(value: unknown, fallback: number): number {
|
|
20
|
+
if (value === "all") return ALL_ROWS;
|
|
21
|
+
const size = Number(value);
|
|
22
|
+
return Number.isFinite(size) && size > 0 ? size : fallback;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Writes a page size to the URL: {@link ALL_ROWS} as `all`. */
|
|
26
|
+
export function formatPageSize(size: number): string {
|
|
27
|
+
return size === ALL_ROWS ? "all" : String(size);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The sorting after a click on a sortable header. The column goes from
|
|
32
|
+
* unsorted to ascending, to descending, and back to unsorted, so the natural
|
|
33
|
+
* order (needed by drag reorder) is one click away. It replaces any other key.
|
|
34
|
+
*/
|
|
35
|
+
export function nextSorting(
|
|
36
|
+
sorting: TableSort[],
|
|
37
|
+
columnId: string,
|
|
38
|
+
): TableSort[] {
|
|
39
|
+
const current = sorting.find((sort) => sort.id === columnId);
|
|
40
|
+
if (!current) return [{ id: columnId, desc: false }];
|
|
41
|
+
if (!current.desc) return [{ id: columnId, desc: true }];
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The `ordering` param for a sorting: comma-separated keys, `-` for descending.
|
|
47
|
+
* A dotted key becomes a Django lookup (`category.name` → `category__name`),
|
|
48
|
+
* the way DRF's OrderingFilter reaches a field of a related object.
|
|
49
|
+
*/
|
|
50
|
+
export function orderingParam(sorting: TableSort[]): string {
|
|
51
|
+
return sorting
|
|
52
|
+
.map((sort) => `${sort.desc ? "-" : ""}${sort.id.split(".").join("__")}`)
|
|
53
|
+
.join(",");
|
|
54
|
+
}
|