@mapomodule/uikit 2.0.0-beta.14 → 2.0.0-beta.16
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/dist/__tests__/MapoListActions.component.test.d.ts +2 -0
- package/dist/__tests__/MapoListActions.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/module.json +1 -1
- package/dist/runtime/components/MapoDetail.vue +2 -0
- package/dist/runtime/components/MapoDetail.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoList.vue +3 -0
- package/dist/runtime/components/MapoList.vue.d.ts +5 -0
- 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/MapoSnackBar.vue +11 -0
- package/dist/runtime/components/MapoSnackBar.vue.d.ts.map +1 -1
- package/dist/runtime/page-meta.nuxt.d.ts +4 -0
- package/dist/runtime/stores/media.d.ts +1 -1
- package/package.json +5 -5
- package/src/__tests__/MapoDetail.component.test.ts +40 -3
- package/src/__tests__/MapoListActions.component.test.ts +175 -0
- package/src/__tests__/MapoSnackBar.component.test.ts +79 -0
- package/src/runtime/components/MapoDetail.vue +2 -0
- package/src/runtime/components/MapoList.vue +7 -0
- package/src/runtime/components/MapoListActions.vue +16 -4
- package/src/runtime/components/MapoSnackBar.vue +12 -0
- package/src/runtime/page-meta.nuxt.d.ts +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapoListActions.component.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/MapoListActions.component.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapoSnackBar.component.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/MapoSnackBar.component.test.ts"],"names":[],"mappings":""}
|
package/dist/module.json
CHANGED
|
@@ -566,6 +566,7 @@ defineSlots();
|
|
|
566
566
|
:current-lang="currentLang"
|
|
567
567
|
:registry="registry"
|
|
568
568
|
:readonly="effectiveReadonly"
|
|
569
|
+
:notify-errors="false"
|
|
569
570
|
>
|
|
570
571
|
<template
|
|
571
572
|
v-for="slotName in formSlotNames"
|
|
@@ -585,6 +586,7 @@ defineSlots();
|
|
|
585
586
|
:current-lang="currentLang"
|
|
586
587
|
:registry="registry"
|
|
587
588
|
:readonly="effectiveReadonly"
|
|
589
|
+
:notify-errors="false"
|
|
588
590
|
>
|
|
589
591
|
<template
|
|
590
592
|
v-for="slotName in formSlotNames"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoDetail.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoDetail.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoDetail.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoDetail.vue"],"names":[],"mappings":"AAg/BA,OAAO,EAUL,KAAK,KAAK,EAEX,MAAM,KAAK,CAAC;AAYb,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIhF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wDAAwD,CAAC;AAEvG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,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,OAA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O;uBACN,OAAO;YAClB,wEAAwE;kBAClE,CAAC,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC;YAC1C,wEAAwE;wBAC5D,MAAM,OAAO,CAAC,IAAI,CAAC;YAC/B,wEAAwE;kBAClE,MAAM,IAAI;YAsCoB,KAAK,EAAE;;;YA3kBvC,OAAO,SAAS,CAAC,GAAG,IAAI;YACxB,SAAS,GAAG,IAAI;YAMf,aAAa,SACT,CAAC,WACC,IAAI,WACJ,MAAM,IAAI,WACV,MAAM,IAAI,GAClB,IAAI;;EA2zCL,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"}
|
|
@@ -21,6 +21,7 @@ const props = defineProps({
|
|
|
21
21
|
registry: { type: Object, required: false },
|
|
22
22
|
detailBase: { type: String, required: false },
|
|
23
23
|
permissionModel: { type: String, required: false },
|
|
24
|
+
defaultActions: { type: Boolean, required: false },
|
|
24
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 },
|
|
@@ -149,6 +150,8 @@ watch([activeTab, activeFilters], () => {
|
|
|
149
150
|
:selection-query="selectionQuery"
|
|
150
151
|
:endpoint="crudEndpoint"
|
|
151
152
|
:lookup="lookup"
|
|
153
|
+
:permission-model="permissionModel"
|
|
154
|
+
:default-actions="defaultActions"
|
|
152
155
|
@action-completed="refresh"
|
|
153
156
|
/>
|
|
154
157
|
</div>
|
|
@@ -39,6 +39,11 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
39
39
|
* hides the trash unless the user has `delete_article`. Omit to always show both.
|
|
40
40
|
*/
|
|
41
41
|
permissionModel?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Whether to include the built-in permanent delete bulk action.
|
|
44
|
+
* Defaults to `true`; custom `actions` are unaffected.
|
|
45
|
+
*/
|
|
46
|
+
defaultActions?: boolean;
|
|
42
47
|
/** Initial page size: a number, or `"all"`. Default: 20. */
|
|
43
48
|
defaultPageSize?: number | "all";
|
|
44
49
|
/**
|
|
@@ -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,CAA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AAI,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"}
|
|
@@ -5,6 +5,16 @@ import { useToast } from "@nuxt/ui/composables/useToast";
|
|
|
5
5
|
const snack = useSnackStore();
|
|
6
6
|
const toast = useToast();
|
|
7
7
|
const _shown = /* @__PURE__ */ new Set();
|
|
8
|
+
function dismissEvictedMessages() {
|
|
9
|
+
const activeToastIds = new Set(
|
|
10
|
+
toast.toasts.value.map(({ id }) => String(id))
|
|
11
|
+
);
|
|
12
|
+
for (const id of _shown) {
|
|
13
|
+
if (activeToastIds.has(String(id))) continue;
|
|
14
|
+
_shown.delete(id);
|
|
15
|
+
snack.dismiss(id);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
8
18
|
watch(
|
|
9
19
|
() => snack.messages,
|
|
10
20
|
(msgs) => {
|
|
@@ -27,6 +37,7 @@ watch(
|
|
|
27
37
|
if (!open) snack.dismiss(msg.id);
|
|
28
38
|
}
|
|
29
39
|
});
|
|
40
|
+
dismissEvictedMessages();
|
|
30
41
|
}
|
|
31
42
|
},
|
|
32
43
|
{ deep: true }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoSnackBar.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoSnackBar.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoSnackBar.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoSnackBar.vue"],"names":[],"mappings":"AAiHA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -10,6 +10,8 @@ declare module "#app" {
|
|
|
10
10
|
parent?: string;
|
|
11
11
|
/** Pin this page to the sidebar footer instead of the main navigation list. */
|
|
12
12
|
sidebarFooter?: boolean;
|
|
13
|
+
/** Sort this page among siblings in the sidebar; lower values appear first. */
|
|
14
|
+
sidebarOrder?: number;
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
|
|
@@ -29,6 +31,8 @@ declare module "vue-router" {
|
|
|
29
31
|
parent?: string;
|
|
30
32
|
/** Pin this page to the sidebar footer instead of the main navigation list. */
|
|
31
33
|
sidebarFooter?: boolean;
|
|
34
|
+
/** Sort this page among siblings in the sidebar; lower values appear first. */
|
|
35
|
+
sidebarOrder?: number;
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
|
|
@@ -154,7 +154,7 @@ export declare const useMediaStore: import("pinia").StoreDefinition<"mapo-media"
|
|
|
154
154
|
setMimeType: (mime: string | null) => void;
|
|
155
155
|
lockMimeType: (mime: string | null) => void;
|
|
156
156
|
reset: () => void;
|
|
157
|
-
}, "pages" | "page" | "languages" | "loading" | "medias" | "folders" | "parentFolders" | "mimeType" | "lockedMime" | "editMedia" | "
|
|
157
|
+
}, "pages" | "page" | "languages" | "loading" | "selection" | "medias" | "folders" | "parentFolders" | "mimeType" | "lockedMime" | "editMedia" | "editList" | "selectMode">, Pick<{
|
|
158
158
|
medias: import("vue").Ref<{
|
|
159
159
|
id: number;
|
|
160
160
|
file: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapomodule/uikit",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.16",
|
|
4
4
|
"description": "Mapo UI components: Sidebar, Topbar, Login, SnackBar, ConfirmDialog, List, Detail, Media",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"lint": "eslint src"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@mapomodule/form": "2.0.0-beta.
|
|
49
|
-
"@mapomodule/i18n": "2.0.0-beta.
|
|
48
|
+
"@mapomodule/form": "2.0.0-beta.13",
|
|
49
|
+
"@mapomodule/i18n": "2.0.0-beta.5",
|
|
50
50
|
"@mapomodule/store": "2.0.0-beta.6",
|
|
51
|
-
"@mapomodule/utils": "2.0.0-beta.
|
|
52
|
-
"@mapomodule/core": "2.0.0-beta.
|
|
51
|
+
"@mapomodule/utils": "2.0.0-beta.7",
|
|
52
|
+
"@mapomodule/core": "2.0.0-beta.12",
|
|
53
53
|
"tailwindcss": "^4.0.0",
|
|
54
54
|
"vue-draggable-plus": "^0.6.0",
|
|
55
55
|
"vue-i18n": "^11.4.8"
|
|
@@ -24,6 +24,7 @@ const crud = vi.hoisted(() => ({
|
|
|
24
24
|
delete: vi.fn(),
|
|
25
25
|
}));
|
|
26
26
|
const confirm = vi.hoisted(() => ({ ask: vi.fn() }));
|
|
27
|
+
const mapoFormProps: Array<{ notifyErrors: boolean }> = [];
|
|
27
28
|
|
|
28
29
|
vi.mock("#app", () => ({
|
|
29
30
|
useRouter: () => router,
|
|
@@ -138,7 +139,18 @@ const stubs: Record<string, Component> = {
|
|
|
138
139
|
UAlert: passthrough("UAlert"),
|
|
139
140
|
UIcon: passthrough("UIcon"),
|
|
140
141
|
UModal: passthrough("UModal"),
|
|
141
|
-
MapoForm:
|
|
142
|
+
MapoForm: {
|
|
143
|
+
name: "MapoForm",
|
|
144
|
+
props: { notifyErrors: { type: Boolean, default: true } },
|
|
145
|
+
setup(props: { notifyErrors?: boolean }, { slots }: SetupContext) {
|
|
146
|
+
const formProps = { notifyErrors: props.notifyErrors ?? true };
|
|
147
|
+
mapoFormProps.push(formProps);
|
|
148
|
+
onUnmounted(() => {
|
|
149
|
+
mapoFormProps.splice(mapoFormProps.indexOf(formProps), 1);
|
|
150
|
+
});
|
|
151
|
+
return () => h("div", null, slots.default?.());
|
|
152
|
+
},
|
|
153
|
+
},
|
|
142
154
|
MapoDetailLangSwitch: passthrough("MapoDetailLangSwitch"),
|
|
143
155
|
};
|
|
144
156
|
|
|
@@ -156,10 +168,17 @@ interface ActionBindings {
|
|
|
156
168
|
|
|
157
169
|
let app: App<HeadlessNode> | undefined;
|
|
158
170
|
|
|
159
|
-
function mountDetail(
|
|
171
|
+
function mountDetail(
|
|
172
|
+
slots: Record<string, (bindings: never) => VNode[]> = {},
|
|
173
|
+
props: Record<string, unknown> = {},
|
|
174
|
+
) {
|
|
160
175
|
const root: Component = {
|
|
161
176
|
render: () =>
|
|
162
|
-
h(
|
|
177
|
+
h(
|
|
178
|
+
MapoDetail as Component,
|
|
179
|
+
{ endpoint: "/api/news/", id: 5, ...props },
|
|
180
|
+
slots,
|
|
181
|
+
),
|
|
163
182
|
};
|
|
164
183
|
app = createApp(root);
|
|
165
184
|
for (const [name, stub] of Object.entries(stubs)) app.component(name, stub);
|
|
@@ -195,6 +214,7 @@ beforeEach(() => {
|
|
|
195
214
|
crud.delete.mockResolvedValue(undefined);
|
|
196
215
|
confirm.ask.mockReset();
|
|
197
216
|
confirm.ask.mockResolvedValue(true);
|
|
217
|
+
mapoFormProps.length = 0;
|
|
198
218
|
});
|
|
199
219
|
|
|
200
220
|
afterEach(() => {
|
|
@@ -203,6 +223,23 @@ afterEach(() => {
|
|
|
203
223
|
});
|
|
204
224
|
|
|
205
225
|
describe("MapoDetail actions", () => {
|
|
226
|
+
it("shows server error toasts only from the main form when sidebar fields are present", async () => {
|
|
227
|
+
mountDetail(
|
|
228
|
+
{},
|
|
229
|
+
{
|
|
230
|
+
fields: [{ key: "title", type: "text" }],
|
|
231
|
+
sidebarFields: [{ key: "slug", type: "text" }],
|
|
232
|
+
},
|
|
233
|
+
);
|
|
234
|
+
await settle();
|
|
235
|
+
|
|
236
|
+
expect(mapoFormProps).toHaveLength(2);
|
|
237
|
+
expect(mapoFormProps.map(({ notifyErrors }) => notifyErrors)).toEqual([
|
|
238
|
+
true,
|
|
239
|
+
false,
|
|
240
|
+
]);
|
|
241
|
+
});
|
|
242
|
+
|
|
206
243
|
it("keeps the buttons busy until the page has gone back after Save", async () => {
|
|
207
244
|
mountDetail();
|
|
208
245
|
await settle();
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
createRenderer,
|
|
4
|
+
defineComponent,
|
|
5
|
+
h,
|
|
6
|
+
nextTick,
|
|
7
|
+
onMounted,
|
|
8
|
+
watchEffect,
|
|
9
|
+
} from "vue";
|
|
10
|
+
import type { App, Component } from "vue";
|
|
11
|
+
|
|
12
|
+
import MapoListActions from "../runtime/components/MapoListActions.vue";
|
|
13
|
+
import type { ActionDescriptor } from "../runtime/types/list";
|
|
14
|
+
|
|
15
|
+
const permissions = vi.hoisted(() => ({
|
|
16
|
+
canDelete: vi.fn(),
|
|
17
|
+
checkPermission: vi.fn(),
|
|
18
|
+
}));
|
|
19
|
+
const crud = vi.hoisted(() => ({ delete: vi.fn() }));
|
|
20
|
+
|
|
21
|
+
vi.mock("vue-i18n", () => ({ useI18n: () => ({ t: (key: string) => key }) }));
|
|
22
|
+
vi.mock("@mapomodule/store/runtime/stores/snack", () => ({
|
|
23
|
+
useSnackStore: () => ({ show: vi.fn() }),
|
|
24
|
+
}));
|
|
25
|
+
vi.mock("@mapomodule/store/runtime/stores/confirm", () => ({
|
|
26
|
+
useConfirmStore: () => ({ ask: vi.fn() }),
|
|
27
|
+
}));
|
|
28
|
+
vi.mock("@mapomodule/store/runtime/composables/usePermissions", () => ({
|
|
29
|
+
usePermissions: () => permissions,
|
|
30
|
+
}));
|
|
31
|
+
vi.mock("@mapomodule/core/runtime/api/crud", () => ({
|
|
32
|
+
useCrud: () => crud,
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
interface HeadlessNode {
|
|
36
|
+
parent: HeadlessNode | null;
|
|
37
|
+
children: HeadlessNode[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const headlessNode = (): HeadlessNode => ({ parent: null, children: [] });
|
|
41
|
+
|
|
42
|
+
const { createApp } = createRenderer<HeadlessNode, HeadlessNode>({
|
|
43
|
+
createElement: headlessNode,
|
|
44
|
+
createText: headlessNode,
|
|
45
|
+
createComment: headlessNode,
|
|
46
|
+
setText: () => {},
|
|
47
|
+
setElementText: () => {},
|
|
48
|
+
patchProp: () => {},
|
|
49
|
+
insert(child, parent, anchor) {
|
|
50
|
+
child.parent = parent;
|
|
51
|
+
const at = anchor ? parent.children.indexOf(anchor) : -1;
|
|
52
|
+
parent.children.splice(at < 0 ? parent.children.length : at, 0, child);
|
|
53
|
+
},
|
|
54
|
+
remove(child) {
|
|
55
|
+
child.parent?.children.splice(child.parent.children.indexOf(child), 1);
|
|
56
|
+
child.parent = null;
|
|
57
|
+
},
|
|
58
|
+
parentNode: (node) => node.parent,
|
|
59
|
+
nextSibling: (node) =>
|
|
60
|
+
node.parent?.children[node.parent.children.indexOf(node) + 1] ?? null,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
let actionItems: { label: string }[];
|
|
64
|
+
let applyDisabled: boolean;
|
|
65
|
+
|
|
66
|
+
// eslint-disable-next-line vue/one-component-per-file
|
|
67
|
+
const USelect: Component = defineComponent({
|
|
68
|
+
name: "USelect",
|
|
69
|
+
props: {
|
|
70
|
+
items: { type: Array, default: () => [] },
|
|
71
|
+
modelValue: { type: String, default: undefined },
|
|
72
|
+
},
|
|
73
|
+
emits: ["update:modelValue"],
|
|
74
|
+
setup(
|
|
75
|
+
props: { items?: { label: string }[] },
|
|
76
|
+
{ emit }: { emit: (event: "update:modelValue", value: string) => void },
|
|
77
|
+
) {
|
|
78
|
+
actionItems = props.items ?? [];
|
|
79
|
+
onMounted(() => {
|
|
80
|
+
const firstAction = props.items?.[0];
|
|
81
|
+
if (firstAction) emit("update:modelValue", firstAction.label);
|
|
82
|
+
});
|
|
83
|
+
return () => h("select");
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// eslint-disable-next-line vue/one-component-per-file -- Separate UI control stub.
|
|
88
|
+
const UButton: Component = defineComponent({
|
|
89
|
+
name: "UButton",
|
|
90
|
+
props: { disabled: Boolean },
|
|
91
|
+
setup(props: { disabled?: boolean }) {
|
|
92
|
+
watchEffect(() => {
|
|
93
|
+
applyDisabled = !!props.disabled;
|
|
94
|
+
});
|
|
95
|
+
return () => h("button");
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
function mount(props: {
|
|
100
|
+
permissionModel?: string;
|
|
101
|
+
defaultActions?: boolean;
|
|
102
|
+
actions?: ActionDescriptor<{ id: number }>[];
|
|
103
|
+
}): App<HeadlessNode> {
|
|
104
|
+
// eslint-disable-next-line vue/one-component-per-file -- Mount the generic component under test.
|
|
105
|
+
const app = createApp(MapoListActions as Component, {
|
|
106
|
+
selection: [{ id: 1 }],
|
|
107
|
+
selectionQuery: new URLSearchParams(),
|
|
108
|
+
endpoint: "/api/items/",
|
|
109
|
+
...props,
|
|
110
|
+
});
|
|
111
|
+
app.component("USelect", USelect);
|
|
112
|
+
app.component("UButton", UButton);
|
|
113
|
+
app.mount(headlessNode());
|
|
114
|
+
return app;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
describe("MapoListActions", () => {
|
|
118
|
+
beforeEach(() => {
|
|
119
|
+
permissions.canDelete.mockReset();
|
|
120
|
+
permissions.checkPermission.mockReset();
|
|
121
|
+
crud.delete.mockReset();
|
|
122
|
+
actionItems = [];
|
|
123
|
+
applyDisabled = true;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("uses the model delete permission for its built-in action", async () => {
|
|
127
|
+
permissions.canDelete.mockReturnValue(false);
|
|
128
|
+
const deniedApp = mount({ permissionModel: "article" });
|
|
129
|
+
await nextTick();
|
|
130
|
+
await nextTick();
|
|
131
|
+
|
|
132
|
+
expect(actionItems.map(({ label }) => label)).toContain(
|
|
133
|
+
"mapo.listActions.permanentDelete",
|
|
134
|
+
);
|
|
135
|
+
expect(permissions.canDelete).toHaveBeenCalledWith("article");
|
|
136
|
+
expect(applyDisabled).toBe(true);
|
|
137
|
+
|
|
138
|
+
deniedApp.unmount();
|
|
139
|
+
permissions.canDelete.mockReturnValue(true);
|
|
140
|
+
const allowedApp = mount({ permissionModel: "article" });
|
|
141
|
+
await nextTick();
|
|
142
|
+
await nextTick();
|
|
143
|
+
|
|
144
|
+
expect(applyDisabled).toBe(false);
|
|
145
|
+
allowedApp.unmount();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("preserves the built-in action when no permission model is provided", async () => {
|
|
149
|
+
const app = mount({});
|
|
150
|
+
await nextTick();
|
|
151
|
+
await nextTick();
|
|
152
|
+
|
|
153
|
+
expect(actionItems.map(({ label }) => label)).toContain(
|
|
154
|
+
"mapo.listActions.permanentDelete",
|
|
155
|
+
);
|
|
156
|
+
expect(applyDisabled).toBe(false);
|
|
157
|
+
expect(permissions.canDelete).not.toHaveBeenCalled();
|
|
158
|
+
|
|
159
|
+
app.unmount();
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("can omit the built-in action without omitting custom actions", async () => {
|
|
163
|
+
const customAction: ActionDescriptor<{ id: number }> = {
|
|
164
|
+
label: "Archive",
|
|
165
|
+
handler: async () => {},
|
|
166
|
+
};
|
|
167
|
+
const app = mount({ defaultActions: false, actions: [customAction] });
|
|
168
|
+
await nextTick();
|
|
169
|
+
await nextTick();
|
|
170
|
+
|
|
171
|
+
expect(actionItems.map(({ label }) => label)).toEqual(["Archive"]);
|
|
172
|
+
|
|
173
|
+
app.unmount();
|
|
174
|
+
});
|
|
175
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { createRenderer, nextTick, ref } from "vue";
|
|
3
|
+
import type { Component } from "vue";
|
|
4
|
+
import { createPinia, setActivePinia } from "pinia";
|
|
5
|
+
|
|
6
|
+
import MapoSnackBar from "../runtime/components/MapoSnackBar.vue";
|
|
7
|
+
import { useSnackStore } from "@mapomodule/store/runtime/stores/snack";
|
|
8
|
+
|
|
9
|
+
const toast = vi.hoisted(() => ({
|
|
10
|
+
add: vi.fn(),
|
|
11
|
+
remove: vi.fn(),
|
|
12
|
+
toasts: null as { value: { id: string }[] } | null,
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
vi.mock("@nuxt/ui/composables/useToast", () => ({
|
|
16
|
+
useToast: () => toast,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
interface HeadlessNode {
|
|
20
|
+
parent: HeadlessNode | null;
|
|
21
|
+
children: HeadlessNode[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const headlessNode = (): HeadlessNode => ({ parent: null, children: [] });
|
|
25
|
+
|
|
26
|
+
const { createApp } = createRenderer<HeadlessNode, HeadlessNode>({
|
|
27
|
+
createElement: headlessNode,
|
|
28
|
+
createText: headlessNode,
|
|
29
|
+
createComment: headlessNode,
|
|
30
|
+
setText: () => {},
|
|
31
|
+
setElementText: () => {},
|
|
32
|
+
patchProp: () => {},
|
|
33
|
+
insert(child, parent, anchor) {
|
|
34
|
+
child.parent = parent;
|
|
35
|
+
const at = anchor ? parent.children.indexOf(anchor) : -1;
|
|
36
|
+
parent.children.splice(at < 0 ? parent.children.length : at, 0, child);
|
|
37
|
+
},
|
|
38
|
+
remove(child) {
|
|
39
|
+
child.parent?.children.splice(child.parent.children.indexOf(child), 1);
|
|
40
|
+
child.parent = null;
|
|
41
|
+
},
|
|
42
|
+
parentNode: (node) => node.parent,
|
|
43
|
+
nextSibling: (node) =>
|
|
44
|
+
node.parent?.children[node.parent.children.indexOf(node) + 1] ?? null,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe("MapoSnackBar", () => {
|
|
48
|
+
it("removes store messages evicted from Nuxt UI's toast queue", async () => {
|
|
49
|
+
setActivePinia(createPinia());
|
|
50
|
+
const activeToasts = ref<{ id: string }[]>([]);
|
|
51
|
+
toast.toasts = activeToasts;
|
|
52
|
+
toast.add.mockImplementation((item: { id: string }) => {
|
|
53
|
+
activeToasts.value = [...activeToasts.value, item].slice(-5);
|
|
54
|
+
});
|
|
55
|
+
toast.remove.mockImplementation((id: string) => {
|
|
56
|
+
activeToasts.value = activeToasts.value.filter((item) => item.id !== id);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const app = createApp(MapoSnackBar as Component);
|
|
60
|
+
app.mount(headlessNode());
|
|
61
|
+
const snack = useSnackStore();
|
|
62
|
+
|
|
63
|
+
for (let index = 0; index < 8; index++) {
|
|
64
|
+
snack.show(`Message ${index}`);
|
|
65
|
+
}
|
|
66
|
+
await nextTick();
|
|
67
|
+
|
|
68
|
+
expect(snack.messages).toHaveLength(5);
|
|
69
|
+
expect(snack.messages.map(({ id }) => String(id))).toEqual(
|
|
70
|
+
activeToasts.value.map(({ id }) => id),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
snack.dismissAll();
|
|
74
|
+
await nextTick();
|
|
75
|
+
|
|
76
|
+
expect(activeToasts.value).toEqual([]);
|
|
77
|
+
app.unmount();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -905,6 +905,7 @@ defineSlots<{
|
|
|
905
905
|
:current-lang="currentLang"
|
|
906
906
|
:registry="registry"
|
|
907
907
|
:readonly="effectiveReadonly"
|
|
908
|
+
:notify-errors="false"
|
|
908
909
|
>
|
|
909
910
|
<template
|
|
910
911
|
v-for="slotName in formSlotNames"
|
|
@@ -924,6 +925,7 @@ defineSlots<{
|
|
|
924
925
|
:current-lang="currentLang"
|
|
925
926
|
:registry="registry"
|
|
926
927
|
:readonly="effectiveReadonly"
|
|
928
|
+
:notify-errors="false"
|
|
927
929
|
>
|
|
928
930
|
<template
|
|
929
931
|
v-for="slotName in formSlotNames"
|
|
@@ -57,6 +57,11 @@ const props = withDefaults(
|
|
|
57
57
|
* hides the trash unless the user has `delete_article`. Omit to always show both.
|
|
58
58
|
*/
|
|
59
59
|
permissionModel?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Whether to include the built-in permanent delete bulk action.
|
|
62
|
+
* Defaults to `true`; custom `actions` are unaffected.
|
|
63
|
+
*/
|
|
64
|
+
defaultActions?: boolean;
|
|
60
65
|
// Pagination
|
|
61
66
|
/** Initial page size: a number, or `"all"`. Default: 20. */
|
|
62
67
|
defaultPageSize?: number | "all";
|
|
@@ -304,6 +309,8 @@ watch([activeTab, activeFilters], () => {
|
|
|
304
309
|
:selection-query="selectionQuery"
|
|
305
310
|
:endpoint="crudEndpoint"
|
|
306
311
|
:lookup="lookup"
|
|
312
|
+
:permission-model="permissionModel"
|
|
313
|
+
:default-actions="defaultActions"
|
|
307
314
|
@action-completed="refresh"
|
|
308
315
|
/>
|
|
309
316
|
</div>
|
|
@@ -15,10 +15,16 @@ const props = withDefaults(
|
|
|
15
15
|
selectionQuery: URLSearchParams;
|
|
16
16
|
endpoint: string;
|
|
17
17
|
lookup?: string;
|
|
18
|
+
/** Django model label used to gate the built-in permanent delete action. */
|
|
19
|
+
permissionModel?: string;
|
|
20
|
+
/** Whether to include the built-in permanent delete action. */
|
|
21
|
+
defaultActions?: boolean;
|
|
18
22
|
}>(),
|
|
19
23
|
{
|
|
20
24
|
actions: () => [],
|
|
21
25
|
lookup: "id",
|
|
26
|
+
permissionModel: undefined,
|
|
27
|
+
defaultActions: true,
|
|
22
28
|
},
|
|
23
29
|
);
|
|
24
30
|
|
|
@@ -34,11 +40,12 @@ defineSlots<{
|
|
|
34
40
|
const { t } = useI18n();
|
|
35
41
|
const snack = useSnackStore();
|
|
36
42
|
const confirm = useConfirmStore();
|
|
43
|
+
const { canDelete, checkPermission } = usePermissions();
|
|
37
44
|
const crud = useCrud<T>(props.endpoint);
|
|
38
45
|
|
|
39
46
|
const isRunning = ref(false);
|
|
40
47
|
|
|
41
|
-
const
|
|
48
|
+
const builtInActions = computed<ActionDescriptor<T>[]>(() => [
|
|
42
49
|
{
|
|
43
50
|
label: t("mapo.listActions.permanentDelete"),
|
|
44
51
|
handler: async ({ selection }) => {
|
|
@@ -51,13 +58,15 @@ const defaultActions = computed<ActionDescriptor<T>[]>(() => [
|
|
|
51
58
|
),
|
|
52
59
|
);
|
|
53
60
|
},
|
|
54
|
-
permissions: "delete",
|
|
55
61
|
handleMultiple: true,
|
|
56
62
|
handleAll: false,
|
|
57
63
|
},
|
|
58
64
|
]);
|
|
59
65
|
|
|
60
|
-
const allActions = computed(() => [
|
|
66
|
+
const allActions = computed(() => [
|
|
67
|
+
...(props.defaultActions ? builtInActions.value : []),
|
|
68
|
+
...props.actions,
|
|
69
|
+
]);
|
|
61
70
|
|
|
62
71
|
const visibleActions = computed(() =>
|
|
63
72
|
allActions.value.filter((a) =>
|
|
@@ -80,13 +89,16 @@ const applyButtonColor = computed(() =>
|
|
|
80
89
|
);
|
|
81
90
|
|
|
82
91
|
function canRun(action: ActionDescriptor<T>): boolean {
|
|
92
|
+
if (builtInActions.value.includes(action)) {
|
|
93
|
+
return !props.permissionModel || canDelete(props.permissionModel);
|
|
94
|
+
}
|
|
95
|
+
|
|
83
96
|
const perms = action.permissions
|
|
84
97
|
? Array.isArray(action.permissions)
|
|
85
98
|
? action.permissions
|
|
86
99
|
: [action.permissions]
|
|
87
100
|
: [];
|
|
88
101
|
if (!perms.length) return true;
|
|
89
|
-
const { checkPermission } = usePermissions();
|
|
90
102
|
return perms.every((p) => checkPermission(p));
|
|
91
103
|
}
|
|
92
104
|
|
|
@@ -8,6 +8,17 @@ const toast = useToast();
|
|
|
8
8
|
|
|
9
9
|
const _shown = new Set<number>();
|
|
10
10
|
|
|
11
|
+
function dismissEvictedMessages() {
|
|
12
|
+
const activeToastIds = new Set(
|
|
13
|
+
toast.toasts.value.map(({ id }) => String(id)),
|
|
14
|
+
);
|
|
15
|
+
for (const id of _shown) {
|
|
16
|
+
if (activeToastIds.has(String(id))) continue;
|
|
17
|
+
_shown.delete(id);
|
|
18
|
+
snack.dismiss(id);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
11
22
|
watch(
|
|
12
23
|
() => snack.messages,
|
|
13
24
|
(msgs) => {
|
|
@@ -30,6 +41,7 @@ watch(
|
|
|
30
41
|
if (!open) snack.dismiss(msg.id);
|
|
31
42
|
},
|
|
32
43
|
});
|
|
44
|
+
dismissEvictedMessages();
|
|
33
45
|
}
|
|
34
46
|
},
|
|
35
47
|
{ deep: true },
|
|
@@ -10,6 +10,8 @@ declare module "#app" {
|
|
|
10
10
|
parent?: string;
|
|
11
11
|
/** Pin this page to the sidebar footer instead of the main navigation list. */
|
|
12
12
|
sidebarFooter?: boolean;
|
|
13
|
+
/** Sort this page among siblings in the sidebar; lower values appear first. */
|
|
14
|
+
sidebarOrder?: number;
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
|
|
@@ -29,6 +31,8 @@ declare module "vue-router" {
|
|
|
29
31
|
parent?: string;
|
|
30
32
|
/** Pin this page to the sidebar footer instead of the main navigation list. */
|
|
31
33
|
sidebarFooter?: boolean;
|
|
34
|
+
/** Sort this page among siblings in the sidebar; lower values appear first. */
|
|
35
|
+
sidebarOrder?: number;
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
|