@mapomodule/uikit 2.0.0-beta.5 → 2.0.0-beta.7
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/module.json +1 -1
- package/dist/runtime/components/MapoDetail.vue +1 -1
- package/dist/runtime/components/MapoList.vue +1 -1
- package/dist/runtime/components/MapoListQuickEdit.vue +1 -1
- package/dist/runtime/components/MapoListTable.vue +2 -2
- package/dist/runtime/components/MapoMediaFileChanger.vue +1 -1
- package/dist/runtime/components/MapoMediaManager.vue +1 -1
- package/dist/runtime/components/MapoMediaManagerDialog.vue +1 -1
- package/dist/runtime/components/MapoMediaPreview.vue +1 -1
- package/dist/runtime/stores/media.d.ts.map +1 -1
- package/dist/runtime/stores/media.js +14 -9
- package/package.json +1 -1
- package/src/runtime/components/MapoListTable.vue +1 -1
- package/src/runtime/stores/media.ts +33 -10
package/dist/module.json
CHANGED
|
@@ -27,7 +27,7 @@ const props = defineProps({
|
|
|
27
27
|
sticky: { type: Boolean, required: false, default: true },
|
|
28
28
|
usePatch: { type: Boolean, required: false, default: true },
|
|
29
29
|
readonly: { type: Boolean, required: false, default: false },
|
|
30
|
-
registry: { type: null, required: false, default: null },
|
|
30
|
+
registry: { type: [Object, null], required: false, default: null },
|
|
31
31
|
draft: { type: Boolean, required: false, default: false },
|
|
32
32
|
draftKey: { type: String, required: false, default: void 0 },
|
|
33
33
|
multipart: { type: null, required: false, default: "auto" },
|
|
@@ -18,7 +18,7 @@ const props = defineProps({
|
|
|
18
18
|
positionField: { type: String, required: false, default: "position" },
|
|
19
19
|
editFields: { type: Array, required: false, default: () => [] },
|
|
20
20
|
languages: { type: Array, required: false },
|
|
21
|
-
registry: { type:
|
|
21
|
+
registry: { type: Object, required: false },
|
|
22
22
|
detailBase: { type: String, required: false },
|
|
23
23
|
permissionModel: { type: String, required: false },
|
|
24
24
|
defaultPageSize: { type: Number, required: false, default: 20 },
|
|
@@ -9,7 +9,7 @@ const props = defineProps({
|
|
|
9
9
|
editFields: { type: Array, required: false, default: () => [] },
|
|
10
10
|
lookup: { type: String, required: false, default: "id" },
|
|
11
11
|
languages: { type: Array, required: false },
|
|
12
|
-
registry: { type:
|
|
12
|
+
registry: { type: Object, required: false },
|
|
13
13
|
offline: { type: Boolean, required: false, default: false },
|
|
14
14
|
localItem: { type: null, required: false, default: null }
|
|
15
15
|
});
|
|
@@ -31,7 +31,7 @@ const props = defineProps({
|
|
|
31
31
|
positionField: { type: String, required: false, default: "position" },
|
|
32
32
|
editFields: { type: Array, required: false, default: () => [] },
|
|
33
33
|
languages: { type: Array, required: false },
|
|
34
|
-
registry: { type:
|
|
34
|
+
registry: { type: Object, required: false },
|
|
35
35
|
detailBase: { type: String, required: false },
|
|
36
36
|
permissionModel: { type: String, required: false }
|
|
37
37
|
});
|
|
@@ -615,7 +615,7 @@ const sortingOptions = computed(() => ({
|
|
|
615
615
|
<UPagination
|
|
616
616
|
:model-value="pagination.pageIndex + 1"
|
|
617
617
|
:total="total"
|
|
618
|
-
:page
|
|
618
|
+
:items-per-page="pagination.pageSize"
|
|
619
619
|
size="sm"
|
|
620
620
|
@update:model-value="
|
|
621
621
|
pagination = { ...pagination, pageIndex: $event - 1 }
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { ref, computed, onUnmounted } from "vue";
|
|
3
3
|
import { humanFileSize } from "@mapomodule/utils";
|
|
4
4
|
const props = defineProps({
|
|
5
|
-
media: { type:
|
|
5
|
+
media: { type: Object, required: true },
|
|
6
6
|
accept: { type: String, required: false }
|
|
7
7
|
});
|
|
8
8
|
const emit = defineEmits(["update:file", "update:maintainUrl"]);
|
|
@@ -8,7 +8,7 @@ const props = defineProps({
|
|
|
8
8
|
noFolders: { type: Boolean, required: false, default: false },
|
|
9
9
|
languages: { type: Array, required: false, default: void 0 },
|
|
10
10
|
defaultLang: { type: String, required: false, default: void 0 },
|
|
11
|
-
initialSelection: { type: null, required: false, default: null }
|
|
11
|
+
initialSelection: { type: [Object, Array, null], required: false, default: null }
|
|
12
12
|
});
|
|
13
13
|
const emit = defineEmits(["update:selection"]);
|
|
14
14
|
const store = useMediaStore();
|
|
@@ -8,7 +8,7 @@ const props = defineProps({
|
|
|
8
8
|
noFolders: { type: Boolean, required: false, default: false },
|
|
9
9
|
languages: { type: Array, required: false, default: void 0 },
|
|
10
10
|
defaultLang: { type: String, required: false, default: void 0 },
|
|
11
|
-
selected: { type: null, required: false, default: null }
|
|
11
|
+
selected: { type: [Object, Array, null], required: false, default: null }
|
|
12
12
|
});
|
|
13
13
|
const emit = defineEmits(["update:modelValue", "confirm"]);
|
|
14
14
|
const store = useMediaStore();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed } from "vue";
|
|
3
3
|
const props = defineProps({
|
|
4
|
-
media: { type:
|
|
4
|
+
media: { type: Object, required: true },
|
|
5
5
|
size: { type: String, required: false, default: "md" },
|
|
6
6
|
contain: { type: Boolean, required: false, default: false },
|
|
7
7
|
showFilename: { type: Boolean, required: false, default: false },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../src/runtime/stores/media.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../src/runtime/stores/media.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EAEX,kBAAkB,EAClB,kBAAkB,EAGlB,UAAU,EACX,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;iBAKxB,CAAC;oBACqB,CAAC;uBACT,CAAC;;;;;;;;;;;;;;;;;;;;iBAFf,CAAC;oBACqB,CAAC;uBACT,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAFf,CAAC;oBACqB,CAAC;uBACT,CAAC;;;;;;;;;;;;;;;;;;;;iBAFf,CAAC;oBACqB,C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W,GAAG,IAAI,KAAG,OAAO,CAAC,IAAI,CAAC;wBAOzC,SAAS,KAAG,OAAO,CAAC,IAAI,CAAC;uBAalC,IAAI;oBAIL,MAAM,GAAG,SAAS,KAAG,IAAI;yBAId,SAAS,KAAG,OAAO,CAAC,SAAS,CAAC;2BAcrD,MAAM,QACT,IAAI,4BAET,OAAO,CAAC,SAAS,CAAC;mCAgBX,OAAO,CAAC,WAAW,CAAC,KAC3B,OAAO,CAAC,IAAI,CAAC;2BAYoB,WAAW,KAAG,OAAO,CAAC,IAAI,CAAC;yBAY7B,SAAS,KAAG,OAAO,CAAC,IAAI,CAAC;oBAapC,SAAS,KAAG,IAAI;6BAkBP,UAAU,KAAG,IAAI;0BAKpB,SAAS,GAAG,SAAS,EAAE,GAAG,IAAI,KAAG,IAAI;qBAI1C,MAAM,GAAG,MAAM,EAAE,KAAG,IAAI;yBAUtB,IAAI;0BAWG,OAAO,CAAC,IAAI,CAAC;2BAiBnC,kBAAkB,eACd,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,KACrC,OAAO,CAAC,SAAS,CAAC;wBAsCM,MAAM,GAAG,IAAI,KAAG,IAAI;yBAKnB,MAAM,GAAG,IAAI,KAAG,IAAI;iBAK9B,IAAI;wUA0DtB,CAAC"}
|
|
@@ -2,7 +2,9 @@ import { defineStore } from "pinia";
|
|
|
2
2
|
import { ref, computed, shallowRef } from "vue";
|
|
3
3
|
import { useConfirmStore } from "@mapomodule/store/runtime/stores/confirm";
|
|
4
4
|
import { useSnackStore } from "@mapomodule/store/runtime/stores/snack";
|
|
5
|
+
import { normalizeEndpoint } from "@mapomodule/utils";
|
|
5
6
|
import { useCrud } from "@mapomodule/core/runtime/api/crud";
|
|
7
|
+
import { applyMultipartPolicy } from "@mapomodule/core/runtime/api/multipart";
|
|
6
8
|
import { useNuxtApp, useRuntimeConfig } from "#app";
|
|
7
9
|
import { defaultMediaAdapter } from "../adapters/defaultMediaAdapter.js";
|
|
8
10
|
export const useMediaStore = defineStore("mapo-media", () => {
|
|
@@ -12,6 +14,11 @@ export const useMediaStore = defineStore("mapo-media", () => {
|
|
|
12
14
|
media: mediaConfig.endpoints?.media ?? "/api/media",
|
|
13
15
|
folders: mediaConfig.endpoints?.folders ?? "/api/media-folders"
|
|
14
16
|
};
|
|
17
|
+
function uploadUrl() {
|
|
18
|
+
const app = runtimeConfig.app;
|
|
19
|
+
const base = (app?.baseURL ?? "/").replace(/\/+$/, "");
|
|
20
|
+
return `${base}${normalizeEndpoint(endpoints.media)}`;
|
|
21
|
+
}
|
|
15
22
|
function adapter() {
|
|
16
23
|
const nuxt = useNuxtApp();
|
|
17
24
|
return nuxt.$mapoMediaAdapter ?? defaultMediaAdapter;
|
|
@@ -226,17 +233,15 @@ export const useMediaStore = defineStore("mapo-media", () => {
|
|
|
226
233
|
await getRoot();
|
|
227
234
|
}
|
|
228
235
|
async function uploadMedia(payload, onProgress) {
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
if (payload.
|
|
232
|
-
if (payload.
|
|
233
|
-
if (payload.
|
|
234
|
-
|
|
235
|
-
if (payload.folder != null)
|
|
236
|
-
formData.append("folder", String(payload.folder));
|
|
236
|
+
const body = { file: payload.file };
|
|
237
|
+
if (payload.title) body.title = payload.title;
|
|
238
|
+
if (payload.alt_text) body.alt_text = payload.alt_text;
|
|
239
|
+
if (payload.description) body.description = payload.description;
|
|
240
|
+
if (payload.folder != null) body.folder = payload.folder;
|
|
241
|
+
const formData = applyMultipartPolicy(body, "force");
|
|
237
242
|
return await new Promise((resolve, reject) => {
|
|
238
243
|
const xhr = new XMLHttpRequest();
|
|
239
|
-
xhr.open("POST",
|
|
244
|
+
xhr.open("POST", uploadUrl());
|
|
240
245
|
xhr.responseType = "json";
|
|
241
246
|
if (onProgress) {
|
|
242
247
|
xhr.upload.addEventListener("progress", (event) => {
|
package/package.json
CHANGED
|
@@ -871,7 +871,7 @@ const sortingOptions = computed(() => ({
|
|
|
871
871
|
<UPagination
|
|
872
872
|
:model-value="pagination.pageIndex + 1"
|
|
873
873
|
:total="total"
|
|
874
|
-
:page
|
|
874
|
+
:items-per-page="pagination.pageSize"
|
|
875
875
|
size="sm"
|
|
876
876
|
@update:model-value="
|
|
877
877
|
pagination = { ...pagination, pageIndex: $event - 1 }
|
|
@@ -2,7 +2,9 @@ import { defineStore } from "pinia";
|
|
|
2
2
|
import { ref, computed, shallowRef } from "vue";
|
|
3
3
|
import { useConfirmStore } from "@mapomodule/store/runtime/stores/confirm";
|
|
4
4
|
import { useSnackStore } from "@mapomodule/store/runtime/stores/snack";
|
|
5
|
+
import { normalizeEndpoint } from "@mapomodule/utils";
|
|
5
6
|
import { useCrud } from "@mapomodule/core/runtime/api/crud";
|
|
7
|
+
import { applyMultipartPolicy } from "@mapomodule/core/runtime/api/multipart";
|
|
6
8
|
import { useNuxtApp, useRuntimeConfig } from "#app";
|
|
7
9
|
import { defaultMediaAdapter } from "../adapters/defaultMediaAdapter.js";
|
|
8
10
|
import type {
|
|
@@ -27,6 +29,24 @@ export const useMediaStore = defineStore("mapo-media", () => {
|
|
|
27
29
|
folders: mediaConfig.endpoints?.folders ?? "/api/media-folders",
|
|
28
30
|
};
|
|
29
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Absolute-from-origin URL for the upload POST.
|
|
34
|
+
*
|
|
35
|
+
* Every other media request goes through `useCrud` → `$mapoFetch`, which
|
|
36
|
+
* inherits `baseURL: app.baseURL` from Nuxt's global `$fetch`. The upload has
|
|
37
|
+
* to use XHR (ofetch exposes no upload-progress hook), so it must reproduce
|
|
38
|
+
* that resolution itself: `normalizeEndpoint` for the path (same call
|
|
39
|
+
* `useCrud` makes) plus the app base. Skipping the base made the upload the
|
|
40
|
+
* only request to miss it, so on a sub-path deployment it bypassed server
|
|
41
|
+
* middleware mounted under that base — including the proxy that attaches
|
|
42
|
+
* `X-CSRFToken`, hence 403s on session-authenticated backends.
|
|
43
|
+
*/
|
|
44
|
+
function uploadUrl(): string {
|
|
45
|
+
const app = runtimeConfig.app as { baseURL?: string } | undefined;
|
|
46
|
+
const base = (app?.baseURL ?? "/").replace(/\/+$/, "");
|
|
47
|
+
return `${base}${normalizeEndpoint(endpoints.media)}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
30
50
|
// Adapter: backend-specific request/response transforms. Provided by a plugin
|
|
31
51
|
// ($mapoMediaAdapter); falls back to plain REST when none is registered.
|
|
32
52
|
function adapter(): MediaAdapter {
|
|
@@ -330,20 +350,23 @@ export const useMediaStore = defineStore("mapo-media", () => {
|
|
|
330
350
|
payload: MediaUploadPayload,
|
|
331
351
|
onProgress?: (percent: number) => void,
|
|
332
352
|
): Promise<MediaItem> {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
if (payload.
|
|
340
|
-
|
|
353
|
+
// Build the body through the same multipart pipeline every other write uses
|
|
354
|
+
// (`data` JSON envelope + files at their dot-path). Hand-rolling a flat
|
|
355
|
+
// FormData here made uploads the only write that spoke a different wire
|
|
356
|
+
// format, which backends parsing the envelope reject.
|
|
357
|
+
const body: Record<string, unknown> = { file: payload.file };
|
|
358
|
+
if (payload.title) body.title = payload.title;
|
|
359
|
+
if (payload.alt_text) body.alt_text = payload.alt_text;
|
|
360
|
+
if (payload.description) body.description = payload.description;
|
|
361
|
+
if (payload.folder != null) body.folder = payload.folder;
|
|
362
|
+
const formData = applyMultipartPolicy(body, "force") as FormData;
|
|
341
363
|
|
|
342
364
|
// ofetch has no upload-progress hook, so uploads go through XHR.
|
|
343
|
-
// Same-origin request: the session cookie is attached automatically
|
|
365
|
+
// Same-origin request: the session cookie is attached automatically, and
|
|
366
|
+
// `uploadUrl()` keeps the target identical to the one `useCrud` would hit.
|
|
344
367
|
return await new Promise<MediaItem>((resolve, reject) => {
|
|
345
368
|
const xhr = new XMLHttpRequest();
|
|
346
|
-
xhr.open("POST",
|
|
369
|
+
xhr.open("POST", uploadUrl());
|
|
347
370
|
xhr.responseType = "json";
|
|
348
371
|
if (onProgress) {
|
|
349
372
|
xhr.upload.addEventListener("progress", (event) => {
|