@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { ref, computed, watch, onMounted, nextTick } from "vue";
|
|
3
|
-
import { useRoute, useRouter } from "
|
|
3
|
+
import { useRoute, useRouter } from "#app";
|
|
4
4
|
const props = defineProps({
|
|
5
5
|
modelValue: { type: String, required: true },
|
|
6
6
|
langs: { type: Array, required: true },
|
|
@@ -39,6 +39,7 @@ function onSelectChange(v) {
|
|
|
39
39
|
const lang = typeof v === "object" && v !== null ? v.value : v;
|
|
40
40
|
if (lang) selectLang(lang);
|
|
41
41
|
}
|
|
42
|
+
const showSelect = computed(() => props.langs.length > props.langThreshold);
|
|
42
43
|
const selectItems = computed(
|
|
43
44
|
() => props.langs.map((lang) => ({
|
|
44
45
|
label: lang.toUpperCase(),
|
|
@@ -68,26 +69,21 @@ watch(
|
|
|
68
69
|
<div
|
|
69
70
|
class="flex items-end gap-0 border-b border-gray-200 dark:border-gray-700 mt-2 mb-4"
|
|
70
71
|
>
|
|
71
|
-
<!-- Language select —
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
:trailing-icon="
|
|
87
|
-
open ? 'i-lucide-chevron-up' : 'i-lucide-chevron-down'
|
|
88
|
-
"
|
|
89
|
-
class="w-full justify-between font-medium"
|
|
90
|
-
>
|
|
72
|
+
<!-- Language select — above langThreshold only, aligned at bottom of row -->
|
|
73
|
+
<template v-if="showSelect">
|
|
74
|
+
<USelectMenu
|
|
75
|
+
:model-value="modelValue"
|
|
76
|
+
:items="selectItems"
|
|
77
|
+
value-key="value"
|
|
78
|
+
label-key="label"
|
|
79
|
+
size="sm"
|
|
80
|
+
variant="ghost"
|
|
81
|
+
class="w-28 shrink-0 mb-px font-medium"
|
|
82
|
+
@update:model-value="onSelectChange"
|
|
83
|
+
>
|
|
84
|
+
<!-- The trigger is already a button with its own chevron: the slot
|
|
85
|
+
holds only what it shows, never another button. -->
|
|
86
|
+
<template #default>
|
|
91
87
|
<span class="flex items-center gap-1">
|
|
92
88
|
<span
|
|
93
89
|
v-if="hasErrors(modelValue)"
|
|
@@ -95,12 +91,12 @@ watch(
|
|
|
95
91
|
/>
|
|
96
92
|
{{ modelValue.toUpperCase() }}
|
|
97
93
|
</span>
|
|
98
|
-
</
|
|
99
|
-
</
|
|
100
|
-
</USelectMenu>
|
|
94
|
+
</template>
|
|
95
|
+
</USelectMenu>
|
|
101
96
|
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
<!-- Divider -->
|
|
98
|
+
<div class="h-5 w-px bg-gray-200 dark:bg-gray-700 mx-2 shrink-0" />
|
|
99
|
+
</template>
|
|
104
100
|
|
|
105
101
|
<!-- Tab bar — always shown, scrollable -->
|
|
106
102
|
<div class="flex gap-1 overflow-x-auto scrollbar-none flex-1">
|
|
@@ -4,8 +4,9 @@ type __VLS_Props = {
|
|
|
4
4
|
errors?: Record<string, string[]>;
|
|
5
5
|
noRouteChange?: boolean;
|
|
6
6
|
/**
|
|
7
|
-
* Number of languages above which
|
|
8
|
-
*
|
|
7
|
+
* Number of languages above which a searchable select appears next to the
|
|
8
|
+
* tab bar, for quick navigation. Default: `8`. `0` always shows it,
|
|
9
|
+
* `Infinity` never does.
|
|
9
10
|
*/
|
|
10
11
|
langThreshold?: number;
|
|
11
12
|
};
|
|
@@ -15,8 +16,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
|
|
|
15
16
|
"onUpdate:modelValue"?: ((lang: string) => any) | undefined;
|
|
16
17
|
}>, {
|
|
17
18
|
errors: Record<string, string[]>;
|
|
18
|
-
noRouteChange: boolean;
|
|
19
19
|
langThreshold: number;
|
|
20
|
+
noRouteChange: boolean;
|
|
20
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
21
22
|
declare const _default: typeof __VLS_export;
|
|
22
23
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoDetailLangSwitch.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoDetailLangSwitch.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoDetailLangSwitch.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoDetailLangSwitch.vue"],"names":[],"mappings":"AA2KA,KAAK,WAAW,GAAG;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAClC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAkQJ,QAAA,MAAM,YAAY;;;;;YA1QL,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;mBAOjB,MAAM;mBANN,OAAO;6EA6QzB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { ref } from "vue";
|
|
3
|
+
import { useI18n } from "vue-i18n";
|
|
4
|
+
const { t } = useI18n();
|
|
3
5
|
const props = defineProps({
|
|
4
6
|
accept: { type: String, required: false, default: "*/*" },
|
|
5
7
|
multiple: { type: Boolean, required: false, default: true },
|
|
@@ -83,7 +85,9 @@ defineExpose({ triggerPick });
|
|
|
83
85
|
>
|
|
84
86
|
<div class="flex flex-col items-center gap-2 text-primary">
|
|
85
87
|
<UIcon name="i-lucide-upload-cloud" class="size-10" />
|
|
86
|
-
<span class="text-sm font-medium">
|
|
88
|
+
<span class="text-sm font-medium">{{
|
|
89
|
+
t("mapo.dropArea.dropHere")
|
|
90
|
+
}}</span>
|
|
87
91
|
</div>
|
|
88
92
|
</div>
|
|
89
93
|
</Transition>
|
|
@@ -18,8 +18,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
|
18
18
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
19
19
|
onFiles?: ((files: File[]) => any) | undefined;
|
|
20
20
|
}>, {
|
|
21
|
-
accept: string;
|
|
22
21
|
multiple: boolean;
|
|
22
|
+
accept: string;
|
|
23
23
|
disabled: boolean;
|
|
24
24
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
25
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoDropArea.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoDropArea.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoDropArea.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoDropArea.vue"],"names":[],"mappings":"AAuIA,KAAK,WAAW,GAAG;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAiDJ,iBAAS,WAAW,SAEnB;AAgJD,QAAA,IAAI,OAAO;;;CAAW,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAO/C,QAAA,MAAM,UAAU;;;;;;;cA9MD,OAAO;YADT,MAAM;cAEJ,OAAO;6EAkNpB,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { useI18n } from "vue-i18n";
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
flags: { type: Boolean, required: false, default: true },
|
|
6
|
+
size: { type: String, required: false, default: "sm" }
|
|
7
|
+
});
|
|
8
|
+
const { locale, locales, setLocale } = useI18n();
|
|
9
|
+
function getFlag(language) {
|
|
10
|
+
const region = language?.split("-").at(-1);
|
|
11
|
+
if (!region || region.length !== 2 || !/^[A-Za-z]+$/.test(region)) return "";
|
|
12
|
+
const codePoints = region.toUpperCase().split("").map((char) => 127397 + char.charCodeAt(0));
|
|
13
|
+
return String.fromCodePoint(...codePoints);
|
|
14
|
+
}
|
|
15
|
+
const items = computed(
|
|
16
|
+
() => locales.value.map((l) => ({
|
|
17
|
+
label: props.flags && getFlag(l.language) ? `${getFlag(l.language)} ${l.name ?? l.code.toUpperCase()}` : l.name ?? l.code.toUpperCase(),
|
|
18
|
+
value: l.code
|
|
19
|
+
}))
|
|
20
|
+
);
|
|
21
|
+
const current = computed({
|
|
22
|
+
get: () => locale.value,
|
|
23
|
+
set: (code) => {
|
|
24
|
+
if (code && code !== locale.value) setLocale(code);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<USelectMenu
|
|
31
|
+
v-model="current"
|
|
32
|
+
:items="items"
|
|
33
|
+
value-key="value"
|
|
34
|
+
label-key="label"
|
|
35
|
+
:size="size"
|
|
36
|
+
:search-input="false"
|
|
37
|
+
class="w-40"
|
|
38
|
+
/>
|
|
39
|
+
</template>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI locale switcher — lists the locales configured in `@nuxtjs/i18n`
|
|
3
|
+
* (via `@mapomodule/i18n`) and switches the interface language with
|
|
4
|
+
* cookie persistence. Port of the v1 `LangSwitcher`.
|
|
5
|
+
*/
|
|
6
|
+
type __VLS_Props = {
|
|
7
|
+
/** Show the flag emoji derived from the locale `language` tag. */
|
|
8
|
+
flags?: boolean;
|
|
9
|
+
/** Nuxt UI USelectMenu `size` prop. */
|
|
10
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
11
|
+
};
|
|
12
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
13
|
+
size: "xs" | "sm" | "md" | "lg" | "xl";
|
|
14
|
+
flags: boolean;
|
|
15
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
|
+
declare const _default: typeof __VLS_export;
|
|
17
|
+
export default _default;
|
|
18
|
+
//# sourceMappingURL=MapoLangSwitcher.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapoLangSwitcher.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoLangSwitcher.vue"],"names":[],"mappings":"AAiFA;;;;GAIG;AACH,KAAK,WAAW,GAAG;IACf,kEAAkE;IAClE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,uCAAuC;IACvC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CACzC,CAAC;AAgGJ,QAAA,MAAM,YAAY;UAjGP,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;WAF/B,OAAO;6EAsGjB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { ref, computed, watch, useSlots } from "vue";
|
|
2
|
+
import { ref, computed, watch, useSlots, onBeforeUnmount } from "vue";
|
|
3
3
|
import { debounce } from "@mapomodule/utils";
|
|
4
|
-
import { useRoute, useRouter } from "
|
|
4
|
+
import { useRoute, useRouter } from "#app";
|
|
5
5
|
const props = defineProps({
|
|
6
6
|
endpoint: { type: String, required: false, default: "" },
|
|
7
7
|
items: { type: Array, required: false, default: void 0 },
|
|
@@ -21,7 +21,8 @@ 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
|
-
|
|
24
|
+
defaultActions: { type: Boolean, required: false },
|
|
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 },
|
|
27
28
|
paginationParams: { type: Function, required: false }
|
|
@@ -81,6 +82,7 @@ const writeUrlState = debounce(() => {
|
|
|
81
82
|
router.replace({ query });
|
|
82
83
|
}, 150);
|
|
83
84
|
watch([activeTab, activeFilters], writeUrlState, { deep: true });
|
|
85
|
+
onBeforeUnmount(() => writeUrlState.cancel());
|
|
84
86
|
const crudEndpoint = computed(
|
|
85
87
|
() => (props.endpoint ?? "").split("?")[0] || (props.endpoint ?? "")
|
|
86
88
|
);
|
|
@@ -148,6 +150,8 @@ watch([activeTab, activeFilters], () => {
|
|
|
148
150
|
:selection-query="selectionQuery"
|
|
149
151
|
:endpoint="crudEndpoint"
|
|
150
152
|
:lookup="lookup"
|
|
153
|
+
:permission-model="permissionModel"
|
|
154
|
+
:default-actions="defaultActions"
|
|
151
155
|
@action-completed="refresh"
|
|
152
156
|
/>
|
|
153
157
|
</div>
|
|
@@ -17,6 +17,7 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
17
17
|
* Ignored when `items` is provided.
|
|
18
18
|
*/
|
|
19
19
|
clientSide?: boolean;
|
|
20
|
+
/** Column definitions. A dotted `key` (`category.name`) reads a field of a related object. */
|
|
20
21
|
columns: ListColumn<T>[];
|
|
21
22
|
lookup?: string;
|
|
22
23
|
filters?: FilterDescriptor[];
|
|
@@ -38,10 +39,19 @@ declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<
|
|
|
38
39
|
* hides the trash unless the user has `delete_article`. Omit to always show both.
|
|
39
40
|
*/
|
|
40
41
|
permissionModel?: string;
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Whether to include the built-in permanent delete bulk action.
|
|
44
|
+
* Defaults to `true`; custom `actions` are unaffected.
|
|
45
|
+
*/
|
|
46
|
+
defaultActions?: boolean;
|
|
47
|
+
/** Initial page size: a number, or `"all"`. Default: 20. */
|
|
48
|
+
defaultPageSize?: number | "all";
|
|
49
|
+
/**
|
|
50
|
+
* Options of the per-page selector. `"all"` adds an option that requests
|
|
51
|
+
* the list without pagination params, like `clientSide` does: the backend
|
|
52
|
+
* has to return the whole collection then. Default: [10, 20, 50, 100].
|
|
53
|
+
*/
|
|
54
|
+
pageSizeOptions?: (number | "all")[];
|
|
45
55
|
/**
|
|
46
56
|
* Custom response parser. Replaces the built-in DRF / flat-array detection.
|
|
47
57
|
* Return `{ items, total }` from any shape your backend returns.
|
|
@@ -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,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import { useSnackStore } from "@mapomodule/store/runtime/stores/snack";
|
|
4
5
|
import { useConfirmStore } from "@mapomodule/store/runtime/stores/confirm";
|
|
5
6
|
import { usePermissions } from "@mapomodule/store/runtime/composables/usePermissions";
|
|
6
7
|
import { useCrud } from "@mapomodule/core/runtime/api/crud";
|
|
8
|
+
import { getErrorDetail } from "@mapomodule/core/runtime/utils/fetchError";
|
|
7
9
|
const props = defineProps({
|
|
8
10
|
actions: { type: Array, required: false, default: () => [] },
|
|
9
11
|
selection: { type: [Array, String], required: true },
|
|
10
12
|
selectionQuery: { type: null, required: true },
|
|
11
13
|
endpoint: { type: String, required: true },
|
|
12
|
-
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 }
|
|
13
17
|
});
|
|
14
18
|
const emit = defineEmits(["actionCompleted"]);
|
|
15
19
|
defineSlots();
|
|
20
|
+
const { t } = useI18n();
|
|
16
21
|
const snack = useSnackStore();
|
|
17
22
|
const confirm = useConfirmStore();
|
|
23
|
+
const { canDelete, checkPermission } = usePermissions();
|
|
18
24
|
const crud = useCrud(props.endpoint);
|
|
19
25
|
const isRunning = ref(false);
|
|
20
|
-
const
|
|
26
|
+
const builtInActions = computed(() => [
|
|
21
27
|
{
|
|
22
|
-
label: "
|
|
28
|
+
label: t("mapo.listActions.permanentDelete"),
|
|
23
29
|
handler: async ({ selection }) => {
|
|
24
30
|
if (!selection) return;
|
|
25
31
|
await Promise.all(
|
|
@@ -30,12 +36,14 @@ const defaultActions = computed(() => [
|
|
|
30
36
|
)
|
|
31
37
|
);
|
|
32
38
|
},
|
|
33
|
-
permissions: "delete",
|
|
34
39
|
handleMultiple: true,
|
|
35
40
|
handleAll: false
|
|
36
41
|
}
|
|
37
42
|
]);
|
|
38
|
-
const allActions = computed(() => [
|
|
43
|
+
const allActions = computed(() => [
|
|
44
|
+
...props.defaultActions ? builtInActions.value : [],
|
|
45
|
+
...props.actions
|
|
46
|
+
]);
|
|
39
47
|
const visibleActions = computed(
|
|
40
48
|
() => allActions.value.filter(
|
|
41
49
|
(a) => props.selection === "all" ? a.handleAll ?? false : a.handleMultiple ?? true
|
|
@@ -49,9 +57,11 @@ const applyButtonColor = computed(
|
|
|
49
57
|
() => selectedAction.value?.dangerous ? "error" : "primary"
|
|
50
58
|
);
|
|
51
59
|
function canRun(action) {
|
|
60
|
+
if (builtInActions.value.includes(action)) {
|
|
61
|
+
return !props.permissionModel || canDelete(props.permissionModel);
|
|
62
|
+
}
|
|
52
63
|
const perms = action.permissions ? Array.isArray(action.permissions) ? action.permissions : [action.permissions] : [];
|
|
53
64
|
if (!perms.length) return true;
|
|
54
|
-
const { checkPermission } = usePermissions();
|
|
55
65
|
return perms.every((p) => checkPermission(p));
|
|
56
66
|
}
|
|
57
67
|
async function runAction() {
|
|
@@ -59,8 +69,10 @@ async function runAction() {
|
|
|
59
69
|
const action = selectedAction.value;
|
|
60
70
|
const ok = await confirm.ask({
|
|
61
71
|
title: action.label,
|
|
62
|
-
message: props.selection === "all" ? "
|
|
63
|
-
|
|
72
|
+
message: props.selection === "all" ? t("mapo.listActions.confirmBulk") : t("mapo.listActions.confirmBulkCount", {
|
|
73
|
+
count: props.selection.length
|
|
74
|
+
}),
|
|
75
|
+
confirmText: t("mapo.confirm"),
|
|
64
76
|
dangerous: !!action.dangerous
|
|
65
77
|
});
|
|
66
78
|
if (!ok) return;
|
|
@@ -71,12 +83,14 @@ async function runAction() {
|
|
|
71
83
|
selectionQuery: props.selectionQuery,
|
|
72
84
|
lookup: props.lookup
|
|
73
85
|
});
|
|
74
|
-
snack.show("
|
|
86
|
+
snack.show(t("mapo.listActions.actionCompleted"), "success");
|
|
75
87
|
emit("actionCompleted");
|
|
76
88
|
selectedLabel.value = void 0;
|
|
77
89
|
} catch (err) {
|
|
78
|
-
|
|
79
|
-
|
|
90
|
+
snack.show(
|
|
91
|
+
getErrorDetail(err) ?? t("mapo.listActions.actionFailed"),
|
|
92
|
+
"error"
|
|
93
|
+
);
|
|
80
94
|
} finally {
|
|
81
95
|
isRunning.value = false;
|
|
82
96
|
}
|
|
@@ -94,7 +108,7 @@ const isActive = computed(
|
|
|
94
108
|
:items="visibleActions"
|
|
95
109
|
value-key="label"
|
|
96
110
|
label-key="label"
|
|
97
|
-
placeholder="
|
|
111
|
+
:placeholder="t('mapo.listActions.bulkActions')"
|
|
98
112
|
size="sm"
|
|
99
113
|
class="min-w-48"
|
|
100
114
|
/>
|
|
@@ -105,7 +119,7 @@ const isActive = computed(
|
|
|
105
119
|
:disabled="!selectedAction || !canRun(selectedAction)"
|
|
106
120
|
@click="runAction"
|
|
107
121
|
>
|
|
108
|
-
|
|
122
|
+
{{ t("mapo.apply") }}
|
|
109
123
|
</UButton>
|
|
110
124
|
<slot name="append" />
|
|
111
125
|
</div>
|
|
@@ -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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, computed, watch } from "vue";
|
|
3
|
+
import { useI18n } from "vue-i18n";
|
|
4
|
+
const { t } = useI18n();
|
|
3
5
|
const props = defineProps({
|
|
4
6
|
filters: { type: Array, required: true },
|
|
5
7
|
modelValue: { type: Array, required: true },
|
|
@@ -145,7 +147,7 @@ const isOpen = ref(false);
|
|
|
145
147
|
color="neutral"
|
|
146
148
|
@click="removeAll"
|
|
147
149
|
>
|
|
148
|
-
|
|
150
|
+
{{ t("mapo.listFilters.clearAll") }}
|
|
149
151
|
</UButton>
|
|
150
152
|
|
|
151
153
|
<!-- Filter dropdown button -->
|
|
@@ -158,7 +160,7 @@ const isOpen = ref(false);
|
|
|
158
160
|
:disabled="disabled"
|
|
159
161
|
trailing-icon=""
|
|
160
162
|
>
|
|
161
|
-
|
|
163
|
+
{{ t("mapo.listFilters.filters") }}
|
|
162
164
|
</UButton>
|
|
163
165
|
|
|
164
166
|
<template #content>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoListFilters.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoListFilters.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoListFilters.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoListFilters.vue"],"names":[],"mappings":"AAySA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACb,MAAM,kBAAkB,CAAC;AAI1B,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAMF,KAAK,WAAW,GAAG;IACjB;;;;;;OAMG;IACH,CAAC,CAAC,EAAE,UAAU,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE;QAC/B,MAAM,EAAE,gBAAgB,GAAG;YAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE,CAAC;QAChD,MAAM,CAAC,EAAE,YAAY,CAAC;QACtB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;QACxE,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;QAClD,cAAc,CAAC,EAAE,CACf,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,YAAY,KACjB,OAAO,CAAC;KACd,KAAK,GAAG,CAAC;CACX,CAAC;AAwdF,QAAA,MAAM,UAAU;;;;kFAGd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { ref, computed, watch } from "vue";
|
|
3
|
+
import { useI18n } from "vue-i18n";
|
|
3
4
|
import { useSnackStore } from "@mapomodule/store/runtime/stores/snack";
|
|
4
5
|
import { useCrud } from "@mapomodule/core/runtime/api/crud";
|
|
6
|
+
import { getErrorDetail } from "@mapomodule/core/runtime/utils/fetchError";
|
|
5
7
|
const props = defineProps({
|
|
6
8
|
open: { type: Boolean, required: true },
|
|
7
9
|
endpoint: { type: String, required: false, default: "" },
|
|
@@ -15,6 +17,7 @@ const props = defineProps({
|
|
|
15
17
|
});
|
|
16
18
|
const emit = defineEmits(["update:open", "saved"]);
|
|
17
19
|
defineSlots();
|
|
20
|
+
const { t } = useI18n();
|
|
18
21
|
const snack = useSnackStore();
|
|
19
22
|
const crud = useCrud(props.endpoint);
|
|
20
23
|
const model = ref({});
|
|
@@ -40,7 +43,7 @@ watch(
|
|
|
40
43
|
try {
|
|
41
44
|
model.value = await crud.detail(id);
|
|
42
45
|
} catch {
|
|
43
|
-
snack.show("
|
|
46
|
+
snack.show(t("mapo.loadItemError"), "error");
|
|
44
47
|
isOpen.value = false;
|
|
45
48
|
} finally {
|
|
46
49
|
loading.value = false;
|
|
@@ -51,18 +54,17 @@ async function save() {
|
|
|
51
54
|
saving.value = true;
|
|
52
55
|
try {
|
|
53
56
|
if (props.offline) {
|
|
54
|
-
snack.show("
|
|
57
|
+
snack.show(t("mapo.saveSuccess"), "success");
|
|
55
58
|
emit("saved", { ...model.value });
|
|
56
59
|
isOpen.value = false;
|
|
57
60
|
return;
|
|
58
61
|
}
|
|
59
62
|
const result = props.itemId != null ? await crud.partialUpdate(props.itemId, model.value) : await crud.create(model.value);
|
|
60
|
-
snack.show("
|
|
63
|
+
snack.show(t("mapo.saveSuccess"), "success");
|
|
61
64
|
emit("saved", result);
|
|
62
65
|
isOpen.value = false;
|
|
63
66
|
} catch (err) {
|
|
64
|
-
|
|
65
|
-
snack.show(detail ?? "Failed to save", "error");
|
|
67
|
+
snack.show(getErrorDetail(err) ?? t("mapo.saveError"), "error");
|
|
66
68
|
} finally {
|
|
67
69
|
saving.value = false;
|
|
68
70
|
}
|
|
@@ -75,7 +77,9 @@ async function save() {
|
|
|
75
77
|
<div class="p-6 space-y-4">
|
|
76
78
|
<div class="flex items-center justify-between">
|
|
77
79
|
<h3 class="text-base font-semibold text-highlighted">
|
|
78
|
-
{{
|
|
80
|
+
{{
|
|
81
|
+
itemId != null ? t("mapo.edit") : t("mapo.listQuickEdit.newItem")
|
|
82
|
+
}}
|
|
79
83
|
</h3>
|
|
80
84
|
<UButton
|
|
81
85
|
size="xs"
|
|
@@ -106,10 +110,10 @@ async function save() {
|
|
|
106
110
|
|
|
107
111
|
<div class="flex justify-end gap-2 pt-2">
|
|
108
112
|
<UButton variant="ghost" color="neutral" @click="isOpen = false">
|
|
109
|
-
|
|
113
|
+
{{ t("mapo.cancel") }}
|
|
110
114
|
</UButton>
|
|
111
115
|
<UButton color="primary" :loading="saving" @click="save">
|
|
112
|
-
|
|
116
|
+
{{ t("mapo.save") }}
|
|
113
117
|
</UButton>
|
|
114
118
|
</div>
|
|
115
119
|
</template>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapoListQuickEdit.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoListQuickEdit.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapoListQuickEdit.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoListQuickEdit.vue"],"names":[],"mappings":"AA4KA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAKhF,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;WAoUO,OAAO,KAAK,EAAE,WAAW,GAAG,mBAAmB,CAAC;cAlU9C,OAAO;mBACF,MAAM;iBACR,MAAM,GAAG,MAAM,GAAG,IAAI;qBAClB,kBAAkB,CAAC,CAAC,CAAC,EAAE;iBAC3B,MAAM;oBACH,MAAM,EAAE;mBACT,aAAa;QACxB;;;;WAIG;kBACO,OAAO;QACjB,kFAAkF;oBACtE,CAAC,GAAG,IAAI;;;;KAoTmE,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;;QAlST;;;WAGG;qBACU;YAA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