@webx-ui/module-catalog 0.1.0
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/LICENSE +21 -0
- package/README.md +57 -0
- package/dist/BulkBar.d.ts +20 -0
- package/dist/BulkParamsDialog.d.ts +12 -0
- package/dist/CategoriesPage.d.ts +23 -0
- package/dist/CategoryCreateDialog.d.ts +14 -0
- package/dist/CategoryEditorPage.d.ts +7 -0
- package/dist/CategoryField.d.ts +14 -0
- package/dist/DeletedPage.d.ts +19 -0
- package/dist/FacetsField.d.ts +10 -0
- package/dist/GalleryField.d.ts +2 -0
- package/dist/ProductCreateDialog.d.ts +4 -0
- package/dist/ProductEditorPage.d.ts +7 -0
- package/dist/ProductsPage.d.ts +20 -0
- package/dist/api.d.ts +59 -0
- package/dist/editor.d.ts +41 -0
- package/dist/errors.d.ts +6 -0
- package/dist/filters.d.ts +18 -0
- package/dist/i18n.d.ts +2 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +2908 -0
- package/dist/index.js.map +1 -0
- package/dist/messages.d.ts +11 -0
- package/dist/module.d.ts +22 -0
- package/dist/paths.d.ts +6 -0
- package/dist/store.d.ts +29 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +270 -0
- package/package.json +66 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2908 @@
|
|
|
1
|
+
import { computed as h, ref as D, defineComponent as le, useTemplateRef as Me, onMounted as ie, nextTick as ct, openBlock as v, createBlock as V, unref as e, isRef as je, withCtx as o, createVNode as k, createElementVNode as G, withKeys as Ke, createTextVNode as P, toDisplayString as _, resolveComponent as Ht, createElementBlock as B, withModifiers as dt, createCommentVNode as M, normalizeClass as Ge, provide as pt, inject as vt, watch as we, onBeforeUnmount as Te, Fragment as ee, renderList as ke, useModel as gt, mergeProps as Jt, mergeModels as Xt, reactive as Qt, createSlots as Yt } from "vue";
|
|
2
|
+
import { useRouter as $e, useRoute as ze, onBeforeRouteLeave as mt } from "vue-router";
|
|
3
|
+
import { readCookie as Zt, useAdmin as ae, useTranslate as te, useErrorText as me, rowMenuWidth as Ae, WxListScreen as He, WxRowMenu as Je, provideHistorySubject as yt, provideRecordAddress as ft, useBodyKeys as ht, WxScreenHead as bt, WxScreen as kt, WxSaveState as _t, useRecordAddress as ea, WxDate as wt, WxFilterChips as ta } from "@webx-ui/module-admin";
|
|
4
|
+
import { useModal as Xe, useLocales as Ue, WxDialog as Qe, WxFormItem as de, WxInput as he, WxTreeSelect as De, WxSpace as Ye, WxButton as Q, createModal as Ze, WxTable as et, WxBadge as Y, WxText as J, toast as E, confirm as ge, localizedValue as xt, WxSkeleton as xe, WxCard as $t, WxBreadcrumb as Ct, WxBreadcrumbItem as be, WxActionBar as St, WxAlert as We, WxSwitch as Ie, WxSortableList as Pt, WxAction as aa, WxUpload as la, WxSelect as Re, WxDropdown as na, WxDropdownItem as oa, WxIcon as Be, WxProgress as sa, useElementWidth as ra, WxEntityCard as ua, WxTooltip as ia, WxInputNumber as ot } from "@webx-ui/core";
|
|
5
|
+
const ca = "catalog";
|
|
6
|
+
function da(n) {
|
|
7
|
+
const t = new URLSearchParams();
|
|
8
|
+
n.q && t.set("q", n.q), n.state && t.set("state", n.state), n.sort && n.sort !== "default" && t.set("sort", n.sort), n.page && n.page > 1 && t.set("page", String(n.page)), n.per_page && t.set("per_page", String(n.per_page));
|
|
9
|
+
for (const [i, f] of Object.entries(n.facets ?? {}))
|
|
10
|
+
if (f === !0)
|
|
11
|
+
t.set(`facets[${i}][]`, "1");
|
|
12
|
+
else if (Array.isArray(f))
|
|
13
|
+
for (const l of f) t.append(`facets[${i}][]`, String(l));
|
|
14
|
+
else
|
|
15
|
+
f.min != null && t.set(`facets[${i}][min]`, String(f.min)), f.max != null && t.set(`facets[${i}][max]`, String(f.max));
|
|
16
|
+
return t;
|
|
17
|
+
}
|
|
18
|
+
function pa(n, t, i, f) {
|
|
19
|
+
const l = new FormData();
|
|
20
|
+
return l.append("file", i), new Promise((m, r) => {
|
|
21
|
+
const s = new XMLHttpRequest();
|
|
22
|
+
s.open("POST", t), s.responseType = "json", s.withCredentials = !0, s.setRequestHeader("Accept", "application/json"), s.setRequestHeader("X-Requested-With", "XMLHttpRequest"), s.setRequestHeader("X-Webx-Locale", n.i18n.state.locale);
|
|
23
|
+
const a = Zt("XSRF-TOKEN");
|
|
24
|
+
a && s.setRequestHeader("X-XSRF-TOKEN", a), s.upload.addEventListener("progress", (w) => {
|
|
25
|
+
w.lengthComputable && f?.(Math.round(w.loaded / w.total * 100));
|
|
26
|
+
}), s.addEventListener("load", () => {
|
|
27
|
+
const w = s.response;
|
|
28
|
+
if (s.status >= 200 && s.status < 300 && w?.data) {
|
|
29
|
+
m(w.data);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
r(
|
|
33
|
+
Object.assign(new Error(w?.message ?? "Upload failed"), {
|
|
34
|
+
status: s.status,
|
|
35
|
+
body: w
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
}), s.addEventListener("error", () => r(new Error("Upload failed"))), s.send(l);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function ne(n) {
|
|
42
|
+
const t = `${n.apiPath}/${ca}`, i = (l) => l.data, f = (l, m) => m.size > 0 ? `${l}?${m}` : l;
|
|
43
|
+
return {
|
|
44
|
+
products: (l = {}) => n.http.get(f(`${t}/products`, da(l))),
|
|
45
|
+
product: (l) => n.http.get(`${t}/products/${l}`).then(i),
|
|
46
|
+
createProduct: (l) => n.http.post(`${t}/products`, { values: l }).then(i),
|
|
47
|
+
saveProduct: (l, m) => n.http.put(`${t}/products/${l}`, { values: m }).then(i),
|
|
48
|
+
removeProduct: (l) => n.http.delete(`${t}/products/${l}`).then(() => {
|
|
49
|
+
}),
|
|
50
|
+
restoreProduct: (l) => n.http.post(`${t}/products/${l}/restore`, {}).then(i),
|
|
51
|
+
addImage: (l, m, r) => typeof m == "string" ? n.http.post(`${t}/products/${l}/images`, { url: m }).then(i) : pa(n, `${t}/products/${l}/images`, m, r),
|
|
52
|
+
saveImages: (l, m) => n.http.put(`${t}/products/${l}/images`, {
|
|
53
|
+
images: m.map(({ id: r, alt: s, title: a }) => ({ id: r, alt: s, title: a }))
|
|
54
|
+
}).then(i),
|
|
55
|
+
removeImage: (l, m) => n.http.delete(`${t}/products/${l}/images/${m}`).then(() => {
|
|
56
|
+
}),
|
|
57
|
+
categories: () => n.http.get(`${t}/categories`).then(i),
|
|
58
|
+
category: (l) => n.http.get(`${t}/categories/${l}`).then(i),
|
|
59
|
+
createCategory: (l, m) => n.http.post(`${t}/categories`, { values: l, parent_id: m }).then(i),
|
|
60
|
+
saveCategory: (l, m) => n.http.put(`${t}/categories/${l}`, { values: m }).then(i),
|
|
61
|
+
moveCategory: (l, m, r) => n.http.post(`${t}/categories/${l}/move`, {
|
|
62
|
+
parent_id: m,
|
|
63
|
+
before_id: r
|
|
64
|
+
}).then(i),
|
|
65
|
+
removeCategory: (l) => n.http.delete(`${t}/categories/${l}`).then(() => {
|
|
66
|
+
}),
|
|
67
|
+
restoreCategory: (l) => n.http.post(`${t}/categories/${l}/restore`, {}).then(i),
|
|
68
|
+
facets: () => n.http.get(`${t}/facets`).then((l) => ({ facets: l.data, sorts: l.meta?.sorts ?? [] })),
|
|
69
|
+
bulkActions: () => n.http.get(`${t}/bulk`).then(i),
|
|
70
|
+
startBulk: (l, m, r) => n.http.post(`${t}/bulk`, { action: l, params: m, selection: r }).then(i),
|
|
71
|
+
bulkRun: (l) => n.http.get(`${t}/bulk/${l}`).then(i),
|
|
72
|
+
deleted: ((l, m = {}) => {
|
|
73
|
+
const r = new URLSearchParams({ type: l });
|
|
74
|
+
return m.q && r.set("q", m.q), m.page && m.page > 1 && r.set("page", String(m.page)), m.per_page && r.set("per_page", String(m.per_page)), n.http.get(`${t}/deleted?${r}`);
|
|
75
|
+
})
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function _e(n, t) {
|
|
79
|
+
const i = n[t]?.[0];
|
|
80
|
+
if (i !== void 0) return i;
|
|
81
|
+
const f = Object.keys(n).find((l) => l.startsWith(`${t}.`));
|
|
82
|
+
return f === void 0 ? void 0 : n[f]?.[0];
|
|
83
|
+
}
|
|
84
|
+
const va = {
|
|
85
|
+
module: {
|
|
86
|
+
title: "Catalog",
|
|
87
|
+
group: "Catalog",
|
|
88
|
+
products: "Products",
|
|
89
|
+
categories: "Categories",
|
|
90
|
+
deleted: "Deleted",
|
|
91
|
+
product: "Product",
|
|
92
|
+
category: "Category"
|
|
93
|
+
},
|
|
94
|
+
states: {
|
|
95
|
+
published: "Published",
|
|
96
|
+
unpublished: "Unpublished",
|
|
97
|
+
deleted: "Deleted"
|
|
98
|
+
},
|
|
99
|
+
product: {
|
|
100
|
+
name: "Name",
|
|
101
|
+
slug: "Address",
|
|
102
|
+
sku: "Article number",
|
|
103
|
+
barcode: "Barcode",
|
|
104
|
+
summary: "Summary",
|
|
105
|
+
description: "Description",
|
|
106
|
+
category_id: "Main category",
|
|
107
|
+
category: "Main category",
|
|
108
|
+
categories: "Additional categories",
|
|
109
|
+
price: "Price",
|
|
110
|
+
old_price: "Old price",
|
|
111
|
+
unit: "Unit",
|
|
112
|
+
priority: "Priority",
|
|
113
|
+
is_published: "Published",
|
|
114
|
+
images: "Pictures",
|
|
115
|
+
"no-category": "No category"
|
|
116
|
+
},
|
|
117
|
+
category: {
|
|
118
|
+
name: "Name",
|
|
119
|
+
slug: "Address",
|
|
120
|
+
description: "Text",
|
|
121
|
+
cover: "Picture",
|
|
122
|
+
cover_id: "Picture",
|
|
123
|
+
is_published: "Published",
|
|
124
|
+
parent: "Parent category",
|
|
125
|
+
facets: "Filters"
|
|
126
|
+
},
|
|
127
|
+
units: {
|
|
128
|
+
pcs: "pcs",
|
|
129
|
+
kg: "kg",
|
|
130
|
+
g: "g",
|
|
131
|
+
m: "m",
|
|
132
|
+
m2: "m²",
|
|
133
|
+
m3: "m³",
|
|
134
|
+
l: "l",
|
|
135
|
+
pack: "pack",
|
|
136
|
+
set: "set"
|
|
137
|
+
},
|
|
138
|
+
panel: {
|
|
139
|
+
create: "Create",
|
|
140
|
+
cancel: "Cancel",
|
|
141
|
+
save: "Save",
|
|
142
|
+
saved: "Saved.",
|
|
143
|
+
"save-failed": "Not saved: what is wrong is said under the fields in red.",
|
|
144
|
+
untitled: "Untitled",
|
|
145
|
+
open: "Open",
|
|
146
|
+
"open-on-site": "Open on the site",
|
|
147
|
+
publish: "Publish",
|
|
148
|
+
unpublish: "Take off the site",
|
|
149
|
+
delete: "Delete",
|
|
150
|
+
restore: "Restore",
|
|
151
|
+
"leave-title": "Leave without saving?",
|
|
152
|
+
"leave-text": "What you changed is not on the server.",
|
|
153
|
+
leave: "Leave",
|
|
154
|
+
"address-moving": "The address is changing. The old one keeps working and leads to the new one.",
|
|
155
|
+
"new-product": "New product",
|
|
156
|
+
"search-products": "Search by name or article number",
|
|
157
|
+
"empty-products": "No products yet.",
|
|
158
|
+
"empty-products-help": "A product lives in one main category and any number of others.",
|
|
159
|
+
"empty-search": "Nothing matches that.",
|
|
160
|
+
"view-all": "All",
|
|
161
|
+
"view-published": "Published",
|
|
162
|
+
"view-unpublished": "Unpublished",
|
|
163
|
+
"view-no-category": "No category",
|
|
164
|
+
"column-product": "Product",
|
|
165
|
+
"column-state": "State",
|
|
166
|
+
"column-updated": "Changed",
|
|
167
|
+
invisible: "Published, but no category of it is on the site, so nobody sees it.",
|
|
168
|
+
sort: "Order",
|
|
169
|
+
"sort-default": "By priority, then newest",
|
|
170
|
+
"range-from": "From",
|
|
171
|
+
"range-to": "To",
|
|
172
|
+
any: "Any",
|
|
173
|
+
selected: "Selected: :count",
|
|
174
|
+
"select-clear": "Clear the selection",
|
|
175
|
+
"bulk-actions": "Actions",
|
|
176
|
+
"select-all-found": "Select everything found: :count",
|
|
177
|
+
"selected-all": "Selected everything found: :count",
|
|
178
|
+
"bulk-apply": "Apply",
|
|
179
|
+
"bulk-confirm-title": "Apply «:action»?",
|
|
180
|
+
"bulk-confirm-text": "Products it applies to: :count",
|
|
181
|
+
"bulk-running": "Running in the background. Done :done of :total",
|
|
182
|
+
"bulk-done": "Done. Products: :count",
|
|
183
|
+
"bulk-refused": "Refused: :count",
|
|
184
|
+
"bulk-stopped": "The run stopped. Done so far: :count",
|
|
185
|
+
"bulk-errors": "What was refused",
|
|
186
|
+
"bulk-close": "Close",
|
|
187
|
+
"bulk-nothing": "None of the selected products fit this action.",
|
|
188
|
+
"product-trail": "Where this product sits",
|
|
189
|
+
"delete-product-title": "Delete “:name”?",
|
|
190
|
+
"delete-product-text": "It goes to «Deleted» and comes off the site. Its address leads to its category from then on.",
|
|
191
|
+
"product-deleted": "The product is in «Deleted».",
|
|
192
|
+
"product-restored": "The product is back.",
|
|
193
|
+
"product-restored-bare": "The product is back without a category and unpublished: its category is deleted.",
|
|
194
|
+
"product-published": "The product is on the site.",
|
|
195
|
+
"product-unpublished": "The product is off the site.",
|
|
196
|
+
"sku-open": "Open that product",
|
|
197
|
+
"sku-open-deleted": "Find it in «Deleted»",
|
|
198
|
+
"gallery-add": "Add pictures",
|
|
199
|
+
"gallery-hint": "JPEG, PNG, WebP or GIF. The first picture is the main one.",
|
|
200
|
+
"gallery-url": "Or by address",
|
|
201
|
+
"gallery-url-add": "Fetch",
|
|
202
|
+
"gallery-empty": "No pictures yet.",
|
|
203
|
+
"gallery-main": "Main",
|
|
204
|
+
"gallery-alt": "Alternative text",
|
|
205
|
+
"gallery-alt-help": "What the picture shows, for search engines and screen readers.",
|
|
206
|
+
"gallery-title": "Title",
|
|
207
|
+
"gallery-order": "Drag to change the order. The first picture is the main one.",
|
|
208
|
+
"gallery-failed": "The picture was not added.",
|
|
209
|
+
"gallery-remove-title": "Delete this picture?",
|
|
210
|
+
"gallery-remove-text": "The file is deleted from the disk at once.",
|
|
211
|
+
"gallery-removed": "The picture is deleted.",
|
|
212
|
+
"gallery-reorder-failed": "The new order was not saved.",
|
|
213
|
+
"gallery-captions-failed": "The captions were not saved.",
|
|
214
|
+
"gallery-locked": "Pictures are added to a product you may edit.",
|
|
215
|
+
"new-category": "New category",
|
|
216
|
+
"add-child": "Add a subcategory",
|
|
217
|
+
"search-categories": "Search by name or address",
|
|
218
|
+
"empty-categories": "No categories yet.",
|
|
219
|
+
"empty-categories-help": "Categories are the shelves of the catalogue; each has an address of its own at the root of the site.",
|
|
220
|
+
"column-products": "Products",
|
|
221
|
+
"category-hidden": "Hidden: a category above it is unpublished.",
|
|
222
|
+
"category-order": "Drag to move a category. Its address stays the same.",
|
|
223
|
+
"category-moved": "The category is moved.",
|
|
224
|
+
"category-trail": "Where this category sits",
|
|
225
|
+
"field-parent": "Inside",
|
|
226
|
+
"parent-root": "At the top level",
|
|
227
|
+
"show-products": "Show its products",
|
|
228
|
+
"delete-category-title": "Delete “:name”?",
|
|
229
|
+
"delete-category-text": "It goes to «Deleted», and its address answers that it is gone.",
|
|
230
|
+
"category-deleted": "The category is in «Deleted».",
|
|
231
|
+
"category-restored": "The category is back.",
|
|
232
|
+
"category-published": "The category is on the site.",
|
|
233
|
+
"category-unpublished": "The category and everything under it is off the site.",
|
|
234
|
+
"pick-category": "Choose a category",
|
|
235
|
+
"pick-categories": "Choose categories",
|
|
236
|
+
"category-gone": "deleted",
|
|
237
|
+
"facets-own": "Own setting",
|
|
238
|
+
"facets-own-help": "Which filters this category shows, and in which order.",
|
|
239
|
+
"facets-inherited": "As in “:name”",
|
|
240
|
+
"facets-default": "All filters, in their default order",
|
|
241
|
+
"facets-inherited-help": "Switch it on to choose for this category. Categories under it take the setting unless they have their own.",
|
|
242
|
+
"facets-empty": "No filters are installed.",
|
|
243
|
+
"facets-failed": "The list of filters did not load.",
|
|
244
|
+
"facets-shown": "Shown",
|
|
245
|
+
"facets-unknown": "Its module is not installed",
|
|
246
|
+
"deleted-search": "Search by name",
|
|
247
|
+
"deleted-empty": "Nothing is deleted.",
|
|
248
|
+
"deleted-help": "A deleted product keeps its pictures and comes back under its old address.",
|
|
249
|
+
"column-deleted": "Deleted",
|
|
250
|
+
"column-parent": "Was inside",
|
|
251
|
+
"restore-bare": "Comes back without a category"
|
|
252
|
+
}
|
|
253
|
+
}, st = /* @__PURE__ */ new WeakSet();
|
|
254
|
+
function oe() {
|
|
255
|
+
try {
|
|
256
|
+
const { i18n: n } = ae();
|
|
257
|
+
st.has(n) || (n.defaults("webx-catalog", va), st.add(n));
|
|
258
|
+
} catch {
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
const rt = /* @__PURE__ */ new WeakMap();
|
|
262
|
+
function At(n) {
|
|
263
|
+
let t = rt.get(n);
|
|
264
|
+
return t || (t = {
|
|
265
|
+
tree: { value: D(null), pending: null },
|
|
266
|
+
facets: { value: D(null), pending: null }
|
|
267
|
+
}, rt.set(n, t)), t;
|
|
268
|
+
}
|
|
269
|
+
function Wt(n, t, i) {
|
|
270
|
+
if (!i && n.value.value !== null) return Promise.resolve(n.value.value);
|
|
271
|
+
if (!i && n.pending) return n.pending;
|
|
272
|
+
const f = t().then((l) => (n.pending === f && (n.value.value = l), l)).finally(() => {
|
|
273
|
+
n.pending === f && (n.pending = null);
|
|
274
|
+
});
|
|
275
|
+
return n.pending = f, f;
|
|
276
|
+
}
|
|
277
|
+
function ye(n) {
|
|
278
|
+
const t = At(n).tree, i = ne(n);
|
|
279
|
+
return {
|
|
280
|
+
nodes: t.value,
|
|
281
|
+
load: (f = !1) => Wt(t, () => i.categories(), f),
|
|
282
|
+
take: (f) => {
|
|
283
|
+
t.pending = null, t.value.value = f;
|
|
284
|
+
},
|
|
285
|
+
drop: () => {
|
|
286
|
+
t.pending = null, t.value.value = null;
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function Vt(n) {
|
|
291
|
+
const t = At(n).facets, i = ne(n);
|
|
292
|
+
return {
|
|
293
|
+
facets: h(() => t.value.value?.facets ?? null),
|
|
294
|
+
sorts: h(() => t.value.value?.sorts ?? []),
|
|
295
|
+
load: () => Wt(
|
|
296
|
+
t,
|
|
297
|
+
() => i.facets().then((f) => ({
|
|
298
|
+
sorts: f.sorts,
|
|
299
|
+
facets: f.facets.map((l) => ({
|
|
300
|
+
...l,
|
|
301
|
+
kind: String(l.kind).toLowerCase()
|
|
302
|
+
}))
|
|
303
|
+
})),
|
|
304
|
+
!1
|
|
305
|
+
)
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function qe(n) {
|
|
309
|
+
return n.flatMap((t) => [t, ...qe(t.children ?? [])]);
|
|
310
|
+
}
|
|
311
|
+
function ga(n, t) {
|
|
312
|
+
const i = new Map(qe(n).map((m) => [m.id, m])), f = [];
|
|
313
|
+
let l = i.get(t);
|
|
314
|
+
for (; l; )
|
|
315
|
+
f.push(l), l = l.parent_id === null ? void 0 : i.get(l.parent_id);
|
|
316
|
+
return f;
|
|
317
|
+
}
|
|
318
|
+
const ma = /* @__PURE__ */ le({
|
|
319
|
+
__name: "CategoryCreateDialog",
|
|
320
|
+
props: {
|
|
321
|
+
parent: { default: null }
|
|
322
|
+
},
|
|
323
|
+
setup(n) {
|
|
324
|
+
const t = n, { open: i, resolve: f, dismiss: l } = Xe(), m = ae(), r = ne(m), s = ye(m), a = Ue();
|
|
325
|
+
oe();
|
|
326
|
+
const w = te("webx-catalog"), b = D(""), y = D(t.parent), x = D(!1), C = D({}), A = Me("field"), S = h(() => s.nodes.value ?? []);
|
|
327
|
+
ie(async () => {
|
|
328
|
+
s.load().catch(() => {
|
|
329
|
+
}), await ct(), A.value?.querySelector("input")?.focus();
|
|
330
|
+
});
|
|
331
|
+
async function q() {
|
|
332
|
+
if (!(b.value.trim() === "" || x.value)) {
|
|
333
|
+
x.value = !0, C.value = {};
|
|
334
|
+
try {
|
|
335
|
+
const F = typeof y.value == "number" ? y.value : null;
|
|
336
|
+
f(
|
|
337
|
+
await r.createCategory(
|
|
338
|
+
{ name: { [a.active.value]: b.value.trim() }, is_published: !1 },
|
|
339
|
+
F
|
|
340
|
+
)
|
|
341
|
+
);
|
|
342
|
+
} catch (F) {
|
|
343
|
+
C.value = F.body?.errors ?? {};
|
|
344
|
+
} finally {
|
|
345
|
+
x.value = !1;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return (F, O) => (v(), V(e(Qe), {
|
|
350
|
+
open: e(i),
|
|
351
|
+
"onUpdate:open": O[3] || (O[3] = (L) => je(i) ? i.value = L : null),
|
|
352
|
+
title: e(w)("panel.new-category"),
|
|
353
|
+
width: 480
|
|
354
|
+
}, {
|
|
355
|
+
footer: o(() => [
|
|
356
|
+
k(e(Ye), { size: "sm" }, {
|
|
357
|
+
default: o(() => [
|
|
358
|
+
k(e(Q), {
|
|
359
|
+
variant: "outline",
|
|
360
|
+
onClick: O[2] || (O[2] = (L) => e(l)())
|
|
361
|
+
}, {
|
|
362
|
+
default: o(() => [
|
|
363
|
+
P(_(e(w)("panel.cancel")), 1)
|
|
364
|
+
]),
|
|
365
|
+
_: 1
|
|
366
|
+
}),
|
|
367
|
+
k(e(Q), {
|
|
368
|
+
type: "primary",
|
|
369
|
+
loading: x.value,
|
|
370
|
+
disabled: b.value.trim() === "",
|
|
371
|
+
onClick: q
|
|
372
|
+
}, {
|
|
373
|
+
default: o(() => [
|
|
374
|
+
P(_(e(w)("panel.create")), 1)
|
|
375
|
+
]),
|
|
376
|
+
_: 1
|
|
377
|
+
}, 8, ["loading", "disabled"])
|
|
378
|
+
]),
|
|
379
|
+
_: 1
|
|
380
|
+
})
|
|
381
|
+
]),
|
|
382
|
+
default: o(() => [
|
|
383
|
+
k(e(de), {
|
|
384
|
+
label: e(w)("category.name"),
|
|
385
|
+
error: e(_e)(C.value, "name") ?? e(_e)(C.value, "slug"),
|
|
386
|
+
required: ""
|
|
387
|
+
}, {
|
|
388
|
+
default: o(() => [
|
|
389
|
+
G("div", {
|
|
390
|
+
ref_key: "field",
|
|
391
|
+
ref: A
|
|
392
|
+
}, [
|
|
393
|
+
k(e(he), {
|
|
394
|
+
modelValue: b.value,
|
|
395
|
+
"onUpdate:modelValue": O[0] || (O[0] = (L) => b.value = L),
|
|
396
|
+
"aria-label": e(w)("category.name"),
|
|
397
|
+
onKeyup: Ke(q, ["enter"])
|
|
398
|
+
}, null, 8, ["modelValue", "aria-label"])
|
|
399
|
+
], 512)
|
|
400
|
+
]),
|
|
401
|
+
_: 1
|
|
402
|
+
}, 8, ["label", "error"]),
|
|
403
|
+
k(e(de), {
|
|
404
|
+
label: e(w)("panel.field-parent"),
|
|
405
|
+
error: e(_e)(C.value, "parent_id")
|
|
406
|
+
}, {
|
|
407
|
+
default: o(() => [
|
|
408
|
+
k(e(De), {
|
|
409
|
+
modelValue: y.value,
|
|
410
|
+
"onUpdate:modelValue": O[1] || (O[1] = (L) => y.value = L),
|
|
411
|
+
nodes: S.value,
|
|
412
|
+
"node-key": "id",
|
|
413
|
+
"label-key": "name",
|
|
414
|
+
"children-key": "children",
|
|
415
|
+
"show-path": "",
|
|
416
|
+
separator: " / ",
|
|
417
|
+
filterable: "",
|
|
418
|
+
clearable: "",
|
|
419
|
+
"default-expand-all": "",
|
|
420
|
+
teleport: "",
|
|
421
|
+
placeholder: e(w)("panel.parent-root")
|
|
422
|
+
}, null, 8, ["modelValue", "nodes", "placeholder"])
|
|
423
|
+
]),
|
|
424
|
+
_: 1
|
|
425
|
+
}, 8, ["label", "error"])
|
|
426
|
+
]),
|
|
427
|
+
_: 1
|
|
428
|
+
}, 8, ["open", "title"]));
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
function Ve(n) {
|
|
432
|
+
if (!n) return null;
|
|
433
|
+
let t;
|
|
434
|
+
try {
|
|
435
|
+
t = new URL(n, "http://panel.invalid").pathname;
|
|
436
|
+
} catch {
|
|
437
|
+
return null;
|
|
438
|
+
}
|
|
439
|
+
const i = t.split("/").filter((f) => f !== "");
|
|
440
|
+
return i.length > 0 ? decodeURIComponent(i[i.length - 1]) : null;
|
|
441
|
+
}
|
|
442
|
+
const ya = { class: "wx-catalog-categories" }, fa = /* @__PURE__ */ le({
|
|
443
|
+
__name: "CategoriesPage",
|
|
444
|
+
props: {
|
|
445
|
+
base: { default: "/catalog" }
|
|
446
|
+
},
|
|
447
|
+
setup(n) {
|
|
448
|
+
const t = n, i = ae(), f = ne(i), l = ye(i), m = $e();
|
|
449
|
+
oe();
|
|
450
|
+
const r = te("webx-catalog"), s = me(), a = D([]), w = D(!0), b = D(!1), y = D(""), x = Ze(ma), C = h(() => i.can("catalog.manage")), A = h(() => i.can("catalog.delete")), S = h(() => y.value.trim() === ""), q = h(() => {
|
|
451
|
+
const z = y.value.trim().toLowerCase();
|
|
452
|
+
return qe(a.value).filter(
|
|
453
|
+
(I) => I.name.toLowerCase().includes(z) || (I.slug ?? "").toLowerCase().includes(z)
|
|
454
|
+
).map((I) => ({ ...I, children: [] }));
|
|
455
|
+
}), F = h(() => S.value ? a.value : q.value), O = h(() => [
|
|
456
|
+
{ key: "name", label: r("category.name"), minWidth: 200 },
|
|
457
|
+
{ key: "slug", label: r("category.slug"), width: 200, hideBelow: 620 },
|
|
458
|
+
{ key: "products_count", label: r("panel.column-products"), width: 110, align: "right" },
|
|
459
|
+
{ key: "state", label: r("panel.column-state"), width: 150, hideBelow: 760 },
|
|
460
|
+
{ key: "actions", label: "", width: Ae, align: "right" }
|
|
461
|
+
]), L = h(
|
|
462
|
+
() => S.value ? {
|
|
463
|
+
childrenKey: "children",
|
|
464
|
+
defaultExpandAll: !0,
|
|
465
|
+
draggable: C.value,
|
|
466
|
+
allowDrop: (z, I) => z.id !== I.id
|
|
467
|
+
} : void 0
|
|
468
|
+
);
|
|
469
|
+
function U(z) {
|
|
470
|
+
a.value = z.map(N);
|
|
471
|
+
}
|
|
472
|
+
function N(z) {
|
|
473
|
+
return { ...z, children: (z.children ?? []).map(N) };
|
|
474
|
+
}
|
|
475
|
+
async function c(z = !0) {
|
|
476
|
+
w.value = !0;
|
|
477
|
+
try {
|
|
478
|
+
U(await l.load(z)), b.value = !0;
|
|
479
|
+
} catch (I) {
|
|
480
|
+
E.danger(s(I));
|
|
481
|
+
} finally {
|
|
482
|
+
w.value = !1;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
function g(z) {
|
|
486
|
+
y.value = z.search;
|
|
487
|
+
}
|
|
488
|
+
function p(z) {
|
|
489
|
+
m.push(`${t.base}/categories/${z.id}`);
|
|
490
|
+
}
|
|
491
|
+
async function j(z) {
|
|
492
|
+
const I = await x({ parent: z?.id ?? null });
|
|
493
|
+
I && (l.drop(), m.push(`${t.base}/categories/${I.category.id}`));
|
|
494
|
+
}
|
|
495
|
+
async function H(z) {
|
|
496
|
+
const I = z.parent?.id ?? null, T = (z.parent ? z.parent.children ?? [] : a.value)[z.index + 1]?.id ?? null;
|
|
497
|
+
try {
|
|
498
|
+
const $ = await f.moveCategory(z.row.id, I, T);
|
|
499
|
+
l.take($), U($), E.success(r("panel.category-moved"));
|
|
500
|
+
} catch ($) {
|
|
501
|
+
E.danger(s($)), await c();
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
async function se(z, I) {
|
|
505
|
+
try {
|
|
506
|
+
await f.saveCategory(z.id, { is_published: I }), E.success(r(I ? "panel.category-published" : "panel.category-unpublished")), await c();
|
|
507
|
+
} catch (Z) {
|
|
508
|
+
E.danger(s(Z));
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
async function X(z) {
|
|
512
|
+
if (await ge({
|
|
513
|
+
title: r("panel.delete-category-title", { name: z.name }),
|
|
514
|
+
message: r("panel.delete-category-text"),
|
|
515
|
+
confirmText: r("panel.delete"),
|
|
516
|
+
cancelText: r("panel.cancel"),
|
|
517
|
+
tone: "danger"
|
|
518
|
+
}))
|
|
519
|
+
try {
|
|
520
|
+
await f.removeCategory(z.id), E.success(r("panel.category-deleted")), await c();
|
|
521
|
+
} catch (Z) {
|
|
522
|
+
E.danger(s(Z));
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
function re(z) {
|
|
526
|
+
return { path: `${t.base}/products`, query: { "f.category": String(z.id) } };
|
|
527
|
+
}
|
|
528
|
+
function ue(z) {
|
|
529
|
+
const I = [
|
|
530
|
+
{ key: "open", icon: "edit", label: r("panel.open"), run: () => p(z) },
|
|
531
|
+
{
|
|
532
|
+
key: "products",
|
|
533
|
+
icon: "list",
|
|
534
|
+
label: r("panel.show-products"),
|
|
535
|
+
run: () => {
|
|
536
|
+
m.push(re(z));
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
];
|
|
540
|
+
return z.url && z.visible && I.push({ key: "site", icon: "link", label: r("panel.open-on-site"), href: z.url }), C.value && I.push(
|
|
541
|
+
{ key: "add", icon: "plus", label: r("panel.add-child"), run: () => {
|
|
542
|
+
j(z);
|
|
543
|
+
} },
|
|
544
|
+
z.is_published ? {
|
|
545
|
+
key: "unpublish",
|
|
546
|
+
icon: "eye-off",
|
|
547
|
+
label: r("panel.unpublish"),
|
|
548
|
+
run: () => {
|
|
549
|
+
se(z, !1);
|
|
550
|
+
}
|
|
551
|
+
} : {
|
|
552
|
+
key: "publish",
|
|
553
|
+
icon: "eye",
|
|
554
|
+
label: r("panel.publish"),
|
|
555
|
+
run: () => {
|
|
556
|
+
se(z, !0);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
), A.value && I.push({
|
|
560
|
+
key: "delete",
|
|
561
|
+
icon: "trash",
|
|
562
|
+
label: r("panel.delete"),
|
|
563
|
+
danger: !0,
|
|
564
|
+
run: () => {
|
|
565
|
+
X(z);
|
|
566
|
+
}
|
|
567
|
+
}), I;
|
|
568
|
+
}
|
|
569
|
+
ie(() => {
|
|
570
|
+
c(!1);
|
|
571
|
+
});
|
|
572
|
+
const ce = h(() => {
|
|
573
|
+
const z = [];
|
|
574
|
+
return C.value && z.push({
|
|
575
|
+
key: "new",
|
|
576
|
+
label: r("panel.new-category"),
|
|
577
|
+
icon: "plus",
|
|
578
|
+
primary: !0,
|
|
579
|
+
run: () => {
|
|
580
|
+
j(null);
|
|
581
|
+
}
|
|
582
|
+
}), A.value && z.push({
|
|
583
|
+
key: "deleted",
|
|
584
|
+
label: r("module.deleted"),
|
|
585
|
+
icon: "trash",
|
|
586
|
+
menu: !0,
|
|
587
|
+
run: () => {
|
|
588
|
+
m.push({ path: `${t.base}/deleted`, query: { type: "categories" } });
|
|
589
|
+
}
|
|
590
|
+
}), z;
|
|
591
|
+
});
|
|
592
|
+
return (z, I) => {
|
|
593
|
+
const Z = Ht("router-link");
|
|
594
|
+
return v(), B("div", ya, [
|
|
595
|
+
k(e(He), {
|
|
596
|
+
title: e(r)("module.categories"),
|
|
597
|
+
subtitle: C.value && a.value.length > 0 ? e(r)("panel.category-order") : void 0,
|
|
598
|
+
back: `${t.base}/products`,
|
|
599
|
+
"back-label": e(r)("module.products"),
|
|
600
|
+
actions: ce.value
|
|
601
|
+
}, {
|
|
602
|
+
default: o(() => [
|
|
603
|
+
(v(), V(e(et), {
|
|
604
|
+
key: b.value ? "tree" : "waiting",
|
|
605
|
+
data: F.value,
|
|
606
|
+
columns: O.value,
|
|
607
|
+
"row-key": "id",
|
|
608
|
+
tree: L.value,
|
|
609
|
+
searchable: "",
|
|
610
|
+
clickable: "",
|
|
611
|
+
hover: "",
|
|
612
|
+
flush: "",
|
|
613
|
+
layout: "fixed",
|
|
614
|
+
loading: w.value,
|
|
615
|
+
"cards-below": 0,
|
|
616
|
+
"search-placeholder": e(r)("panel.search-categories"),
|
|
617
|
+
"empty-text": y.value ? e(r)("panel.empty-search") : e(r)("panel.empty-categories"),
|
|
618
|
+
"aria-label": e(r)("module.categories"),
|
|
619
|
+
onRowClick: p,
|
|
620
|
+
onStateChange: g,
|
|
621
|
+
onNodeDrop: H
|
|
622
|
+
}, {
|
|
623
|
+
"cell-name": o(({ row: T }) => [
|
|
624
|
+
G("span", {
|
|
625
|
+
class: Ge(["wx-catalog-categories__name", { "is-hidden": !T.visible }])
|
|
626
|
+
}, _(T.name), 3)
|
|
627
|
+
]),
|
|
628
|
+
"cell-slug": o(({ row: T }) => [
|
|
629
|
+
T.slug ? (v(), V(e(J), {
|
|
630
|
+
key: 0,
|
|
631
|
+
mono: "",
|
|
632
|
+
size: "sm",
|
|
633
|
+
tone: "muted",
|
|
634
|
+
truncate: ""
|
|
635
|
+
}, {
|
|
636
|
+
default: o(() => [
|
|
637
|
+
P(" /" + _(e(Ve)(T.url) ?? T.slug) + "/ ", 1)
|
|
638
|
+
]),
|
|
639
|
+
_: 2
|
|
640
|
+
}, 1024)) : M("", !0)
|
|
641
|
+
]),
|
|
642
|
+
"cell-products_count": o(({ row: T }) => [
|
|
643
|
+
T.products_count > 0 ? (v(), V(Z, {
|
|
644
|
+
key: 0,
|
|
645
|
+
class: "wx-catalog-categories__count",
|
|
646
|
+
to: re(T),
|
|
647
|
+
onClick: I[0] || (I[0] = dt(() => {
|
|
648
|
+
}, ["stop"]))
|
|
649
|
+
}, {
|
|
650
|
+
default: o(() => [
|
|
651
|
+
P(_(T.products_count), 1)
|
|
652
|
+
]),
|
|
653
|
+
_: 2
|
|
654
|
+
}, 1032, ["to"])) : (v(), V(e(J), {
|
|
655
|
+
key: 1,
|
|
656
|
+
size: "sm",
|
|
657
|
+
tone: "muted"
|
|
658
|
+
}, {
|
|
659
|
+
default: o(() => [...I[1] || (I[1] = [
|
|
660
|
+
P("0", -1)
|
|
661
|
+
])]),
|
|
662
|
+
_: 1
|
|
663
|
+
}))
|
|
664
|
+
]),
|
|
665
|
+
"cell-state": o(({ row: T }) => [
|
|
666
|
+
T.is_published ? T.visible ? (v(), V(e(Y), {
|
|
667
|
+
key: 2,
|
|
668
|
+
type: "success",
|
|
669
|
+
dot: "",
|
|
670
|
+
size: "sm"
|
|
671
|
+
}, {
|
|
672
|
+
default: o(() => [
|
|
673
|
+
P(_(e(r)("states.published")), 1)
|
|
674
|
+
]),
|
|
675
|
+
_: 1
|
|
676
|
+
})) : (v(), V(e(Y), {
|
|
677
|
+
key: 1,
|
|
678
|
+
type: "warning",
|
|
679
|
+
dot: "",
|
|
680
|
+
size: "sm",
|
|
681
|
+
title: e(r)("panel.category-hidden")
|
|
682
|
+
}, {
|
|
683
|
+
default: o(() => [
|
|
684
|
+
P(_(e(r)("states.published")), 1)
|
|
685
|
+
]),
|
|
686
|
+
_: 1
|
|
687
|
+
}, 8, ["title"])) : (v(), V(e(Y), {
|
|
688
|
+
key: 0,
|
|
689
|
+
dot: "",
|
|
690
|
+
size: "sm"
|
|
691
|
+
}, {
|
|
692
|
+
default: o(() => [
|
|
693
|
+
P(_(e(r)("states.unpublished")), 1)
|
|
694
|
+
]),
|
|
695
|
+
_: 1
|
|
696
|
+
}))
|
|
697
|
+
]),
|
|
698
|
+
"cell-actions": o(({ row: T }) => [
|
|
699
|
+
k(e(Je), {
|
|
700
|
+
actions: ue(T),
|
|
701
|
+
label: T.name
|
|
702
|
+
}, null, 8, ["actions", "label"])
|
|
703
|
+
]),
|
|
704
|
+
_: 1
|
|
705
|
+
}, 8, ["data", "columns", "tree", "loading", "search-placeholder", "empty-text", "aria-label"]))
|
|
706
|
+
]),
|
|
707
|
+
_: 1
|
|
708
|
+
}, 8, ["title", "subtitle", "back", "back-label", "actions"])
|
|
709
|
+
]);
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
}), pe = (n, t) => {
|
|
713
|
+
const i = n.__vccOpts || n;
|
|
714
|
+
for (const [f, l] of t)
|
|
715
|
+
i[f] = l;
|
|
716
|
+
return i;
|
|
717
|
+
}, ha = /* @__PURE__ */ pe(fa, [["__scopeId", "data-v-b896daca"]]), Tt = /* @__PURE__ */ Symbol("wx-catalog-product");
|
|
718
|
+
function ba(n) {
|
|
719
|
+
pt(Tt, n);
|
|
720
|
+
}
|
|
721
|
+
function ka() {
|
|
722
|
+
return vt(Tt, null);
|
|
723
|
+
}
|
|
724
|
+
const zt = /* @__PURE__ */ Symbol("wx-catalog-category");
|
|
725
|
+
function _a(n) {
|
|
726
|
+
pt(zt, n);
|
|
727
|
+
}
|
|
728
|
+
function wa() {
|
|
729
|
+
return vt(zt, null);
|
|
730
|
+
}
|
|
731
|
+
const xa = /* @__PURE__ */ le({
|
|
732
|
+
name: "WxCatalogCategoryEditor",
|
|
733
|
+
__name: "CategoryEditorPage",
|
|
734
|
+
props: {
|
|
735
|
+
base: { default: "/catalog" }
|
|
736
|
+
},
|
|
737
|
+
setup(n) {
|
|
738
|
+
const t = n, i = ae(), f = ne(i), l = ye(i), m = ze(), r = $e(), s = Ue();
|
|
739
|
+
oe();
|
|
740
|
+
const a = te("webx-catalog"), w = me(), b = h(() => Number(m.params.id)), y = h(() => `${t.base}/categories`), x = D(null), C = D(void 0), A = D({}), S = D(""), q = D(!0), F = D(!1), O = D({}), L = h(() => i.can("catalog.manage")), U = h(() => i.can("catalog.delete")), N = h(() => !L.value || F.value), c = h(() => JSON.stringify(A.value)), g = h(() => S.value !== "" && c.value !== S.value), p = h(() => F.value ? "saving" : g.value ? "unsaved" : "saved"), j = h(() => {
|
|
741
|
+
const T = A.value.name;
|
|
742
|
+
return xt(T, s.active.value, x.value?.name ?? "") || a("panel.untitled");
|
|
743
|
+
}), H = h(() => {
|
|
744
|
+
const T = Ve(x.value?.url);
|
|
745
|
+
return T === null ? void 0 : `/${T}/`;
|
|
746
|
+
}), se = h(
|
|
747
|
+
() => x.value ? ga(l.nodes.value ?? [], x.value.id).slice(1).reverse() : []
|
|
748
|
+
);
|
|
749
|
+
_a({ category: x, locked: N, facetsFrom: C }), yt({ id: h(() => x.value?.id ?? null) }), ft({
|
|
750
|
+
values: A,
|
|
751
|
+
prefix: D(""),
|
|
752
|
+
path: h(() => Ve(x.value?.url)),
|
|
753
|
+
moving: () => a("panel.address-moving")
|
|
754
|
+
});
|
|
755
|
+
function X(T) {
|
|
756
|
+
x.value = T.category, C.value = T.facets_from, A.value = T.values, S.value = JSON.stringify(T.values);
|
|
757
|
+
}
|
|
758
|
+
async function re() {
|
|
759
|
+
q.value = !0;
|
|
760
|
+
try {
|
|
761
|
+
const [T] = await Promise.all([f.category(b.value), l.load().catch(() => [])]);
|
|
762
|
+
X(T);
|
|
763
|
+
} catch (T) {
|
|
764
|
+
E.danger(w(T)), r.push(y.value);
|
|
765
|
+
} finally {
|
|
766
|
+
q.value = !1;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
async function ue() {
|
|
770
|
+
if (!(!x.value || F.value || !L.value)) {
|
|
771
|
+
F.value = !0, O.value = {};
|
|
772
|
+
try {
|
|
773
|
+
X(await f.saveCategory(x.value.id, A.value)), l.drop(), l.load().catch(() => {
|
|
774
|
+
}), E.success(a("panel.saved"));
|
|
775
|
+
} catch (T) {
|
|
776
|
+
const $ = T.body;
|
|
777
|
+
$?.errors && Object.keys($.errors).length > 0 ? (O.value = $.errors, E.danger(a("panel.save-failed"))) : E.danger(w(T));
|
|
778
|
+
} finally {
|
|
779
|
+
F.value = !1;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
async function ce() {
|
|
784
|
+
const T = x.value;
|
|
785
|
+
if (!(!T || !await ge({
|
|
786
|
+
title: a("panel.delete-category-title", { name: T.name }),
|
|
787
|
+
message: a("panel.delete-category-text"),
|
|
788
|
+
confirmText: a("panel.delete"),
|
|
789
|
+
cancelText: a("panel.cancel"),
|
|
790
|
+
tone: "danger"
|
|
791
|
+
})))
|
|
792
|
+
try {
|
|
793
|
+
await f.removeCategory(T.id), l.drop(), E.success(a("panel.category-deleted")), S.value = c.value, r.push(y.value);
|
|
794
|
+
} catch (R) {
|
|
795
|
+
E.danger(w(R));
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
function z(T) {
|
|
799
|
+
g.value && T.preventDefault();
|
|
800
|
+
}
|
|
801
|
+
function I(T) {
|
|
802
|
+
(T.ctrlKey || T.metaKey) && T.key.toLowerCase() === "s" && (T.preventDefault(), g.value && ue());
|
|
803
|
+
}
|
|
804
|
+
ht(I), we(b, () => {
|
|
805
|
+
re();
|
|
806
|
+
}), ie(() => {
|
|
807
|
+
re(), window.addEventListener("beforeunload", z);
|
|
808
|
+
}), Te(() => {
|
|
809
|
+
window.removeEventListener("beforeunload", z);
|
|
810
|
+
}), mt(async () => !g.value || !L.value ? !0 : await ge({
|
|
811
|
+
title: a("panel.leave-title"),
|
|
812
|
+
message: a("panel.leave-text"),
|
|
813
|
+
confirmText: a("panel.leave"),
|
|
814
|
+
cancelText: a("panel.cancel"),
|
|
815
|
+
tone: "danger"
|
|
816
|
+
}));
|
|
817
|
+
const Z = h(() => {
|
|
818
|
+
const T = x.value, $ = [];
|
|
819
|
+
return T && (T.url && T.visible && $.push({ key: "site", label: a("panel.open-on-site"), icon: "link", href: T.url }), $.push({
|
|
820
|
+
key: "products",
|
|
821
|
+
label: a("panel.show-products"),
|
|
822
|
+
icon: "list",
|
|
823
|
+
menu: !0,
|
|
824
|
+
run: () => {
|
|
825
|
+
r.push({
|
|
826
|
+
path: `${t.base}/products`,
|
|
827
|
+
query: { "f.category": String(T.id) }
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
}), U.value && $.push({
|
|
831
|
+
key: "delete",
|
|
832
|
+
label: a("panel.delete"),
|
|
833
|
+
icon: "trash",
|
|
834
|
+
danger: !0,
|
|
835
|
+
menu: !0,
|
|
836
|
+
run: () => {
|
|
837
|
+
ce();
|
|
838
|
+
}
|
|
839
|
+
})), $;
|
|
840
|
+
});
|
|
841
|
+
return (T, $) => (v(), B("div", {
|
|
842
|
+
class: "wx-catalog-category-editor",
|
|
843
|
+
onKeydown: I
|
|
844
|
+
}, [
|
|
845
|
+
q.value || !x.value ? (v(), B(ee, { key: 0 }, [
|
|
846
|
+
k(e(xe), {
|
|
847
|
+
class: "wx-catalog-category-editor__ghost",
|
|
848
|
+
title: "",
|
|
849
|
+
rows: 1
|
|
850
|
+
}),
|
|
851
|
+
k(e($t), null, {
|
|
852
|
+
default: o(() => [
|
|
853
|
+
k(e(xe), { rows: 6 })
|
|
854
|
+
]),
|
|
855
|
+
_: 1
|
|
856
|
+
})
|
|
857
|
+
], 64)) : (v(), B(ee, { key: 1 }, [
|
|
858
|
+
k(e(bt), {
|
|
859
|
+
divider: "",
|
|
860
|
+
back: y.value,
|
|
861
|
+
"back-label": e(a)("module.categories"),
|
|
862
|
+
title: j.value,
|
|
863
|
+
subtitle: H.value,
|
|
864
|
+
actions: Z.value
|
|
865
|
+
}, {
|
|
866
|
+
trail: o(() => [
|
|
867
|
+
k(e(Ct), {
|
|
868
|
+
size: "sm",
|
|
869
|
+
label: e(a)("panel.category-trail")
|
|
870
|
+
}, {
|
|
871
|
+
default: o(() => [
|
|
872
|
+
k(e(be), {
|
|
873
|
+
as: "router-link",
|
|
874
|
+
to: y.value
|
|
875
|
+
}, {
|
|
876
|
+
default: o(() => [
|
|
877
|
+
P(_(e(a)("module.categories")), 1)
|
|
878
|
+
]),
|
|
879
|
+
_: 1
|
|
880
|
+
}, 8, ["to"]),
|
|
881
|
+
(v(!0), B(ee, null, ke(se.value, (R) => (v(), V(e(be), {
|
|
882
|
+
key: R.id,
|
|
883
|
+
as: "router-link",
|
|
884
|
+
to: `${y.value}/${R.id}`
|
|
885
|
+
}, {
|
|
886
|
+
default: o(() => [
|
|
887
|
+
P(_(R.name), 1)
|
|
888
|
+
]),
|
|
889
|
+
_: 2
|
|
890
|
+
}, 1032, ["to"]))), 128)),
|
|
891
|
+
k(e(be), { current: "" }, {
|
|
892
|
+
default: o(() => [
|
|
893
|
+
P(_(j.value), 1)
|
|
894
|
+
]),
|
|
895
|
+
_: 1
|
|
896
|
+
})
|
|
897
|
+
]),
|
|
898
|
+
_: 1
|
|
899
|
+
}, 8, ["label"])
|
|
900
|
+
]),
|
|
901
|
+
"title-after": o(() => [
|
|
902
|
+
x.value.is_published ? x.value.visible ? M("", !0) : (v(), V(e(Y), {
|
|
903
|
+
key: 1,
|
|
904
|
+
type: "warning",
|
|
905
|
+
dot: ""
|
|
906
|
+
}, {
|
|
907
|
+
default: o(() => [
|
|
908
|
+
P(_(e(a)("panel.category-hidden")), 1)
|
|
909
|
+
]),
|
|
910
|
+
_: 1
|
|
911
|
+
})) : (v(), V(e(Y), {
|
|
912
|
+
key: 0,
|
|
913
|
+
dot: ""
|
|
914
|
+
}, {
|
|
915
|
+
default: o(() => [
|
|
916
|
+
P(_(e(a)("states.unpublished")), 1)
|
|
917
|
+
]),
|
|
918
|
+
_: 1
|
|
919
|
+
}))
|
|
920
|
+
]),
|
|
921
|
+
_: 1
|
|
922
|
+
}, 8, ["back", "back-label", "title", "subtitle", "actions"]),
|
|
923
|
+
k(e(kt), {
|
|
924
|
+
modelValue: A.value,
|
|
925
|
+
"onUpdate:modelValue": $[0] || ($[0] = (R) => A.value = R),
|
|
926
|
+
name: "catalog.category-form",
|
|
927
|
+
errors: O.value,
|
|
928
|
+
disabled: N.value
|
|
929
|
+
}, null, 8, ["modelValue", "errors", "disabled"]),
|
|
930
|
+
L.value ? (v(), V(e(St), { key: 0 }, {
|
|
931
|
+
state: o(() => [
|
|
932
|
+
k(e(_t), { state: p.value }, null, 8, ["state"])
|
|
933
|
+
]),
|
|
934
|
+
default: o(() => [
|
|
935
|
+
k(e(Q), {
|
|
936
|
+
type: "primary",
|
|
937
|
+
loading: F.value,
|
|
938
|
+
disabled: !g.value,
|
|
939
|
+
onClick: ue
|
|
940
|
+
}, {
|
|
941
|
+
default: o(() => [
|
|
942
|
+
P(_(e(a)("panel.save")), 1)
|
|
943
|
+
]),
|
|
944
|
+
_: 1
|
|
945
|
+
}, 8, ["loading", "disabled"])
|
|
946
|
+
]),
|
|
947
|
+
_: 1
|
|
948
|
+
})) : M("", !0)
|
|
949
|
+
], 64))
|
|
950
|
+
], 32));
|
|
951
|
+
}
|
|
952
|
+
}), $a = /* @__PURE__ */ pe(xa, [["__scopeId", "data-v-45d5817b"]]), Ca = /* @__PURE__ */ le({
|
|
953
|
+
name: "WxCatalogCategoryField",
|
|
954
|
+
inheritAttrs: !1,
|
|
955
|
+
__name: "CategoryField",
|
|
956
|
+
props: /* @__PURE__ */ Xt({
|
|
957
|
+
multiple: { type: Boolean, default: !1 }
|
|
958
|
+
}, {
|
|
959
|
+
modelValue: { default: null },
|
|
960
|
+
modelModifiers: {}
|
|
961
|
+
}),
|
|
962
|
+
emits: ["update:modelValue"],
|
|
963
|
+
setup(n) {
|
|
964
|
+
const t = n, i = gt(n, "modelValue"), f = ae(), l = ye(f), m = ea();
|
|
965
|
+
oe();
|
|
966
|
+
const r = te("webx-catalog"), s = h(() => {
|
|
967
|
+
const b = m?.values.value.category_id;
|
|
968
|
+
return typeof b == "number" ? b : null;
|
|
969
|
+
}), a = h(() => {
|
|
970
|
+
const b = (y) => y.map((x) => ({
|
|
971
|
+
...x,
|
|
972
|
+
locked: t.multiple && x.id === s.value,
|
|
973
|
+
children: b(x.children ?? [])
|
|
974
|
+
}));
|
|
975
|
+
return b(l.nodes.value ?? []);
|
|
976
|
+
}), w = h({
|
|
977
|
+
get: () => t.multiple ? Array.isArray(i.value) ? i.value : [] : typeof i.value == "number" ? i.value : null,
|
|
978
|
+
set: (b) => {
|
|
979
|
+
if (t.multiple) {
|
|
980
|
+
const y = (Array.isArray(b) ? b : []).map(Number);
|
|
981
|
+
i.value = y.filter((x) => x !== s.value);
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
i.value = b == null || Array.isArray(b) ? null : Number(b);
|
|
985
|
+
}
|
|
986
|
+
});
|
|
987
|
+
return ie(() => {
|
|
988
|
+
l.load().catch(() => {
|
|
989
|
+
});
|
|
990
|
+
}), (b, y) => (v(), V(e(De), Jt(b.$attrs, {
|
|
991
|
+
modelValue: w.value,
|
|
992
|
+
"onUpdate:modelValue": y[0] || (y[0] = (x) => w.value = x),
|
|
993
|
+
class: "wx-catalog-category",
|
|
994
|
+
nodes: a.value,
|
|
995
|
+
multiple: t.multiple,
|
|
996
|
+
"check-strictly": t.multiple,
|
|
997
|
+
"node-key": "id",
|
|
998
|
+
"label-key": "name",
|
|
999
|
+
"children-key": "children",
|
|
1000
|
+
"disabled-key": "locked",
|
|
1001
|
+
"show-path": !t.multiple,
|
|
1002
|
+
separator: " / ",
|
|
1003
|
+
filterable: "",
|
|
1004
|
+
clearable: "",
|
|
1005
|
+
"default-expand-all": "",
|
|
1006
|
+
teleport: "",
|
|
1007
|
+
placeholder: t.multiple ? e(r)("panel.pick-categories") : e(r)("panel.pick-category")
|
|
1008
|
+
}), null, 16, ["modelValue", "nodes", "multiple", "check-strictly", "show-path", "placeholder"]));
|
|
1009
|
+
}
|
|
1010
|
+
}), Sa = { class: "wx-catalog-deleted" }, Pa = { class: "wx-catalog-deleted__name" }, Aa = { class: "wx-catalog-deleted__title" }, Wa = {
|
|
1011
|
+
key: 0,
|
|
1012
|
+
class: "wx-catalog-deleted__code"
|
|
1013
|
+
}, Va = {
|
|
1014
|
+
key: 1,
|
|
1015
|
+
class: "wx-catalog-deleted__code"
|
|
1016
|
+
}, Ta = {
|
|
1017
|
+
key: 1,
|
|
1018
|
+
class: "wx-catalog-deleted__ref"
|
|
1019
|
+
}, za = /* @__PURE__ */ le({
|
|
1020
|
+
__name: "DeletedPage",
|
|
1021
|
+
props: {
|
|
1022
|
+
base: { default: "/catalog" }
|
|
1023
|
+
},
|
|
1024
|
+
setup(n) {
|
|
1025
|
+
const t = n, i = ae(), f = ne(i), l = ye(i), m = ze(), r = $e();
|
|
1026
|
+
oe();
|
|
1027
|
+
const s = te("webx-catalog"), a = me(), w = D(null), b = D(!0), y = D(typeof m.query.q == "string" ? m.query.q : ""), x = h(() => i.can("catalog.delete")), C = h({
|
|
1028
|
+
get: () => m.query.type === "categories" ? "categories" : "products",
|
|
1029
|
+
set: (c) => {
|
|
1030
|
+
y.value = "", w.value = null, r.replace({
|
|
1031
|
+
query: { type: c === "categories" ? "categories" : void 0 }
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
}), A = h(() => [
|
|
1035
|
+
{ value: "products", label: s("module.products") },
|
|
1036
|
+
{ value: "categories", label: s("module.categories") }
|
|
1037
|
+
]), S = h(
|
|
1038
|
+
() => C.value === "categories" ? [
|
|
1039
|
+
{ key: "name", label: s("category.name"), minWidth: 200 },
|
|
1040
|
+
{ key: "parent", label: s("panel.column-parent"), width: 200, hideBelow: 640 },
|
|
1041
|
+
{ key: "deleted_at", label: s("panel.column-deleted"), width: 150 },
|
|
1042
|
+
{ key: "actions", label: "", width: Ae, align: "right" }
|
|
1043
|
+
] : [
|
|
1044
|
+
{ key: "name", label: s("panel.column-product"), minWidth: 200 },
|
|
1045
|
+
{ key: "category", label: s("product.category"), width: 220, hideBelow: 640 },
|
|
1046
|
+
{ key: "deleted_at", label: s("panel.column-deleted"), width: 150 },
|
|
1047
|
+
{ key: "actions", label: "", width: Ae, align: "right" }
|
|
1048
|
+
]
|
|
1049
|
+
);
|
|
1050
|
+
let q = 0;
|
|
1051
|
+
async function F(c) {
|
|
1052
|
+
const g = ++q;
|
|
1053
|
+
b.value = !0;
|
|
1054
|
+
try {
|
|
1055
|
+
const p = await f.deleted(C.value, {
|
|
1056
|
+
q: c?.search ?? y.value,
|
|
1057
|
+
page: c?.page,
|
|
1058
|
+
per_page: c?.perPage
|
|
1059
|
+
});
|
|
1060
|
+
g === q && (w.value = p);
|
|
1061
|
+
} catch (p) {
|
|
1062
|
+
E.danger(a(p));
|
|
1063
|
+
} finally {
|
|
1064
|
+
g === q && (b.value = !1);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
function O(c) {
|
|
1068
|
+
r.replace({
|
|
1069
|
+
query: { ...m.query, q: c.search === "" ? void 0 : c.search }
|
|
1070
|
+
}), F(c);
|
|
1071
|
+
}
|
|
1072
|
+
async function L(c) {
|
|
1073
|
+
try {
|
|
1074
|
+
if (C.value === "categories")
|
|
1075
|
+
await f.restoreCategory(c.id), l.drop(), E.success(s("panel.category-restored"));
|
|
1076
|
+
else {
|
|
1077
|
+
const p = (await f.restoreProduct(c.id)).category === null && c.category !== null;
|
|
1078
|
+
E.success(s(p ? "panel.product-restored-bare" : "panel.product-restored"));
|
|
1079
|
+
}
|
|
1080
|
+
await F();
|
|
1081
|
+
} catch (g) {
|
|
1082
|
+
E.danger(a(g));
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
function U(c, g) {
|
|
1086
|
+
const p = c[g];
|
|
1087
|
+
return p && typeof p == "object" ? p : null;
|
|
1088
|
+
}
|
|
1089
|
+
function N(c) {
|
|
1090
|
+
const g = [];
|
|
1091
|
+
return x.value && g.push({
|
|
1092
|
+
key: "restore",
|
|
1093
|
+
icon: "refresh",
|
|
1094
|
+
label: s("panel.restore"),
|
|
1095
|
+
run: () => {
|
|
1096
|
+
L(c);
|
|
1097
|
+
}
|
|
1098
|
+
}), g;
|
|
1099
|
+
}
|
|
1100
|
+
return (c, g) => (v(), B("div", Sa, [
|
|
1101
|
+
k(e(He), {
|
|
1102
|
+
view: C.value,
|
|
1103
|
+
"onUpdate:view": g[1] || (g[1] = (p) => C.value = p),
|
|
1104
|
+
title: e(s)("module.deleted"),
|
|
1105
|
+
subtitle: e(s)("panel.deleted-help"),
|
|
1106
|
+
back: `${t.base}/products`,
|
|
1107
|
+
"back-label": e(s)("module.products"),
|
|
1108
|
+
views: A.value
|
|
1109
|
+
}, {
|
|
1110
|
+
default: o(() => [
|
|
1111
|
+
(v(), V(e(et), {
|
|
1112
|
+
key: String(C.value),
|
|
1113
|
+
search: y.value,
|
|
1114
|
+
"onUpdate:search": g[0] || (g[0] = (p) => y.value = p),
|
|
1115
|
+
data: w.value,
|
|
1116
|
+
columns: S.value,
|
|
1117
|
+
"row-key": "id",
|
|
1118
|
+
searchable: "",
|
|
1119
|
+
clickable: !1,
|
|
1120
|
+
hover: !1,
|
|
1121
|
+
flush: "",
|
|
1122
|
+
layout: "fixed",
|
|
1123
|
+
loading: b.value,
|
|
1124
|
+
"search-placeholder": e(s)("panel.deleted-search"),
|
|
1125
|
+
"empty-text": y.value ? e(s)("panel.empty-search") : e(s)("panel.deleted-empty"),
|
|
1126
|
+
"aria-label": e(s)("module.deleted"),
|
|
1127
|
+
onStateChange: O
|
|
1128
|
+
}, {
|
|
1129
|
+
"cell-name": o(({ row: p }) => [
|
|
1130
|
+
G("div", Pa, [
|
|
1131
|
+
G("span", Aa, _(p.name), 1),
|
|
1132
|
+
"sku" in p && p.sku ? (v(), B("span", Wa, _(p.sku), 1)) : "slug" in p && p.slug ? (v(), B("span", Va, " /" + _(p.slug) + "/ ", 1)) : M("", !0)
|
|
1133
|
+
])
|
|
1134
|
+
]),
|
|
1135
|
+
"cell-category": o(({ row: p }) => [
|
|
1136
|
+
U(p, "category") ? (v(), B("span", Ta, [
|
|
1137
|
+
k(e(J), {
|
|
1138
|
+
size: "sm",
|
|
1139
|
+
truncate: "",
|
|
1140
|
+
tone: U(p, "category")?.deleted ? "muted" : void 0
|
|
1141
|
+
}, {
|
|
1142
|
+
default: o(() => [
|
|
1143
|
+
P(_(U(p, "category")?.name), 1)
|
|
1144
|
+
]),
|
|
1145
|
+
_: 2
|
|
1146
|
+
}, 1032, ["tone"]),
|
|
1147
|
+
U(p, "category")?.deleted ? (v(), V(e(Y), {
|
|
1148
|
+
key: 0,
|
|
1149
|
+
type: "warning",
|
|
1150
|
+
size: "sm",
|
|
1151
|
+
round: ""
|
|
1152
|
+
}, {
|
|
1153
|
+
default: o(() => [
|
|
1154
|
+
P(_(e(s)("panel.restore-bare")), 1)
|
|
1155
|
+
]),
|
|
1156
|
+
_: 1
|
|
1157
|
+
})) : M("", !0)
|
|
1158
|
+
])) : (v(), V(e(J), {
|
|
1159
|
+
key: 0,
|
|
1160
|
+
size: "sm",
|
|
1161
|
+
tone: "muted"
|
|
1162
|
+
}, {
|
|
1163
|
+
default: o(() => [
|
|
1164
|
+
P(_(e(s)("product.no-category")), 1)
|
|
1165
|
+
]),
|
|
1166
|
+
_: 1
|
|
1167
|
+
}))
|
|
1168
|
+
]),
|
|
1169
|
+
"cell-parent": o(({ row: p }) => [
|
|
1170
|
+
U(p, "parent") ? (v(), V(e(J), {
|
|
1171
|
+
key: 1,
|
|
1172
|
+
size: "sm",
|
|
1173
|
+
truncate: "",
|
|
1174
|
+
tone: U(p, "parent")?.deleted ? "muted" : void 0
|
|
1175
|
+
}, {
|
|
1176
|
+
default: o(() => [
|
|
1177
|
+
P(_(U(p, "parent")?.name) + " ", 1),
|
|
1178
|
+
U(p, "parent")?.deleted ? (v(), B(ee, { key: 0 }, [
|
|
1179
|
+
P(" (" + _(e(s)("panel.category-gone")) + ")", 1)
|
|
1180
|
+
], 64)) : M("", !0)
|
|
1181
|
+
]),
|
|
1182
|
+
_: 2
|
|
1183
|
+
}, 1032, ["tone"])) : (v(), V(e(J), {
|
|
1184
|
+
key: 0,
|
|
1185
|
+
size: "sm",
|
|
1186
|
+
tone: "muted"
|
|
1187
|
+
}, {
|
|
1188
|
+
default: o(() => [
|
|
1189
|
+
P(_(e(s)("panel.parent-root")), 1)
|
|
1190
|
+
]),
|
|
1191
|
+
_: 1
|
|
1192
|
+
}))
|
|
1193
|
+
]),
|
|
1194
|
+
"cell-deleted_at": o(({ row: p }) => [
|
|
1195
|
+
k(e(wt), {
|
|
1196
|
+
value: p.deleted_at,
|
|
1197
|
+
compact: ""
|
|
1198
|
+
}, null, 8, ["value"])
|
|
1199
|
+
]),
|
|
1200
|
+
"cell-actions": o(({ row: p }) => [
|
|
1201
|
+
x.value ? (v(), V(e(Je), {
|
|
1202
|
+
key: 0,
|
|
1203
|
+
actions: N(p),
|
|
1204
|
+
label: p.name
|
|
1205
|
+
}, null, 8, ["actions", "label"])) : M("", !0)
|
|
1206
|
+
]),
|
|
1207
|
+
_: 1
|
|
1208
|
+
}, 8, ["search", "data", "columns", "loading", "search-placeholder", "empty-text", "aria-label"]))
|
|
1209
|
+
]),
|
|
1210
|
+
_: 1
|
|
1211
|
+
}, 8, ["view", "title", "subtitle", "back", "back-label", "views"])
|
|
1212
|
+
]));
|
|
1213
|
+
}
|
|
1214
|
+
}), Ua = /* @__PURE__ */ pe(za, [["__scopeId", "data-v-1fad643b"]]), Da = { class: "wx-catalog-facets" }, qa = { class: "wx-catalog-facets__own" }, Na = {
|
|
1215
|
+
key: 0,
|
|
1216
|
+
class: "wx-catalog-facets__inherited"
|
|
1217
|
+
}, Fa = /* @__PURE__ */ le({
|
|
1218
|
+
name: "WxCatalogFacetsField",
|
|
1219
|
+
__name: "FacetsField",
|
|
1220
|
+
props: {
|
|
1221
|
+
modelValue: { default: null },
|
|
1222
|
+
modelModifiers: {}
|
|
1223
|
+
},
|
|
1224
|
+
emits: ["update:modelValue"],
|
|
1225
|
+
setup(n) {
|
|
1226
|
+
const t = gt(n, "modelValue"), i = ae(), f = ne(i), l = Vt(i), m = wa();
|
|
1227
|
+
oe();
|
|
1228
|
+
const r = te("webx-catalog"), s = D(!0), a = D(!1), w = D(null), b = h(() => l.facets.value ?? []), y = h(() => new Map(b.value.map((c) => [c.key, c.label]))), x = h(() => Array.isArray(t.value)), C = h(() => m?.locked.value ?? !1);
|
|
1229
|
+
function A(c) {
|
|
1230
|
+
const g = new Set(c.map((p) => p.key));
|
|
1231
|
+
return [
|
|
1232
|
+
...c.map((p) => ({ key: p.key, visible: p.visible })),
|
|
1233
|
+
...b.value.filter((p) => !g.has(p.key)).map((p) => ({ key: p.key, visible: !1 }))
|
|
1234
|
+
];
|
|
1235
|
+
}
|
|
1236
|
+
const S = h(
|
|
1237
|
+
() => w.value === null ? b.value.map((c) => ({ key: c.key, visible: !0 })) : A(w.value.rows)
|
|
1238
|
+
), q = h({
|
|
1239
|
+
get: () => A(t.value ?? []).map((c) => ({
|
|
1240
|
+
...c,
|
|
1241
|
+
label: y.value.get(c.key) ?? c.key,
|
|
1242
|
+
known: y.value.has(c.key)
|
|
1243
|
+
})),
|
|
1244
|
+
set: (c) => {
|
|
1245
|
+
t.value = c.map((g) => ({ key: g.key, visible: g.visible }));
|
|
1246
|
+
}
|
|
1247
|
+
}), F = h(
|
|
1248
|
+
() => S.value.filter((c) => c.visible && y.value.has(c.key)).map((c) => y.value.get(c.key)).join(", ")
|
|
1249
|
+
);
|
|
1250
|
+
function O(c) {
|
|
1251
|
+
t.value = c ? S.value.map((g) => ({ ...g })) : null;
|
|
1252
|
+
}
|
|
1253
|
+
function L(c, g) {
|
|
1254
|
+
q.value = q.value.map(
|
|
1255
|
+
(p) => p.key === c ? { ...p, visible: !!g } : p
|
|
1256
|
+
);
|
|
1257
|
+
}
|
|
1258
|
+
async function U(c) {
|
|
1259
|
+
const g = m?.facetsFrom.value;
|
|
1260
|
+
if (w.value = null, g === null) return;
|
|
1261
|
+
if (g !== void 0) {
|
|
1262
|
+
const j = await f.category(g.id);
|
|
1263
|
+
Array.isArray(j.values.facets) && (w.value = { name: g.name, rows: j.values.facets });
|
|
1264
|
+
return;
|
|
1265
|
+
}
|
|
1266
|
+
let p = c;
|
|
1267
|
+
for (; p !== null; ) {
|
|
1268
|
+
const j = await f.category(p), H = j.values.facets;
|
|
1269
|
+
if (Array.isArray(H)) {
|
|
1270
|
+
w.value = { name: j.category.name, rows: H };
|
|
1271
|
+
return;
|
|
1272
|
+
}
|
|
1273
|
+
p = j.category.parent_id;
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
async function N() {
|
|
1277
|
+
s.value = !0, a.value = !1;
|
|
1278
|
+
try {
|
|
1279
|
+
await Promise.all([l.load(), U(m?.category.value?.parent_id ?? null)]);
|
|
1280
|
+
} catch {
|
|
1281
|
+
a.value = !0;
|
|
1282
|
+
} finally {
|
|
1283
|
+
s.value = !1;
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
return we(
|
|
1287
|
+
() => [m?.category.value?.parent_id, JSON.stringify(m?.facetsFrom.value)],
|
|
1288
|
+
(c, g) => {
|
|
1289
|
+
(c[0] !== g[0] || c[1] !== g[1]) && N();
|
|
1290
|
+
}
|
|
1291
|
+
), ie(N), (c, g) => (v(), B("div", Da, [
|
|
1292
|
+
s.value ? (v(), V(e(xe), {
|
|
1293
|
+
key: 0,
|
|
1294
|
+
rows: 3
|
|
1295
|
+
})) : a.value ? (v(), V(e(We), {
|
|
1296
|
+
key: 1,
|
|
1297
|
+
type: "warning",
|
|
1298
|
+
variant: "soft",
|
|
1299
|
+
description: e(r)("panel.facets-failed")
|
|
1300
|
+
}, null, 8, ["description"])) : (v(), B(ee, { key: 2 }, [
|
|
1301
|
+
G("div", qa, [
|
|
1302
|
+
k(e(Ie), {
|
|
1303
|
+
"model-value": x.value,
|
|
1304
|
+
disabled: C.value,
|
|
1305
|
+
label: e(r)("panel.facets-own"),
|
|
1306
|
+
"onUpdate:modelValue": O
|
|
1307
|
+
}, null, 8, ["model-value", "disabled", "label"]),
|
|
1308
|
+
k(e(J), {
|
|
1309
|
+
size: "sm",
|
|
1310
|
+
tone: "muted"
|
|
1311
|
+
}, {
|
|
1312
|
+
default: o(() => [
|
|
1313
|
+
P(_(x.value ? e(r)("panel.facets-own-help") : e(r)("panel.facets-inherited-help")), 1)
|
|
1314
|
+
]),
|
|
1315
|
+
_: 1
|
|
1316
|
+
})
|
|
1317
|
+
]),
|
|
1318
|
+
x.value ? (v(), V(e(Pt), {
|
|
1319
|
+
key: 1,
|
|
1320
|
+
modelValue: q.value,
|
|
1321
|
+
"onUpdate:modelValue": g[0] || (g[0] = (p) => q.value = p),
|
|
1322
|
+
size: "sm",
|
|
1323
|
+
"item-key": "key",
|
|
1324
|
+
"item-label": "label",
|
|
1325
|
+
disabled: C.value,
|
|
1326
|
+
"empty-text": e(r)("panel.facets-empty")
|
|
1327
|
+
}, {
|
|
1328
|
+
default: o(({ item: p }) => [
|
|
1329
|
+
G("span", {
|
|
1330
|
+
class: Ge(["wx-catalog-facets__name", { "is-off": !p.visible }])
|
|
1331
|
+
}, _(p.label), 3),
|
|
1332
|
+
p.known ? M("", !0) : (v(), V(e(J), {
|
|
1333
|
+
key: 0,
|
|
1334
|
+
size: "sm",
|
|
1335
|
+
tone: "muted"
|
|
1336
|
+
}, {
|
|
1337
|
+
default: o(() => [
|
|
1338
|
+
P(_(e(r)("panel.facets-unknown")), 1)
|
|
1339
|
+
]),
|
|
1340
|
+
_: 1
|
|
1341
|
+
}))
|
|
1342
|
+
]),
|
|
1343
|
+
actions: o(({ item: p }) => [
|
|
1344
|
+
k(e(Ie), {
|
|
1345
|
+
size: "sm",
|
|
1346
|
+
"model-value": p.visible,
|
|
1347
|
+
disabled: C.value || !p.known,
|
|
1348
|
+
"aria-label": `${e(r)("panel.facets-shown")}: ${p.label}`,
|
|
1349
|
+
"onUpdate:modelValue": (j) => L(p.key, j)
|
|
1350
|
+
}, null, 8, ["model-value", "disabled", "aria-label", "onUpdate:modelValue"])
|
|
1351
|
+
]),
|
|
1352
|
+
_: 1
|
|
1353
|
+
}, 8, ["modelValue", "disabled", "empty-text"])) : (v(), B("div", Na, [
|
|
1354
|
+
k(e(J), { weight: "medium" }, {
|
|
1355
|
+
default: o(() => [
|
|
1356
|
+
P(_(w.value ? e(r)("panel.facets-inherited", { name: w.value.name }) : e(r)("panel.facets-default")), 1)
|
|
1357
|
+
]),
|
|
1358
|
+
_: 1
|
|
1359
|
+
}),
|
|
1360
|
+
F.value ? (v(), V(e(J), {
|
|
1361
|
+
key: 0,
|
|
1362
|
+
size: "sm",
|
|
1363
|
+
tone: "muted"
|
|
1364
|
+
}, {
|
|
1365
|
+
default: o(() => [
|
|
1366
|
+
P(_(F.value), 1)
|
|
1367
|
+
]),
|
|
1368
|
+
_: 1
|
|
1369
|
+
})) : b.value.length === 0 ? (v(), V(e(J), {
|
|
1370
|
+
key: 1,
|
|
1371
|
+
size: "sm",
|
|
1372
|
+
tone: "muted"
|
|
1373
|
+
}, {
|
|
1374
|
+
default: o(() => [
|
|
1375
|
+
P(_(e(r)("panel.facets-empty")), 1)
|
|
1376
|
+
]),
|
|
1377
|
+
_: 1
|
|
1378
|
+
})) : M("", !0)
|
|
1379
|
+
]))
|
|
1380
|
+
], 64))
|
|
1381
|
+
]));
|
|
1382
|
+
}
|
|
1383
|
+
}), Oa = /* @__PURE__ */ pe(Fa, [["__scopeId", "data-v-4ca00a4d"]]), Ea = { class: "wx-catalog-gallery" }, Ia = { class: "wx-catalog-gallery__item" }, Ra = ["href"], Ba = ["src"], La = { class: "wx-catalog-gallery__words" }, Ma = { class: "wx-catalog-gallery__address" }, ja = 800, Ka = /* @__PURE__ */ le({
|
|
1384
|
+
name: "WxCatalogGallery",
|
|
1385
|
+
__name: "GalleryField",
|
|
1386
|
+
setup(n) {
|
|
1387
|
+
const t = ae(), i = ne(t), f = ka();
|
|
1388
|
+
oe();
|
|
1389
|
+
const l = te("webx-catalog"), m = me(), r = D([]), s = D(""), a = D(!1), w = h(() => f?.product.value?.id ?? null), b = h(() => f === null || f.locked.value), y = h({
|
|
1390
|
+
get: () => f?.images.value ?? [],
|
|
1391
|
+
set: (N) => {
|
|
1392
|
+
f && (f.images.value = N);
|
|
1393
|
+
}
|
|
1394
|
+
});
|
|
1395
|
+
let x, C = "";
|
|
1396
|
+
function A(N) {
|
|
1397
|
+
return JSON.stringify(N.map((c) => [c.id, c.alt, c.title]));
|
|
1398
|
+
}
|
|
1399
|
+
async function S(N) {
|
|
1400
|
+
const c = w.value;
|
|
1401
|
+
if (c === null) return;
|
|
1402
|
+
clearTimeout(x);
|
|
1403
|
+
const g = A(y.value);
|
|
1404
|
+
C = g;
|
|
1405
|
+
try {
|
|
1406
|
+
const p = await i.saveImages(c, y.value);
|
|
1407
|
+
A(y.value) === g && (y.value = p);
|
|
1408
|
+
} catch (p) {
|
|
1409
|
+
E.danger(`${N} ${m(p)}`);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
function q(N, c, g) {
|
|
1413
|
+
y.value = y.value.map(
|
|
1414
|
+
(p) => p.id === N.id ? { ...p, [c]: g ?? {} } : p
|
|
1415
|
+
), clearTimeout(x), x = setTimeout(() => {
|
|
1416
|
+
S(l("panel.gallery-captions-failed"));
|
|
1417
|
+
}, ja);
|
|
1418
|
+
}
|
|
1419
|
+
function F() {
|
|
1420
|
+
S(l("panel.gallery-reorder-failed"));
|
|
1421
|
+
}
|
|
1422
|
+
async function O(N) {
|
|
1423
|
+
const c = w.value;
|
|
1424
|
+
if (c !== null)
|
|
1425
|
+
for (const g of N) {
|
|
1426
|
+
if (!g.raw) continue;
|
|
1427
|
+
const p = (j) => {
|
|
1428
|
+
r.value = r.value.map((H) => H.id === g.id ? { ...H, ...j } : H);
|
|
1429
|
+
};
|
|
1430
|
+
p({ status: "uploading", progress: 0 });
|
|
1431
|
+
try {
|
|
1432
|
+
const j = await i.addImage(c, g.raw, (H) => p({ progress: H }));
|
|
1433
|
+
y.value = [...y.value, j], r.value = r.value.filter((H) => H.id !== g.id);
|
|
1434
|
+
} catch (j) {
|
|
1435
|
+
p({ status: "error", error: m(j) });
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
async function L() {
|
|
1440
|
+
const N = w.value, c = s.value.trim();
|
|
1441
|
+
if (!(N === null || c === "")) {
|
|
1442
|
+
a.value = !0;
|
|
1443
|
+
try {
|
|
1444
|
+
y.value = [...y.value, await i.addImage(N, c)], s.value = "";
|
|
1445
|
+
} catch (g) {
|
|
1446
|
+
E.danger(`${l("panel.gallery-failed")} ${m(g)}`);
|
|
1447
|
+
} finally {
|
|
1448
|
+
a.value = !1;
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
async function U(N) {
|
|
1453
|
+
const c = w.value;
|
|
1454
|
+
if (!(c === null || !await ge({
|
|
1455
|
+
title: l("panel.gallery-remove-title"),
|
|
1456
|
+
message: l("panel.gallery-remove-text"),
|
|
1457
|
+
confirmText: l("panel.delete"),
|
|
1458
|
+
cancelText: l("panel.cancel"),
|
|
1459
|
+
tone: "danger"
|
|
1460
|
+
})))
|
|
1461
|
+
try {
|
|
1462
|
+
await i.removeImage(c, N.id), y.value = y.value.filter((p) => p.id !== N.id), E.success(l("panel.gallery-removed"));
|
|
1463
|
+
} catch (p) {
|
|
1464
|
+
E.danger(m(p));
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
return Te(() => {
|
|
1468
|
+
x !== void 0 && A(y.value) !== C && S(""), clearTimeout(x);
|
|
1469
|
+
}), (N, c) => (v(), B("div", Ea, [
|
|
1470
|
+
e(f) ? (v(), B(ee, { key: 1 }, [
|
|
1471
|
+
b.value && y.value.length === 0 ? (v(), V(e(We), {
|
|
1472
|
+
key: 0,
|
|
1473
|
+
type: "info",
|
|
1474
|
+
variant: "soft",
|
|
1475
|
+
description: e(l)("panel.gallery-locked")
|
|
1476
|
+
}, null, 8, ["description"])) : M("", !0),
|
|
1477
|
+
y.value.length > 0 ? (v(), V(e(Pt), {
|
|
1478
|
+
key: 1,
|
|
1479
|
+
modelValue: y.value,
|
|
1480
|
+
"onUpdate:modelValue": c[0] || (c[0] = (g) => y.value = g),
|
|
1481
|
+
class: "wx-catalog-gallery__list",
|
|
1482
|
+
"item-key": "id",
|
|
1483
|
+
"item-label": (g) => g.path.split("/").pop() ?? String(g.id),
|
|
1484
|
+
disabled: b.value,
|
|
1485
|
+
title: e(l)("panel.gallery-order"),
|
|
1486
|
+
onMove: F
|
|
1487
|
+
}, {
|
|
1488
|
+
default: o(({ item: g, index: p }) => [
|
|
1489
|
+
G("div", Ia, [
|
|
1490
|
+
G("a", {
|
|
1491
|
+
class: "wx-catalog-gallery__thumb",
|
|
1492
|
+
href: g.url,
|
|
1493
|
+
target: "_blank",
|
|
1494
|
+
rel: "noopener"
|
|
1495
|
+
}, [
|
|
1496
|
+
G("img", {
|
|
1497
|
+
src: g.thumb ?? g.url,
|
|
1498
|
+
alt: ""
|
|
1499
|
+
}, null, 8, Ba),
|
|
1500
|
+
p === 0 ? (v(), V(e(Y), {
|
|
1501
|
+
key: 0,
|
|
1502
|
+
class: "wx-catalog-gallery__main",
|
|
1503
|
+
type: "primary",
|
|
1504
|
+
size: "sm"
|
|
1505
|
+
}, {
|
|
1506
|
+
default: o(() => [
|
|
1507
|
+
P(_(e(l)("panel.gallery-main")), 1)
|
|
1508
|
+
]),
|
|
1509
|
+
_: 1
|
|
1510
|
+
})) : M("", !0)
|
|
1511
|
+
], 8, Ra),
|
|
1512
|
+
G("div", La, [
|
|
1513
|
+
k(e(de), {
|
|
1514
|
+
label: e(l)("panel.gallery-alt"),
|
|
1515
|
+
help: e(l)("panel.gallery-alt-help")
|
|
1516
|
+
}, {
|
|
1517
|
+
default: o(() => [
|
|
1518
|
+
k(e(he), {
|
|
1519
|
+
"model-value": g.alt,
|
|
1520
|
+
localized: "",
|
|
1521
|
+
size: "sm",
|
|
1522
|
+
disabled: b.value,
|
|
1523
|
+
"onUpdate:modelValue": (j) => q(g, "alt", j)
|
|
1524
|
+
}, null, 8, ["model-value", "disabled", "onUpdate:modelValue"])
|
|
1525
|
+
]),
|
|
1526
|
+
_: 2
|
|
1527
|
+
}, 1032, ["label", "help"]),
|
|
1528
|
+
k(e(de), {
|
|
1529
|
+
label: e(l)("panel.gallery-title")
|
|
1530
|
+
}, {
|
|
1531
|
+
default: o(() => [
|
|
1532
|
+
k(e(he), {
|
|
1533
|
+
"model-value": g.title,
|
|
1534
|
+
localized: "",
|
|
1535
|
+
size: "sm",
|
|
1536
|
+
disabled: b.value,
|
|
1537
|
+
"onUpdate:modelValue": (j) => q(g, "title", j)
|
|
1538
|
+
}, null, 8, ["model-value", "disabled", "onUpdate:modelValue"])
|
|
1539
|
+
]),
|
|
1540
|
+
_: 2
|
|
1541
|
+
}, 1032, ["label"]),
|
|
1542
|
+
g.width && g.height ? (v(), V(e(J), {
|
|
1543
|
+
key: 0,
|
|
1544
|
+
size: "sm",
|
|
1545
|
+
tone: "muted"
|
|
1546
|
+
}, {
|
|
1547
|
+
default: o(() => [
|
|
1548
|
+
P(_(g.width) + " × " + _(g.height), 1)
|
|
1549
|
+
]),
|
|
1550
|
+
_: 2
|
|
1551
|
+
}, 1024)) : M("", !0)
|
|
1552
|
+
])
|
|
1553
|
+
])
|
|
1554
|
+
]),
|
|
1555
|
+
actions: o(({ item: g }) => [
|
|
1556
|
+
b.value ? M("", !0) : (v(), V(e(aa), {
|
|
1557
|
+
key: 0,
|
|
1558
|
+
type: "remove",
|
|
1559
|
+
size: "sm",
|
|
1560
|
+
title: e(l)("panel.delete"),
|
|
1561
|
+
onClick: (p) => U(g)
|
|
1562
|
+
}, null, 8, ["title", "onClick"]))
|
|
1563
|
+
]),
|
|
1564
|
+
_: 1
|
|
1565
|
+
}, 8, ["modelValue", "item-label", "disabled", "title"])) : b.value ? M("", !0) : (v(), V(e(J), {
|
|
1566
|
+
key: 2,
|
|
1567
|
+
tone: "muted"
|
|
1568
|
+
}, {
|
|
1569
|
+
default: o(() => [
|
|
1570
|
+
P(_(e(l)("panel.gallery-empty")), 1)
|
|
1571
|
+
]),
|
|
1572
|
+
_: 1
|
|
1573
|
+
})),
|
|
1574
|
+
b.value ? M("", !0) : (v(), B(ee, { key: 3 }, [
|
|
1575
|
+
k(e(la), {
|
|
1576
|
+
modelValue: r.value,
|
|
1577
|
+
"onUpdate:modelValue": c[1] || (c[1] = (g) => r.value = g),
|
|
1578
|
+
accept: "image/jpeg,image/png,image/webp,image/gif",
|
|
1579
|
+
multiple: "",
|
|
1580
|
+
"button-text": e(l)("panel.gallery-add"),
|
|
1581
|
+
hint: e(l)("panel.gallery-hint"),
|
|
1582
|
+
onAdd: O
|
|
1583
|
+
}, null, 8, ["modelValue", "button-text", "hint"]),
|
|
1584
|
+
k(e(de), {
|
|
1585
|
+
label: e(l)("panel.gallery-url")
|
|
1586
|
+
}, {
|
|
1587
|
+
default: o(() => [
|
|
1588
|
+
G("div", Ma, [
|
|
1589
|
+
k(e(he), {
|
|
1590
|
+
modelValue: s.value,
|
|
1591
|
+
"onUpdate:modelValue": c[2] || (c[2] = (g) => s.value = g),
|
|
1592
|
+
type: "url",
|
|
1593
|
+
size: "sm",
|
|
1594
|
+
placeholder: "https://",
|
|
1595
|
+
onKeydown: Ke(dt(L, ["prevent"]), ["enter"])
|
|
1596
|
+
}, null, 8, ["modelValue", "onKeydown"]),
|
|
1597
|
+
k(e(Q), {
|
|
1598
|
+
size: "sm",
|
|
1599
|
+
variant: "outline",
|
|
1600
|
+
loading: a.value,
|
|
1601
|
+
disabled: s.value.trim() === "",
|
|
1602
|
+
onClick: L
|
|
1603
|
+
}, {
|
|
1604
|
+
default: o(() => [
|
|
1605
|
+
P(_(e(l)("panel.gallery-url-add")), 1)
|
|
1606
|
+
]),
|
|
1607
|
+
_: 1
|
|
1608
|
+
}, 8, ["loading", "disabled"])
|
|
1609
|
+
])
|
|
1610
|
+
]),
|
|
1611
|
+
_: 1
|
|
1612
|
+
}, 8, ["label"])
|
|
1613
|
+
], 64))
|
|
1614
|
+
], 64)) : (v(), V(e(We), {
|
|
1615
|
+
key: 0,
|
|
1616
|
+
type: "info",
|
|
1617
|
+
variant: "soft",
|
|
1618
|
+
description: e(l)("panel.gallery-empty")
|
|
1619
|
+
}, null, 8, ["description"]))
|
|
1620
|
+
]));
|
|
1621
|
+
}
|
|
1622
|
+
}), Ga = /* @__PURE__ */ pe(Ka, [["__scopeId", "data-v-9479a729"]]), Ha = /* @__PURE__ */ le({
|
|
1623
|
+
name: "WxCatalogProductEditor",
|
|
1624
|
+
__name: "ProductEditorPage",
|
|
1625
|
+
props: {
|
|
1626
|
+
base: { default: "/catalog" }
|
|
1627
|
+
},
|
|
1628
|
+
setup(n) {
|
|
1629
|
+
const t = n, i = ae(), f = ne(i), l = ze(), m = $e(), r = Ue();
|
|
1630
|
+
oe();
|
|
1631
|
+
const s = te("webx-catalog"), a = me(), w = h(() => Number(l.params.id)), b = h(() => `${t.base}/products`), y = D(null), x = D({}), C = D([]), A = D(""), S = D(!0), q = D(!1), F = D({}), O = D(null), L = h(() => i.can("catalog.manage")), U = h(() => i.can("catalog.delete")), N = h(() => !L.value || q.value), c = h(() => JSON.stringify(x.value)), g = h(() => A.value !== "" && c.value !== A.value), p = h(() => q.value ? "saving" : g.value ? "unsaved" : "saved"), j = h(
|
|
1632
|
+
() => i.state.manifest?.modules.find(($) => $.id === "catalog")?.title ?? s("module.title")
|
|
1633
|
+
), H = h(() => {
|
|
1634
|
+
const $ = x.value.name;
|
|
1635
|
+
return xt($, r.active.value, y.value?.name ?? "") || s("panel.untitled");
|
|
1636
|
+
}), se = h(() => {
|
|
1637
|
+
const $ = y.value;
|
|
1638
|
+
if ($)
|
|
1639
|
+
return $.is_published && !$.visible ? s("panel.invisible") : $.sku ?? void 0;
|
|
1640
|
+
});
|
|
1641
|
+
ba({ product: y, images: C, locked: N }), yt({ id: h(() => y.value?.id ?? null) }), ft({
|
|
1642
|
+
values: x,
|
|
1643
|
+
prefix: D(""),
|
|
1644
|
+
path: h(() => Ve(y.value?.url)?.replace(new RegExp(`-${y.value?.id}$`), "") ?? null),
|
|
1645
|
+
moving: () => s("panel.address-moving")
|
|
1646
|
+
});
|
|
1647
|
+
function X($) {
|
|
1648
|
+
y.value = $.product, x.value = $.values, C.value = $.images, A.value = JSON.stringify($.values);
|
|
1649
|
+
}
|
|
1650
|
+
async function re() {
|
|
1651
|
+
S.value = !0;
|
|
1652
|
+
try {
|
|
1653
|
+
X(await f.product(w.value));
|
|
1654
|
+
} catch ($) {
|
|
1655
|
+
E.danger(a($)), m.push(b.value);
|
|
1656
|
+
} finally {
|
|
1657
|
+
S.value = !1;
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
async function ue() {
|
|
1661
|
+
if (!(!y.value || q.value || !L.value)) {
|
|
1662
|
+
q.value = !0, F.value = {}, O.value = null;
|
|
1663
|
+
try {
|
|
1664
|
+
X(await f.saveProduct(y.value.id, x.value)), E.success(s("panel.saved"));
|
|
1665
|
+
} catch ($) {
|
|
1666
|
+
const R = $.body;
|
|
1667
|
+
R?.errors && Object.keys(R.errors).length > 0 ? (F.value = R.errors, O.value = R.meta?.taken_by ?? null, E.danger(s("panel.save-failed"))) : E.danger(a($));
|
|
1668
|
+
} finally {
|
|
1669
|
+
q.value = !1;
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
const ce = h(() => {
|
|
1674
|
+
const $ = O.value;
|
|
1675
|
+
if (!$) return null;
|
|
1676
|
+
if ($.deleted) {
|
|
1677
|
+
const R = typeof x.value.sku == "string" ? x.value.sku : "";
|
|
1678
|
+
return { path: `${t.base}/deleted`, query: R ? { q: R } : {} };
|
|
1679
|
+
}
|
|
1680
|
+
return { path: `${t.base}/products/${$.id}` };
|
|
1681
|
+
});
|
|
1682
|
+
async function z() {
|
|
1683
|
+
const $ = y.value;
|
|
1684
|
+
if (!(!$ || !await ge({
|
|
1685
|
+
title: s("panel.delete-product-title", { name: $.name }),
|
|
1686
|
+
message: s("panel.delete-product-text"),
|
|
1687
|
+
confirmText: s("panel.delete"),
|
|
1688
|
+
cancelText: s("panel.cancel"),
|
|
1689
|
+
tone: "danger"
|
|
1690
|
+
})))
|
|
1691
|
+
try {
|
|
1692
|
+
await f.removeProduct($.id), E.success(s("panel.product-deleted")), A.value = c.value, m.push(b.value);
|
|
1693
|
+
} catch (ve) {
|
|
1694
|
+
E.danger(a(ve));
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
function I($) {
|
|
1698
|
+
g.value && $.preventDefault();
|
|
1699
|
+
}
|
|
1700
|
+
function Z($) {
|
|
1701
|
+
($.ctrlKey || $.metaKey) && $.key.toLowerCase() === "s" && ($.preventDefault(), g.value && ue());
|
|
1702
|
+
}
|
|
1703
|
+
ht(Z), we(w, () => {
|
|
1704
|
+
re();
|
|
1705
|
+
}), ie(() => {
|
|
1706
|
+
re(), window.addEventListener("beforeunload", I);
|
|
1707
|
+
}), Te(() => {
|
|
1708
|
+
window.removeEventListener("beforeunload", I);
|
|
1709
|
+
}), mt(async () => !g.value || !L.value ? !0 : await ge({
|
|
1710
|
+
title: s("panel.leave-title"),
|
|
1711
|
+
message: s("panel.leave-text"),
|
|
1712
|
+
confirmText: s("panel.leave"),
|
|
1713
|
+
cancelText: s("panel.cancel"),
|
|
1714
|
+
tone: "danger"
|
|
1715
|
+
}));
|
|
1716
|
+
const T = h(() => {
|
|
1717
|
+
const $ = y.value, R = [];
|
|
1718
|
+
return $ && ($.url && R.push({ key: "site", label: s("panel.open-on-site"), icon: "link", href: $.url }), U.value && R.push({
|
|
1719
|
+
key: "delete",
|
|
1720
|
+
label: s("panel.delete"),
|
|
1721
|
+
icon: "trash",
|
|
1722
|
+
danger: !0,
|
|
1723
|
+
menu: !0,
|
|
1724
|
+
run: () => {
|
|
1725
|
+
z();
|
|
1726
|
+
}
|
|
1727
|
+
})), R;
|
|
1728
|
+
});
|
|
1729
|
+
return ($, R) => (v(), B("div", {
|
|
1730
|
+
class: "wx-catalog-product",
|
|
1731
|
+
onKeydown: Z
|
|
1732
|
+
}, [
|
|
1733
|
+
S.value || !y.value ? (v(), B(ee, { key: 0 }, [
|
|
1734
|
+
k(e(xe), {
|
|
1735
|
+
class: "wx-catalog-product__ghost",
|
|
1736
|
+
title: "",
|
|
1737
|
+
rows: 1
|
|
1738
|
+
}),
|
|
1739
|
+
k(e($t), null, {
|
|
1740
|
+
default: o(() => [
|
|
1741
|
+
k(e(xe), { rows: 8 })
|
|
1742
|
+
]),
|
|
1743
|
+
_: 1
|
|
1744
|
+
})
|
|
1745
|
+
], 64)) : (v(), B(ee, { key: 1 }, [
|
|
1746
|
+
k(e(bt), {
|
|
1747
|
+
divider: "",
|
|
1748
|
+
back: b.value,
|
|
1749
|
+
"back-label": e(s)("module.products"),
|
|
1750
|
+
title: H.value,
|
|
1751
|
+
subtitle: se.value,
|
|
1752
|
+
actions: T.value
|
|
1753
|
+
}, {
|
|
1754
|
+
trail: o(() => [
|
|
1755
|
+
k(e(Ct), {
|
|
1756
|
+
size: "sm",
|
|
1757
|
+
label: e(s)("panel.product-trail")
|
|
1758
|
+
}, {
|
|
1759
|
+
default: o(() => [
|
|
1760
|
+
k(e(be), {
|
|
1761
|
+
as: "router-link",
|
|
1762
|
+
to: b.value
|
|
1763
|
+
}, {
|
|
1764
|
+
default: o(() => [
|
|
1765
|
+
P(_(j.value), 1)
|
|
1766
|
+
]),
|
|
1767
|
+
_: 1
|
|
1768
|
+
}, 8, ["to"]),
|
|
1769
|
+
y.value.category ? (v(), V(e(be), {
|
|
1770
|
+
key: 0,
|
|
1771
|
+
current: ""
|
|
1772
|
+
}, {
|
|
1773
|
+
default: o(() => [
|
|
1774
|
+
P(_(y.value.category.name), 1)
|
|
1775
|
+
]),
|
|
1776
|
+
_: 1
|
|
1777
|
+
})) : (v(), V(e(be), {
|
|
1778
|
+
key: 1,
|
|
1779
|
+
current: ""
|
|
1780
|
+
}, {
|
|
1781
|
+
default: o(() => [
|
|
1782
|
+
P(_(e(s)("product.no-category")), 1)
|
|
1783
|
+
]),
|
|
1784
|
+
_: 1
|
|
1785
|
+
}))
|
|
1786
|
+
]),
|
|
1787
|
+
_: 1
|
|
1788
|
+
}, 8, ["label"])
|
|
1789
|
+
]),
|
|
1790
|
+
"title-after": o(() => [
|
|
1791
|
+
k(e(Y), {
|
|
1792
|
+
type: y.value.is_published ? y.value.visible ? "success" : "warning" : "default",
|
|
1793
|
+
dot: ""
|
|
1794
|
+
}, {
|
|
1795
|
+
default: o(() => [
|
|
1796
|
+
P(_(e(s)(`states.${y.value.state}`)), 1)
|
|
1797
|
+
]),
|
|
1798
|
+
_: 1
|
|
1799
|
+
}, 8, ["type"]),
|
|
1800
|
+
y.value.category ? M("", !0) : (v(), V(e(Y), {
|
|
1801
|
+
key: 0,
|
|
1802
|
+
type: "warning",
|
|
1803
|
+
round: ""
|
|
1804
|
+
}, {
|
|
1805
|
+
default: o(() => [
|
|
1806
|
+
P(_(e(s)("product.no-category")), 1)
|
|
1807
|
+
]),
|
|
1808
|
+
_: 1
|
|
1809
|
+
}))
|
|
1810
|
+
]),
|
|
1811
|
+
_: 1
|
|
1812
|
+
}, 8, ["back", "back-label", "title", "subtitle", "actions"]),
|
|
1813
|
+
O.value && ce.value ? (v(), V(e(We), {
|
|
1814
|
+
key: 0,
|
|
1815
|
+
type: "warning",
|
|
1816
|
+
description: F.value.sku?.[0] ?? "",
|
|
1817
|
+
closable: "",
|
|
1818
|
+
onClose: R[1] || (R[1] = (ve) => O.value = null)
|
|
1819
|
+
}, {
|
|
1820
|
+
actions: o(() => [
|
|
1821
|
+
k(e(Q), {
|
|
1822
|
+
size: "sm",
|
|
1823
|
+
variant: "outline",
|
|
1824
|
+
onClick: R[0] || (R[0] = (ve) => e(m).push(ce.value))
|
|
1825
|
+
}, {
|
|
1826
|
+
default: o(() => [
|
|
1827
|
+
P(_(O.value.deleted ? e(s)("panel.sku-open-deleted") : e(s)("panel.sku-open")), 1)
|
|
1828
|
+
]),
|
|
1829
|
+
_: 1
|
|
1830
|
+
})
|
|
1831
|
+
]),
|
|
1832
|
+
_: 1
|
|
1833
|
+
}, 8, ["description"])) : M("", !0),
|
|
1834
|
+
k(e(kt), {
|
|
1835
|
+
modelValue: x.value,
|
|
1836
|
+
"onUpdate:modelValue": R[2] || (R[2] = (ve) => x.value = ve),
|
|
1837
|
+
name: "catalog.product-form",
|
|
1838
|
+
errors: F.value,
|
|
1839
|
+
disabled: N.value
|
|
1840
|
+
}, null, 8, ["modelValue", "errors", "disabled"]),
|
|
1841
|
+
L.value ? (v(), V(e(St), { key: 1 }, {
|
|
1842
|
+
state: o(() => [
|
|
1843
|
+
k(e(_t), { state: p.value }, null, 8, ["state"])
|
|
1844
|
+
]),
|
|
1845
|
+
default: o(() => [
|
|
1846
|
+
k(e(Q), {
|
|
1847
|
+
type: "primary",
|
|
1848
|
+
loading: q.value,
|
|
1849
|
+
disabled: !g.value,
|
|
1850
|
+
onClick: ue
|
|
1851
|
+
}, {
|
|
1852
|
+
default: o(() => [
|
|
1853
|
+
P(_(e(s)("panel.save")), 1)
|
|
1854
|
+
]),
|
|
1855
|
+
_: 1
|
|
1856
|
+
}, 8, ["loading", "disabled"])
|
|
1857
|
+
]),
|
|
1858
|
+
_: 1
|
|
1859
|
+
})) : M("", !0)
|
|
1860
|
+
], 64))
|
|
1861
|
+
], 32));
|
|
1862
|
+
}
|
|
1863
|
+
}), Ja = /* @__PURE__ */ pe(Ha, [["__scopeId", "data-v-837dd378"]]), Xa = /* @__PURE__ */ le({
|
|
1864
|
+
__name: "BulkParamsDialog",
|
|
1865
|
+
props: {
|
|
1866
|
+
action: {},
|
|
1867
|
+
count: {}
|
|
1868
|
+
},
|
|
1869
|
+
setup(n) {
|
|
1870
|
+
const t = n, { open: i, resolve: f, dismiss: l } = Xe(), m = ae(), r = ye(m);
|
|
1871
|
+
oe();
|
|
1872
|
+
const s = te("webx-catalog"), a = Qt({}), w = h(
|
|
1873
|
+
() => t.action.params.every(
|
|
1874
|
+
(C) => !C.rules?.includes("required") || a[C.name] !== void 0 && a[C.name] !== null && a[C.name] !== ""
|
|
1875
|
+
)
|
|
1876
|
+
);
|
|
1877
|
+
ie(() => {
|
|
1878
|
+
t.action.params.some((C) => C.type === "category") && r.load().catch(() => {
|
|
1879
|
+
});
|
|
1880
|
+
});
|
|
1881
|
+
function b(C) {
|
|
1882
|
+
return Array.isArray(C.values) ? C.values.map(
|
|
1883
|
+
(A) => typeof A == "object" ? { value: A.value, label: A.label } : { value: A, label: String(A) }
|
|
1884
|
+
) : [];
|
|
1885
|
+
}
|
|
1886
|
+
function y(C, A) {
|
|
1887
|
+
a[C.name] = Array.isArray(A) ? A[0] ?? null : A;
|
|
1888
|
+
}
|
|
1889
|
+
function x() {
|
|
1890
|
+
w.value && f({ ...a });
|
|
1891
|
+
}
|
|
1892
|
+
return (C, A) => (v(), V(e(Qe), {
|
|
1893
|
+
open: e(i),
|
|
1894
|
+
"onUpdate:open": A[1] || (A[1] = (S) => je(i) ? i.value = S : null),
|
|
1895
|
+
title: e(s)("panel.bulk-confirm-title", { action: n.action.label }),
|
|
1896
|
+
width: 440
|
|
1897
|
+
}, {
|
|
1898
|
+
footer: o(() => [
|
|
1899
|
+
k(e(Ye), { size: "sm" }, {
|
|
1900
|
+
default: o(() => [
|
|
1901
|
+
k(e(Q), {
|
|
1902
|
+
variant: "outline",
|
|
1903
|
+
onClick: A[0] || (A[0] = (S) => e(l)())
|
|
1904
|
+
}, {
|
|
1905
|
+
default: o(() => [
|
|
1906
|
+
P(_(e(s)("panel.cancel")), 1)
|
|
1907
|
+
]),
|
|
1908
|
+
_: 1
|
|
1909
|
+
}),
|
|
1910
|
+
k(e(Q), {
|
|
1911
|
+
type: n.action.permission === "catalog.delete" && !n.action.trashed ? "danger" : "primary",
|
|
1912
|
+
disabled: !w.value,
|
|
1913
|
+
onClick: x
|
|
1914
|
+
}, {
|
|
1915
|
+
default: o(() => [
|
|
1916
|
+
P(_(e(s)("panel.bulk-apply")), 1)
|
|
1917
|
+
]),
|
|
1918
|
+
_: 1
|
|
1919
|
+
}, 8, ["type", "disabled"])
|
|
1920
|
+
]),
|
|
1921
|
+
_: 1
|
|
1922
|
+
})
|
|
1923
|
+
]),
|
|
1924
|
+
default: o(() => [
|
|
1925
|
+
k(e(J), {
|
|
1926
|
+
tone: "muted",
|
|
1927
|
+
size: "sm"
|
|
1928
|
+
}, {
|
|
1929
|
+
default: o(() => [
|
|
1930
|
+
P(_(e(s)("panel.bulk-confirm-text", { count: n.count })), 1)
|
|
1931
|
+
]),
|
|
1932
|
+
_: 1
|
|
1933
|
+
}),
|
|
1934
|
+
(v(!0), B(ee, null, ke(n.action.params, (S) => (v(), V(e(de), {
|
|
1935
|
+
key: S.name,
|
|
1936
|
+
label: S.label,
|
|
1937
|
+
required: S.rules?.includes("required"),
|
|
1938
|
+
class: "wx-catalog-bulk-params__field"
|
|
1939
|
+
}, {
|
|
1940
|
+
default: o(() => [
|
|
1941
|
+
S.type === "category" ? (v(), V(e(De), {
|
|
1942
|
+
key: 0,
|
|
1943
|
+
"model-value": a[S.name] ?? null,
|
|
1944
|
+
nodes: e(r).nodes.value ?? [],
|
|
1945
|
+
"node-key": "id",
|
|
1946
|
+
"label-key": "name",
|
|
1947
|
+
"children-key": "children",
|
|
1948
|
+
"check-strictly": "",
|
|
1949
|
+
filterable: "",
|
|
1950
|
+
"filter-placeholder": e(s)("panel.search-categories"),
|
|
1951
|
+
"aria-label": S.label,
|
|
1952
|
+
"onUpdate:modelValue": (q) => y(S, q)
|
|
1953
|
+
}, null, 8, ["model-value", "nodes", "filter-placeholder", "aria-label", "onUpdate:modelValue"])) : Array.isArray(S.values) ? (v(), V(e(Re), {
|
|
1954
|
+
key: 1,
|
|
1955
|
+
"model-value": a[S.name] ?? null,
|
|
1956
|
+
options: b(S),
|
|
1957
|
+
"aria-label": S.label,
|
|
1958
|
+
"onUpdate:modelValue": (q) => a[S.name] = q
|
|
1959
|
+
}, null, 8, ["model-value", "options", "aria-label", "onUpdate:modelValue"])) : (v(), V(e(he), {
|
|
1960
|
+
key: 2,
|
|
1961
|
+
modelValue: a[S.name],
|
|
1962
|
+
"onUpdate:modelValue": (q) => a[S.name] = q,
|
|
1963
|
+
"aria-label": S.label
|
|
1964
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "aria-label"]))
|
|
1965
|
+
]),
|
|
1966
|
+
_: 2
|
|
1967
|
+
}, 1032, ["label", "required"]))), 128))
|
|
1968
|
+
]),
|
|
1969
|
+
_: 1
|
|
1970
|
+
}, 8, ["open", "title"]));
|
|
1971
|
+
}
|
|
1972
|
+
}), Qa = /* @__PURE__ */ pe(Xa, [["__scopeId", "data-v-b83c3fb0"]]), Ya = { class: "wx-catalog-bulk" }, Za = {
|
|
1973
|
+
key: 1,
|
|
1974
|
+
class: "wx-catalog-bulk__progress",
|
|
1975
|
+
role: "status"
|
|
1976
|
+
}, el = {
|
|
1977
|
+
key: 2,
|
|
1978
|
+
class: "wx-catalog-bulk__refused"
|
|
1979
|
+
}, tl = { class: "wx-catalog-bulk__errors" }, ut = 1500, al = /* @__PURE__ */ le({
|
|
1980
|
+
__name: "BulkBar",
|
|
1981
|
+
props: {
|
|
1982
|
+
count: {},
|
|
1983
|
+
selection: {}
|
|
1984
|
+
},
|
|
1985
|
+
emits: ["finished"],
|
|
1986
|
+
setup(n, { emit: t }) {
|
|
1987
|
+
const i = n, f = t, l = ae(), m = ne(l);
|
|
1988
|
+
oe();
|
|
1989
|
+
const r = te("webx-catalog"), s = me(), a = Ze(
|
|
1990
|
+
Qa
|
|
1991
|
+
), w = D([]), b = D(null), y = D(!1);
|
|
1992
|
+
let x;
|
|
1993
|
+
const C = h(
|
|
1994
|
+
() => b.value !== null && (b.value.status === "queued" || b.value.status === "running")
|
|
1995
|
+
), A = h(
|
|
1996
|
+
() => b.value !== null && !C.value && b.value.failed > 0 ? b.value : null
|
|
1997
|
+
);
|
|
1998
|
+
ie(async () => {
|
|
1999
|
+
try {
|
|
2000
|
+
w.value = await m.bulkActions();
|
|
2001
|
+
} catch {
|
|
2002
|
+
w.value = [];
|
|
2003
|
+
}
|
|
2004
|
+
}), Te(() => clearTimeout(x));
|
|
2005
|
+
function S(U) {
|
|
2006
|
+
return U.params.length > 0 || U.permission === "catalog.delete" && !U.trashed;
|
|
2007
|
+
}
|
|
2008
|
+
async function q(U) {
|
|
2009
|
+
let N = {};
|
|
2010
|
+
if (S(U)) {
|
|
2011
|
+
const c = await a({ action: U, count: i.count });
|
|
2012
|
+
if (!c) return;
|
|
2013
|
+
N = c;
|
|
2014
|
+
}
|
|
2015
|
+
y.value = !0;
|
|
2016
|
+
try {
|
|
2017
|
+
F(await m.startBulk(U.key, N, i.selection));
|
|
2018
|
+
} catch (c) {
|
|
2019
|
+
E.danger(s(c));
|
|
2020
|
+
} finally {
|
|
2021
|
+
y.value = !1;
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
function F(U) {
|
|
2025
|
+
if (b.value = U, U.status === "queued" || U.status === "running") {
|
|
2026
|
+
x = setTimeout(() => {
|
|
2027
|
+
O(U.id);
|
|
2028
|
+
}, ut);
|
|
2029
|
+
return;
|
|
2030
|
+
}
|
|
2031
|
+
L(U);
|
|
2032
|
+
}
|
|
2033
|
+
async function O(U) {
|
|
2034
|
+
try {
|
|
2035
|
+
F(await m.bulkRun(U));
|
|
2036
|
+
} catch {
|
|
2037
|
+
x = setTimeout(() => {
|
|
2038
|
+
O(U);
|
|
2039
|
+
}, ut * 2);
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
function L(U) {
|
|
2043
|
+
U.total === 0 ? E.warning(r("panel.bulk-nothing")) : U.status === "failed" ? E.danger(r("panel.bulk-stopped", { count: U.done })) : U.failed === 0 && E.success(r("panel.bulk-done", { count: U.done })), U.failed === 0 && U.status !== "failed" && (b.value = null), f(
|
|
2044
|
+
"finished",
|
|
2045
|
+
U.errors.map((N) => N.id)
|
|
2046
|
+
);
|
|
2047
|
+
}
|
|
2048
|
+
return (U, N) => (v(), B("div", Ya, [
|
|
2049
|
+
w.value.length > 0 && !C.value ? (v(), V(e(na), {
|
|
2050
|
+
key: 0,
|
|
2051
|
+
align: "start"
|
|
2052
|
+
}, {
|
|
2053
|
+
trigger: o(() => [
|
|
2054
|
+
k(e(Q), {
|
|
2055
|
+
size: "sm",
|
|
2056
|
+
variant: "outline",
|
|
2057
|
+
loading: y.value
|
|
2058
|
+
}, {
|
|
2059
|
+
default: o(() => [
|
|
2060
|
+
P(_(e(r)("panel.bulk-actions")) + " ", 1),
|
|
2061
|
+
k(e(Be), {
|
|
2062
|
+
name: "chevron-down",
|
|
2063
|
+
size: "sm"
|
|
2064
|
+
})
|
|
2065
|
+
]),
|
|
2066
|
+
_: 1
|
|
2067
|
+
}, 8, ["loading"])
|
|
2068
|
+
]),
|
|
2069
|
+
default: o(() => [
|
|
2070
|
+
(v(!0), B(ee, null, ke(w.value, (c) => (v(), V(e(oa), {
|
|
2071
|
+
key: c.key,
|
|
2072
|
+
tone: c.permission === "catalog.delete" && !c.trashed ? "danger" : "default",
|
|
2073
|
+
onClick: (g) => q(c)
|
|
2074
|
+
}, {
|
|
2075
|
+
default: o(() => [
|
|
2076
|
+
P(_(c.label), 1)
|
|
2077
|
+
]),
|
|
2078
|
+
_: 2
|
|
2079
|
+
}, 1032, ["tone", "onClick"]))), 128))
|
|
2080
|
+
]),
|
|
2081
|
+
_: 1
|
|
2082
|
+
})) : M("", !0),
|
|
2083
|
+
C.value && b.value ? (v(), B("div", Za, [
|
|
2084
|
+
k(e(sa), {
|
|
2085
|
+
value: b.value.done + b.value.failed,
|
|
2086
|
+
max: Math.max(1, b.value.total),
|
|
2087
|
+
size: "sm",
|
|
2088
|
+
"aria-label": b.value.label
|
|
2089
|
+
}, null, 8, ["value", "max", "aria-label"]),
|
|
2090
|
+
k(e(J), {
|
|
2091
|
+
size: "sm",
|
|
2092
|
+
tone: "muted"
|
|
2093
|
+
}, {
|
|
2094
|
+
default: o(() => [
|
|
2095
|
+
P(_(b.value.label) + " · " + _(e(r)("panel.bulk-running", { done: b.value.done + b.value.failed, total: b.value.total })), 1)
|
|
2096
|
+
]),
|
|
2097
|
+
_: 1
|
|
2098
|
+
})
|
|
2099
|
+
])) : M("", !0),
|
|
2100
|
+
A.value ? (v(), B("div", el, [
|
|
2101
|
+
k(e(J), {
|
|
2102
|
+
size: "sm",
|
|
2103
|
+
weight: "medium"
|
|
2104
|
+
}, {
|
|
2105
|
+
default: o(() => [
|
|
2106
|
+
P(_(A.value.label) + " · " + _(e(r)("panel.bulk-done", { count: A.value.done })) + " · " + _(e(r)("panel.bulk-refused", { count: A.value.failed })), 1)
|
|
2107
|
+
]),
|
|
2108
|
+
_: 1
|
|
2109
|
+
}),
|
|
2110
|
+
G("details", tl, [
|
|
2111
|
+
G("summary", null, _(e(r)("panel.bulk-errors")), 1),
|
|
2112
|
+
G("ul", null, [
|
|
2113
|
+
(v(!0), B(ee, null, ke(A.value.errors, (c) => (v(), B("li", {
|
|
2114
|
+
key: c.id
|
|
2115
|
+
}, [
|
|
2116
|
+
G("strong", null, _(c.name), 1),
|
|
2117
|
+
P(" — " + _(c.message), 1)
|
|
2118
|
+
]))), 128))
|
|
2119
|
+
])
|
|
2120
|
+
]),
|
|
2121
|
+
k(e(Q), {
|
|
2122
|
+
size: "sm",
|
|
2123
|
+
variant: "text",
|
|
2124
|
+
onClick: N[0] || (N[0] = (c) => b.value = null)
|
|
2125
|
+
}, {
|
|
2126
|
+
default: o(() => [
|
|
2127
|
+
P(_(e(r)("panel.bulk-close")), 1)
|
|
2128
|
+
]),
|
|
2129
|
+
_: 1
|
|
2130
|
+
})
|
|
2131
|
+
])) : M("", !0)
|
|
2132
|
+
]));
|
|
2133
|
+
}
|
|
2134
|
+
}), ll = /* @__PURE__ */ pe(al, [["__scopeId", "data-v-94557c14"]]), nl = /* @__PURE__ */ le({
|
|
2135
|
+
__name: "ProductCreateDialog",
|
|
2136
|
+
setup(n) {
|
|
2137
|
+
const { open: t, resolve: i, dismiss: f } = Xe(), l = ae(), m = ne(l), r = Ue();
|
|
2138
|
+
oe();
|
|
2139
|
+
const s = te("webx-catalog"), a = D(""), w = D(!1), b = D({}), y = Me("field");
|
|
2140
|
+
ie(async () => {
|
|
2141
|
+
await ct(), y.value?.querySelector("input")?.focus();
|
|
2142
|
+
});
|
|
2143
|
+
async function x() {
|
|
2144
|
+
if (!(a.value.trim() === "" || w.value)) {
|
|
2145
|
+
w.value = !0, b.value = {};
|
|
2146
|
+
try {
|
|
2147
|
+
i(
|
|
2148
|
+
await m.createProduct({
|
|
2149
|
+
name: { [r.active.value]: a.value.trim() },
|
|
2150
|
+
is_published: !1
|
|
2151
|
+
})
|
|
2152
|
+
);
|
|
2153
|
+
} catch (C) {
|
|
2154
|
+
b.value = C.body?.errors ?? {};
|
|
2155
|
+
} finally {
|
|
2156
|
+
w.value = !1;
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
return (C, A) => (v(), V(e(Qe), {
|
|
2161
|
+
open: e(t),
|
|
2162
|
+
"onUpdate:open": A[2] || (A[2] = (S) => je(t) ? t.value = S : null),
|
|
2163
|
+
title: e(s)("panel.new-product"),
|
|
2164
|
+
width: 440
|
|
2165
|
+
}, {
|
|
2166
|
+
footer: o(() => [
|
|
2167
|
+
k(e(Ye), { size: "sm" }, {
|
|
2168
|
+
default: o(() => [
|
|
2169
|
+
k(e(Q), {
|
|
2170
|
+
variant: "outline",
|
|
2171
|
+
onClick: A[1] || (A[1] = (S) => e(f)())
|
|
2172
|
+
}, {
|
|
2173
|
+
default: o(() => [
|
|
2174
|
+
P(_(e(s)("panel.cancel")), 1)
|
|
2175
|
+
]),
|
|
2176
|
+
_: 1
|
|
2177
|
+
}),
|
|
2178
|
+
k(e(Q), {
|
|
2179
|
+
type: "primary",
|
|
2180
|
+
loading: w.value,
|
|
2181
|
+
disabled: a.value.trim() === "",
|
|
2182
|
+
onClick: x
|
|
2183
|
+
}, {
|
|
2184
|
+
default: o(() => [
|
|
2185
|
+
P(_(e(s)("panel.create")), 1)
|
|
2186
|
+
]),
|
|
2187
|
+
_: 1
|
|
2188
|
+
}, 8, ["loading", "disabled"])
|
|
2189
|
+
]),
|
|
2190
|
+
_: 1
|
|
2191
|
+
})
|
|
2192
|
+
]),
|
|
2193
|
+
default: o(() => [
|
|
2194
|
+
k(e(de), {
|
|
2195
|
+
label: e(s)("product.name"),
|
|
2196
|
+
error: e(_e)(b.value, "name") ?? e(_e)(b.value, "slug"),
|
|
2197
|
+
required: ""
|
|
2198
|
+
}, {
|
|
2199
|
+
default: o(() => [
|
|
2200
|
+
G("div", {
|
|
2201
|
+
ref_key: "field",
|
|
2202
|
+
ref: y
|
|
2203
|
+
}, [
|
|
2204
|
+
k(e(he), {
|
|
2205
|
+
modelValue: a.value,
|
|
2206
|
+
"onUpdate:modelValue": A[0] || (A[0] = (S) => a.value = S),
|
|
2207
|
+
"aria-label": e(s)("product.name"),
|
|
2208
|
+
onKeyup: Ke(x, ["enter"])
|
|
2209
|
+
}, null, 8, ["modelValue", "aria-label"])
|
|
2210
|
+
], 512)
|
|
2211
|
+
]),
|
|
2212
|
+
_: 1
|
|
2213
|
+
}, 8, ["label", "error"])
|
|
2214
|
+
]),
|
|
2215
|
+
_: 1
|
|
2216
|
+
}, 8, ["open", "title"]));
|
|
2217
|
+
}
|
|
2218
|
+
}), Le = "f.";
|
|
2219
|
+
function ol(n, t) {
|
|
2220
|
+
const i = {};
|
|
2221
|
+
for (const f of t) {
|
|
2222
|
+
const l = n[`${Le}${f.key}`], m = typeof l == "string" ? l.trim() : "";
|
|
2223
|
+
if (m !== "")
|
|
2224
|
+
if (f.kind === "toggle")
|
|
2225
|
+
m === "1" && (i[f.key] = !0);
|
|
2226
|
+
else if (f.kind === "range") {
|
|
2227
|
+
const [r, s] = m.split("-", 2).map((w) => w === "" ? null : Number(w)), a = {
|
|
2228
|
+
min: Number.isFinite(r) ? r : null,
|
|
2229
|
+
max: Number.isFinite(s) ? s : null
|
|
2230
|
+
};
|
|
2231
|
+
(a.min !== null || a.max !== null) && (i[f.key] = a);
|
|
2232
|
+
} else {
|
|
2233
|
+
const r = m.split(",").filter((s) => s !== "");
|
|
2234
|
+
r.length > 0 && (i[f.key] = r);
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
return i;
|
|
2238
|
+
}
|
|
2239
|
+
function sl(n) {
|
|
2240
|
+
if (n == null) return;
|
|
2241
|
+
if (n === !0) return "1";
|
|
2242
|
+
if (Array.isArray(n)) return n.length > 0 ? n.join(",") : void 0;
|
|
2243
|
+
const t = n.min ?? null, i = n.max ?? null;
|
|
2244
|
+
return t === null && i === null ? void 0 : `${t ?? ""}-${i ?? ""}`;
|
|
2245
|
+
}
|
|
2246
|
+
const rl = {
|
|
2247
|
+
key: 0,
|
|
2248
|
+
class: "wx-catalog-products__selection"
|
|
2249
|
+
}, ul = {
|
|
2250
|
+
key: 1,
|
|
2251
|
+
class: "wx-catalog-products__range"
|
|
2252
|
+
}, il = ["src"], cl = { class: "wx-catalog-products__name" }, dl = { class: "wx-catalog-products__title" }, pl = { class: "wx-catalog-products__sku" }, vl = { class: "wx-catalog-products__price" }, gl = { key: 0 }, ml = { key: 0 }, it = 640, yl = /* @__PURE__ */ le({
|
|
2253
|
+
__name: "ProductsPage",
|
|
2254
|
+
props: {
|
|
2255
|
+
base: { default: "/catalog" }
|
|
2256
|
+
},
|
|
2257
|
+
setup(n) {
|
|
2258
|
+
const t = n, i = ae(), f = ne(i), l = ye(i), m = Vt(i), r = ze(), s = $e();
|
|
2259
|
+
oe();
|
|
2260
|
+
const a = te("webx-catalog"), w = te("webx-admin"), b = me(), y = Me("root"), x = ra(y), C = D(null), A = D(!0), S = D([]), q = D(!1), F = D(typeof r.query.q == "string" ? r.query.q : ""), O = D(Number(r.query.page ?? 1) || 1);
|
|
2261
|
+
let L;
|
|
2262
|
+
const U = Ze(nl), N = h(() => i.can("catalog.manage")), c = h(() => i.can("catalog.delete")), g = h(() => a("module.products")), p = h({
|
|
2263
|
+
get: () => typeof r.query.view == "string" ? r.query.view : "",
|
|
2264
|
+
set: (d) => {
|
|
2265
|
+
s.replace({
|
|
2266
|
+
query: { ...r.query, view: d === "" ? void 0 : String(d), page: void 0 }
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
}), j = h(
|
|
2270
|
+
() => m.sorts.value.length > 0 ? m.sorts.value : [{ key: "default", label: a("panel.sort-default") }]
|
|
2271
|
+
), H = h(() => {
|
|
2272
|
+
const d = r.query.sort;
|
|
2273
|
+
return typeof d == "string" && m.sorts.value.some((W) => W.key === d) ? d : "default";
|
|
2274
|
+
}), se = h(() => m.facets.value ?? []), X = h(() => ol(r.query, se.value)), re = h(() => {
|
|
2275
|
+
const d = C.value?.counts.no_category ?? 0;
|
|
2276
|
+
return [
|
|
2277
|
+
{ value: "", label: a("panel.view-all") },
|
|
2278
|
+
{ value: "published", label: a("panel.view-published") },
|
|
2279
|
+
{ value: "unpublished", label: a("panel.view-unpublished") },
|
|
2280
|
+
{
|
|
2281
|
+
value: "no-category",
|
|
2282
|
+
label: a("panel.view-no-category"),
|
|
2283
|
+
badge: d > 0 ? d : void 0
|
|
2284
|
+
}
|
|
2285
|
+
];
|
|
2286
|
+
}), ue = h(() => (C.value?.data ?? []).some((d) => "price" in d)), ce = h(() => C.value?.columns ?? []), z = h(() => x.value > 0 && x.value < it), I = h(
|
|
2287
|
+
() => new Map(qe(l.nodes.value ?? []).map((d) => [String(d.id), d.name]))
|
|
2288
|
+
), Z = h(() => z.value ? [{ key: "card", label: "" }] : [
|
|
2289
|
+
{ key: "image", label: "", width: 64 },
|
|
2290
|
+
{ key: "name", label: a("panel.column-product"), minWidth: 200 },
|
|
2291
|
+
{ key: "category", label: a("product.category"), width: 180, hideBelow: 860 },
|
|
2292
|
+
...ue.value ? [{ key: "price", label: a("product.price"), width: 150, align: "right" }] : [],
|
|
2293
|
+
...ce.value.map((d) => ({
|
|
2294
|
+
key: `x.${d.key}`,
|
|
2295
|
+
label: d.label,
|
|
2296
|
+
width: 120,
|
|
2297
|
+
hideBelow: 1040
|
|
2298
|
+
})),
|
|
2299
|
+
{ key: "state", label: a("panel.column-state"), width: 150, hideBelow: 720 },
|
|
2300
|
+
{ key: "updated_at", label: a("panel.column-updated"), width: 130, hideBelow: 1180 },
|
|
2301
|
+
{ key: "actions", label: "", width: Ae, align: "right" }
|
|
2302
|
+
]);
|
|
2303
|
+
function T(d) {
|
|
2304
|
+
return {
|
|
2305
|
+
q: d?.search ?? F.value,
|
|
2306
|
+
state: p.value,
|
|
2307
|
+
sort: H.value,
|
|
2308
|
+
page: d?.page ?? O.value,
|
|
2309
|
+
per_page: d?.perPage ?? L,
|
|
2310
|
+
facets: X.value
|
|
2311
|
+
};
|
|
2312
|
+
}
|
|
2313
|
+
let $ = 0;
|
|
2314
|
+
async function R(d) {
|
|
2315
|
+
const W = ++$;
|
|
2316
|
+
A.value = !0;
|
|
2317
|
+
try {
|
|
2318
|
+
const u = await f.products(T(d));
|
|
2319
|
+
W === $ && (C.value = u);
|
|
2320
|
+
} catch (u) {
|
|
2321
|
+
E.danger(b(u));
|
|
2322
|
+
} finally {
|
|
2323
|
+
W === $ && (A.value = !1);
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
function ve(d) {
|
|
2327
|
+
L = d.perPage;
|
|
2328
|
+
const W = {
|
|
2329
|
+
...r.query,
|
|
2330
|
+
q: d.search === "" ? void 0 : d.search,
|
|
2331
|
+
page: d.page === 1 ? void 0 : String(d.page)
|
|
2332
|
+
};
|
|
2333
|
+
s.replace({ query: W }), R(d);
|
|
2334
|
+
}
|
|
2335
|
+
function fe(d, W) {
|
|
2336
|
+
s.replace({
|
|
2337
|
+
query: { ...r.query, [`${Le}${d}`]: sl(W), page: void 0 }
|
|
2338
|
+
});
|
|
2339
|
+
}
|
|
2340
|
+
function Ut(d) {
|
|
2341
|
+
s.replace({
|
|
2342
|
+
query: {
|
|
2343
|
+
...r.query,
|
|
2344
|
+
sort: typeof d == "string" && d !== "default" ? d : void 0,
|
|
2345
|
+
page: void 0
|
|
2346
|
+
}
|
|
2347
|
+
});
|
|
2348
|
+
}
|
|
2349
|
+
function Dt() {
|
|
2350
|
+
const d = Object.fromEntries(
|
|
2351
|
+
Object.entries(r.query).filter(([W]) => !W.startsWith(Le))
|
|
2352
|
+
);
|
|
2353
|
+
s.replace({ query: { ...d, page: void 0 } });
|
|
2354
|
+
}
|
|
2355
|
+
function qt(d) {
|
|
2356
|
+
const W = C.value?.facets?.[d]?.values ?? [], u = W.map((K) => ({
|
|
2357
|
+
value: K.value,
|
|
2358
|
+
label: `${K.label} (${K.count})`
|
|
2359
|
+
}));
|
|
2360
|
+
for (const K of Ne(d))
|
|
2361
|
+
W.some((Gt) => Gt.value === K) || u.push({ value: K, label: K });
|
|
2362
|
+
return u;
|
|
2363
|
+
}
|
|
2364
|
+
function Nt(d, W) {
|
|
2365
|
+
return d.kind === "tree" ? I.value.get(String(W)) ?? `#${W}` : C.value?.facets?.[d.key]?.values?.find((u) => u.value === String(W))?.label ?? String(W);
|
|
2366
|
+
}
|
|
2367
|
+
function tt(d, W) {
|
|
2368
|
+
const u = C.value?.facets?.[d]?.[W];
|
|
2369
|
+
return typeof u == "number" ? lt.value.format(u) : "";
|
|
2370
|
+
}
|
|
2371
|
+
const Ce = h(
|
|
2372
|
+
() => se.value.flatMap((d) => {
|
|
2373
|
+
const W = X.value[d.key];
|
|
2374
|
+
if (W === void 0) return [];
|
|
2375
|
+
let u;
|
|
2376
|
+
return W === !0 ? u = d.label : Array.isArray(W) ? u = `${d.label}: ${W.map((K) => Nt(d, K)).join(", ")}` : u = `${d.label}: ${W.min ?? "…"} – ${W.max ?? "…"}`, [{ key: d.key, label: u, clear: () => fe(d.key, null) }];
|
|
2377
|
+
})
|
|
2378
|
+
), Ft = h(() => F.value !== "" || Ce.value.length > 0 || p.value !== "" ? a("panel.empty-search") : a("panel.empty-products"));
|
|
2379
|
+
function Se(d) {
|
|
2380
|
+
const W = X.value[d];
|
|
2381
|
+
return W && !Array.isArray(W) && W !== !0 ? W : {};
|
|
2382
|
+
}
|
|
2383
|
+
function Ne(d) {
|
|
2384
|
+
const W = X.value[d];
|
|
2385
|
+
return Array.isArray(W) ? W.map(String) : [];
|
|
2386
|
+
}
|
|
2387
|
+
function Ot(d) {
|
|
2388
|
+
return Ne(d).map(Number);
|
|
2389
|
+
}
|
|
2390
|
+
const Pe = h(() => C.value?.total ?? 0), Et = h(() => {
|
|
2391
|
+
if (!q.value) return { ids: S.value.map(Number) };
|
|
2392
|
+
const d = {};
|
|
2393
|
+
for (const [W, u] of Object.entries(X.value))
|
|
2394
|
+
d[W] = u === !0 ? ["1"] : u;
|
|
2395
|
+
return { query: { q: F.value, state: String(p.value), facets: d } };
|
|
2396
|
+
});
|
|
2397
|
+
function It() {
|
|
2398
|
+
S.value = [], q.value = !1;
|
|
2399
|
+
}
|
|
2400
|
+
function Rt(d) {
|
|
2401
|
+
q.value = !1, S.value = d, R();
|
|
2402
|
+
}
|
|
2403
|
+
we([p, H, () => JSON.stringify(X.value), F], () => {
|
|
2404
|
+
q.value = !1;
|
|
2405
|
+
}), we([p, H, () => JSON.stringify(X.value)], () => {
|
|
2406
|
+
O.value !== 1 ? O.value = 1 : R();
|
|
2407
|
+
}), ie(() => {
|
|
2408
|
+
m.load().catch(() => {
|
|
2409
|
+
}), l.load().catch(() => {
|
|
2410
|
+
});
|
|
2411
|
+
});
|
|
2412
|
+
function Fe(d) {
|
|
2413
|
+
s.push({ path: `${t.base}/products/${d.id}` });
|
|
2414
|
+
}
|
|
2415
|
+
async function Bt() {
|
|
2416
|
+
const d = await U({});
|
|
2417
|
+
d && Fe(d.product);
|
|
2418
|
+
}
|
|
2419
|
+
async function at(d, W) {
|
|
2420
|
+
try {
|
|
2421
|
+
await f.saveProduct(d.id, { is_published: W }), E.success(a(W ? "panel.product-published" : "panel.product-unpublished")), await R();
|
|
2422
|
+
} catch (u) {
|
|
2423
|
+
E.danger(b(u));
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
async function Lt(d) {
|
|
2427
|
+
if (await ge({
|
|
2428
|
+
title: a("panel.delete-product-title", { name: d.name }),
|
|
2429
|
+
message: a("panel.delete-product-text"),
|
|
2430
|
+
confirmText: a("panel.delete"),
|
|
2431
|
+
cancelText: a("panel.cancel"),
|
|
2432
|
+
tone: "danger"
|
|
2433
|
+
}))
|
|
2434
|
+
try {
|
|
2435
|
+
await f.removeProduct(d.id), S.value = S.value.filter((u) => u !== d.id), E.success(a("panel.product-deleted")), await R();
|
|
2436
|
+
} catch (u) {
|
|
2437
|
+
E.danger(b(u));
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
function Mt(d) {
|
|
2441
|
+
const W = [
|
|
2442
|
+
{ key: "open", icon: "edit", label: a("panel.open"), run: () => Fe(d) }
|
|
2443
|
+
];
|
|
2444
|
+
return d.url && W.push({ key: "site", icon: "link", label: a("panel.open-on-site"), href: d.url }), N.value && W.push(
|
|
2445
|
+
d.is_published ? {
|
|
2446
|
+
key: "unpublish",
|
|
2447
|
+
icon: "eye-off",
|
|
2448
|
+
label: a("panel.unpublish"),
|
|
2449
|
+
run: () => {
|
|
2450
|
+
at(d, !1);
|
|
2451
|
+
}
|
|
2452
|
+
} : {
|
|
2453
|
+
key: "publish",
|
|
2454
|
+
icon: "eye",
|
|
2455
|
+
label: a("panel.publish"),
|
|
2456
|
+
run: () => {
|
|
2457
|
+
at(d, !0);
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
), c.value && W.push({
|
|
2461
|
+
key: "delete",
|
|
2462
|
+
icon: "trash",
|
|
2463
|
+
label: a("panel.delete"),
|
|
2464
|
+
danger: !0,
|
|
2465
|
+
run: () => {
|
|
2466
|
+
Lt(d);
|
|
2467
|
+
}
|
|
2468
|
+
}), W;
|
|
2469
|
+
}
|
|
2470
|
+
function Oe(d) {
|
|
2471
|
+
return d.is_published ? d.visible ? "success" : "warning" : "default";
|
|
2472
|
+
}
|
|
2473
|
+
const lt = h(
|
|
2474
|
+
() => new Intl.NumberFormat(i.i18n.state.locale, {
|
|
2475
|
+
minimumFractionDigits: 0,
|
|
2476
|
+
maximumFractionDigits: 2
|
|
2477
|
+
})
|
|
2478
|
+
);
|
|
2479
|
+
function Ee(d) {
|
|
2480
|
+
return d == null ? "—" : lt.value.format(d);
|
|
2481
|
+
}
|
|
2482
|
+
function nt(d) {
|
|
2483
|
+
return d.unit ? ` / ${a(`units.${d.unit}`)}` : "";
|
|
2484
|
+
}
|
|
2485
|
+
function jt(d, W) {
|
|
2486
|
+
const u = d.columns?.[W];
|
|
2487
|
+
return u == null || u === "" ? "—" : typeof u == "boolean" ? u ? "✓" : "—" : String(u);
|
|
2488
|
+
}
|
|
2489
|
+
const Kt = h(() => {
|
|
2490
|
+
const d = [];
|
|
2491
|
+
return N.value && d.push({
|
|
2492
|
+
key: "new",
|
|
2493
|
+
label: a("panel.new-product"),
|
|
2494
|
+
icon: "plus",
|
|
2495
|
+
primary: !0,
|
|
2496
|
+
run: () => {
|
|
2497
|
+
Bt();
|
|
2498
|
+
}
|
|
2499
|
+
}), d.push({
|
|
2500
|
+
key: "categories",
|
|
2501
|
+
label: a("module.categories"),
|
|
2502
|
+
icon: "folder",
|
|
2503
|
+
run: () => {
|
|
2504
|
+
s.push(`${t.base}/categories`);
|
|
2505
|
+
}
|
|
2506
|
+
}), c.value && d.push({
|
|
2507
|
+
key: "deleted",
|
|
2508
|
+
label: a("module.deleted"),
|
|
2509
|
+
icon: "trash",
|
|
2510
|
+
menu: !0,
|
|
2511
|
+
run: () => {
|
|
2512
|
+
s.push(`${t.base}/deleted`);
|
|
2513
|
+
}
|
|
2514
|
+
}), d;
|
|
2515
|
+
});
|
|
2516
|
+
return (d, W) => (v(), B("div", {
|
|
2517
|
+
ref_key: "root",
|
|
2518
|
+
ref: y,
|
|
2519
|
+
class: "wx-catalog-products"
|
|
2520
|
+
}, [
|
|
2521
|
+
k(e(He), {
|
|
2522
|
+
view: p.value,
|
|
2523
|
+
"onUpdate:view": W[4] || (W[4] = (u) => p.value = u),
|
|
2524
|
+
title: g.value,
|
|
2525
|
+
views: re.value,
|
|
2526
|
+
actions: Kt.value
|
|
2527
|
+
}, {
|
|
2528
|
+
default: o(() => [
|
|
2529
|
+
S.value.length > 0 || q.value ? (v(), B("div", rl, [
|
|
2530
|
+
k(e(J), {
|
|
2531
|
+
size: "sm",
|
|
2532
|
+
weight: "medium"
|
|
2533
|
+
}, {
|
|
2534
|
+
default: o(() => [
|
|
2535
|
+
P(_(q.value ? e(a)("panel.selected-all", { count: Pe.value }) : e(a)("panel.selected", { count: S.value.length })), 1)
|
|
2536
|
+
]),
|
|
2537
|
+
_: 1
|
|
2538
|
+
}),
|
|
2539
|
+
!q.value && Pe.value > S.value.length ? (v(), V(e(Q), {
|
|
2540
|
+
key: 0,
|
|
2541
|
+
size: "sm",
|
|
2542
|
+
variant: "text",
|
|
2543
|
+
onClick: W[0] || (W[0] = (u) => q.value = !0)
|
|
2544
|
+
}, {
|
|
2545
|
+
default: o(() => [
|
|
2546
|
+
P(_(e(a)("panel.select-all-found", { count: Pe.value })), 1)
|
|
2547
|
+
]),
|
|
2548
|
+
_: 1
|
|
2549
|
+
})) : M("", !0),
|
|
2550
|
+
k(e(Q), {
|
|
2551
|
+
size: "sm",
|
|
2552
|
+
variant: "text",
|
|
2553
|
+
onClick: It
|
|
2554
|
+
}, {
|
|
2555
|
+
default: o(() => [
|
|
2556
|
+
P(_(e(a)("panel.select-clear")), 1)
|
|
2557
|
+
]),
|
|
2558
|
+
_: 1
|
|
2559
|
+
}),
|
|
2560
|
+
N.value || c.value ? (v(), V(ll, {
|
|
2561
|
+
key: 1,
|
|
2562
|
+
count: q.value ? Pe.value : S.value.length,
|
|
2563
|
+
selection: Et.value,
|
|
2564
|
+
onFinished: Rt
|
|
2565
|
+
}, null, 8, ["count", "selection"])) : M("", !0)
|
|
2566
|
+
])) : M("", !0),
|
|
2567
|
+
k(e(et), {
|
|
2568
|
+
selected: S.value,
|
|
2569
|
+
"onUpdate:selected": W[1] || (W[1] = (u) => S.value = u),
|
|
2570
|
+
search: F.value,
|
|
2571
|
+
"onUpdate:search": W[2] || (W[2] = (u) => F.value = u),
|
|
2572
|
+
page: O.value,
|
|
2573
|
+
"onUpdate:page": W[3] || (W[3] = (u) => O.value = u),
|
|
2574
|
+
data: C.value,
|
|
2575
|
+
columns: Z.value,
|
|
2576
|
+
"row-key": "id",
|
|
2577
|
+
searchable: "",
|
|
2578
|
+
selectable: "",
|
|
2579
|
+
clickable: "",
|
|
2580
|
+
hover: "",
|
|
2581
|
+
flush: "",
|
|
2582
|
+
loading: A.value,
|
|
2583
|
+
layout: "fixed",
|
|
2584
|
+
"cards-below": it,
|
|
2585
|
+
"filters-count": Ce.value.length,
|
|
2586
|
+
"filters-label": e(w)("filters.title"),
|
|
2587
|
+
"search-placeholder": e(a)("panel.search-products"),
|
|
2588
|
+
"empty-text": Ft.value,
|
|
2589
|
+
"aria-label": g.value,
|
|
2590
|
+
onRowClick: Fe,
|
|
2591
|
+
onStateChange: ve
|
|
2592
|
+
}, Yt({
|
|
2593
|
+
filters: o(() => [
|
|
2594
|
+
k(e(de), {
|
|
2595
|
+
label: e(a)("panel.sort")
|
|
2596
|
+
}, {
|
|
2597
|
+
default: o(() => [
|
|
2598
|
+
k(e(Re), {
|
|
2599
|
+
"model-value": H.value,
|
|
2600
|
+
options: j.value.map((u) => ({ value: u.key, label: u.label })),
|
|
2601
|
+
size: "sm",
|
|
2602
|
+
"onUpdate:modelValue": Ut
|
|
2603
|
+
}, null, 8, ["model-value", "options"])
|
|
2604
|
+
]),
|
|
2605
|
+
_: 1
|
|
2606
|
+
}, 8, ["label"]),
|
|
2607
|
+
(v(!0), B(ee, null, ke(se.value, (u) => (v(), V(e(de), {
|
|
2608
|
+
key: u.key,
|
|
2609
|
+
label: u.label
|
|
2610
|
+
}, {
|
|
2611
|
+
default: o(() => [
|
|
2612
|
+
u.kind === "tree" ? (v(), V(e(De), {
|
|
2613
|
+
key: 0,
|
|
2614
|
+
"model-value": Ot(u.key),
|
|
2615
|
+
nodes: e(l).nodes.value ?? [],
|
|
2616
|
+
"node-key": "id",
|
|
2617
|
+
"label-key": "name",
|
|
2618
|
+
"children-key": "children",
|
|
2619
|
+
multiple: "",
|
|
2620
|
+
"check-strictly": "",
|
|
2621
|
+
filterable: "",
|
|
2622
|
+
clearable: "",
|
|
2623
|
+
size: "sm",
|
|
2624
|
+
placeholder: e(a)("panel.any"),
|
|
2625
|
+
"onUpdate:modelValue": (K) => fe(u.key, Array.isArray(K) ? K.map(String) : [])
|
|
2626
|
+
}, null, 8, ["model-value", "nodes", "placeholder", "onUpdate:modelValue"])) : u.kind === "range" ? (v(), B("div", ul, [
|
|
2627
|
+
k(e(ot), {
|
|
2628
|
+
"model-value": Se(u.key).min ?? null,
|
|
2629
|
+
min: 0,
|
|
2630
|
+
controls: !1,
|
|
2631
|
+
size: "sm",
|
|
2632
|
+
placeholder: tt(u.key, "min") || e(a)("panel.range-from"),
|
|
2633
|
+
"aria-label": `${u.label}: ${e(a)("panel.range-from")}`,
|
|
2634
|
+
"onUpdate:modelValue": (K) => fe(u.key, { ...Se(u.key), min: K ?? null })
|
|
2635
|
+
}, null, 8, ["model-value", "placeholder", "aria-label", "onUpdate:modelValue"]),
|
|
2636
|
+
k(e(ot), {
|
|
2637
|
+
"model-value": Se(u.key).max ?? null,
|
|
2638
|
+
min: 0,
|
|
2639
|
+
controls: !1,
|
|
2640
|
+
size: "sm",
|
|
2641
|
+
placeholder: tt(u.key, "max") || e(a)("panel.range-to"),
|
|
2642
|
+
"aria-label": `${u.label}: ${e(a)("panel.range-to")}`,
|
|
2643
|
+
"onUpdate:modelValue": (K) => fe(u.key, { ...Se(u.key), max: K ?? null })
|
|
2644
|
+
}, null, 8, ["model-value", "placeholder", "aria-label", "onUpdate:modelValue"])
|
|
2645
|
+
])) : u.kind === "toggle" ? (v(), V(e(Ie), {
|
|
2646
|
+
key: 2,
|
|
2647
|
+
"model-value": X.value[u.key] === !0,
|
|
2648
|
+
size: "sm",
|
|
2649
|
+
"onUpdate:modelValue": (K) => fe(u.key, K ? !0 : null)
|
|
2650
|
+
}, null, 8, ["model-value", "onUpdate:modelValue"])) : (v(), V(e(Re), {
|
|
2651
|
+
key: 3,
|
|
2652
|
+
"model-value": Ne(u.key),
|
|
2653
|
+
options: qt(u.key),
|
|
2654
|
+
multiple: "",
|
|
2655
|
+
filterable: "",
|
|
2656
|
+
clearable: "",
|
|
2657
|
+
size: "sm",
|
|
2658
|
+
placeholder: e(a)("panel.any"),
|
|
2659
|
+
"onUpdate:modelValue": (K) => fe(u.key, Array.isArray(K) ? K.map(String) : [])
|
|
2660
|
+
}, null, 8, ["model-value", "options", "placeholder", "onUpdate:modelValue"]))
|
|
2661
|
+
]),
|
|
2662
|
+
_: 2
|
|
2663
|
+
}, 1032, ["label"]))), 128)),
|
|
2664
|
+
Ce.value.length > 0 ? (v(), V(e(Q), {
|
|
2665
|
+
key: 0,
|
|
2666
|
+
variant: "text",
|
|
2667
|
+
size: "sm",
|
|
2668
|
+
block: "",
|
|
2669
|
+
onClick: Dt
|
|
2670
|
+
}, {
|
|
2671
|
+
icon: o(() => [
|
|
2672
|
+
k(e(Be), { name: "close" })
|
|
2673
|
+
]),
|
|
2674
|
+
default: o(() => [
|
|
2675
|
+
P(" " + _(e(w)("filters.reset")), 1)
|
|
2676
|
+
]),
|
|
2677
|
+
_: 1
|
|
2678
|
+
})) : M("", !0)
|
|
2679
|
+
]),
|
|
2680
|
+
applied: o(() => [
|
|
2681
|
+
k(e(ta), { filters: Ce.value }, null, 8, ["filters"])
|
|
2682
|
+
]),
|
|
2683
|
+
"cell-image": o(({ row: u }) => [
|
|
2684
|
+
G("span", {
|
|
2685
|
+
class: Ge(["wx-catalog-products__image", { "is-empty": !u.image }])
|
|
2686
|
+
}, [
|
|
2687
|
+
u.image ? (v(), B("img", {
|
|
2688
|
+
key: 0,
|
|
2689
|
+
src: u.image.thumb ?? u.image.url,
|
|
2690
|
+
alt: "",
|
|
2691
|
+
loading: "lazy"
|
|
2692
|
+
}, null, 8, il)) : (v(), V(e(Be), {
|
|
2693
|
+
key: 1,
|
|
2694
|
+
name: "image",
|
|
2695
|
+
size: "sm"
|
|
2696
|
+
}))
|
|
2697
|
+
], 2)
|
|
2698
|
+
]),
|
|
2699
|
+
"cell-name": o(({ row: u }) => [
|
|
2700
|
+
G("div", cl, [
|
|
2701
|
+
G("span", dl, _(u.name), 1),
|
|
2702
|
+
G("span", pl, _(u.sku ?? ""), 1)
|
|
2703
|
+
])
|
|
2704
|
+
]),
|
|
2705
|
+
"cell-category": o(({ row: u }) => [
|
|
2706
|
+
u.category ? (v(), V(e(J), {
|
|
2707
|
+
key: 1,
|
|
2708
|
+
size: "sm",
|
|
2709
|
+
truncate: "",
|
|
2710
|
+
tone: u.category.deleted ? "muted" : void 0
|
|
2711
|
+
}, {
|
|
2712
|
+
default: o(() => [
|
|
2713
|
+
P(_(u.category.name), 1)
|
|
2714
|
+
]),
|
|
2715
|
+
_: 2
|
|
2716
|
+
}, 1032, ["tone"])) : (v(), V(e(Y), {
|
|
2717
|
+
key: 0,
|
|
2718
|
+
type: "warning",
|
|
2719
|
+
size: "sm",
|
|
2720
|
+
round: ""
|
|
2721
|
+
}, {
|
|
2722
|
+
default: o(() => [
|
|
2723
|
+
P(_(e(a)("product.no-category")), 1)
|
|
2724
|
+
]),
|
|
2725
|
+
_: 1
|
|
2726
|
+
}))
|
|
2727
|
+
]),
|
|
2728
|
+
"cell-price": o(({ row: u }) => [
|
|
2729
|
+
G("span", vl, [
|
|
2730
|
+
G("span", null, [
|
|
2731
|
+
P(_(Ee(u.price)), 1),
|
|
2732
|
+
u.price != null ? (v(), B("small", gl, _(nt(u)), 1)) : M("", !0)
|
|
2733
|
+
]),
|
|
2734
|
+
u.old_price != null ? (v(), B("s", ml, _(Ee(u.old_price)), 1)) : M("", !0)
|
|
2735
|
+
])
|
|
2736
|
+
]),
|
|
2737
|
+
"cell-state": o(({ row: u }) => [
|
|
2738
|
+
u.is_published && !u.visible ? (v(), V(e(ia), {
|
|
2739
|
+
key: 0,
|
|
2740
|
+
content: e(a)("panel.invisible")
|
|
2741
|
+
}, {
|
|
2742
|
+
default: o(() => [
|
|
2743
|
+
k(e(Y), {
|
|
2744
|
+
type: Oe(u),
|
|
2745
|
+
dot: "",
|
|
2746
|
+
size: "sm"
|
|
2747
|
+
}, {
|
|
2748
|
+
default: o(() => [
|
|
2749
|
+
P(_(e(a)(`states.${u.state}`)), 1)
|
|
2750
|
+
]),
|
|
2751
|
+
_: 2
|
|
2752
|
+
}, 1032, ["type"])
|
|
2753
|
+
]),
|
|
2754
|
+
_: 2
|
|
2755
|
+
}, 1032, ["content"])) : (v(), V(e(Y), {
|
|
2756
|
+
key: 1,
|
|
2757
|
+
type: Oe(u),
|
|
2758
|
+
dot: "",
|
|
2759
|
+
size: "sm"
|
|
2760
|
+
}, {
|
|
2761
|
+
default: o(() => [
|
|
2762
|
+
P(_(e(a)(`states.${u.state}`)), 1)
|
|
2763
|
+
]),
|
|
2764
|
+
_: 2
|
|
2765
|
+
}, 1032, ["type"]))
|
|
2766
|
+
]),
|
|
2767
|
+
"cell-updated_at": o(({ row: u }) => [
|
|
2768
|
+
k(e(wt), {
|
|
2769
|
+
value: u.updated_at,
|
|
2770
|
+
compact: ""
|
|
2771
|
+
}, null, 8, ["value"])
|
|
2772
|
+
]),
|
|
2773
|
+
"cell-card": o(({ row: u }) => [
|
|
2774
|
+
k(e(ua), {
|
|
2775
|
+
variant: "plain",
|
|
2776
|
+
title: u.name,
|
|
2777
|
+
image: u.image?.thumb ?? u.image?.url ?? void 0,
|
|
2778
|
+
"image-size": "56px",
|
|
2779
|
+
"title-lines": 2,
|
|
2780
|
+
subtitle: u.sku ?? void 0
|
|
2781
|
+
}, {
|
|
2782
|
+
meta: o(() => [
|
|
2783
|
+
k(e(Y), {
|
|
2784
|
+
type: Oe(u),
|
|
2785
|
+
dot: "",
|
|
2786
|
+
size: "sm"
|
|
2787
|
+
}, {
|
|
2788
|
+
default: o(() => [
|
|
2789
|
+
P(_(e(a)(`states.${u.state}`)), 1)
|
|
2790
|
+
]),
|
|
2791
|
+
_: 2
|
|
2792
|
+
}, 1032, ["type"]),
|
|
2793
|
+
u.category ? M("", !0) : (v(), V(e(Y), {
|
|
2794
|
+
key: 0,
|
|
2795
|
+
type: "warning",
|
|
2796
|
+
size: "sm",
|
|
2797
|
+
round: ""
|
|
2798
|
+
}, {
|
|
2799
|
+
default: o(() => [
|
|
2800
|
+
P(_(e(a)("product.no-category")), 1)
|
|
2801
|
+
]),
|
|
2802
|
+
_: 1
|
|
2803
|
+
})),
|
|
2804
|
+
ue.value && u.price != null ? (v(), V(e(J), {
|
|
2805
|
+
key: 1,
|
|
2806
|
+
size: "sm"
|
|
2807
|
+
}, {
|
|
2808
|
+
default: o(() => [
|
|
2809
|
+
P(_(Ee(u.price)) + _(nt(u)), 1)
|
|
2810
|
+
]),
|
|
2811
|
+
_: 2
|
|
2812
|
+
}, 1024)) : M("", !0)
|
|
2813
|
+
]),
|
|
2814
|
+
_: 2
|
|
2815
|
+
}, 1032, ["title", "image", "subtitle"])
|
|
2816
|
+
]),
|
|
2817
|
+
"cell-actions": o(({ row: u }) => [
|
|
2818
|
+
k(e(Je), {
|
|
2819
|
+
actions: Mt(u),
|
|
2820
|
+
label: u.name
|
|
2821
|
+
}, null, 8, ["actions", "label"])
|
|
2822
|
+
]),
|
|
2823
|
+
_: 2
|
|
2824
|
+
}, [
|
|
2825
|
+
ke(ce.value, (u) => ({
|
|
2826
|
+
name: `cell-x.${u.key}`,
|
|
2827
|
+
fn: o(({ row: K }) => [
|
|
2828
|
+
k(e(J), {
|
|
2829
|
+
size: "sm",
|
|
2830
|
+
truncate: ""
|
|
2831
|
+
}, {
|
|
2832
|
+
default: o(() => [
|
|
2833
|
+
P(_(jt(K, u.key)), 1)
|
|
2834
|
+
]),
|
|
2835
|
+
_: 2
|
|
2836
|
+
}, 1024)
|
|
2837
|
+
])
|
|
2838
|
+
}))
|
|
2839
|
+
]), 1032, ["selected", "search", "page", "data", "columns", "loading", "filters-count", "filters-label", "search-placeholder", "empty-text", "aria-label"])
|
|
2840
|
+
]),
|
|
2841
|
+
_: 1
|
|
2842
|
+
}, 8, ["view", "title", "views", "actions"])
|
|
2843
|
+
], 512));
|
|
2844
|
+
}
|
|
2845
|
+
}), fl = /* @__PURE__ */ pe(yl, [["__scopeId", "data-v-541fe844"]]);
|
|
2846
|
+
function wl(n = {}) {
|
|
2847
|
+
const t = n.path ?? "/catalog", i = { base: t };
|
|
2848
|
+
return {
|
|
2849
|
+
id: "catalog",
|
|
2850
|
+
path: t,
|
|
2851
|
+
routes: [
|
|
2852
|
+
{ path: t, redirect: `${t}/products` },
|
|
2853
|
+
{ path: `${t}/products`, name: "webx.catalog.products", component: fl, props: i },
|
|
2854
|
+
{
|
|
2855
|
+
path: `${t}/products/:id(\\d+)`,
|
|
2856
|
+
name: "webx.catalog.products.edit",
|
|
2857
|
+
component: Ja,
|
|
2858
|
+
props: i
|
|
2859
|
+
},
|
|
2860
|
+
{
|
|
2861
|
+
path: `${t}/categories`,
|
|
2862
|
+
name: "webx.catalog.categories",
|
|
2863
|
+
component: ha,
|
|
2864
|
+
props: i
|
|
2865
|
+
},
|
|
2866
|
+
{
|
|
2867
|
+
path: `${t}/categories/:id(\\d+)`,
|
|
2868
|
+
name: "webx.catalog.categories.edit",
|
|
2869
|
+
component: $a,
|
|
2870
|
+
props: i
|
|
2871
|
+
},
|
|
2872
|
+
{ path: `${t}/deleted`, name: "webx.catalog.deleted", component: Ua, props: i }
|
|
2873
|
+
],
|
|
2874
|
+
types: {
|
|
2875
|
+
"wx-catalog-category": { component: Ca, kind: "field" },
|
|
2876
|
+
// Wide: a row of the list carries a name, a switch and a grip, and half a line is too narrow
|
|
2877
|
+
// to read which filter is which.
|
|
2878
|
+
"wx-catalog-facets": { component: Oa, kind: "field", wide: !0 },
|
|
2879
|
+
"wx-catalog-gallery": { component: Ga, kind: "display" }
|
|
2880
|
+
}
|
|
2881
|
+
};
|
|
2882
|
+
}
|
|
2883
|
+
export {
|
|
2884
|
+
ca as CATALOG_API,
|
|
2885
|
+
ha as WxCatalogCategoriesPage,
|
|
2886
|
+
ma as WxCatalogCategoryCreateDialog,
|
|
2887
|
+
$a as WxCatalogCategoryEditor,
|
|
2888
|
+
Ca as WxCatalogCategoryField,
|
|
2889
|
+
Ua as WxCatalogDeletedPage,
|
|
2890
|
+
Oa as WxCatalogFacetsField,
|
|
2891
|
+
Ga as WxCatalogGallery,
|
|
2892
|
+
nl as WxCatalogProductCreateDialog,
|
|
2893
|
+
Ja as WxCatalogProductEditor,
|
|
2894
|
+
fl as WxCatalogProductsPage,
|
|
2895
|
+
wl as catalog,
|
|
2896
|
+
va as catalogMessages,
|
|
2897
|
+
zt as categoryEditorKey,
|
|
2898
|
+
ne as createCatalogApi,
|
|
2899
|
+
Tt as productEditorKey,
|
|
2900
|
+
da as productSearch,
|
|
2901
|
+
_a as provideCatalogCategoryEditor,
|
|
2902
|
+
ba as provideProductEditor,
|
|
2903
|
+
wa as useCatalogCategoryEditor,
|
|
2904
|
+
ye as useCategoryTree,
|
|
2905
|
+
Vt as useFacetRegistry,
|
|
2906
|
+
ka as useProductEditor
|
|
2907
|
+
};
|
|
2908
|
+
//# sourceMappingURL=index.js.map
|