@feedmepos/mf-media 2.0.1 → 2.0.2-dev.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/dist/{AiStudio-2cced8ce.js → AiStudio-6f993b76.js} +74 -74
- package/dist/AssetLibrary-4168fa7a.js +350 -0
- package/dist/app.js +181 -160
- package/dist/{media-picker-1cd70533.js → media-picker-fdef87dc.js} +1467 -1449
- package/dist/src/api/businesses.d.ts +9 -0
- package/dist/src/app.d.ts +21 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/AssetLibrary-b9219b4e.js +0 -306
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import { defineComponent as Ce, computed as f, ref as s, watch as O, onMounted as Se, resolveComponent as S, openBlock as m, createElementBlock as P, createElementVNode as c, toDisplayString as T, unref as t, createBlock as A, createCommentVNode as _, createVNode as r, withCtx as K } from "vue";
|
|
2
|
+
import { baseClientInstance as Te, useCoreStore as Ae, useI18n as Re } from "@feedmepos/mf-common";
|
|
3
|
+
import { useDialog as De } from "@feedmepos/ui-library";
|
|
4
|
+
import { r as Fe, F as ze, y as Oe, b as Pe, h as Q, a as Ue, o as Ne, f as Ee, $ as Me, v as $e, m as Le, u as je, E as Ge, c as re, g as qe } from "./media-picker-fdef87dc.js";
|
|
5
|
+
async function He(W, w = 20) {
|
|
6
|
+
const { data: l } = await Te("").get("/my/businesses-pagination", {
|
|
7
|
+
params: { skip: 0, limit: w, search: W || void 0 }
|
|
8
|
+
});
|
|
9
|
+
return l.resources.map((v) => ({ id: v._id, name: v.name }));
|
|
10
|
+
}
|
|
11
|
+
const Je = { class: "flex items-center justify-between mb-8" }, Ke = { class: "fm-typo-en-title-md-600 fm-step-title line-clamp-2" }, Qe = { class: "flex gap-8" }, We = { class: "flex flex-col gap-12 mb-16" }, Xe = { class: "flex gap-12" }, Ye = { class: "flex items-center gap-12" }, Ze = { class: "flex-1 text-xs text-fm-color-typo-secondary" }, ea = {
|
|
12
|
+
key: 0,
|
|
13
|
+
class: "text-fm-color-typo-primary font-semibold"
|
|
14
|
+
}, aa = { key: 1 }, la = {
|
|
15
|
+
key: 0,
|
|
16
|
+
class: "fixed bottom-24 left-1/2 -translate-x-1/2 flex items-center gap-12 bg-white border rounded-lg shadow-lg px-16 py-8 z-30"
|
|
17
|
+
}, ta = { class: "text-sm font-semibold" }, sa = { class: "flex justify-end gap-8 w-full" }, na = "all", da = /* @__PURE__ */ Ce({
|
|
18
|
+
__name: "AssetLibrary",
|
|
19
|
+
setup(W) {
|
|
20
|
+
const w = Ae(), { t: l } = Re(), v = f(() => {
|
|
21
|
+
var e;
|
|
22
|
+
return ((e = w.currentBusiness.value) == null ? void 0 : e.id) ?? "";
|
|
23
|
+
}), de = f(() => {
|
|
24
|
+
var e;
|
|
25
|
+
return (e = w.currentRestaurant.value) == null ? void 0 : e._id;
|
|
26
|
+
}), R = De(), U = f(() => {
|
|
27
|
+
var e;
|
|
28
|
+
return ((e = w.sessionUser.value) == null ? void 0 : e.role.isAdmin) ?? !1;
|
|
29
|
+
}), h = s(!1), k = s(void 0), N = s([]);
|
|
30
|
+
async function X(e) {
|
|
31
|
+
try {
|
|
32
|
+
N.value = (await He(e)).map((a) => ({ label: a.name, value: a.id }));
|
|
33
|
+
} catch {
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function ce() {
|
|
37
|
+
h.value = !h.value, k.value = void 0, y.value = void 0, h.value && N.value.length === 0 && X("");
|
|
38
|
+
}
|
|
39
|
+
const B = f(
|
|
40
|
+
() => U.value && h.value ? k.value || na : v.value
|
|
41
|
+
), D = s(""), I = s([]), y = s(void 0), Y = f(
|
|
42
|
+
() => (w.restaurants.value ?? []).map((e) => ({ label: e.profile.name, value: e._id }))
|
|
43
|
+
);
|
|
44
|
+
O(k, () => {
|
|
45
|
+
y.value = void 0;
|
|
46
|
+
});
|
|
47
|
+
const F = s(void 0), Z = s([]), ee = f(() => Z.value.map((e) => ({ label: e, value: e }))), x = s([]), V = s([]), E = s(!1), p = s(1), M = s(0), $ = s(0), L = s(!1), ae = s(null), le = s("recent"), ve = {
|
|
48
|
+
recent: { sortBy: "createdAt", descending: !0 },
|
|
49
|
+
name: { sortBy: "fileName", descending: !1 },
|
|
50
|
+
size: { sortBy: "fileSizeBytes", descending: !0 }
|
|
51
|
+
}, te = [{ icon: "grid_view" }, { icon: "view_list" }], j = s(te[0]), me = f(() => j.value.icon === "grid_view" ? "grid" : "list"), G = Fe(() => v.value);
|
|
52
|
+
async function b() {
|
|
53
|
+
if (B.value) {
|
|
54
|
+
x.value.length === 0 && (E.value = !0), L.value = !0;
|
|
55
|
+
try {
|
|
56
|
+
const [e, a, o] = await Promise.all([
|
|
57
|
+
Ee({
|
|
58
|
+
businessId: B.value,
|
|
59
|
+
restaurantId: y.value,
|
|
60
|
+
refType: F.value,
|
|
61
|
+
search: D.value || void 0,
|
|
62
|
+
tags: I.value.length ? I.value : void 0,
|
|
63
|
+
// AI-composed images are assets from the moment their bytes land — they have to be, or
|
|
64
|
+
// their URL could not render — so the library hides them until "save to the asset
|
|
65
|
+
// centre" removes this tag.
|
|
66
|
+
excludeTags: [Me],
|
|
67
|
+
skip: $e(p.value, Q),
|
|
68
|
+
limit: Q,
|
|
69
|
+
...ve[le.value]
|
|
70
|
+
}),
|
|
71
|
+
Le(B.value),
|
|
72
|
+
// Caught rather than left to reject the whole Promise.all: this endpoint is new, and
|
|
73
|
+
// a backend that hasn't deployed it yet must not be able to take the asset list down
|
|
74
|
+
// with it — the refType dropdown just stays empty (see the v-if on refTypeOptions)
|
|
75
|
+
// until the backend catches up.
|
|
76
|
+
je(B.value, y.value).catch(() => [])
|
|
77
|
+
]);
|
|
78
|
+
x.value = e.resources, M.value = e.meta.totalResources, $.value = e.meta.totalPages, V.value = a, Z.value = o, await G.load(
|
|
79
|
+
e.resources.filter((u) => !Ge(u)).filter((u) => !!u.refId && !!u.refType).filter((u) => u.businessId === v.value).map((u) => ({ refType: u.refType, refId: u.refId }))
|
|
80
|
+
);
|
|
81
|
+
} finally {
|
|
82
|
+
E.value = !1, L.value = !1;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async function q() {
|
|
87
|
+
p.value = 1, z(), await b();
|
|
88
|
+
}
|
|
89
|
+
async function H() {
|
|
90
|
+
await b();
|
|
91
|
+
const e = qe(p.value, $.value);
|
|
92
|
+
e !== p.value && (p.value = e, await b());
|
|
93
|
+
}
|
|
94
|
+
async function pe(e) {
|
|
95
|
+
var a;
|
|
96
|
+
e !== p.value && (p.value = e, z(), (a = ae.value) == null || a.scrollIntoView({ block: "start" }), await b());
|
|
97
|
+
}
|
|
98
|
+
Se(b), O(B, q), O([I, le, y, F], q);
|
|
99
|
+
let se;
|
|
100
|
+
O(D, () => {
|
|
101
|
+
clearTimeout(se), se = setTimeout(q, 250);
|
|
102
|
+
});
|
|
103
|
+
const i = s(/* @__PURE__ */ new Set());
|
|
104
|
+
function fe(e) {
|
|
105
|
+
const a = new Set(i.value);
|
|
106
|
+
a.has(e.id) ? a.delete(e.id) : a.add(e.id), i.value = a;
|
|
107
|
+
}
|
|
108
|
+
function z() {
|
|
109
|
+
i.value = /* @__PURE__ */ new Set();
|
|
110
|
+
}
|
|
111
|
+
function ye() {
|
|
112
|
+
i.value = new Set(x.value.map((e) => e.id));
|
|
113
|
+
}
|
|
114
|
+
function be() {
|
|
115
|
+
const e = i.value.size;
|
|
116
|
+
R.open({
|
|
117
|
+
title: l("media.library.deleteBulkTitle"),
|
|
118
|
+
message: l("media.library.deleteBulkMessage", { count: e, disclaimer: l("media.library.deleteDisclaimer") }),
|
|
119
|
+
primaryActions: { text: l("media.library.deleteConfirmButton"), close: !1, variant: "destructive" },
|
|
120
|
+
secondaryActions: { text: l("media.library.cancelButton"), close: !0 }
|
|
121
|
+
}).onPrimary(async () => {
|
|
122
|
+
await Promise.all(
|
|
123
|
+
[...i.value].map((a) => {
|
|
124
|
+
const o = x.value.find((u) => u.id === a);
|
|
125
|
+
return o ? re(o.businessId, o) : Promise.resolve();
|
|
126
|
+
})
|
|
127
|
+
), z(), await H(), R.close();
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function ge(e) {
|
|
131
|
+
R.open({
|
|
132
|
+
title: l("media.library.deleteOneTitle"),
|
|
133
|
+
message: l("media.library.deleteOneMessage", { fileName: e.fileName, disclaimer: l("media.library.deleteDisclaimer") }),
|
|
134
|
+
primaryActions: { text: l("media.library.deleteConfirmButton"), close: !1, variant: "destructive" },
|
|
135
|
+
secondaryActions: { text: l("media.library.cancelButton"), close: !0 }
|
|
136
|
+
}).onPrimary(async () => {
|
|
137
|
+
await re(e.businessId, e);
|
|
138
|
+
const a = new Set(i.value);
|
|
139
|
+
a.delete(e.id), i.value = a, await H(), R.close();
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
const d = s(null), we = f(
|
|
143
|
+
() => {
|
|
144
|
+
var e;
|
|
145
|
+
return (e = d.value) != null && e.refId ? G.byRefId.value.get(d.value.refId) ?? null : null;
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
function he(e) {
|
|
149
|
+
d.value = e;
|
|
150
|
+
}
|
|
151
|
+
async function ne() {
|
|
152
|
+
await b(), d.value && (d.value = x.value.find((e) => {
|
|
153
|
+
var a;
|
|
154
|
+
return e.id === ((a = d.value) == null ? void 0 : a.id);
|
|
155
|
+
}) ?? null);
|
|
156
|
+
}
|
|
157
|
+
async function Be() {
|
|
158
|
+
d.value = null, await H();
|
|
159
|
+
}
|
|
160
|
+
const C = s(!1), g = s(null);
|
|
161
|
+
function xe() {
|
|
162
|
+
var e;
|
|
163
|
+
(e = g.value) == null || e.reset(), C.value = !0;
|
|
164
|
+
}
|
|
165
|
+
async function _e() {
|
|
166
|
+
var e;
|
|
167
|
+
(e = g.value) != null && e.stagedCount || (C.value = !1), await b();
|
|
168
|
+
}
|
|
169
|
+
return (e, a) => {
|
|
170
|
+
var ie;
|
|
171
|
+
const o = S("FmButton"), u = S("FmSearch"), J = S("FmSelect"), ke = S("FmButtonGroup"), Ie = S("FmDialog");
|
|
172
|
+
return m(), P("div", {
|
|
173
|
+
ref_key: "libraryRoot",
|
|
174
|
+
ref: ae,
|
|
175
|
+
class: "p-24 relative min-h-full"
|
|
176
|
+
}, [
|
|
177
|
+
c("div", Je, [
|
|
178
|
+
c("h1", Ke, T(t(l)("media.title")), 1),
|
|
179
|
+
c("div", Qe, [
|
|
180
|
+
U.value ? (m(), A(o, {
|
|
181
|
+
key: 0,
|
|
182
|
+
label: h.value ? t(l)("media.library.backToMyBusinessButton") : t(l)("media.library.viewAllBusinessesButton"),
|
|
183
|
+
"prepend-icon": "apps",
|
|
184
|
+
variant: "secondary",
|
|
185
|
+
onClick: ce
|
|
186
|
+
}, null, 8, ["label"])) : _("", !0),
|
|
187
|
+
r(o, {
|
|
188
|
+
label: t(l)("media.library.uploadButton"),
|
|
189
|
+
"prepend-icon": "add",
|
|
190
|
+
variant: "primary",
|
|
191
|
+
onClick: xe
|
|
192
|
+
}, null, 8, ["label"])
|
|
193
|
+
])
|
|
194
|
+
]),
|
|
195
|
+
c("div", We, [
|
|
196
|
+
c("div", Xe, [
|
|
197
|
+
r(u, {
|
|
198
|
+
modelValue: D.value,
|
|
199
|
+
"onUpdate:modelValue": a[0] || (a[0] = (n) => D.value = n),
|
|
200
|
+
placeholder: t(l)("media.library.searchPlaceholder"),
|
|
201
|
+
class: "max-w-[280px]"
|
|
202
|
+
}, null, 8, ["modelValue", "placeholder"]),
|
|
203
|
+
U.value && h.value ? (m(), A(J, {
|
|
204
|
+
key: 0,
|
|
205
|
+
modelValue: k.value,
|
|
206
|
+
"onUpdate:modelValue": a[1] || (a[1] = (n) => k.value = n),
|
|
207
|
+
items: N.value,
|
|
208
|
+
placeholder: t(l)("media.library.allBusinessesOption"),
|
|
209
|
+
searchable: "",
|
|
210
|
+
clearable: "",
|
|
211
|
+
"on-search": X,
|
|
212
|
+
class: "max-w-[240px]"
|
|
213
|
+
}, null, 8, ["modelValue", "items", "placeholder"])) : _("", !0),
|
|
214
|
+
Y.value.length && B.value === v.value ? (m(), A(J, {
|
|
215
|
+
key: 1,
|
|
216
|
+
modelValue: y.value,
|
|
217
|
+
"onUpdate:modelValue": a[2] || (a[2] = (n) => y.value = n),
|
|
218
|
+
items: Y.value,
|
|
219
|
+
placeholder: t(l)("media.library.allRestaurantsOption"),
|
|
220
|
+
searchable: "",
|
|
221
|
+
clearable: "",
|
|
222
|
+
class: "max-w-[240px]"
|
|
223
|
+
}, null, 8, ["modelValue", "items", "placeholder"])) : _("", !0),
|
|
224
|
+
ee.value.length ? (m(), A(J, {
|
|
225
|
+
key: 2,
|
|
226
|
+
modelValue: F.value,
|
|
227
|
+
"onUpdate:modelValue": a[3] || (a[3] = (n) => F.value = n),
|
|
228
|
+
items: ee.value,
|
|
229
|
+
placeholder: t(l)("media.library.allRefTypesOption"),
|
|
230
|
+
searchable: "",
|
|
231
|
+
clearable: "",
|
|
232
|
+
class: "max-w-[240px]"
|
|
233
|
+
}, null, 8, ["modelValue", "items", "placeholder"])) : _("", !0)
|
|
234
|
+
]),
|
|
235
|
+
V.value.length ? (m(), A(t(ze), {
|
|
236
|
+
key: 0,
|
|
237
|
+
modelValue: I.value,
|
|
238
|
+
"onUpdate:modelValue": a[4] || (a[4] = (n) => I.value = n),
|
|
239
|
+
tags: V.value
|
|
240
|
+
}, null, 8, ["modelValue", "tags"])) : _("", !0),
|
|
241
|
+
c("div", Ye, [
|
|
242
|
+
c("div", Ze, [
|
|
243
|
+
i.value.size > 0 ? (m(), P("span", ea, T(t(l)("media.library.selectedCount", { count: i.value.size })), 1)) : (m(), P("span", aa, T(t(l)("media.library.totalSummary", { count: M.value })), 1))
|
|
244
|
+
]),
|
|
245
|
+
r(o, {
|
|
246
|
+
label: t(l)("media.library.selectAllButton"),
|
|
247
|
+
variant: "tertiary",
|
|
248
|
+
size: "md",
|
|
249
|
+
onClick: ye
|
|
250
|
+
}, null, 8, ["label"]),
|
|
251
|
+
r(ke, {
|
|
252
|
+
modelValue: j.value,
|
|
253
|
+
"onUpdate:modelValue": a[5] || (a[5] = (n) => j.value = n),
|
|
254
|
+
items: te
|
|
255
|
+
}, null, 8, ["modelValue"])
|
|
256
|
+
])
|
|
257
|
+
]),
|
|
258
|
+
r(t(Oe), {
|
|
259
|
+
assets: x.value,
|
|
260
|
+
loading: E.value,
|
|
261
|
+
view: me.value,
|
|
262
|
+
selectable: "",
|
|
263
|
+
"selected-ids": i.value,
|
|
264
|
+
"variants-by-ref-id": t(G).byRefId.value,
|
|
265
|
+
onOpen: he,
|
|
266
|
+
onToggle: fe,
|
|
267
|
+
onDelete: ge
|
|
268
|
+
}, null, 8, ["assets", "loading", "view", "selected-ids", "variants-by-ref-id"]),
|
|
269
|
+
r(t(Pe), {
|
|
270
|
+
page: p.value,
|
|
271
|
+
"page-size": t(Q),
|
|
272
|
+
"total-resources": M.value,
|
|
273
|
+
"total-pages": $.value,
|
|
274
|
+
disabled: L.value,
|
|
275
|
+
"onUpdate:page": pe
|
|
276
|
+
}, null, 8, ["page", "page-size", "total-resources", "total-pages", "disabled"]),
|
|
277
|
+
i.value.size > 0 ? (m(), P("div", la, [
|
|
278
|
+
c("span", ta, T(t(l)("media.library.selectedCount", { count: i.value.size })), 1),
|
|
279
|
+
r(o, {
|
|
280
|
+
label: t(l)("media.library.cancelButton"),
|
|
281
|
+
variant: "tertiary",
|
|
282
|
+
size: "md",
|
|
283
|
+
onClick: z
|
|
284
|
+
}, null, 8, ["label"]),
|
|
285
|
+
r(o, {
|
|
286
|
+
label: t(l)("media.library.deleteSelectedButton"),
|
|
287
|
+
variant: "destructive",
|
|
288
|
+
size: "md",
|
|
289
|
+
"prepend-icon": "delete",
|
|
290
|
+
onClick: be
|
|
291
|
+
}, null, 8, ["label"])
|
|
292
|
+
])) : _("", !0),
|
|
293
|
+
r(t(Ue), {
|
|
294
|
+
asset: d.value,
|
|
295
|
+
image: we.value,
|
|
296
|
+
"business-id": ((ie = d.value) == null ? void 0 : ie.businessId) ?? v.value,
|
|
297
|
+
onClose: a[6] || (a[6] = (n) => d.value = null),
|
|
298
|
+
onRenamed: ne,
|
|
299
|
+
onDeleted: Be,
|
|
300
|
+
onChanged: ne
|
|
301
|
+
}, null, 8, ["asset", "image", "business-id"]),
|
|
302
|
+
r(Ie, {
|
|
303
|
+
modelValue: C.value,
|
|
304
|
+
"onUpdate:modelValue": a[10] || (a[10] = (n) => C.value = n),
|
|
305
|
+
"max-width": 480
|
|
306
|
+
}, {
|
|
307
|
+
"dialog-header": K(() => [
|
|
308
|
+
c("div", null, T(t(l)("media.library.uploadDialogTitle")), 1)
|
|
309
|
+
]),
|
|
310
|
+
"dialog-footer": K(() => {
|
|
311
|
+
var n, oe;
|
|
312
|
+
return [
|
|
313
|
+
c("div", sa, [
|
|
314
|
+
r(o, {
|
|
315
|
+
label: t(l)("media.library.cancelButton"),
|
|
316
|
+
variant: "tertiary",
|
|
317
|
+
onClick: a[8] || (a[8] = (Ve) => C.value = !1)
|
|
318
|
+
}, null, 8, ["label"]),
|
|
319
|
+
r(o, {
|
|
320
|
+
label: t(l)("media.library.uploadSubmitButton", { count: ((n = g.value) == null ? void 0 : n.stagedCount) ?? 0 }),
|
|
321
|
+
variant: "primary",
|
|
322
|
+
disabled: !((oe = g.value) != null && oe.stagedCount) || g.value.uploading,
|
|
323
|
+
onClick: a[9] || (a[9] = (Ve) => {
|
|
324
|
+
var ue;
|
|
325
|
+
return (ue = g.value) == null ? void 0 : ue.upload();
|
|
326
|
+
})
|
|
327
|
+
}, null, 8, ["label", "disabled"])
|
|
328
|
+
])
|
|
329
|
+
];
|
|
330
|
+
}),
|
|
331
|
+
default: K(() => [
|
|
332
|
+
r(t(Ne), {
|
|
333
|
+
ref_key: "uploadPanelRef",
|
|
334
|
+
ref: g,
|
|
335
|
+
"business-id": v.value,
|
|
336
|
+
"restaurant-id": de.value,
|
|
337
|
+
"available-tags": V.value,
|
|
338
|
+
onTagCreated: a[7] || (a[7] = (n) => V.value.push(n)),
|
|
339
|
+
onUploaded: _e
|
|
340
|
+
}, null, 8, ["business-id", "restaurant-id", "available-tags"])
|
|
341
|
+
]),
|
|
342
|
+
_: 1
|
|
343
|
+
}, 8, ["modelValue"])
|
|
344
|
+
], 512);
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
export {
|
|
349
|
+
da as default
|
|
350
|
+
};
|