@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
package/dist/module.mjs
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { readFileSync, existsSync } from 'node:fs';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
|
-
import { defineNuxtModule, createResolver, addTypeTemplate, addComponent, addLayout, extendPages } from '@nuxt/kit';
|
|
3
|
+
import { defineNuxtModule, createResolver, hasNuxtModule, installModule, addTypeTemplate, addComponent, addLayout, addPlugin, addImports, extendPages } from '@nuxt/kit';
|
|
4
4
|
|
|
5
|
+
const MAPO_MEDIA_DEFAULTS = {
|
|
6
|
+
endpoints: {
|
|
7
|
+
media: "/api/media",
|
|
8
|
+
folders: "/api/media-folders"
|
|
9
|
+
},
|
|
10
|
+
maxImageSize: 10,
|
|
11
|
+
maxVideoSize: 100,
|
|
12
|
+
maxDefaultSize: 10,
|
|
13
|
+
permissionsModel: "media"
|
|
14
|
+
};
|
|
5
15
|
const module$1 = defineNuxtModule({
|
|
6
16
|
meta: {
|
|
7
17
|
name: "@mapomodule/uikit",
|
|
@@ -18,6 +28,14 @@ const module$1 = defineNuxtModule({
|
|
|
18
28
|
},
|
|
19
29
|
async setup(options, nuxt) {
|
|
20
30
|
const resolver = createResolver(import.meta.url);
|
|
31
|
+
nuxt.options.build.transpile.push(resolver.resolve("./runtime"));
|
|
32
|
+
nuxt.options.imports.transform ??= {};
|
|
33
|
+
(nuxt.options.imports.transform.include ??= []).push(
|
|
34
|
+
/@mapomodule[\\/]uikit[\\/]/
|
|
35
|
+
);
|
|
36
|
+
if (!hasNuxtModule("@mapomodule/i18n")) {
|
|
37
|
+
await installModule(await resolver.resolvePath("@mapomodule/i18n"));
|
|
38
|
+
}
|
|
21
39
|
addTypeTemplate({
|
|
22
40
|
filename: "types/mapo-uikit-page-meta.d.ts",
|
|
23
41
|
getContents: () => readFileSync(
|
|
@@ -36,7 +54,22 @@ const module$1 = defineNuxtModule({
|
|
|
36
54
|
if (options.ui && Object.keys(options.ui).length) {
|
|
37
55
|
nuxt.options.ui = { ...options.ui, ...nuxt.options.ui ?? {} };
|
|
38
56
|
}
|
|
57
|
+
nuxt.options.runtimeConfig.public.mapoUikit = {
|
|
58
|
+
contentLanguages: options.contentLanguages ?? []
|
|
59
|
+
};
|
|
60
|
+
const media = options.media ?? {};
|
|
61
|
+
nuxt.options.runtimeConfig.public.mapoMedia = {
|
|
62
|
+
endpoints: {
|
|
63
|
+
media: media.endpoints?.media ?? MAPO_MEDIA_DEFAULTS.endpoints.media,
|
|
64
|
+
folders: media.endpoints?.folders ?? MAPO_MEDIA_DEFAULTS.endpoints.folders
|
|
65
|
+
},
|
|
66
|
+
maxImageSize: media.maxImageSize ?? MAPO_MEDIA_DEFAULTS.maxImageSize,
|
|
67
|
+
maxVideoSize: media.maxVideoSize ?? MAPO_MEDIA_DEFAULTS.maxVideoSize,
|
|
68
|
+
maxDefaultSize: media.maxDefaultSize ?? MAPO_MEDIA_DEFAULTS.maxDefaultSize,
|
|
69
|
+
permissionsModel: media.permissionsModel ?? MAPO_MEDIA_DEFAULTS.permissionsModel
|
|
70
|
+
};
|
|
39
71
|
const components = [
|
|
72
|
+
// ─── Shell / Layout ───────────────────────────────────────────────────
|
|
40
73
|
"MapoSnackBar",
|
|
41
74
|
"MapoConfirmDialog",
|
|
42
75
|
"MapoLogin",
|
|
@@ -47,6 +80,9 @@ const module$1 = defineNuxtModule({
|
|
|
47
80
|
"MapoLogoutButton",
|
|
48
81
|
"MapoSidebarProfile",
|
|
49
82
|
"MapoTopbar",
|
|
83
|
+
"MapoLangSwitcher",
|
|
84
|
+
"MapoThemeToggle",
|
|
85
|
+
// ─── CRUD / Detail / List ─────────────────────────────────────────────
|
|
50
86
|
"MapoDetail",
|
|
51
87
|
"MapoDetailLangSwitch",
|
|
52
88
|
"MapoList",
|
|
@@ -55,7 +91,23 @@ const module$1 = defineNuxtModule({
|
|
|
55
91
|
"MapoListFilters",
|
|
56
92
|
"MapoListActions",
|
|
57
93
|
"MapoListQuickEdit",
|
|
58
|
-
"MapoListTable"
|
|
94
|
+
"MapoListTable",
|
|
95
|
+
// ─── Media ───────────────────────────────────────────────────────────
|
|
96
|
+
"MapoDropArea",
|
|
97
|
+
"MapoMediaBreadcrumbs",
|
|
98
|
+
"MapoMediaFolders",
|
|
99
|
+
"MapoMediaFolderPicker",
|
|
100
|
+
"MapoMediaGallery",
|
|
101
|
+
"MapoMediaFileChanger",
|
|
102
|
+
"MapoMediaEditor",
|
|
103
|
+
"MapoMediaUploader",
|
|
104
|
+
"MapoMediaManager",
|
|
105
|
+
"MapoMediaManagerDialog",
|
|
106
|
+
// ─── Menu Manager ─────────────────────────────────────────────────────
|
|
107
|
+
"MapoMenuTreeviewNode",
|
|
108
|
+
"MapoMenuTreeview",
|
|
109
|
+
"MapoMenuNodeEditor",
|
|
110
|
+
"MapoMenuManager"
|
|
59
111
|
];
|
|
60
112
|
for (const name of components) {
|
|
61
113
|
addComponent({
|
|
@@ -63,6 +115,13 @@ const module$1 = defineNuxtModule({
|
|
|
63
115
|
filePath: resolver.resolve(`./runtime/components/${name}.vue`)
|
|
64
116
|
});
|
|
65
117
|
}
|
|
118
|
+
for (const name of ["MapoMediaManagerDialog", "MapoMediaPreview"]) {
|
|
119
|
+
addComponent({
|
|
120
|
+
name,
|
|
121
|
+
global: true,
|
|
122
|
+
filePath: resolver.resolve(`./runtime/components/${name}.vue`)
|
|
123
|
+
});
|
|
124
|
+
}
|
|
66
125
|
addLayout(
|
|
67
126
|
{ src: resolver.resolve("./runtime/layouts/default.vue") },
|
|
68
127
|
"mapo-default"
|
|
@@ -80,6 +139,16 @@ const module$1 = defineNuxtModule({
|
|
|
80
139
|
/* @__PURE__ */ new Set([...existing, "lucide"])
|
|
81
140
|
);
|
|
82
141
|
});
|
|
142
|
+
addPlugin({
|
|
143
|
+
src: resolver.resolve("./runtime/plugins/media-adapter"),
|
|
144
|
+
order: 5
|
|
145
|
+
});
|
|
146
|
+
addImports([
|
|
147
|
+
{
|
|
148
|
+
name: "useMediaStore",
|
|
149
|
+
from: resolver.resolve("./runtime/stores/media")
|
|
150
|
+
}
|
|
151
|
+
]);
|
|
83
152
|
nuxt.hook("components:extend", (components2) => {
|
|
84
153
|
const overrideDir = resolve(nuxt.options.srcDir, "mapooverride");
|
|
85
154
|
if (!existsSync(overrideDir)) return;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MediaAdapter } from "../types/media.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default media adapter — plain REST semantics.
|
|
4
|
+
*
|
|
5
|
+
* - List/detail params: passes `page`, `search`, `all`, and `mime` as-is.
|
|
6
|
+
* - Response: assumes the backend already returns the canonical
|
|
7
|
+
* `{ media: { items, paginator }, folders, parent_folder }` shape.
|
|
8
|
+
* - Detail params: passes `language_code` when a language is active.
|
|
9
|
+
* - Metadata PATCH: only the edited fields when the pre-edit copy is known.
|
|
10
|
+
*
|
|
11
|
+
* Integrations override any subset of these via their own `$mapoMediaAdapter`
|
|
12
|
+
* plugin (see `@mapomodule/mapo-integrations-camomilla`).
|
|
13
|
+
*/
|
|
14
|
+
export declare const defaultMediaAdapter: Required<MediaAdapter>;
|
|
15
|
+
//# sourceMappingURL=defaultMediaAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultMediaAdapter.d.ts","sourceRoot":"","sources":["../../../src/runtime/adapters/defaultMediaAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAKb,MAAM,mBAAmB,CAAC;AAG3B;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,YAAY,CA6CtD,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { mediaMetadataPatch } from "../utils/mediaMetadata.js";
|
|
2
|
+
export const defaultMediaAdapter = {
|
|
3
|
+
buildListParams(ctx) {
|
|
4
|
+
const params = {};
|
|
5
|
+
if (ctx.page != null) params.page = ctx.page;
|
|
6
|
+
if (ctx.search) params.search = ctx.search;
|
|
7
|
+
if (ctx.all) params.all = true;
|
|
8
|
+
if (ctx.mime) params.mime = ctx.mime;
|
|
9
|
+
return params;
|
|
10
|
+
},
|
|
11
|
+
parseRootResponse(raw) {
|
|
12
|
+
return raw;
|
|
13
|
+
},
|
|
14
|
+
buildDetailParams(ctx) {
|
|
15
|
+
return ctx.lang ? { language_code: ctx.lang } : {};
|
|
16
|
+
},
|
|
17
|
+
buildFolderPayload(folder) {
|
|
18
|
+
return { ...folder };
|
|
19
|
+
},
|
|
20
|
+
buildMediaPatchPayload(media, previous) {
|
|
21
|
+
if (previous) return mediaMetadataPatch(media, previous);
|
|
22
|
+
return {
|
|
23
|
+
title: media.title,
|
|
24
|
+
alt_text: media.alt_text,
|
|
25
|
+
description: media.description,
|
|
26
|
+
translations: media.translations
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
buildMoveMediaPayload(folderId) {
|
|
30
|
+
return { folder: folderId };
|
|
31
|
+
},
|
|
32
|
+
buildReplaceFilePayload(file, maintainUrl) {
|
|
33
|
+
return { file, maintain_url: maintainUrl };
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@import "tailwindcss";@import "@nuxt/ui";@source "../components/**/*.vue";@source "../layouts/**/*.vue";@source "../pages/**/*.vue";@source "../../../../form/src/runtime/components/**/*.vue";@source "../../../../form/src/runtime/composables/**/*.ts";@source inline("col-span-1 col-span-2 col-span-3 col-span-4 col-span-5 col-span-6 col-span-7 col-span-8 col-span-9 col-span-10 col-span-11 col-span-12");@source inline("md:col-span-1 md:col-span-2 md:col-span-3 md:col-span-4 md:col-span-5 md:col-span-6 md:col-span-7 md:col-span-8 md:col-span-9 md:col-span-10 md:col-span-11 md:col-span-12");@source inline("grid-cols-12");@source inline("flex-1 min-h-0 h-full");.mapo-group-expand-body,.mapo-group-expand-body .mapo-form-field,.mapo-group-expand-body .mapo-form-field>div,.mapo-group-expand-body>*{flex:1;min-height:0}.mapo-group-expand-body [contenteditable],.mapo-group-expand-body textarea{height:100%!important;overflow-y:auto!important;resize:none!important}.mapo-group-expand-body .mapo-form-field>div>*{height:100%}@layer base{body,html{height:100%}:root{--mapo-topbar-height:56px}#__nuxt,#__nuxt>*{height:100%}}
|
|
1
|
+
@import "tailwindcss";@import "@nuxt/ui";@source "../components/**/*.vue";@source "../layouts/**/*.vue";@source "../pages/**/*.vue";@source "../../../../form/src/runtime/components/**/*.vue";@source "../../../../form/src/runtime/composables/**/*.ts";@source inline("col-span-1 col-span-2 col-span-3 col-span-4 col-span-5 col-span-6 col-span-7 col-span-8 col-span-9 col-span-10 col-span-11 col-span-12");@source inline("md:col-span-1 md:col-span-2 md:col-span-3 md:col-span-4 md:col-span-5 md:col-span-6 md:col-span-7 md:col-span-8 md:col-span-9 md:col-span-10 md:col-span-11 md:col-span-12");@source inline("grid-cols-12");@source inline("flex-1 min-h-0 h-full");.mapo-group-expand-body,.mapo-group-expand-body .mapo-form-field,.mapo-group-expand-body .mapo-form-field>div,.mapo-group-expand-body>*{flex:1;min-height:0}.mapo-group-expand-body [contenteditable],.mapo-group-expand-body textarea{height:100%!important;overflow-y:auto!important;resize:none!important}.mapo-group-expand-body .mapo-form-field>div>*{height:100%}@layer base{body,html{height:100%}:root{--mapo-topbar-height:56px}#__nuxt,#__nuxt>*{height:100%}[role=button]:not(:disabled),button:not(:disabled){cursor:pointer}}
|
|
@@ -1,15 +1,34 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { ref, watch } from "vue";
|
|
3
|
+
import { useI18n } from "vue-i18n";
|
|
2
4
|
import { useConfirmStore } from "@mapomodule/store/runtime/stores/confirm";
|
|
5
|
+
const { t } = useI18n();
|
|
3
6
|
const store = useConfirmStore();
|
|
7
|
+
const modalMounted = ref(store.active);
|
|
8
|
+
watch(
|
|
9
|
+
() => store.active,
|
|
10
|
+
(active) => {
|
|
11
|
+
if (active) modalMounted.value = true;
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
function onAfterLeave() {
|
|
15
|
+
if (store.active) return;
|
|
16
|
+
modalMounted.value = false;
|
|
17
|
+
}
|
|
4
18
|
</script>
|
|
5
19
|
|
|
6
20
|
<template>
|
|
7
|
-
<UModal
|
|
21
|
+
<UModal
|
|
22
|
+
v-if="modalMounted"
|
|
23
|
+
v-model:open="store.active"
|
|
24
|
+
:dismissible="false"
|
|
25
|
+
@after:leave="onAfterLeave"
|
|
26
|
+
>
|
|
8
27
|
<template #content>
|
|
9
28
|
<div class="p-6 space-y-4">
|
|
10
29
|
<div class="space-y-1">
|
|
11
30
|
<h3 class="text-base font-semibold text-highlighted">
|
|
12
|
-
{{ store.options?.title ?? "
|
|
31
|
+
{{ store.options?.title ?? t("mapo.confirm") }}
|
|
13
32
|
</h3>
|
|
14
33
|
<p class="text-sm text-muted">
|
|
15
34
|
{{ store.options?.message }}
|
|
@@ -18,13 +37,13 @@ const store = useConfirmStore();
|
|
|
18
37
|
|
|
19
38
|
<div class="flex justify-end gap-3">
|
|
20
39
|
<UButton variant="ghost" color="neutral" @click="store.cancel()">
|
|
21
|
-
{{ store.options?.cancelText ?? "
|
|
40
|
+
{{ store.options?.cancelText ?? t("mapo.cancel") }}
|
|
22
41
|
</UButton>
|
|
23
42
|
<UButton
|
|
24
43
|
:color="store.options?.dangerous ? 'error' : 'primary'"
|
|
25
44
|
@click="store.confirm()"
|
|
26
45
|
>
|
|
27
|
-
{{ store.options?.confirmText ?? "
|
|
46
|
+
{{ store.options?.confirmText ?? t("mapo.confirm") }}
|
|
28
47
|
</UButton>
|
|
29
48
|
</div>
|
|
30
49
|
</div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoConfirmDialog.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoConfirmDialog.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoConfirmDialog.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoConfirmDialog.vue"],"names":[],"mappings":"AAyOA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -7,27 +7,39 @@ import {
|
|
|
7
7
|
useSlots,
|
|
8
8
|
onMounted,
|
|
9
9
|
onBeforeUnmount,
|
|
10
|
-
provide
|
|
10
|
+
provide,
|
|
11
|
+
shallowRef
|
|
11
12
|
} from "vue";
|
|
12
|
-
import { useRouter, onBeforeRouteLeave } from "
|
|
13
|
-
import {
|
|
13
|
+
import { useRouter, onBeforeRouteLeave, useNuxtApp } from "#app";
|
|
14
|
+
import { useI18n } from "vue-i18n";
|
|
14
15
|
import { objectDiff, debounce, deepClone } from "@mapomodule/utils";
|
|
15
16
|
import { useCrud } from "@mapomodule/core/runtime/api/crud";
|
|
17
|
+
import {
|
|
18
|
+
getErrorData,
|
|
19
|
+
getErrorDetail,
|
|
20
|
+
getErrorStatus
|
|
21
|
+
} from "@mapomodule/core/runtime/utils/fetchError";
|
|
16
22
|
import { useSnackStore } from "@mapomodule/store/runtime/stores/snack";
|
|
17
23
|
import { useConfirmStore } from "@mapomodule/store/runtime/stores/confirm";
|
|
18
24
|
import { usePermissions } from "@mapomodule/store/runtime/composables/usePermissions";
|
|
25
|
+
import { languagesFromMetadata, restrictLanguages } from "../utils/langInfo";
|
|
26
|
+
import { useContentLanguages } from "../utils/contentLanguages";
|
|
27
|
+
import { useFormFromSchema } from "@mapomodule/form/runtime/composables/useFormFromSchema";
|
|
19
28
|
const props = defineProps({
|
|
20
29
|
endpoint: { type: String, required: true },
|
|
21
30
|
id: { type: [String, Number], required: true },
|
|
22
|
-
fields: { type: Array, required:
|
|
31
|
+
fields: { type: Array, required: false, default: void 0 },
|
|
32
|
+
experimentalFieldsFromSchema: { type: Boolean, required: false, default: false },
|
|
33
|
+
schemaFieldOptions: { type: Object, required: false, default: void 0 },
|
|
23
34
|
sidebarFields: { type: Array, required: false, default: () => [] },
|
|
24
35
|
languages: { type: Array, required: false, default: () => [] },
|
|
36
|
+
langThreshold: { type: Number, required: false, default: void 0 },
|
|
25
37
|
modelName: { type: [String, null], required: false, default: null },
|
|
26
38
|
sidebarCols: { type: Number, required: false, default: 4 },
|
|
27
39
|
sticky: { type: Boolean, required: false, default: true },
|
|
28
40
|
usePatch: { type: Boolean, required: false, default: true },
|
|
29
41
|
readonly: { type: Boolean, required: false, default: false },
|
|
30
|
-
registry: { type: null, required: false, default: null },
|
|
42
|
+
registry: { type: [Object, null], required: false, default: null },
|
|
31
43
|
draft: { type: Boolean, required: false, default: false },
|
|
32
44
|
draftKey: { type: String, required: false, default: void 0 },
|
|
33
45
|
multipart: { type: null, required: false, default: "auto" },
|
|
@@ -38,6 +50,7 @@ const props = defineProps({
|
|
|
38
50
|
const emit = defineEmits(["saved", "deleted", "draft-found"]);
|
|
39
51
|
const { $mapoFormRegistry } = useNuxtApp();
|
|
40
52
|
const registry = computed(() => props.registry ?? $mapoFormRegistry);
|
|
53
|
+
const { t } = useI18n();
|
|
41
54
|
const router = useRouter();
|
|
42
55
|
const snack = useSnackStore();
|
|
43
56
|
const confirm = useConfirmStore();
|
|
@@ -58,24 +71,33 @@ function recordId() {
|
|
|
58
71
|
const backup = ref(null);
|
|
59
72
|
const errors = ref({});
|
|
60
73
|
const isLoading = ref(String(props.id) !== "new");
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
74
|
+
const pendingAction = ref(null);
|
|
75
|
+
const isBusy = computed(() => pendingAction.value !== null);
|
|
76
|
+
const isSaving = computed(() => {
|
|
77
|
+
const savingAndLeaving = pendingAction.value === "save";
|
|
78
|
+
const savingAndStaying = pendingAction.value === "saveContinue";
|
|
79
|
+
return savingAndLeaving || savingAndStaying;
|
|
80
|
+
});
|
|
81
|
+
const isDeleting = computed(() => pendingAction.value === "delete");
|
|
82
|
+
const currentLang = ref("");
|
|
64
83
|
const draftBanner = ref(null);
|
|
65
84
|
const isDirty = computed(
|
|
66
85
|
() => backup.value !== null && Object.keys(objectDiff(backup.value, model.value)).length > 0
|
|
67
86
|
);
|
|
68
87
|
const mainCols = computed(() => 12 - props.sidebarCols);
|
|
69
88
|
const derivedLangs = ref([]);
|
|
89
|
+
const contentLanguages = useContentLanguages();
|
|
70
90
|
const activeLangs = computed(() => {
|
|
71
91
|
if (props.forceLanguages?.length) return props.forceLanguages;
|
|
72
|
-
|
|
73
|
-
return
|
|
92
|
+
const declared = props.languages.length ? props.languages : derivedLangs.value;
|
|
93
|
+
return restrictLanguages(declared, contentLanguages);
|
|
74
94
|
});
|
|
75
95
|
watch(
|
|
76
96
|
activeLangs,
|
|
77
97
|
(langs) => {
|
|
78
|
-
|
|
98
|
+
const isOffered = langs.includes(currentLang.value);
|
|
99
|
+
if (isOffered || !langs.length) return;
|
|
100
|
+
currentLang.value = langs[0];
|
|
79
101
|
},
|
|
80
102
|
{ immediate: true }
|
|
81
103
|
);
|
|
@@ -172,6 +194,31 @@ if (props.draft || props.draftKey) {
|
|
|
172
194
|
}, 2e3);
|
|
173
195
|
watch(model, saveDraft, { deep: true });
|
|
174
196
|
}
|
|
197
|
+
const derivedFields = shallowRef([]);
|
|
198
|
+
const activeFields = computed(
|
|
199
|
+
() => props.fields?.length ? props.fields : derivedFields.value
|
|
200
|
+
);
|
|
201
|
+
async function describeEndpoint() {
|
|
202
|
+
const wantsLangs = !props.languages.length && !props.forceLanguages?.length;
|
|
203
|
+
const wantsFields = props.experimentalFieldsFromSchema && !props.fields?.length;
|
|
204
|
+
if (!wantsLangs && !wantsFields) return;
|
|
205
|
+
let metadata;
|
|
206
|
+
try {
|
|
207
|
+
metadata = await crud.options();
|
|
208
|
+
} catch {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (wantsLangs) derivedLangs.value = languagesFromMetadata(metadata);
|
|
212
|
+
if (wantsFields) {
|
|
213
|
+
const schema = metadata.schema;
|
|
214
|
+
if (schema?.properties) {
|
|
215
|
+
derivedFields.value = useFormFromSchema(
|
|
216
|
+
schema,
|
|
217
|
+
props.schemaFieldOptions
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
175
222
|
async function fetchModel() {
|
|
176
223
|
if (isNew.value) {
|
|
177
224
|
backup.value = null;
|
|
@@ -182,34 +229,29 @@ async function fetchModel() {
|
|
|
182
229
|
try {
|
|
183
230
|
model.value = await crud.detail(props.id);
|
|
184
231
|
backup.value = deepClone(model.value);
|
|
185
|
-
const langInfo = model.value?.lang_info;
|
|
186
|
-
const siteLangs = langInfo?.site_languages;
|
|
187
|
-
if (siteLangs?.length && !props.languages.length && !props.forceLanguages?.length) {
|
|
188
|
-
derivedLangs.value = siteLangs;
|
|
189
|
-
}
|
|
190
232
|
checkDraft();
|
|
191
233
|
} catch (err) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
snack.show(detail ?? "Failed to load item", "error");
|
|
195
|
-
if (status === 404) router.back();
|
|
234
|
+
snack.show(getErrorDetail(err) ?? t("mapo.loadItemError"), "error");
|
|
235
|
+
if (getErrorStatus(err) === 404) router.back();
|
|
196
236
|
} finally {
|
|
197
237
|
isLoading.value = false;
|
|
198
238
|
}
|
|
199
239
|
}
|
|
200
240
|
async function save(andBack = false) {
|
|
241
|
+
if (isBusy.value) return;
|
|
201
242
|
const validationResults = formValidators.map((fn) => fn());
|
|
202
243
|
const allValid = validationResults.every((r) => r.valid);
|
|
203
244
|
if (!allValid) {
|
|
204
245
|
const fieldErrors = validationResults.flatMap(
|
|
205
246
|
(r) => Object.entries(r.errors)
|
|
206
247
|
);
|
|
207
|
-
const message = fieldErrors.length ? fieldErrors.map(([field, msg]) => `${field}: ${msg}`).join("\n") : "
|
|
248
|
+
const message = fieldErrors.length ? fieldErrors.map(([field, msg]) => `${field}: ${msg}`).join("\n") : t("mapo.fixErrors");
|
|
208
249
|
snack.show(message, "error");
|
|
209
250
|
return;
|
|
210
251
|
}
|
|
211
252
|
errors.value = {};
|
|
212
|
-
|
|
253
|
+
pendingAction.value = andBack ? "save" : "saveContinue";
|
|
254
|
+
let leaving = false;
|
|
213
255
|
try {
|
|
214
256
|
const multipartOpts = { multipart: props.multipart };
|
|
215
257
|
let result;
|
|
@@ -235,7 +277,7 @@ async function save(andBack = false) {
|
|
|
235
277
|
backup.value = deepClone(model.value);
|
|
236
278
|
clearDraft();
|
|
237
279
|
snack.show(
|
|
238
|
-
isNew.value ? "
|
|
280
|
+
isNew.value ? t("mapo.createSuccess") : t("mapo.saveSuccess"),
|
|
239
281
|
"success"
|
|
240
282
|
);
|
|
241
283
|
emit("saved", model.value);
|
|
@@ -245,20 +287,19 @@ async function save(andBack = false) {
|
|
|
245
287
|
params: { id }
|
|
246
288
|
});
|
|
247
289
|
}
|
|
248
|
-
if (andBack)
|
|
290
|
+
if (andBack) leaving = leave();
|
|
249
291
|
} catch (err) {
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
if (response?.status === 400 && data && typeof data === "object") {
|
|
292
|
+
const data = getErrorData(err);
|
|
293
|
+
if (getErrorStatus(err) === 400 && data && typeof data === "object") {
|
|
253
294
|
errors.value = data;
|
|
254
295
|
const detail = data.detail;
|
|
255
296
|
if (detail) snack.show(detail, "error");
|
|
256
297
|
} else {
|
|
257
298
|
const detail = data?.detail;
|
|
258
|
-
snack.show(detail ?? "
|
|
299
|
+
snack.show(detail ?? t("mapo.saveError"), "error");
|
|
259
300
|
}
|
|
260
301
|
} finally {
|
|
261
|
-
|
|
302
|
+
if (!leaving) pendingAction.value = null;
|
|
262
303
|
}
|
|
263
304
|
}
|
|
264
305
|
function getPatch() {
|
|
@@ -266,36 +307,51 @@ function getPatch() {
|
|
|
266
307
|
return objectDiff(backup.value, model.value);
|
|
267
308
|
}
|
|
268
309
|
async function deleteItem() {
|
|
310
|
+
if (isBusy.value) return;
|
|
269
311
|
const ok = await confirm.ask({
|
|
270
|
-
title: "
|
|
271
|
-
message: "
|
|
272
|
-
confirmText: "
|
|
312
|
+
title: t("mapo.delete"),
|
|
313
|
+
message: t("mapo.detail.deleteQuestion"),
|
|
314
|
+
confirmText: t("mapo.delete"),
|
|
273
315
|
dangerous: true
|
|
274
316
|
});
|
|
275
317
|
if (!ok) return;
|
|
276
|
-
|
|
318
|
+
pendingAction.value = "delete";
|
|
319
|
+
let leaving = false;
|
|
277
320
|
try {
|
|
278
321
|
await crud.delete(recordId());
|
|
279
322
|
backup.value = deepClone(model.value);
|
|
280
|
-
snack.show("
|
|
323
|
+
snack.show(t("mapo.deleteSuccess"), "success");
|
|
281
324
|
emit("deleted");
|
|
282
|
-
|
|
325
|
+
leaving = leave();
|
|
283
326
|
} catch (err) {
|
|
284
|
-
|
|
285
|
-
snack.show(detail ?? "Failed to delete", "error");
|
|
327
|
+
snack.show(getErrorDetail(err) ?? t("mapo.deleteError"), "error");
|
|
286
328
|
} finally {
|
|
287
|
-
|
|
329
|
+
if (!leaving) pendingAction.value = null;
|
|
288
330
|
}
|
|
289
331
|
}
|
|
290
332
|
function back() {
|
|
333
|
+
if (isBusy.value) return;
|
|
334
|
+
pendingAction.value = "back";
|
|
335
|
+
const leaving = leave();
|
|
336
|
+
if (!leaving) pendingAction.value = null;
|
|
337
|
+
}
|
|
338
|
+
function leave() {
|
|
339
|
+
const hasPreviousPage = router.options.history.state.back != null;
|
|
340
|
+
if (hasPreviousPage) {
|
|
341
|
+
const stopWatching = router.afterEach((_to, _from, failure) => {
|
|
342
|
+
stopWatching();
|
|
343
|
+
if (failure) pendingAction.value = null;
|
|
344
|
+
});
|
|
345
|
+
}
|
|
291
346
|
router.back();
|
|
347
|
+
return hasPreviousPage;
|
|
292
348
|
}
|
|
293
349
|
async function guardUnsaved() {
|
|
294
350
|
if (!isDirty.value) return true;
|
|
295
351
|
return confirm.ask({
|
|
296
|
-
title: "
|
|
297
|
-
message: "
|
|
298
|
-
confirmText: "
|
|
352
|
+
title: t("mapo.unsavedData"),
|
|
353
|
+
message: t("mapo.confirmLeaveChanges"),
|
|
354
|
+
confirmText: t("mapo.leave"),
|
|
299
355
|
dangerous: true
|
|
300
356
|
});
|
|
301
357
|
}
|
|
@@ -319,6 +375,7 @@ onMounted(() => {
|
|
|
319
375
|
preventWindowClose
|
|
320
376
|
);
|
|
321
377
|
}
|
|
378
|
+
describeEndpoint();
|
|
322
379
|
fetchModel();
|
|
323
380
|
});
|
|
324
381
|
onBeforeUnmount(() => {
|
|
@@ -373,12 +430,16 @@ defineSlots();
|
|
|
373
430
|
color="warning"
|
|
374
431
|
variant="subtle"
|
|
375
432
|
class="mb-3"
|
|
376
|
-
:title="
|
|
377
|
-
|
|
433
|
+
:title="
|
|
434
|
+
t('mapo.detail.draftSavedAt', {
|
|
435
|
+
date: draftBanner.savedAt.toLocaleString()
|
|
436
|
+
})
|
|
437
|
+
"
|
|
438
|
+
:description="t('mapo.detail.draftFound')"
|
|
378
439
|
>
|
|
379
440
|
<template #actions>
|
|
380
441
|
<UButton size="xs" color="warning" @click="draftBanner?.restore()">
|
|
381
|
-
|
|
442
|
+
{{ t("mapo.restore") }}
|
|
382
443
|
</UButton>
|
|
383
444
|
<UButton
|
|
384
445
|
size="xs"
|
|
@@ -386,7 +447,7 @@ defineSlots();
|
|
|
386
447
|
variant="ghost"
|
|
387
448
|
@click="draftBanner?.discard()"
|
|
388
449
|
>
|
|
389
|
-
|
|
450
|
+
{{ t("mapo.discard") }}
|
|
390
451
|
</UButton>
|
|
391
452
|
</template>
|
|
392
453
|
</UAlert>
|
|
@@ -396,7 +457,7 @@ defineSlots();
|
|
|
396
457
|
<!-- Title -->
|
|
397
458
|
<slot name="title" v-bind="slotBindings">
|
|
398
459
|
<h1 class="text-2xl font-bold text-gray-900 dark:text-white mb-6">
|
|
399
|
-
{{ isNew ? "
|
|
460
|
+
{{ isNew ? t("mapo.new") : t("mapo.edit") }}
|
|
400
461
|
<span v-if="modelName"> {{ modelName }}</span>
|
|
401
462
|
</h1>
|
|
402
463
|
</slot>
|
|
@@ -411,6 +472,7 @@ defineSlots();
|
|
|
411
472
|
v-model="currentLang"
|
|
412
473
|
:langs="activeLangs"
|
|
413
474
|
:errors="errors"
|
|
475
|
+
:lang-threshold="langThreshold"
|
|
414
476
|
/>
|
|
415
477
|
</slot>
|
|
416
478
|
|
|
@@ -420,7 +482,7 @@ defineSlots();
|
|
|
420
482
|
<slot name="body" v-bind="slotBindings">
|
|
421
483
|
<MapoForm
|
|
422
484
|
v-model="model"
|
|
423
|
-
:fields="
|
|
485
|
+
:fields="activeFields"
|
|
424
486
|
:errors="errors"
|
|
425
487
|
:languages="activeLangs"
|
|
426
488
|
:current-lang="currentLang"
|
|
@@ -443,7 +505,8 @@ defineSlots();
|
|
|
443
505
|
<!-- Sidebar column -->
|
|
444
506
|
<div :class="sidebarColsClass">
|
|
445
507
|
<div :style="sidebarStyle" class="space-y-4">
|
|
446
|
-
<!-- Action buttons (Save / Save&continue / Back — no delete here)
|
|
508
|
+
<!-- Action buttons (Save / Save&continue / Back — no delete here).
|
|
509
|
+
While one works, it spins and all of them are disabled. -->
|
|
447
510
|
<slot name="side-buttons" v-bind="slotBindings">
|
|
448
511
|
<UCard>
|
|
449
512
|
<div class="flex flex-col gap-2">
|
|
@@ -451,11 +514,12 @@ defineSlots();
|
|
|
451
514
|
<UButton
|
|
452
515
|
v-if="!effectiveReadonly"
|
|
453
516
|
block
|
|
454
|
-
:loading="
|
|
517
|
+
:loading="pendingAction === 'save'"
|
|
518
|
+
:disabled="isBusy"
|
|
455
519
|
icon="i-lucide-save"
|
|
456
520
|
@click="save(true)"
|
|
457
521
|
>
|
|
458
|
-
{{ isNew ? "
|
|
522
|
+
{{ isNew ? t("mapo.create") : t("mapo.save") }}
|
|
459
523
|
</UButton>
|
|
460
524
|
</slot>
|
|
461
525
|
|
|
@@ -464,11 +528,14 @@ defineSlots();
|
|
|
464
528
|
v-if="!effectiveReadonly"
|
|
465
529
|
block
|
|
466
530
|
variant="soft"
|
|
467
|
-
:loading="
|
|
531
|
+
:loading="pendingAction === 'saveContinue'"
|
|
532
|
+
:disabled="isBusy"
|
|
468
533
|
icon="i-lucide-save"
|
|
469
534
|
@click="save(false)"
|
|
470
535
|
>
|
|
471
|
-
{{
|
|
536
|
+
{{
|
|
537
|
+
isNew ? t("mapo.createContinue") : t("mapo.saveContinue")
|
|
538
|
+
}}
|
|
472
539
|
</UButton>
|
|
473
540
|
</slot>
|
|
474
541
|
|
|
@@ -477,9 +544,11 @@ defineSlots();
|
|
|
477
544
|
block
|
|
478
545
|
variant="ghost"
|
|
479
546
|
icon="i-lucide-arrow-left"
|
|
547
|
+
:loading="pendingAction === 'back'"
|
|
548
|
+
:disabled="isBusy"
|
|
480
549
|
@click="back"
|
|
481
550
|
>
|
|
482
|
-
|
|
551
|
+
{{ t("mapo.back") }}
|
|
483
552
|
</UButton>
|
|
484
553
|
</slot>
|
|
485
554
|
</div>
|
|
@@ -501,6 +570,7 @@ defineSlots();
|
|
|
501
570
|
:current-lang="currentLang"
|
|
502
571
|
:registry="registry"
|
|
503
572
|
:readonly="effectiveReadonly"
|
|
573
|
+
:notify-errors="false"
|
|
504
574
|
>
|
|
505
575
|
<template
|
|
506
576
|
v-for="slotName in formSlotNames"
|
|
@@ -520,6 +590,7 @@ defineSlots();
|
|
|
520
590
|
:current-lang="currentLang"
|
|
521
591
|
:registry="registry"
|
|
522
592
|
:readonly="effectiveReadonly"
|
|
593
|
+
:notify-errors="false"
|
|
523
594
|
>
|
|
524
595
|
<template
|
|
525
596
|
v-for="slotName in formSlotNames"
|
|
@@ -542,7 +613,7 @@ defineSlots();
|
|
|
542
613
|
icon="i-lucide-eye"
|
|
543
614
|
@click="previewOpen = true"
|
|
544
615
|
>
|
|
545
|
-
|
|
616
|
+
{{ t("mapo.preview") }}
|
|
546
617
|
</UButton>
|
|
547
618
|
|
|
548
619
|
<!-- Danger zone: delete action, visually separated from save actions -->
|
|
@@ -554,10 +625,11 @@ defineSlots();
|
|
|
554
625
|
color="error"
|
|
555
626
|
variant="soft"
|
|
556
627
|
:loading="isDeleting"
|
|
628
|
+
:disabled="isBusy"
|
|
557
629
|
icon="i-lucide-trash-2"
|
|
558
630
|
@click="deleteItem"
|
|
559
631
|
>
|
|
560
|
-
|
|
632
|
+
{{ t("mapo.delete") }}
|
|
561
633
|
</UButton>
|
|
562
634
|
</slot>
|
|
563
635
|
</UCard>
|