@webx-ui/module-catalog-properties 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 +46 -0
- package/dist/CategoryPropertiesField.d.ts +2 -0
- package/dist/IntervalsField.d.ts +2 -0
- package/dist/MergeDialog.d.ts +7 -0
- package/dist/NumberExample.d.ts +2 -0
- package/dist/ProductPropertiesField.d.ts +11 -0
- package/dist/PropertiesPage.d.ts +7 -0
- package/dist/PropertyCreateDialog.d.ts +4 -0
- package/dist/PropertyEditorPage.d.ts +7 -0
- package/dist/TypeField.d.ts +15 -0
- package/dist/ValueDialog.d.ts +18 -0
- package/dist/ValueRow.d.ts +7 -0
- package/dist/ValueSelect.d.ts +18 -0
- package/dist/ValueTreeSelect.d.ts +18 -0
- package/dist/ValuesField.d.ts +2 -0
- package/dist/api.d.ts +48 -0
- package/dist/editor.d.ts +22 -0
- package/dist/format.d.ts +27 -0
- package/dist/i18n.d.ts +4 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +2418 -0
- package/dist/index.js.map +1 -0
- package/dist/messages.d.ts +8 -0
- package/dist/module.d.ts +22 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +124 -0
- package/package.json +72 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2418 @@
|
|
|
1
|
+
import { defineComponent as le, computed as x, ref as _, watch as re, openBlock as d, createElementBlock as j, createBlock as U, unref as e, Fragment as oe, createVNode as b, withCtx as f, createTextVNode as G, toDisplayString as M, renderList as xe, createElementVNode as K, createCommentVNode as H, provide as aa, inject as He, useModel as Se, onBeforeUnmount as Ue, mergeModels as Me, useTemplateRef as Je, onMounted as Oe, nextTick as Ye, isRef as ze, withKeys as We, resolveDynamicComponent as ta, createSlots as la, mergeProps as oa, normalizeStyle as ra, withModifiers as na, h as sa } from "vue";
|
|
2
|
+
import { useAdmin as ie, useTranslate as se, useErrorText as ye, createCategoriesApi as ia, WxListScreen as ua, WxRowMenu as Ae, provideHistorySubject as da, useBodyKeys as ca, WxScreenHead as pa, WxScreen as va, WxSaveState as ma, categoryRoutes as fa } from "@webx-ui/module-admin";
|
|
3
|
+
import { localizedValue as Qe, WxAlert as de, WxSkeleton as ke, WxText as ne, WxSortableList as Ee, WxButton as te, WxSelect as Ve, toast as Y, WxAction as ga, WxInput as ge, WxInputNumber as Ne, useLocales as Be, WxTreeSelect as ya, WxFormItem as fe, WxSwitch as ha, confirm as $e, useModal as De, WxDialog as Re, WxRadioGroup as ba, WxSpace as Le, createModal as Ie, WxEmpty as _a, WxTooltip as wa, WxIcon as xa, WxCard as ka, WxBreadcrumb as Va, WxBreadcrumbItem as Fe, WxBadge as $a, WxActionBar as Pa, WxColorPicker as Sa, WxTree as je } from "@webx-ui/core";
|
|
4
|
+
import { useCatalogCategoryEditor as Ca, createCatalogApi as Ta, useProductEditor as Wa } from "@webx-ui/module-catalog";
|
|
5
|
+
import { screenErrorsKey as Aa } from "@webx-ui/schema";
|
|
6
|
+
import { useRouter as Xe, useRoute as Na, onBeforeRouteLeave as Ia } from "vue-router";
|
|
7
|
+
import { openMediaPicker as Ua } from "@webx-ui/module-media";
|
|
8
|
+
const Ma = "catalog/properties", Ze = "catalog/property-groups", Oa = "catalog/property-sets";
|
|
9
|
+
function za(r) {
|
|
10
|
+
const a = new URLSearchParams();
|
|
11
|
+
r.q && a.set("q", r.q), r.type && a.set("type", r.type), r.group != null && a.set("group", String(r.group)), r.trashed && a.set("trashed", "1");
|
|
12
|
+
for (const n of r.ids ?? []) a.append("ids[]", String(n));
|
|
13
|
+
return r.page && r.page > 1 && a.set("page", String(r.page)), r.per_page && a.set("per_page", String(r.per_page)), a;
|
|
14
|
+
}
|
|
15
|
+
function ce(r) {
|
|
16
|
+
const a = `${r.apiPath}/${Ma}`, n = (t) => t.data, V = (t, p) => p.size > 0 ? `${t}?${p}` : t;
|
|
17
|
+
return {
|
|
18
|
+
list: (t = {}) => r.http.get(V(a, za({ per_page: 500, ...t }))),
|
|
19
|
+
get: (t) => r.http.get(`${a}/${t}`).then(n),
|
|
20
|
+
create: (t) => r.http.post(a, { values: t }).then(n),
|
|
21
|
+
save: (t, p) => r.http.put(`${a}/${t}`, { values: p }).then(n),
|
|
22
|
+
reorder: (t) => r.http.post(`${a}/reorder`, { ids: t }).then(() => {
|
|
23
|
+
}),
|
|
24
|
+
remove: (t) => r.http.delete(`${a}/${t}`).then(() => {
|
|
25
|
+
}),
|
|
26
|
+
restore: (t) => r.http.post(`${a}/${t}/restore`, {}).then(n),
|
|
27
|
+
saveIntervals: (t, p) => r.http.put(`${a}/${t}/intervals`, {
|
|
28
|
+
intervals: p.map(({ id: l, title: o, slug: c, min: S, max: h }) => ({
|
|
29
|
+
id: l ?? null,
|
|
30
|
+
title: o,
|
|
31
|
+
slug: c,
|
|
32
|
+
min: S,
|
|
33
|
+
max: h
|
|
34
|
+
}))
|
|
35
|
+
}).then(n),
|
|
36
|
+
values: (t, p = null) => {
|
|
37
|
+
const l = new URLSearchParams();
|
|
38
|
+
return p !== null && l.set("parent_id", String(p)), r.http.get(V(`${a}/${t}/values`, l)).then(n);
|
|
39
|
+
},
|
|
40
|
+
searchValues: (t, p, l = 50) => r.http.get(V(`${a}/${t}/values`, new URLSearchParams({ q: p, per_page: String(l) }))).then(n),
|
|
41
|
+
valuesById: (t, p) => {
|
|
42
|
+
if (p.length === 0) return Promise.resolve([]);
|
|
43
|
+
const l = new URLSearchParams();
|
|
44
|
+
for (const o of p) l.append("ids[]", String(o));
|
|
45
|
+
return r.http.get(V(`${a}/${t}/values`, l)).then(n);
|
|
46
|
+
},
|
|
47
|
+
createValue: (t, p) => r.http.post(`${a}/${t}/values`, p).then(n),
|
|
48
|
+
saveValue: (t, p, l) => r.http.put(`${a}/${t}/values/${p}`, l).then(n),
|
|
49
|
+
moveValue: (t, p, l, o) => r.http.post(`${a}/${t}/values/${p}/move`, {
|
|
50
|
+
parent_id: l,
|
|
51
|
+
before_id: o
|
|
52
|
+
}).then(n),
|
|
53
|
+
mergeValue: (t, p, l, o = !1) => r.http.post(`${a}/${t}/values/${p}/merge`, {
|
|
54
|
+
into: l,
|
|
55
|
+
dry_run: o
|
|
56
|
+
}).then((c) => c.data.moved),
|
|
57
|
+
removeValue: (t, p) => r.http.delete(`${a}/${t}/values/${p}`).then(() => {
|
|
58
|
+
}),
|
|
59
|
+
categorySet: (t) => r.http.get(`${r.apiPath}/catalog/categories/${t}/properties`).then(n),
|
|
60
|
+
saveCategorySet: (t, p) => r.http.put(`${r.apiPath}/catalog/categories/${t}/properties`, { ids: p }).then(n),
|
|
61
|
+
effectiveSet: (t) => r.http.get(`${r.apiPath}/${Oa}/${t}`).then(n)
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function Q(r, a, n = "") {
|
|
65
|
+
return r == null || Array.isArray(r) ? n : Qe(r, a, n);
|
|
66
|
+
}
|
|
67
|
+
function ee(r, a) {
|
|
68
|
+
return Q(r.title, a) || Q(r.code, a) || `#${r.id}`;
|
|
69
|
+
}
|
|
70
|
+
function qe(r, a, n) {
|
|
71
|
+
const V = Math.max(0, Math.min(6, Math.trunc(a.precision ?? 0)));
|
|
72
|
+
let t;
|
|
73
|
+
try {
|
|
74
|
+
t = new Intl.NumberFormat(n || void 0, {
|
|
75
|
+
minimumFractionDigits: V,
|
|
76
|
+
maximumFractionDigits: V
|
|
77
|
+
}).format(r);
|
|
78
|
+
} catch {
|
|
79
|
+
t = r.toFixed(V);
|
|
80
|
+
}
|
|
81
|
+
return `${a.prefix ?? ""}${t}${a.suffix ?? ""}`;
|
|
82
|
+
}
|
|
83
|
+
function Ea(r) {
|
|
84
|
+
const a = Math.max(0, Math.min(6, Math.trunc(r ?? 0)));
|
|
85
|
+
return a === 0 ? 12 : Number(12.5.toFixed(Math.min(a, 1)));
|
|
86
|
+
}
|
|
87
|
+
function Ba(r, a) {
|
|
88
|
+
const n = a === null ? 0 : String(a).split(".")[1]?.length ?? 0;
|
|
89
|
+
return Math.min(6, Math.max(r, n));
|
|
90
|
+
}
|
|
91
|
+
const Da = {
|
|
92
|
+
module: {
|
|
93
|
+
title: "Properties",
|
|
94
|
+
property: "Property",
|
|
95
|
+
group: "Property group",
|
|
96
|
+
value: "Property value"
|
|
97
|
+
},
|
|
98
|
+
property: {
|
|
99
|
+
"tab-main": "Main",
|
|
100
|
+
"tab-values": "Values",
|
|
101
|
+
"tab-intervals": "Intervals",
|
|
102
|
+
"tab-history": "History",
|
|
103
|
+
"card-values": "Values",
|
|
104
|
+
"card-filter": "Filter and search",
|
|
105
|
+
"card-showing": "Where it is shown",
|
|
106
|
+
title: "Name",
|
|
107
|
+
code: "Code",
|
|
108
|
+
"code-help": "Latin letters, digits and hyphens: the property in a filter address (color_black), per language. Made from the name when left empty.",
|
|
109
|
+
type: "Type",
|
|
110
|
+
"type-help": "Chosen once: the values of the products have its shape.",
|
|
111
|
+
types: {
|
|
112
|
+
select: "Reference book",
|
|
113
|
+
number: "Number",
|
|
114
|
+
text: "Text",
|
|
115
|
+
bool: "Yes / no"
|
|
116
|
+
},
|
|
117
|
+
group_id: "Group",
|
|
118
|
+
is_multiple: "Several values",
|
|
119
|
+
is_tree: "Values in a tree",
|
|
120
|
+
leaves_only: "Only the last level",
|
|
121
|
+
is_filterable: "In the filter",
|
|
122
|
+
filter_mode: "Filter by",
|
|
123
|
+
modes: {
|
|
124
|
+
slider: "Slider",
|
|
125
|
+
intervals: "Intervals"
|
|
126
|
+
},
|
|
127
|
+
is_indexable: "Pages of one value open to search engines",
|
|
128
|
+
is_searchable: "Search by value",
|
|
129
|
+
in_card: "On the card in the catalogue",
|
|
130
|
+
on_page: "In the specifications of the product",
|
|
131
|
+
in_list: "Column in the list of products",
|
|
132
|
+
value_order: "Order of values",
|
|
133
|
+
orders: {
|
|
134
|
+
alpha: "Alphabetical",
|
|
135
|
+
manual: "By hand"
|
|
136
|
+
},
|
|
137
|
+
has_color: "Values have a colour",
|
|
138
|
+
has_image: "Values have a picture",
|
|
139
|
+
unit_prefix: "Before the number",
|
|
140
|
+
unit_suffix: "After the number",
|
|
141
|
+
precision: "Digits after the point",
|
|
142
|
+
toggle_slug: "The word for «yes» in an address",
|
|
143
|
+
seo_pattern: "Page title pattern",
|
|
144
|
+
"seo-pattern-help": "{category}, {property} and {value} are replaced. Empty — the catalogue's own pattern."
|
|
145
|
+
},
|
|
146
|
+
value: {
|
|
147
|
+
title: "Name",
|
|
148
|
+
slug: "Slug",
|
|
149
|
+
color: "Colour",
|
|
150
|
+
image: "Picture",
|
|
151
|
+
merged: "Merged",
|
|
152
|
+
"merged-line": ":value, products: :count"
|
|
153
|
+
},
|
|
154
|
+
product: {
|
|
155
|
+
tab: "Specifications",
|
|
156
|
+
properties: "Properties",
|
|
157
|
+
property: "Property",
|
|
158
|
+
value: "Value",
|
|
159
|
+
yes: "Yes"
|
|
160
|
+
},
|
|
161
|
+
group: {
|
|
162
|
+
title: "Name",
|
|
163
|
+
is_visible: "Heading on the page",
|
|
164
|
+
"visible-help": "Off, the properties of the group stand in the specifications without its heading.",
|
|
165
|
+
new: "New group",
|
|
166
|
+
empty: "No groups yet.",
|
|
167
|
+
"empty-help": "A group is a heading of the specifications — «Screen», «Processor». A property without one stands last, without a heading.",
|
|
168
|
+
order: "The order here is the order of the headings in the specifications of a product",
|
|
169
|
+
hidden: "Heading not shown",
|
|
170
|
+
count: "Properties: :count",
|
|
171
|
+
"delete-blocked": "While properties are in this group it cannot go — move them to another first.",
|
|
172
|
+
"delete-text": "It goes to the bin.",
|
|
173
|
+
deleted: "The group is in the bin.",
|
|
174
|
+
saved: "The group is saved."
|
|
175
|
+
},
|
|
176
|
+
panel: {
|
|
177
|
+
"category-tab": "Properties",
|
|
178
|
+
new: "New property",
|
|
179
|
+
groups: "Groups",
|
|
180
|
+
"groups-title": "Groups of properties",
|
|
181
|
+
"view-all": "Properties",
|
|
182
|
+
"view-deleted": "Deleted",
|
|
183
|
+
"type-any": "Any type",
|
|
184
|
+
"group-any": "Any group",
|
|
185
|
+
empty: "No properties yet.",
|
|
186
|
+
"empty-help": "A property is what a product is described by — a colour, a weight, Wi-Fi — and, when it is in the filter, what the catalogue is narrowed by.",
|
|
187
|
+
"empty-found": "Nothing here.",
|
|
188
|
+
order: "The order here is the order of the filter's blocks, unless a category sets its own on its «Filters» tab.",
|
|
189
|
+
"order-narrowed": "The order is dragged on the whole list: clear the type and the group first.",
|
|
190
|
+
count: "Products: :count",
|
|
191
|
+
edit: "Edit",
|
|
192
|
+
delete: "Delete",
|
|
193
|
+
restore: "Restore",
|
|
194
|
+
cancel: "Cancel",
|
|
195
|
+
create: "Create",
|
|
196
|
+
save: "Save",
|
|
197
|
+
add: "Add",
|
|
198
|
+
search: "Search",
|
|
199
|
+
searching: "Searching…",
|
|
200
|
+
"nothing-found": "Nothing found",
|
|
201
|
+
"delete-title": "Delete «:name»?",
|
|
202
|
+
"delete-text": "It goes to «Deleted»: its filter and its old addresses go, the values of the products stay, and a restore brings everything back.",
|
|
203
|
+
deleted: "The property is in «Deleted».",
|
|
204
|
+
restored: "The property is back.",
|
|
205
|
+
"in-bin": "Deleted",
|
|
206
|
+
"reorder-failed": "The order was not saved.",
|
|
207
|
+
saved: "The property is saved.",
|
|
208
|
+
"save-failed": "Not saved: check the marked fields.",
|
|
209
|
+
untitled: "Untitled",
|
|
210
|
+
trail: "Where you are",
|
|
211
|
+
"leave-title": "Leave without saving?",
|
|
212
|
+
"leave-text": "The changes to «Main» are not saved yet.",
|
|
213
|
+
leave: "Leave",
|
|
214
|
+
example: "On the site:",
|
|
215
|
+
"slug-help": "The value in a filter's address: /laptops/color_black/. Made from the name when left empty.",
|
|
216
|
+
"values-unsaved": "The values are written once the property is saved as a reference book.",
|
|
217
|
+
"values-failed": "The values did not load. Reload the page.",
|
|
218
|
+
"values-empty": "No values yet.",
|
|
219
|
+
"values-order-manual": "By hand: the order and the nesting are dragged, and the site shows them so.",
|
|
220
|
+
"values-order-alpha": "Alphabetical: the site sorts them by name in each language. Switch the order to «By hand» on «Main» to drag them.",
|
|
221
|
+
"value-new": "New value — its name, then Enter",
|
|
222
|
+
"value-new-inside": "New value in «:name»",
|
|
223
|
+
"value-add-inside": "Add inside",
|
|
224
|
+
"value-delete-title": "Delete «:name»?",
|
|
225
|
+
"value-delete-text": "No product holds it. Its old address leads to the category without it.",
|
|
226
|
+
"value-delete-branch": "No product holds it, nor anything under it. Everything under it goes too.",
|
|
227
|
+
"value-in-use": "Products hold this value: merge it into another instead. Products: :count",
|
|
228
|
+
"picture-pick": "Choose a picture",
|
|
229
|
+
"picture-change": "Another picture",
|
|
230
|
+
"picture-remove": "Remove",
|
|
231
|
+
"value-pick": "Choose",
|
|
232
|
+
"value-create": "Create «:name»",
|
|
233
|
+
"merge-with": "Merge with…",
|
|
234
|
+
"merge-title": "Merge «:name»",
|
|
235
|
+
"merge-into": "Into",
|
|
236
|
+
"merge-help": "Its products get the value chosen here, its addresses lead there, and it is gone.",
|
|
237
|
+
"merge-confirm": "«:name» becomes «:target» on the products. Products: :count",
|
|
238
|
+
merge: "Merge",
|
|
239
|
+
merged: "Merged. Products moved: :count",
|
|
240
|
+
"intervals-unsaved": "Intervals are the filter of a number by steps: save the property with «Filter by: Intervals» first.",
|
|
241
|
+
"intervals-help": "A step includes its lower end and not its upper one: «1–2 kg» and «2–3 kg» do not share a product of exactly 2 kg. An empty end is open.",
|
|
242
|
+
"intervals-empty": "No intervals yet.",
|
|
243
|
+
"interval-title": "Label",
|
|
244
|
+
"interval-min": "From",
|
|
245
|
+
"interval-max": "Up to",
|
|
246
|
+
"interval-slug": "Slug",
|
|
247
|
+
"interval-open": "Open",
|
|
248
|
+
"interval-add": "Add an interval",
|
|
249
|
+
"intervals-sort": "Sort by bounds",
|
|
250
|
+
"intervals-save": "Save the intervals",
|
|
251
|
+
"intervals-saved": "The intervals are saved.",
|
|
252
|
+
"set-unsaved": "The set is chosen once the category is saved.",
|
|
253
|
+
"set-failed": "The properties did not load. Reload the page.",
|
|
254
|
+
"set-help": "The products of the category and of everything under it are described by these properties. The ones from above come with the category and are removed where they were added.",
|
|
255
|
+
"set-from": "from «:name»",
|
|
256
|
+
"set-empty": "The category adds no properties of its own.",
|
|
257
|
+
"set-add": "Add a property…",
|
|
258
|
+
"set-remove": "Remove «:name» from the set",
|
|
259
|
+
"product-no-category": "The properties of a product are those of its main category: choose one on «Main».",
|
|
260
|
+
"product-empty-set": "The main category has no properties. They are chosen on the category's «Properties» tab.",
|
|
261
|
+
outside: "Outside the category's set: :count",
|
|
262
|
+
"outside-help": "The product holds these, but its main category does not have them: they are not shown anywhere. Moved back to such a category, the product shows them again.",
|
|
263
|
+
"outside-clear": "Delete these values",
|
|
264
|
+
"outside-clear-title": "Delete the values outside the set?",
|
|
265
|
+
"outside-clear-text": "They are deleted from the product for good; the journal keeps what they were.",
|
|
266
|
+
"outside-cleared": "The values outside the set are deleted."
|
|
267
|
+
}
|
|
268
|
+
}, ae = "webx-catalog-properties", Ge = /* @__PURE__ */ new WeakSet();
|
|
269
|
+
function _e() {
|
|
270
|
+
try {
|
|
271
|
+
const { i18n: r } = ie();
|
|
272
|
+
Ge.has(r) || (r.defaults(ae, Da), Ge.add(r));
|
|
273
|
+
} catch {
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const Ra = { class: "wx-catalog-category-properties" }, La = {
|
|
277
|
+
key: 0,
|
|
278
|
+
class: "wx-catalog-category-properties__inherited"
|
|
279
|
+
}, Fa = { class: "wx-catalog-category-properties__name" }, ja = { class: "wx-catalog-category-properties__row" }, Ga = { class: "wx-catalog-category-properties__name" }, Ka = /* @__PURE__ */ le({
|
|
280
|
+
name: "WxCatalogCategoryProperties",
|
|
281
|
+
__name: "CategoryPropertiesField",
|
|
282
|
+
setup(r) {
|
|
283
|
+
const a = ie(), n = ce(a), V = Ca();
|
|
284
|
+
_e();
|
|
285
|
+
const t = se(ae), p = ye(), l = x(() => a.i18n.state.locale), o = x(() => V?.category.value?.id ?? null), c = x(() => (V?.locked.value ?? !0) || !a.can("catalog.manage")), S = _(null), h = _([]), w = _([]), W = _(!0), O = _(!1), k = _(!1), m = _(null), C = x(
|
|
286
|
+
() => /* @__PURE__ */ new Set([
|
|
287
|
+
...(S.value?.inherited ?? []).map((s) => s.property.id),
|
|
288
|
+
...h.value.map((s) => s.id)
|
|
289
|
+
])
|
|
290
|
+
), B = x(
|
|
291
|
+
() => w.value.filter((s) => !C.value.has(s.id)).map((s) => ({ value: s.id, label: ee(s, l.value) }))
|
|
292
|
+
);
|
|
293
|
+
function z(s) {
|
|
294
|
+
S.value = s, h.value = [...s.own];
|
|
295
|
+
}
|
|
296
|
+
async function $() {
|
|
297
|
+
if (o.value !== null) {
|
|
298
|
+
W.value = !0, O.value = !1;
|
|
299
|
+
try {
|
|
300
|
+
const [s, T] = await Promise.all([n.categorySet(o.value), n.list()]);
|
|
301
|
+
z(s), w.value = T.data;
|
|
302
|
+
} catch {
|
|
303
|
+
O.value = !0;
|
|
304
|
+
} finally {
|
|
305
|
+
W.value = !1;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
re(o, () => {
|
|
310
|
+
$();
|
|
311
|
+
}, { immediate: !0 }), re(
|
|
312
|
+
() => V?.category.value?.parent_id,
|
|
313
|
+
(s, T) => {
|
|
314
|
+
T !== void 0 && s !== T && $();
|
|
315
|
+
}
|
|
316
|
+
);
|
|
317
|
+
async function E(s) {
|
|
318
|
+
if (o.value !== null) {
|
|
319
|
+
k.value = !0;
|
|
320
|
+
try {
|
|
321
|
+
z(await n.saveCategorySet(o.value, s));
|
|
322
|
+
} catch (T) {
|
|
323
|
+
const P = T.body, Z = P?.errors ? Object.values(P.errors)[0]?.[0] : void 0;
|
|
324
|
+
Y.danger(Z ?? p(T)), S.value && (h.value = [...S.value.own]);
|
|
325
|
+
} finally {
|
|
326
|
+
k.value = !1;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function D(s) {
|
|
331
|
+
typeof s == "number" && (m.value = null, E([...h.value.map((T) => T.id), s]));
|
|
332
|
+
}
|
|
333
|
+
function X(s) {
|
|
334
|
+
E(h.value.filter((T) => T.id !== s).map((T) => T.id));
|
|
335
|
+
}
|
|
336
|
+
function i() {
|
|
337
|
+
E(h.value.map((s) => s.id));
|
|
338
|
+
}
|
|
339
|
+
const v = (s) => t(`property.types.${s.type}`);
|
|
340
|
+
return (s, T) => (d(), j("div", Ra, [
|
|
341
|
+
o.value === null ? (d(), U(e(de), {
|
|
342
|
+
key: 0,
|
|
343
|
+
type: "info",
|
|
344
|
+
variant: "soft",
|
|
345
|
+
description: e(t)("panel.set-unsaved")
|
|
346
|
+
}, null, 8, ["description"])) : W.value ? (d(), U(e(ke), {
|
|
347
|
+
key: 1,
|
|
348
|
+
rows: 4
|
|
349
|
+
})) : O.value ? (d(), U(e(de), {
|
|
350
|
+
key: 2,
|
|
351
|
+
type: "warning",
|
|
352
|
+
variant: "soft",
|
|
353
|
+
description: e(t)("panel.set-failed")
|
|
354
|
+
}, null, 8, ["description"])) : (d(), j(oe, { key: 3 }, [
|
|
355
|
+
b(e(ne), {
|
|
356
|
+
size: "sm",
|
|
357
|
+
tone: "muted"
|
|
358
|
+
}, {
|
|
359
|
+
default: f(() => [
|
|
360
|
+
G(M(e(t)("panel.set-help")), 1)
|
|
361
|
+
]),
|
|
362
|
+
_: 1
|
|
363
|
+
}),
|
|
364
|
+
S.value && S.value.inherited.length > 0 ? (d(), j("ul", La, [
|
|
365
|
+
(d(!0), j(oe, null, xe(S.value.inherited, (P) => (d(), j("li", {
|
|
366
|
+
key: P.property.id,
|
|
367
|
+
class: "wx-catalog-category-properties__row is-inherited"
|
|
368
|
+
}, [
|
|
369
|
+
K("span", Fa, M(e(ee)(P.property, l.value)), 1),
|
|
370
|
+
b(e(ne), {
|
|
371
|
+
size: "sm",
|
|
372
|
+
tone: "muted",
|
|
373
|
+
truncate: ""
|
|
374
|
+
}, {
|
|
375
|
+
default: f(() => [
|
|
376
|
+
G(M(v(P.property)) + " · " + M(e(t)("panel.set-from", { name: P.from.name })), 1)
|
|
377
|
+
]),
|
|
378
|
+
_: 2
|
|
379
|
+
}, 1024)
|
|
380
|
+
]))), 128))
|
|
381
|
+
])) : H("", !0),
|
|
382
|
+
b(e(Ee), {
|
|
383
|
+
modelValue: h.value,
|
|
384
|
+
"onUpdate:modelValue": T[0] || (T[0] = (P) => h.value = P),
|
|
385
|
+
size: "sm",
|
|
386
|
+
"item-key": "id",
|
|
387
|
+
"item-label": (P) => e(ee)(P, l.value),
|
|
388
|
+
disabled: c.value || k.value,
|
|
389
|
+
"empty-text": e(t)("panel.set-empty"),
|
|
390
|
+
onMove: i
|
|
391
|
+
}, {
|
|
392
|
+
default: f(({ item: P }) => [
|
|
393
|
+
K("span", ja, [
|
|
394
|
+
K("span", Ga, M(e(ee)(P, l.value)), 1),
|
|
395
|
+
b(e(ne), {
|
|
396
|
+
size: "sm",
|
|
397
|
+
tone: "muted",
|
|
398
|
+
truncate: ""
|
|
399
|
+
}, {
|
|
400
|
+
default: f(() => [
|
|
401
|
+
G(M(v(P)), 1)
|
|
402
|
+
]),
|
|
403
|
+
_: 2
|
|
404
|
+
}, 1024)
|
|
405
|
+
])
|
|
406
|
+
]),
|
|
407
|
+
actions: f(({ item: P }) => [
|
|
408
|
+
c.value ? H("", !0) : (d(), U(e(te), {
|
|
409
|
+
key: 0,
|
|
410
|
+
size: "sm",
|
|
411
|
+
variant: "text",
|
|
412
|
+
icon: "close",
|
|
413
|
+
disabled: k.value,
|
|
414
|
+
"aria-label": e(t)("panel.set-remove", { name: e(ee)(P, l.value) }),
|
|
415
|
+
onClick: (Z) => X(P.id)
|
|
416
|
+
}, null, 8, ["disabled", "aria-label", "onClick"]))
|
|
417
|
+
]),
|
|
418
|
+
_: 1
|
|
419
|
+
}, 8, ["modelValue", "item-label", "disabled", "empty-text"]),
|
|
420
|
+
c.value ? H("", !0) : (d(), U(e(Ve), {
|
|
421
|
+
key: 1,
|
|
422
|
+
class: "wx-catalog-category-properties__add",
|
|
423
|
+
"model-value": m.value,
|
|
424
|
+
options: B.value,
|
|
425
|
+
placeholder: e(t)("panel.set-add"),
|
|
426
|
+
"empty-text": e(t)("panel.nothing-found"),
|
|
427
|
+
disabled: k.value,
|
|
428
|
+
filterable: "",
|
|
429
|
+
"onUpdate:modelValue": D
|
|
430
|
+
}, null, 8, ["model-value", "options", "placeholder", "empty-text", "disabled"]))
|
|
431
|
+
], 64))
|
|
432
|
+
]));
|
|
433
|
+
}
|
|
434
|
+
}), he = (r, a) => {
|
|
435
|
+
const n = r.__vccOpts || r;
|
|
436
|
+
for (const [V, t] of a)
|
|
437
|
+
n[V] = t;
|
|
438
|
+
return n;
|
|
439
|
+
}, Ha = /* @__PURE__ */ he(Ka, [["__scopeId", "data-v-eb81b022"]]), ea = /* @__PURE__ */ Symbol("wx-catalog-property");
|
|
440
|
+
function Ja(r) {
|
|
441
|
+
aa(ea, r);
|
|
442
|
+
}
|
|
443
|
+
function Ce() {
|
|
444
|
+
return He(ea, null);
|
|
445
|
+
}
|
|
446
|
+
const Ya = { class: "wx-catalog-intervals" }, Qa = {
|
|
447
|
+
class: "wx-catalog-intervals__head",
|
|
448
|
+
"aria-hidden": "true"
|
|
449
|
+
}, Xa = { class: "wx-catalog-intervals__row" }, Za = {
|
|
450
|
+
key: 0,
|
|
451
|
+
class: "wx-catalog-intervals__bar"
|
|
452
|
+
}, qa = /* @__PURE__ */ le({
|
|
453
|
+
name: "WxCatalogPropertyIntervals",
|
|
454
|
+
__name: "IntervalsField",
|
|
455
|
+
setup(r) {
|
|
456
|
+
const a = ie(), n = ce(a), V = Ce();
|
|
457
|
+
_e();
|
|
458
|
+
const t = se(ae), p = ye(), l = x(() => V?.property.value ?? null), o = x(() => V?.locked.value ?? !0), c = _([]), S = _(""), h = _(!1), w = _({});
|
|
459
|
+
let W = 0;
|
|
460
|
+
const O = (i) => i && !Array.isArray(i) ? { ...i } : {};
|
|
461
|
+
function k(i) {
|
|
462
|
+
return {
|
|
463
|
+
key: i.id ? `i${i.id}` : `n${++W}`,
|
|
464
|
+
id: i.id ?? null,
|
|
465
|
+
title: O(i.title),
|
|
466
|
+
slug: O(i.slug),
|
|
467
|
+
min: i.min,
|
|
468
|
+
max: i.max
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
const m = (i) => JSON.stringify(i.map(({ id: v, title: s, slug: T, min: P, max: Z }) => ({ id: v, title: s, slug: T, min: P, max: Z })));
|
|
472
|
+
function C(i) {
|
|
473
|
+
c.value = i.map(k), S.value = m(c.value);
|
|
474
|
+
}
|
|
475
|
+
re(
|
|
476
|
+
() => V?.intervals.value,
|
|
477
|
+
(i) => C(i ?? []),
|
|
478
|
+
{ immediate: !0 }
|
|
479
|
+
);
|
|
480
|
+
const B = x(() => m(c.value) !== S.value);
|
|
481
|
+
function z() {
|
|
482
|
+
const i = c.value[c.value.length - 1];
|
|
483
|
+
c.value = [
|
|
484
|
+
...c.value,
|
|
485
|
+
{ key: `n${++W}`, id: null, title: {}, slug: {}, min: i?.max ?? null, max: null }
|
|
486
|
+
];
|
|
487
|
+
}
|
|
488
|
+
function $(i) {
|
|
489
|
+
c.value = c.value.filter((v) => v.key !== i);
|
|
490
|
+
}
|
|
491
|
+
function E() {
|
|
492
|
+
const i = (s) => s.min ?? Number.NEGATIVE_INFINITY, v = (s) => s.max ?? Number.POSITIVE_INFINITY;
|
|
493
|
+
c.value = [...c.value].sort((s, T) => i(s) - i(T) || v(s) - v(T));
|
|
494
|
+
}
|
|
495
|
+
function D(i, v) {
|
|
496
|
+
const s = `intervals.${i}.${v}`, T = Object.keys(w.value).find(
|
|
497
|
+
(P) => P === s || P.startsWith(`${s}.`)
|
|
498
|
+
);
|
|
499
|
+
return T === void 0 ? void 0 : w.value[T]?.[0];
|
|
500
|
+
}
|
|
501
|
+
async function X() {
|
|
502
|
+
if (!(!l.value || h.value)) {
|
|
503
|
+
h.value = !0, w.value = {};
|
|
504
|
+
try {
|
|
505
|
+
const i = await n.saveIntervals(
|
|
506
|
+
l.value.id,
|
|
507
|
+
c.value.map(({ id: v, title: s, slug: T, min: P, max: Z }) => ({ id: v, title: s, slug: T, min: P, max: Z }))
|
|
508
|
+
);
|
|
509
|
+
V ? V.intervals.value = i : C(i), Y.success(t("panel.intervals-saved"));
|
|
510
|
+
} catch (i) {
|
|
511
|
+
const v = i.body;
|
|
512
|
+
v?.errors ? (w.value = v.errors, Y.danger(t("panel.save-failed"))) : Y.danger(p(i));
|
|
513
|
+
} finally {
|
|
514
|
+
h.value = !1;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
return (i, v) => (d(), j("div", Ya, [
|
|
519
|
+
!l.value || l.value.filter_mode !== "intervals" ? (d(), U(e(de), {
|
|
520
|
+
key: 0,
|
|
521
|
+
type: "info",
|
|
522
|
+
variant: "soft",
|
|
523
|
+
description: e(t)("panel.intervals-unsaved")
|
|
524
|
+
}, null, 8, ["description"])) : (d(), j(oe, { key: 1 }, [
|
|
525
|
+
b(e(ne), {
|
|
526
|
+
size: "sm",
|
|
527
|
+
tone: "muted"
|
|
528
|
+
}, {
|
|
529
|
+
default: f(() => [
|
|
530
|
+
G(M(e(t)("panel.intervals-help")), 1)
|
|
531
|
+
]),
|
|
532
|
+
_: 1
|
|
533
|
+
}),
|
|
534
|
+
K("div", Qa, [
|
|
535
|
+
K("span", null, M(e(t)("panel.interval-title")), 1),
|
|
536
|
+
K("span", null, M(e(t)("panel.interval-min")), 1),
|
|
537
|
+
K("span", null, M(e(t)("panel.interval-max")), 1),
|
|
538
|
+
K("span", null, M(e(t)("panel.interval-slug")), 1)
|
|
539
|
+
]),
|
|
540
|
+
b(e(Ee), {
|
|
541
|
+
modelValue: c.value,
|
|
542
|
+
"onUpdate:modelValue": v[0] || (v[0] = (s) => c.value = s),
|
|
543
|
+
class: "wx-catalog-intervals__list",
|
|
544
|
+
"item-key": "key",
|
|
545
|
+
"item-label": (s) => s.title[e(a).i18n.state.locale] ?? "",
|
|
546
|
+
disabled: o.value,
|
|
547
|
+
"empty-text": e(t)("panel.intervals-empty")
|
|
548
|
+
}, {
|
|
549
|
+
default: f(({ item: s, index: T }) => [
|
|
550
|
+
K("div", Xa, [
|
|
551
|
+
b(e(ge), {
|
|
552
|
+
modelValue: s.title,
|
|
553
|
+
"onUpdate:modelValue": (P) => s.title = P,
|
|
554
|
+
localized: "",
|
|
555
|
+
size: "sm",
|
|
556
|
+
disabled: o.value,
|
|
557
|
+
"aria-label": e(t)("panel.interval-title"),
|
|
558
|
+
status: D(T, "title") ? "error" : void 0
|
|
559
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "disabled", "aria-label", "status"]),
|
|
560
|
+
b(e(Ne), {
|
|
561
|
+
modelValue: s.min,
|
|
562
|
+
"onUpdate:modelValue": (P) => s.min = P,
|
|
563
|
+
size: "sm",
|
|
564
|
+
controls: !1,
|
|
565
|
+
disabled: o.value,
|
|
566
|
+
placeholder: e(t)("panel.interval-open"),
|
|
567
|
+
"aria-label": e(t)("panel.interval-min")
|
|
568
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "disabled", "placeholder", "aria-label"]),
|
|
569
|
+
b(e(Ne), {
|
|
570
|
+
modelValue: s.max,
|
|
571
|
+
"onUpdate:modelValue": (P) => s.max = P,
|
|
572
|
+
size: "sm",
|
|
573
|
+
controls: !1,
|
|
574
|
+
disabled: o.value,
|
|
575
|
+
placeholder: e(t)("panel.interval-open"),
|
|
576
|
+
"aria-label": e(t)("panel.interval-max"),
|
|
577
|
+
status: D(T, "max") ? "error" : void 0
|
|
578
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "disabled", "placeholder", "aria-label", "status"]),
|
|
579
|
+
b(e(ge), {
|
|
580
|
+
modelValue: s.slug,
|
|
581
|
+
"onUpdate:modelValue": (P) => s.slug = P,
|
|
582
|
+
localized: "",
|
|
583
|
+
size: "sm",
|
|
584
|
+
disabled: o.value,
|
|
585
|
+
"aria-label": e(t)("panel.interval-slug"),
|
|
586
|
+
status: D(T, "slug") ? "error" : void 0
|
|
587
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "disabled", "aria-label", "status"]),
|
|
588
|
+
(d(!0), j(oe, null, xe(["title", "max", "slug"].map((P) => D(T, P)).filter(Boolean), (P) => (d(), U(e(ne), {
|
|
589
|
+
key: P,
|
|
590
|
+
class: "wx-catalog-intervals__error",
|
|
591
|
+
size: "sm"
|
|
592
|
+
}, {
|
|
593
|
+
default: f(() => [
|
|
594
|
+
G(M(P), 1)
|
|
595
|
+
]),
|
|
596
|
+
_: 2
|
|
597
|
+
}, 1024))), 128))
|
|
598
|
+
])
|
|
599
|
+
]),
|
|
600
|
+
actions: f(({ item: s }) => [
|
|
601
|
+
b(e(ga), {
|
|
602
|
+
type: "remove",
|
|
603
|
+
label: e(t)("panel.delete"),
|
|
604
|
+
disabled: o.value,
|
|
605
|
+
onClick: (T) => $(s.key)
|
|
606
|
+
}, null, 8, ["label", "disabled", "onClick"])
|
|
607
|
+
]),
|
|
608
|
+
_: 1
|
|
609
|
+
}, 8, ["modelValue", "item-label", "disabled", "empty-text"]),
|
|
610
|
+
o.value ? H("", !0) : (d(), j("div", Za, [
|
|
611
|
+
b(e(te), {
|
|
612
|
+
size: "sm",
|
|
613
|
+
icon: "plus",
|
|
614
|
+
onClick: z
|
|
615
|
+
}, {
|
|
616
|
+
default: f(() => [
|
|
617
|
+
G(M(e(t)("panel.interval-add")), 1)
|
|
618
|
+
]),
|
|
619
|
+
_: 1
|
|
620
|
+
}),
|
|
621
|
+
b(e(te), {
|
|
622
|
+
size: "sm",
|
|
623
|
+
variant: "outline",
|
|
624
|
+
disabled: c.value.length < 2,
|
|
625
|
+
onClick: E
|
|
626
|
+
}, {
|
|
627
|
+
default: f(() => [
|
|
628
|
+
G(M(e(t)("panel.intervals-sort")), 1)
|
|
629
|
+
]),
|
|
630
|
+
_: 1
|
|
631
|
+
}, 8, ["disabled"]),
|
|
632
|
+
v[1] || (v[1] = K("span", { class: "wx-catalog-intervals__spacer" }, null, -1)),
|
|
633
|
+
b(e(te), {
|
|
634
|
+
type: "primary",
|
|
635
|
+
size: "sm",
|
|
636
|
+
loading: h.value,
|
|
637
|
+
disabled: !B.value,
|
|
638
|
+
onClick: X
|
|
639
|
+
}, {
|
|
640
|
+
default: f(() => [
|
|
641
|
+
G(M(e(t)("panel.intervals-save")), 1)
|
|
642
|
+
]),
|
|
643
|
+
_: 1
|
|
644
|
+
}, 8, ["loading", "disabled"])
|
|
645
|
+
]))
|
|
646
|
+
], 64))
|
|
647
|
+
]));
|
|
648
|
+
}
|
|
649
|
+
}), et = /* @__PURE__ */ he(qa, [["__scopeId", "data-v-998ebd41"]]), at = { class: "wx-catalog-property-example__value" }, tt = /* @__PURE__ */ le({
|
|
650
|
+
name: "WxCatalogPropertyExample",
|
|
651
|
+
__name: "NumberExample",
|
|
652
|
+
setup(r) {
|
|
653
|
+
const a = Ce(), n = Be(), V = se(ae), t = x(() => {
|
|
654
|
+
const p = a?.values.value ?? {}, l = n.active.value, o = Number(p.precision ?? 0);
|
|
655
|
+
return qe(
|
|
656
|
+
Ea(o),
|
|
657
|
+
{
|
|
658
|
+
precision: o,
|
|
659
|
+
prefix: Q(p.unit_prefix, l),
|
|
660
|
+
suffix: Q(p.unit_suffix, l)
|
|
661
|
+
},
|
|
662
|
+
l
|
|
663
|
+
);
|
|
664
|
+
});
|
|
665
|
+
return (p, l) => (d(), U(e(ne), {
|
|
666
|
+
class: "wx-catalog-property-example",
|
|
667
|
+
size: "sm",
|
|
668
|
+
tone: "muted"
|
|
669
|
+
}, {
|
|
670
|
+
default: f(() => [
|
|
671
|
+
G(M(e(V)("panel.example")) + " ", 1),
|
|
672
|
+
K("span", at, M(t.value), 1)
|
|
673
|
+
]),
|
|
674
|
+
_: 1
|
|
675
|
+
}));
|
|
676
|
+
}
|
|
677
|
+
}), lt = /* @__PURE__ */ he(tt, [["__scopeId", "data-v-54ac1b0d"]]), Te = -1, ot = /* @__PURE__ */ le({
|
|
678
|
+
name: "WxCatalogPropertyValueSelect",
|
|
679
|
+
__name: "ValueSelect",
|
|
680
|
+
props: /* @__PURE__ */ Me({
|
|
681
|
+
property: {},
|
|
682
|
+
disabled: { type: Boolean, default: !1 },
|
|
683
|
+
ariaLabel: { default: void 0 }
|
|
684
|
+
}, {
|
|
685
|
+
modelValue: { default: null },
|
|
686
|
+
modelModifiers: {}
|
|
687
|
+
}),
|
|
688
|
+
emits: ["update:modelValue"],
|
|
689
|
+
setup(r) {
|
|
690
|
+
const a = r, n = Se(r, "modelValue"), V = ie(), t = ce(V), p = se(ae), l = ye(), o = x(() => V.i18n.state.locale), c = x(() => V.can("catalog.manage")), S = _(/* @__PURE__ */ new Map()), h = _([]), w = _(""), W = _(!1), O = x(
|
|
691
|
+
() => n.value === null ? [] : Array.isArray(n.value) ? n.value : [n.value]
|
|
692
|
+
);
|
|
693
|
+
function k(i) {
|
|
694
|
+
const v = new Map(S.value);
|
|
695
|
+
for (const s of i) v.set(s.id, Q(s.title, o.value, `#${s.id}`));
|
|
696
|
+
return S.value = v, i.map((s) => s.id);
|
|
697
|
+
}
|
|
698
|
+
const m = x(() => {
|
|
699
|
+
const i = w.value.trim().toLocaleLowerCase(o.value);
|
|
700
|
+
return [...S.value.values()].some((v) => v.toLocaleLowerCase(o.value) === i);
|
|
701
|
+
}), C = x(() => {
|
|
702
|
+
const v = [.../* @__PURE__ */ new Set([...O.value, ...h.value])].map((s) => ({
|
|
703
|
+
value: s,
|
|
704
|
+
label: S.value.get(s) ?? `#${s}`
|
|
705
|
+
}));
|
|
706
|
+
return c.value && w.value.trim() !== "" && !m.value && v.push({ value: Te, label: p("panel.value-create", { name: w.value.trim() }) }), v;
|
|
707
|
+
});
|
|
708
|
+
re(
|
|
709
|
+
O,
|
|
710
|
+
async (i) => {
|
|
711
|
+
const v = i.filter((s) => !S.value.has(s));
|
|
712
|
+
if (v.length !== 0)
|
|
713
|
+
try {
|
|
714
|
+
k(await t.valuesById(a.property.id, v));
|
|
715
|
+
} catch {
|
|
716
|
+
}
|
|
717
|
+
},
|
|
718
|
+
{ immediate: !0 }
|
|
719
|
+
);
|
|
720
|
+
let B, z = 0;
|
|
721
|
+
async function $(i) {
|
|
722
|
+
const v = ++z;
|
|
723
|
+
try {
|
|
724
|
+
const s = await t.searchValues(a.property.id, i.trim(), 30);
|
|
725
|
+
v === z && (h.value = k(s));
|
|
726
|
+
} catch {
|
|
727
|
+
v === z && (h.value = []);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
function E(i) {
|
|
731
|
+
w.value = i, clearTimeout(B), B = setTimeout(() => {
|
|
732
|
+
$(i);
|
|
733
|
+
}, 200);
|
|
734
|
+
}
|
|
735
|
+
Ue(() => clearTimeout(B));
|
|
736
|
+
async function D() {
|
|
737
|
+
const i = w.value.trim();
|
|
738
|
+
if (i === "" || W.value) return null;
|
|
739
|
+
W.value = !0;
|
|
740
|
+
try {
|
|
741
|
+
const [v] = k([
|
|
742
|
+
await t.createValue(a.property.id, { title: { [o.value]: i } })
|
|
743
|
+
]);
|
|
744
|
+
return w.value = "", v ?? null;
|
|
745
|
+
} catch (v) {
|
|
746
|
+
return Y.danger(l(v)), null;
|
|
747
|
+
} finally {
|
|
748
|
+
W.value = !1;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
async function X(i) {
|
|
752
|
+
const v = i === null ? [] : Array.isArray(i) ? i.map(Number) : [Number(i)];
|
|
753
|
+
if (v.includes(Te)) {
|
|
754
|
+
const s = await D(), T = v.filter((P) => P !== Te);
|
|
755
|
+
s !== null && T.push(s), n.value = a.property.is_multiple ? T : s ?? O.value[0] ?? null;
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
n.value = a.property.is_multiple ? v : v[0] ?? null;
|
|
759
|
+
}
|
|
760
|
+
return (i, v) => (d(), U(e(Ve), {
|
|
761
|
+
"model-value": a.property.is_multiple ? O.value : O.value[0] ?? null,
|
|
762
|
+
options: C.value,
|
|
763
|
+
multiple: a.property.is_multiple,
|
|
764
|
+
disabled: a.disabled || W.value,
|
|
765
|
+
"aria-label": a.ariaLabel,
|
|
766
|
+
placeholder: e(p)("panel.value-pick"),
|
|
767
|
+
"empty-text": e(p)("panel.nothing-found"),
|
|
768
|
+
filterable: "",
|
|
769
|
+
clearable: "",
|
|
770
|
+
"onUpdate:modelValue": X,
|
|
771
|
+
onSearch: E,
|
|
772
|
+
onOpen: v[0] || (v[0] = (s) => $(w.value))
|
|
773
|
+
}, null, 8, ["model-value", "options", "multiple", "disabled", "aria-label", "placeholder", "empty-text"]));
|
|
774
|
+
}
|
|
775
|
+
}), rt = /* @__PURE__ */ le({
|
|
776
|
+
name: "WxCatalogPropertyValueTree",
|
|
777
|
+
__name: "ValueTreeSelect",
|
|
778
|
+
props: /* @__PURE__ */ Me({
|
|
779
|
+
property: {},
|
|
780
|
+
disabled: { type: Boolean, default: !1 },
|
|
781
|
+
ariaLabel: { default: void 0 }
|
|
782
|
+
}, {
|
|
783
|
+
modelValue: { default: null },
|
|
784
|
+
modelModifiers: {}
|
|
785
|
+
}),
|
|
786
|
+
emits: ["update:modelValue"],
|
|
787
|
+
setup(r) {
|
|
788
|
+
const a = r, n = Se(r, "modelValue"), V = ie(), t = ce(V), p = se(ae), l = x(() => V.i18n.state.locale), o = _([]), c = _([]);
|
|
789
|
+
function S(m) {
|
|
790
|
+
return {
|
|
791
|
+
...m,
|
|
792
|
+
label: Q(m.title, l.value, `#${m.id}`),
|
|
793
|
+
leaf: !m.has_children,
|
|
794
|
+
blocked: a.property.leaves_only && m.has_children,
|
|
795
|
+
children: void 0
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
const h = x(
|
|
799
|
+
() => n.value === null ? [] : Array.isArray(n.value) ? n.value : [n.value]
|
|
800
|
+
);
|
|
801
|
+
async function w() {
|
|
802
|
+
try {
|
|
803
|
+
o.value = (await t.values(a.property.id)).map(S);
|
|
804
|
+
} catch {
|
|
805
|
+
o.value = [];
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
w(), re(
|
|
809
|
+
h,
|
|
810
|
+
async (m) => {
|
|
811
|
+
const C = new Set(c.value.map((z) => z[z.length - 1]?.id)), B = m.filter((z) => !C.has(z));
|
|
812
|
+
if (B.length !== 0)
|
|
813
|
+
try {
|
|
814
|
+
const z = await t.valuesById(a.property.id, B);
|
|
815
|
+
c.value = [
|
|
816
|
+
...c.value.filter(($) => m.includes($[$.length - 1]?.id ?? -1)),
|
|
817
|
+
...z.map(($) => [...($.ancestors ?? []).map(S), S($)])
|
|
818
|
+
];
|
|
819
|
+
} catch {
|
|
820
|
+
}
|
|
821
|
+
},
|
|
822
|
+
{ immediate: !0 }
|
|
823
|
+
);
|
|
824
|
+
const W = x(
|
|
825
|
+
() => a.property.is_multiple ? c.value : c.value.find((m) => m[m.length - 1]?.id === h.value[0]) ?? []
|
|
826
|
+
);
|
|
827
|
+
async function O(m) {
|
|
828
|
+
return (await t.values(a.property.id, m.id)).map(S);
|
|
829
|
+
}
|
|
830
|
+
function k(m) {
|
|
831
|
+
const C = m === null ? [] : Array.isArray(m) ? m.map(Number) : [Number(m)];
|
|
832
|
+
n.value = a.property.is_multiple ? C : C[0] ?? null;
|
|
833
|
+
}
|
|
834
|
+
return (m, C) => (d(), U(e(ya), {
|
|
835
|
+
"model-value": a.property.is_multiple ? h.value : h.value[0] ?? null,
|
|
836
|
+
nodes: o.value,
|
|
837
|
+
multiple: a.property.is_multiple,
|
|
838
|
+
"check-strictly": !0,
|
|
839
|
+
"selected-path": W.value,
|
|
840
|
+
load: O,
|
|
841
|
+
lazy: "",
|
|
842
|
+
"node-key": "id",
|
|
843
|
+
"label-key": "label",
|
|
844
|
+
"leaf-key": "leaf",
|
|
845
|
+
"disabled-key": "blocked",
|
|
846
|
+
"show-path": "",
|
|
847
|
+
clearable: "",
|
|
848
|
+
disabled: a.disabled,
|
|
849
|
+
"aria-label": a.ariaLabel,
|
|
850
|
+
placeholder: e(p)("panel.value-pick"),
|
|
851
|
+
"empty-text": e(p)("panel.values-empty"),
|
|
852
|
+
"onUpdate:modelValue": k
|
|
853
|
+
}, null, 8, ["model-value", "nodes", "multiple", "selected-path", "disabled", "aria-label", "placeholder", "empty-text"]));
|
|
854
|
+
}
|
|
855
|
+
}), nt = { class: "wx-catalog-product-properties" }, st = {
|
|
856
|
+
key: 2,
|
|
857
|
+
class: "wx-catalog-product-properties__number"
|
|
858
|
+
}, it = {
|
|
859
|
+
key: 0,
|
|
860
|
+
class: "wx-catalog-product-properties__unit"
|
|
861
|
+
}, ut = {
|
|
862
|
+
key: 1,
|
|
863
|
+
class: "wx-catalog-product-properties__unit"
|
|
864
|
+
}, dt = {
|
|
865
|
+
key: 2,
|
|
866
|
+
class: "wx-catalog-product-properties__outside"
|
|
867
|
+
}, ct = { class: "wx-catalog-product-properties__list" }, pt = /* @__PURE__ */ le({
|
|
868
|
+
name: "WxCatalogProductProperties",
|
|
869
|
+
__name: "ProductPropertiesField",
|
|
870
|
+
props: {
|
|
871
|
+
modelValue: { default: null },
|
|
872
|
+
modelModifiers: {}
|
|
873
|
+
},
|
|
874
|
+
emits: ["update:modelValue"],
|
|
875
|
+
setup(r) {
|
|
876
|
+
const a = Se(r, "modelValue"), n = He(Aa, _(void 0)), V = ie(), t = ce(V), p = Ta(V), l = Wa(), o = Be();
|
|
877
|
+
_e();
|
|
878
|
+
const c = se(ae), S = ye(), h = x(() => V.i18n.state.locale), w = x(() => l?.locked.value ?? !1), W = x(() => o.active.value || h.value), O = x(() => {
|
|
879
|
+
const u = l?.values?.value.category_id;
|
|
880
|
+
return typeof u == "number" ? u : u ? Number(u) : null;
|
|
881
|
+
}), k = _(null), m = _(!1), C = _(!1), B = _({}), z = _(/* @__PURE__ */ new Map()), $ = _(/* @__PURE__ */ new Map()), E = _(!1), D = x(
|
|
882
|
+
() => new Set((k.value?.groups ?? []).flatMap((u) => u.properties.map((y) => y.id)))
|
|
883
|
+
), X = x(
|
|
884
|
+
() => Object.entries(B.value).filter(([u]) => !D.value.has(Number(u))).map(([u, y]) => ({ id: Number(u), value: y }))
|
|
885
|
+
);
|
|
886
|
+
re(
|
|
887
|
+
() => l?.product.value,
|
|
888
|
+
() => {
|
|
889
|
+
const u = l?.values?.value["properties.outside"] ?? {};
|
|
890
|
+
B.value = { ...Array.isArray(u) ? {} : u, ...a.value ?? {} };
|
|
891
|
+
},
|
|
892
|
+
{ immediate: !0 }
|
|
893
|
+
);
|
|
894
|
+
function i() {
|
|
895
|
+
const u = {}, y = a.value ?? {};
|
|
896
|
+
for (const R of D.value) {
|
|
897
|
+
const J = String(R);
|
|
898
|
+
J in y ? u[J] = y[J] ?? null : J in B.value && (u[J] = B.value[J] ?? null);
|
|
899
|
+
}
|
|
900
|
+
JSON.stringify(u) !== JSON.stringify(y) && (a.value = u);
|
|
901
|
+
}
|
|
902
|
+
let v = 0;
|
|
903
|
+
async function s() {
|
|
904
|
+
const u = ++v;
|
|
905
|
+
if (O.value === null) {
|
|
906
|
+
k.value = { groups: [] }, i();
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
m.value = !0, C.value = !1;
|
|
910
|
+
try {
|
|
911
|
+
const y = await t.effectiveSet(O.value);
|
|
912
|
+
if (u !== v) return;
|
|
913
|
+
k.value = y, i();
|
|
914
|
+
} catch {
|
|
915
|
+
u === v && (C.value = !0);
|
|
916
|
+
} finally {
|
|
917
|
+
u === v && (m.value = !1);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
re(O, () => {
|
|
921
|
+
s();
|
|
922
|
+
}, { immediate: !0 }), re(
|
|
923
|
+
X,
|
|
924
|
+
async (u) => {
|
|
925
|
+
const y = u.map((R) => R.id).filter((R) => !z.value.has(R));
|
|
926
|
+
if (y.length !== 0)
|
|
927
|
+
try {
|
|
928
|
+
const R = await t.list({ ids: y }), J = new Map(z.value);
|
|
929
|
+
for (const q of R.data) J.set(q.id, q);
|
|
930
|
+
z.value = J;
|
|
931
|
+
const N = new Map($.value);
|
|
932
|
+
for (const q of u) {
|
|
933
|
+
const Pe = J.get(q.id);
|
|
934
|
+
Pe && N.set(q.id, await T(Pe, q.value));
|
|
935
|
+
}
|
|
936
|
+
$.value = N;
|
|
937
|
+
} catch {
|
|
938
|
+
}
|
|
939
|
+
},
|
|
940
|
+
{ immediate: !0 }
|
|
941
|
+
);
|
|
942
|
+
async function T(u, y) {
|
|
943
|
+
if (y === null) return "";
|
|
944
|
+
switch (u.type) {
|
|
945
|
+
case "select": {
|
|
946
|
+
const R = Array.isArray(y) ? y : [y];
|
|
947
|
+
return (await t.valuesById(u.id, R)).map((N) => Q(N.title, h.value, `#${N.id}`)).join(", ");
|
|
948
|
+
}
|
|
949
|
+
case "number":
|
|
950
|
+
return qe(
|
|
951
|
+
Number(y),
|
|
952
|
+
{
|
|
953
|
+
precision: u.precision,
|
|
954
|
+
prefix: Q(u.unit_prefix, h.value),
|
|
955
|
+
suffix: Q(u.unit_suffix, h.value)
|
|
956
|
+
},
|
|
957
|
+
h.value
|
|
958
|
+
);
|
|
959
|
+
case "bool":
|
|
960
|
+
return c("product.yes");
|
|
961
|
+
default:
|
|
962
|
+
return Q(y, h.value);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
function P(u) {
|
|
966
|
+
return a.value?.[String(u)] ?? null;
|
|
967
|
+
}
|
|
968
|
+
function Z(u, y) {
|
|
969
|
+
const R = y === null || Array.isArray(y) && y.length === 0 || typeof y == "object" && !Array.isArray(y) && Object.values(y).every((J) => (J ?? "").trim() === "");
|
|
970
|
+
a.value = { ...a.value ?? {}, [String(u)]: R ? null : y };
|
|
971
|
+
}
|
|
972
|
+
function pe(u) {
|
|
973
|
+
const y = P(u);
|
|
974
|
+
return typeof y == "number" || Array.isArray(y) ? y : null;
|
|
975
|
+
}
|
|
976
|
+
function ue(u) {
|
|
977
|
+
return typeof u == "number" ? u : null;
|
|
978
|
+
}
|
|
979
|
+
function me(u) {
|
|
980
|
+
return u && typeof u == "object" && !Array.isArray(u) ? u : {};
|
|
981
|
+
}
|
|
982
|
+
function be(u) {
|
|
983
|
+
const y = `properties.values.${u}`, R = n.value ?? {}, J = Object.keys(R).find((N) => N === y || N.startsWith(`${y}.`));
|
|
984
|
+
return J === void 0 ? void 0 : R[J]?.[0];
|
|
985
|
+
}
|
|
986
|
+
async function F() {
|
|
987
|
+
const u = l?.product.value;
|
|
988
|
+
if (!(!u || !await $e({
|
|
989
|
+
title: c("panel.outside-clear-title"),
|
|
990
|
+
message: c("panel.outside-clear-text"),
|
|
991
|
+
confirmText: c("panel.delete"),
|
|
992
|
+
cancelText: c("panel.cancel"),
|
|
993
|
+
tone: "danger"
|
|
994
|
+
}))) {
|
|
995
|
+
E.value = !0;
|
|
996
|
+
try {
|
|
997
|
+
await p.startBulk("clear-outside-set", {}, { ids: [u.id] });
|
|
998
|
+
const R = {};
|
|
999
|
+
for (const [J, N] of Object.entries(B.value))
|
|
1000
|
+
D.value.has(Number(J)) && (R[J] = N);
|
|
1001
|
+
B.value = R, Y.success(c("panel.outside-cleared"));
|
|
1002
|
+
} catch (R) {
|
|
1003
|
+
Y.danger(S(R));
|
|
1004
|
+
} finally {
|
|
1005
|
+
E.value = !1;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
const A = (u) => u.group ? Q(u.group.title, h.value) : "";
|
|
1010
|
+
return (u, y) => (d(), j("div", nt, [
|
|
1011
|
+
m.value && !k.value ? (d(), U(e(ke), {
|
|
1012
|
+
key: 0,
|
|
1013
|
+
rows: 4
|
|
1014
|
+
})) : C.value ? (d(), U(e(de), {
|
|
1015
|
+
key: 1,
|
|
1016
|
+
type: "warning",
|
|
1017
|
+
variant: "soft",
|
|
1018
|
+
description: e(c)("panel.set-failed")
|
|
1019
|
+
}, null, 8, ["description"])) : k.value ? (d(), j(oe, { key: 2 }, [
|
|
1020
|
+
O.value === null ? (d(), U(e(de), {
|
|
1021
|
+
key: 0,
|
|
1022
|
+
type: "info",
|
|
1023
|
+
variant: "soft",
|
|
1024
|
+
description: e(c)("panel.product-no-category")
|
|
1025
|
+
}, null, 8, ["description"])) : k.value.groups.length === 0 ? (d(), U(e(de), {
|
|
1026
|
+
key: 1,
|
|
1027
|
+
type: "info",
|
|
1028
|
+
variant: "soft",
|
|
1029
|
+
description: e(c)("panel.product-empty-set")
|
|
1030
|
+
}, null, 8, ["description"])) : H("", !0),
|
|
1031
|
+
(d(!0), j(oe, null, xe(k.value.groups, (R, J) => (d(), j("section", {
|
|
1032
|
+
key: R.group?.id ?? `none-${J}`,
|
|
1033
|
+
class: "wx-catalog-product-properties__group"
|
|
1034
|
+
}, [
|
|
1035
|
+
A(R) ? (d(), U(e(ne), {
|
|
1036
|
+
key: 0,
|
|
1037
|
+
class: "wx-catalog-product-properties__heading",
|
|
1038
|
+
weight: "semibold"
|
|
1039
|
+
}, {
|
|
1040
|
+
default: f(() => [
|
|
1041
|
+
G(M(A(R)), 1)
|
|
1042
|
+
]),
|
|
1043
|
+
_: 2
|
|
1044
|
+
}, 1024)) : H("", !0),
|
|
1045
|
+
(d(!0), j(oe, null, xe(R.properties, (N) => (d(), U(e(fe), {
|
|
1046
|
+
key: N.id,
|
|
1047
|
+
label: N.type === "bool" ? void 0 : e(ee)(N, h.value),
|
|
1048
|
+
error: be(N.id)
|
|
1049
|
+
}, {
|
|
1050
|
+
default: f(() => [
|
|
1051
|
+
N.type === "select" && N.is_tree ? (d(), U(rt, {
|
|
1052
|
+
key: 0,
|
|
1053
|
+
property: N,
|
|
1054
|
+
"model-value": pe(N.id),
|
|
1055
|
+
disabled: w.value,
|
|
1056
|
+
"aria-label": e(ee)(N, h.value),
|
|
1057
|
+
"onUpdate:modelValue": (q) => Z(N.id, q)
|
|
1058
|
+
}, null, 8, ["property", "model-value", "disabled", "aria-label", "onUpdate:modelValue"])) : N.type === "select" ? (d(), U(ot, {
|
|
1059
|
+
key: 1,
|
|
1060
|
+
property: N,
|
|
1061
|
+
"model-value": pe(N.id),
|
|
1062
|
+
disabled: w.value,
|
|
1063
|
+
"aria-label": e(ee)(N, h.value),
|
|
1064
|
+
"onUpdate:modelValue": (q) => Z(N.id, q)
|
|
1065
|
+
}, null, 8, ["property", "model-value", "disabled", "aria-label", "onUpdate:modelValue"])) : N.type === "number" ? (d(), j("span", st, [
|
|
1066
|
+
e(Q)(N.unit_prefix, W.value) ? (d(), j("span", it, M(e(Q)(N.unit_prefix, W.value)), 1)) : H("", !0),
|
|
1067
|
+
b(e(Ne), {
|
|
1068
|
+
"model-value": ue(P(N.id)),
|
|
1069
|
+
precision: e(Ba)(N.precision, ue(P(N.id))),
|
|
1070
|
+
controls: !1,
|
|
1071
|
+
disabled: w.value,
|
|
1072
|
+
"aria-label": e(ee)(N, h.value),
|
|
1073
|
+
"onUpdate:modelValue": (q) => Z(N.id, q ?? null)
|
|
1074
|
+
}, null, 8, ["model-value", "precision", "disabled", "aria-label", "onUpdate:modelValue"]),
|
|
1075
|
+
e(Q)(N.unit_suffix, W.value) ? (d(), j("span", ut, M(e(Q)(N.unit_suffix, W.value)), 1)) : H("", !0)
|
|
1076
|
+
])) : N.type === "bool" ? (d(), U(e(ha), {
|
|
1077
|
+
key: 3,
|
|
1078
|
+
"model-value": P(N.id) === !0,
|
|
1079
|
+
disabled: w.value,
|
|
1080
|
+
label: e(ee)(N, h.value),
|
|
1081
|
+
"onUpdate:modelValue": (q) => Z(N.id, q ? !0 : null)
|
|
1082
|
+
}, null, 8, ["model-value", "disabled", "label", "onUpdate:modelValue"])) : (d(), U(e(ge), {
|
|
1083
|
+
key: 4,
|
|
1084
|
+
"model-value": me(P(N.id)),
|
|
1085
|
+
localized: "",
|
|
1086
|
+
disabled: w.value,
|
|
1087
|
+
"aria-label": e(ee)(N, h.value),
|
|
1088
|
+
"onUpdate:modelValue": (q) => Z(N.id, q)
|
|
1089
|
+
}, null, 8, ["model-value", "disabled", "aria-label", "onUpdate:modelValue"]))
|
|
1090
|
+
]),
|
|
1091
|
+
_: 2
|
|
1092
|
+
}, 1032, ["label", "error"]))), 128))
|
|
1093
|
+
]))), 128)),
|
|
1094
|
+
X.value.length > 0 ? (d(), j("details", dt, [
|
|
1095
|
+
K("summary", null, [
|
|
1096
|
+
b(e(ne), { weight: "medium" }, {
|
|
1097
|
+
default: f(() => [
|
|
1098
|
+
G(M(e(c)("panel.outside", { count: X.value.length })), 1)
|
|
1099
|
+
]),
|
|
1100
|
+
_: 1
|
|
1101
|
+
})
|
|
1102
|
+
]),
|
|
1103
|
+
b(e(ne), {
|
|
1104
|
+
size: "sm",
|
|
1105
|
+
tone: "muted"
|
|
1106
|
+
}, {
|
|
1107
|
+
default: f(() => [
|
|
1108
|
+
G(M(e(c)("panel.outside-help")), 1)
|
|
1109
|
+
]),
|
|
1110
|
+
_: 1
|
|
1111
|
+
}),
|
|
1112
|
+
K("dl", ct, [
|
|
1113
|
+
(d(!0), j(oe, null, xe(X.value, (R) => (d(), j(oe, {
|
|
1114
|
+
key: R.id
|
|
1115
|
+
}, [
|
|
1116
|
+
K("dt", null, M(z.value.get(R.id) ? e(ee)(z.value.get(R.id), h.value) : `#${R.id}`), 1),
|
|
1117
|
+
K("dd", null, M($.value.get(R.id) ?? "…"), 1)
|
|
1118
|
+
], 64))), 128))
|
|
1119
|
+
]),
|
|
1120
|
+
!w.value && e(V).can("catalog.manage") ? (d(), U(e(te), {
|
|
1121
|
+
key: 0,
|
|
1122
|
+
size: "sm",
|
|
1123
|
+
variant: "outline",
|
|
1124
|
+
icon: "trash",
|
|
1125
|
+
loading: E.value,
|
|
1126
|
+
onClick: F
|
|
1127
|
+
}, {
|
|
1128
|
+
default: f(() => [
|
|
1129
|
+
G(M(e(c)("panel.outside-clear")), 1)
|
|
1130
|
+
]),
|
|
1131
|
+
_: 1
|
|
1132
|
+
}, 8, ["loading"])) : H("", !0)
|
|
1133
|
+
])) : H("", !0)
|
|
1134
|
+
], 64)) : H("", !0)
|
|
1135
|
+
]));
|
|
1136
|
+
}
|
|
1137
|
+
}), vt = /* @__PURE__ */ he(pt, [["__scopeId", "data-v-c26faef7"]]), mt = /* @__PURE__ */ le({
|
|
1138
|
+
name: "WxCatalogPropertyCreateDialog",
|
|
1139
|
+
__name: "PropertyCreateDialog",
|
|
1140
|
+
setup(r) {
|
|
1141
|
+
const { open: a, resolve: n, dismiss: V } = De(), t = ce(ie()), p = se(ae), l = _(""), o = _("select"), c = _(!1), S = _({}), h = Je("field"), w = x(
|
|
1142
|
+
() => ["select", "number", "text", "bool"].map((k) => ({
|
|
1143
|
+
value: k,
|
|
1144
|
+
label: p(`property.types.${k}`)
|
|
1145
|
+
}))
|
|
1146
|
+
);
|
|
1147
|
+
Oe(async () => {
|
|
1148
|
+
await Ye(), h.value?.querySelector("input")?.focus();
|
|
1149
|
+
});
|
|
1150
|
+
function W(k) {
|
|
1151
|
+
const m = Object.keys(S.value).find((C) => C === k || C.startsWith(`${k}.`));
|
|
1152
|
+
return m === void 0 ? void 0 : S.value[m]?.[0];
|
|
1153
|
+
}
|
|
1154
|
+
async function O() {
|
|
1155
|
+
if (!(l.value.trim() === "" || c.value)) {
|
|
1156
|
+
c.value = !0, S.value = {};
|
|
1157
|
+
try {
|
|
1158
|
+
n(await t.create({ title: l.value.trim(), type: o.value }));
|
|
1159
|
+
} catch (k) {
|
|
1160
|
+
S.value = k.body?.errors ?? {};
|
|
1161
|
+
} finally {
|
|
1162
|
+
c.value = !1;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
return (k, m) => (d(), U(e(Re), {
|
|
1167
|
+
open: e(a),
|
|
1168
|
+
"onUpdate:open": m[3] || (m[3] = (C) => ze(a) ? a.value = C : null),
|
|
1169
|
+
title: e(p)("panel.new"),
|
|
1170
|
+
width: 440
|
|
1171
|
+
}, {
|
|
1172
|
+
footer: f(() => [
|
|
1173
|
+
b(e(Le), { size: "sm" }, {
|
|
1174
|
+
default: f(() => [
|
|
1175
|
+
b(e(te), {
|
|
1176
|
+
variant: "outline",
|
|
1177
|
+
onClick: m[2] || (m[2] = (C) => e(V)())
|
|
1178
|
+
}, {
|
|
1179
|
+
default: f(() => [
|
|
1180
|
+
G(M(e(p)("panel.cancel")), 1)
|
|
1181
|
+
]),
|
|
1182
|
+
_: 1
|
|
1183
|
+
}),
|
|
1184
|
+
b(e(te), {
|
|
1185
|
+
type: "primary",
|
|
1186
|
+
loading: c.value,
|
|
1187
|
+
disabled: l.value.trim() === "",
|
|
1188
|
+
onClick: O
|
|
1189
|
+
}, {
|
|
1190
|
+
default: f(() => [
|
|
1191
|
+
G(M(e(p)("panel.create")), 1)
|
|
1192
|
+
]),
|
|
1193
|
+
_: 1
|
|
1194
|
+
}, 8, ["loading", "disabled"])
|
|
1195
|
+
]),
|
|
1196
|
+
_: 1
|
|
1197
|
+
})
|
|
1198
|
+
]),
|
|
1199
|
+
default: f(() => [
|
|
1200
|
+
b(e(fe), {
|
|
1201
|
+
label: e(p)("property.title"),
|
|
1202
|
+
error: W("title") ?? W("code"),
|
|
1203
|
+
required: ""
|
|
1204
|
+
}, {
|
|
1205
|
+
default: f(() => [
|
|
1206
|
+
K("div", {
|
|
1207
|
+
ref_key: "field",
|
|
1208
|
+
ref: h
|
|
1209
|
+
}, [
|
|
1210
|
+
b(e(ge), {
|
|
1211
|
+
modelValue: l.value,
|
|
1212
|
+
"onUpdate:modelValue": m[0] || (m[0] = (C) => l.value = C),
|
|
1213
|
+
"aria-label": e(p)("property.title"),
|
|
1214
|
+
onKeyup: We(O, ["enter"])
|
|
1215
|
+
}, null, 8, ["modelValue", "aria-label"])
|
|
1216
|
+
], 512)
|
|
1217
|
+
]),
|
|
1218
|
+
_: 1
|
|
1219
|
+
}, 8, ["label", "error"]),
|
|
1220
|
+
b(e(fe), {
|
|
1221
|
+
label: e(p)("property.type"),
|
|
1222
|
+
help: e(p)("property.type-help"),
|
|
1223
|
+
error: W("type")
|
|
1224
|
+
}, {
|
|
1225
|
+
default: f(() => [
|
|
1226
|
+
b(e(ba), {
|
|
1227
|
+
modelValue: o.value,
|
|
1228
|
+
"onUpdate:modelValue": m[1] || (m[1] = (C) => o.value = C),
|
|
1229
|
+
options: w.value
|
|
1230
|
+
}, null, 8, ["modelValue", "options"])
|
|
1231
|
+
]),
|
|
1232
|
+
_: 1
|
|
1233
|
+
}, 8, ["label", "help", "error"])
|
|
1234
|
+
]),
|
|
1235
|
+
_: 1
|
|
1236
|
+
}, 8, ["open", "title"]));
|
|
1237
|
+
}
|
|
1238
|
+
}), ft = { class: "wx-catalog-properties__filters" }, gt = { class: "wx-catalog-property-row__name" }, yt = { class: "wx-catalog-property-row__flags" }, ht = /* @__PURE__ */ le({
|
|
1239
|
+
name: "WxCatalogPropertiesPage",
|
|
1240
|
+
__name: "PropertiesPage",
|
|
1241
|
+
props: {
|
|
1242
|
+
base: { default: "/catalog" }
|
|
1243
|
+
},
|
|
1244
|
+
setup(r) {
|
|
1245
|
+
const a = r, n = ie(), V = ce(n), t = ia(n, Ze), p = Xe();
|
|
1246
|
+
_e();
|
|
1247
|
+
const l = se(ae), o = ye(), c = x(() => `${a.base}/properties`), S = x(() => n.i18n.state.locale), h = x(() => n.can("catalog.manage")), w = _([]), W = _(!0), O = _("all"), k = _(null), m = _(null), C = _([]), B = x(() => O.value === "deleted"), z = x(() => k.value !== null || m.value !== null), $ = x(
|
|
1248
|
+
() => n.state.manifest?.modules.find((A) => A.id === "catalog-properties")?.title ?? l("module.title")
|
|
1249
|
+
), E = x(() => [
|
|
1250
|
+
{ value: "all", label: l("panel.view-all") },
|
|
1251
|
+
{ value: "deleted", label: l("panel.view-deleted") }
|
|
1252
|
+
]), D = x(
|
|
1253
|
+
() => ["select", "number", "text", "bool"].map((A) => ({
|
|
1254
|
+
value: A,
|
|
1255
|
+
label: l(`property.types.${A}`)
|
|
1256
|
+
}))
|
|
1257
|
+
), X = Ie(mt), i = x(() => {
|
|
1258
|
+
const A = [
|
|
1259
|
+
{
|
|
1260
|
+
key: "groups",
|
|
1261
|
+
label: l("panel.groups"),
|
|
1262
|
+
icon: "folder",
|
|
1263
|
+
run: () => {
|
|
1264
|
+
p.push(`${c.value}/groups`);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
];
|
|
1268
|
+
return h.value && A.push({ key: "new", label: l("panel.new"), icon: "plus", primary: !0, run: pe }), A;
|
|
1269
|
+
}), v = [
|
|
1270
|
+
{ flag: "is_filterable", icon: "filter" },
|
|
1271
|
+
{ flag: "is_searchable", icon: "search" },
|
|
1272
|
+
{ flag: "in_card", icon: "grid" },
|
|
1273
|
+
{ flag: "on_page", icon: "file-text" },
|
|
1274
|
+
{ flag: "in_list", icon: "list" }
|
|
1275
|
+
];
|
|
1276
|
+
function s(A) {
|
|
1277
|
+
return v.filter(({ flag: u }) => A[u] === !0).map(({ flag: u, icon: y }) => ({
|
|
1278
|
+
icon: y,
|
|
1279
|
+
label: l(`property.${String(u)}`)
|
|
1280
|
+
}));
|
|
1281
|
+
}
|
|
1282
|
+
async function T() {
|
|
1283
|
+
W.value = !0;
|
|
1284
|
+
try {
|
|
1285
|
+
const A = await V.list({
|
|
1286
|
+
trashed: B.value,
|
|
1287
|
+
type: k.value ?? void 0,
|
|
1288
|
+
group: m.value
|
|
1289
|
+
});
|
|
1290
|
+
w.value = A.data;
|
|
1291
|
+
} catch (A) {
|
|
1292
|
+
Y.danger(o(A));
|
|
1293
|
+
} finally {
|
|
1294
|
+
W.value = !1;
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
async function P() {
|
|
1298
|
+
try {
|
|
1299
|
+
C.value = (await t.list()).data.map((A) => ({ value: A.id, label: A.name }));
|
|
1300
|
+
} catch {
|
|
1301
|
+
C.value = [];
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
re([B, k, m], () => {
|
|
1305
|
+
T();
|
|
1306
|
+
}), T(), P();
|
|
1307
|
+
function Z(A) {
|
|
1308
|
+
p.push(`${c.value}/${A.id}`);
|
|
1309
|
+
}
|
|
1310
|
+
async function pe() {
|
|
1311
|
+
const A = await X({});
|
|
1312
|
+
A !== void 0 && p.push(`${c.value}/${A.property.id}`);
|
|
1313
|
+
}
|
|
1314
|
+
async function ue(A) {
|
|
1315
|
+
const u = ee(A, S.value);
|
|
1316
|
+
if (await $e({
|
|
1317
|
+
title: l("panel.delete-title", { name: u }),
|
|
1318
|
+
message: l("panel.delete-text"),
|
|
1319
|
+
confirmText: l("panel.delete"),
|
|
1320
|
+
cancelText: l("panel.cancel"),
|
|
1321
|
+
tone: "danger"
|
|
1322
|
+
}))
|
|
1323
|
+
try {
|
|
1324
|
+
await V.remove(A.id), Y.success(l("panel.deleted")), await T();
|
|
1325
|
+
} catch (R) {
|
|
1326
|
+
Y.danger(o(R));
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
async function me(A) {
|
|
1330
|
+
try {
|
|
1331
|
+
await V.restore(A.id), Y.success(l("panel.restored")), await T();
|
|
1332
|
+
} catch (u) {
|
|
1333
|
+
Y.danger(o(u));
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
function be(A) {
|
|
1337
|
+
if (B.value)
|
|
1338
|
+
return h.value ? [
|
|
1339
|
+
{
|
|
1340
|
+
key: "restore",
|
|
1341
|
+
label: l("panel.restore"),
|
|
1342
|
+
icon: "refresh",
|
|
1343
|
+
run: () => {
|
|
1344
|
+
me(A);
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
] : [];
|
|
1348
|
+
const u = [
|
|
1349
|
+
{ key: "edit", label: l("panel.edit"), icon: "edit", run: () => Z(A) }
|
|
1350
|
+
];
|
|
1351
|
+
return h.value && u.push({
|
|
1352
|
+
key: "delete",
|
|
1353
|
+
label: l("panel.delete"),
|
|
1354
|
+
icon: "trash",
|
|
1355
|
+
danger: !0,
|
|
1356
|
+
run: () => {
|
|
1357
|
+
ue(A);
|
|
1358
|
+
}
|
|
1359
|
+
}), u;
|
|
1360
|
+
}
|
|
1361
|
+
async function F() {
|
|
1362
|
+
try {
|
|
1363
|
+
await V.reorder(w.value.map((A) => A.id));
|
|
1364
|
+
} catch (A) {
|
|
1365
|
+
Y.danger(o(A, l("panel.reorder-failed"))), await T();
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
return (A, u) => (d(), U(e(ua), {
|
|
1369
|
+
view: O.value,
|
|
1370
|
+
"onUpdate:view": u[3] || (u[3] = (y) => O.value = y),
|
|
1371
|
+
class: "wx-catalog-properties",
|
|
1372
|
+
title: $.value,
|
|
1373
|
+
views: E.value,
|
|
1374
|
+
actions: i.value,
|
|
1375
|
+
padding: "sm"
|
|
1376
|
+
}, {
|
|
1377
|
+
default: f(() => [
|
|
1378
|
+
K("div", ft, [
|
|
1379
|
+
b(e(Ve), {
|
|
1380
|
+
modelValue: k.value,
|
|
1381
|
+
"onUpdate:modelValue": u[0] || (u[0] = (y) => k.value = y),
|
|
1382
|
+
options: D.value,
|
|
1383
|
+
placeholder: e(l)("panel.type-any"),
|
|
1384
|
+
"aria-label": e(l)("property.type"),
|
|
1385
|
+
clearable: "",
|
|
1386
|
+
size: "sm"
|
|
1387
|
+
}, null, 8, ["modelValue", "options", "placeholder", "aria-label"]),
|
|
1388
|
+
b(e(Ve), {
|
|
1389
|
+
modelValue: m.value,
|
|
1390
|
+
"onUpdate:modelValue": u[1] || (u[1] = (y) => m.value = y),
|
|
1391
|
+
options: C.value,
|
|
1392
|
+
placeholder: e(l)("panel.group-any"),
|
|
1393
|
+
"aria-label": e(l)("property.group_id"),
|
|
1394
|
+
clearable: "",
|
|
1395
|
+
filterable: "",
|
|
1396
|
+
size: "sm"
|
|
1397
|
+
}, null, 8, ["modelValue", "options", "placeholder", "aria-label"])
|
|
1398
|
+
]),
|
|
1399
|
+
W.value ? (d(), U(e(ke), {
|
|
1400
|
+
key: 0,
|
|
1401
|
+
class: "wx-catalog-properties__loading",
|
|
1402
|
+
rows: 5
|
|
1403
|
+
})) : w.value.length === 0 ? (d(), U(e(_a), {
|
|
1404
|
+
key: 1,
|
|
1405
|
+
title: z.value || B.value ? e(l)("panel.empty-found") : e(l)("panel.empty"),
|
|
1406
|
+
description: z.value || B.value ? void 0 : e(l)("panel.empty-help")
|
|
1407
|
+
}, null, 8, ["title", "description"])) : (d(), j(oe, { key: 2 }, [
|
|
1408
|
+
b(e(Ee), {
|
|
1409
|
+
modelValue: w.value,
|
|
1410
|
+
"onUpdate:modelValue": u[2] || (u[2] = (y) => w.value = y),
|
|
1411
|
+
class: "wx-catalog-properties__list",
|
|
1412
|
+
plain: "",
|
|
1413
|
+
"item-key": "id",
|
|
1414
|
+
"item-label": (y) => e(ee)(y, S.value),
|
|
1415
|
+
disabled: !h.value || z.value || B.value,
|
|
1416
|
+
onMove: F
|
|
1417
|
+
}, {
|
|
1418
|
+
default: f(({ item: y }) => [
|
|
1419
|
+
(d(), U(ta(B.value ? "div" : "router-link"), {
|
|
1420
|
+
class: "wx-catalog-property-row",
|
|
1421
|
+
to: B.value ? void 0 : `${c.value}/${y.id}`
|
|
1422
|
+
}, {
|
|
1423
|
+
default: f(() => [
|
|
1424
|
+
K("span", gt, [
|
|
1425
|
+
b(e(ne), {
|
|
1426
|
+
truncate: "",
|
|
1427
|
+
weight: "medium"
|
|
1428
|
+
}, {
|
|
1429
|
+
default: f(() => [
|
|
1430
|
+
G(M(e(ee)(y, S.value)), 1)
|
|
1431
|
+
]),
|
|
1432
|
+
_: 2
|
|
1433
|
+
}, 1024),
|
|
1434
|
+
K("span", yt, [
|
|
1435
|
+
(d(!0), j(oe, null, xe(s(y), (R) => (d(), U(e(wa), {
|
|
1436
|
+
key: R.icon,
|
|
1437
|
+
content: R.label
|
|
1438
|
+
}, {
|
|
1439
|
+
default: f(() => [
|
|
1440
|
+
b(e(xa), {
|
|
1441
|
+
name: R.icon,
|
|
1442
|
+
size: "sm",
|
|
1443
|
+
label: R.label
|
|
1444
|
+
}, null, 8, ["name", "label"])
|
|
1445
|
+
]),
|
|
1446
|
+
_: 2
|
|
1447
|
+
}, 1032, ["content"]))), 128))
|
|
1448
|
+
])
|
|
1449
|
+
]),
|
|
1450
|
+
b(e(ne), {
|
|
1451
|
+
size: "sm",
|
|
1452
|
+
tone: "muted",
|
|
1453
|
+
truncate: ""
|
|
1454
|
+
}, {
|
|
1455
|
+
default: f(() => [
|
|
1456
|
+
G(M([
|
|
1457
|
+
e(Q)(y.code, S.value),
|
|
1458
|
+
e(l)(`property.types.${y.type}`),
|
|
1459
|
+
y.group ? e(Q)(y.group.title, S.value) : null
|
|
1460
|
+
].filter(Boolean).join(" · ")), 1)
|
|
1461
|
+
]),
|
|
1462
|
+
_: 2
|
|
1463
|
+
}, 1024)
|
|
1464
|
+
]),
|
|
1465
|
+
_: 2
|
|
1466
|
+
}, 1032, ["to"]))
|
|
1467
|
+
]),
|
|
1468
|
+
actions: f(({ item: y }) => [
|
|
1469
|
+
b(e(ne), {
|
|
1470
|
+
class: "wx-catalog-property-row__count",
|
|
1471
|
+
size: "sm",
|
|
1472
|
+
tone: "muted"
|
|
1473
|
+
}, {
|
|
1474
|
+
default: f(() => [
|
|
1475
|
+
G(M(e(l)("panel.count", { count: y.products_count })), 1)
|
|
1476
|
+
]),
|
|
1477
|
+
_: 2
|
|
1478
|
+
}, 1024),
|
|
1479
|
+
b(e(Ae), {
|
|
1480
|
+
actions: be(y),
|
|
1481
|
+
label: e(ee)(y, S.value)
|
|
1482
|
+
}, null, 8, ["actions", "label"])
|
|
1483
|
+
]),
|
|
1484
|
+
_: 1
|
|
1485
|
+
}, 8, ["modelValue", "item-label", "disabled"]),
|
|
1486
|
+
B.value ? H("", !0) : (d(), U(e(de), {
|
|
1487
|
+
key: 0,
|
|
1488
|
+
class: "wx-catalog-properties__note",
|
|
1489
|
+
type: "info",
|
|
1490
|
+
description: z.value ? e(l)("panel.order-narrowed") : e(l)("panel.order")
|
|
1491
|
+
}, null, 8, ["description"]))
|
|
1492
|
+
], 64))
|
|
1493
|
+
]),
|
|
1494
|
+
_: 1
|
|
1495
|
+
}, 8, ["view", "title", "views", "actions"]));
|
|
1496
|
+
}
|
|
1497
|
+
}), bt = /* @__PURE__ */ le({
|
|
1498
|
+
name: "WxCatalogPropertyEditor",
|
|
1499
|
+
__name: "PropertyEditorPage",
|
|
1500
|
+
props: {
|
|
1501
|
+
base: { default: "/catalog" }
|
|
1502
|
+
},
|
|
1503
|
+
setup(r) {
|
|
1504
|
+
const a = r, n = ie(), V = ce(n), t = Na(), p = Xe(), l = Be();
|
|
1505
|
+
_e();
|
|
1506
|
+
const o = se(ae), c = ye(), S = x(() => Number(t.params.id)), h = x(() => `${a.base}/properties`), w = _(null), W = _({}), O = _([]), k = _(""), m = _(!0), C = _(!1), B = _({}), z = x(() => n.can("catalog.manage")), $ = x(() => !z.value || C.value), E = x(() => JSON.stringify(W.value)), D = x(() => k.value !== "" && E.value !== k.value), X = x(() => C.value ? "saving" : D.value ? "unsaved" : "saved"), i = x(
|
|
1507
|
+
() => n.state.manifest?.modules.find((F) => F.id === "catalog-properties")?.title ?? o("module.title")
|
|
1508
|
+
), v = x(() => {
|
|
1509
|
+
const F = W.value.title, A = w.value ? ee(w.value, n.i18n.state.locale) : "";
|
|
1510
|
+
return Qe(F, l.active.value, A) || o("panel.untitled");
|
|
1511
|
+
}), s = x(() => {
|
|
1512
|
+
const F = w.value;
|
|
1513
|
+
if (F)
|
|
1514
|
+
return [Q(F.code, l.active.value), o(`property.types.${F.type}`)].filter(Boolean).join(" · ");
|
|
1515
|
+
});
|
|
1516
|
+
Ja({ property: w, values: W, intervals: O, locked: $ }), da({ id: x(() => w.value?.id ?? null) });
|
|
1517
|
+
function T(F) {
|
|
1518
|
+
w.value = F.property, W.value = F.values, O.value = F.intervals, k.value = JSON.stringify(F.values);
|
|
1519
|
+
}
|
|
1520
|
+
async function P() {
|
|
1521
|
+
m.value = !0;
|
|
1522
|
+
try {
|
|
1523
|
+
T(await V.get(S.value));
|
|
1524
|
+
} catch (F) {
|
|
1525
|
+
Y.danger(c(F)), p.push(h.value);
|
|
1526
|
+
} finally {
|
|
1527
|
+
m.value = !1;
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
async function Z() {
|
|
1531
|
+
if (!(!w.value || C.value || !z.value)) {
|
|
1532
|
+
C.value = !0, B.value = {};
|
|
1533
|
+
try {
|
|
1534
|
+
T(await V.save(w.value.id, W.value)), Y.success(o("panel.saved"));
|
|
1535
|
+
} catch (F) {
|
|
1536
|
+
const A = F.body;
|
|
1537
|
+
A?.errors && Object.keys(A.errors).length > 0 ? (B.value = A.errors, Y.danger(o("panel.save-failed"))) : Y.danger(c(F));
|
|
1538
|
+
} finally {
|
|
1539
|
+
C.value = !1;
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
async function pe() {
|
|
1544
|
+
const F = w.value;
|
|
1545
|
+
if (!(!F || !await $e({
|
|
1546
|
+
title: o("panel.delete-title", { name: v.value }),
|
|
1547
|
+
message: o("panel.delete-text"),
|
|
1548
|
+
confirmText: o("panel.delete"),
|
|
1549
|
+
cancelText: o("panel.cancel"),
|
|
1550
|
+
tone: "danger"
|
|
1551
|
+
})))
|
|
1552
|
+
try {
|
|
1553
|
+
await V.remove(F.id), Y.success(o("panel.deleted")), k.value = E.value, p.push(h.value);
|
|
1554
|
+
} catch (u) {
|
|
1555
|
+
Y.danger(c(u));
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
function ue(F) {
|
|
1559
|
+
D.value && F.preventDefault();
|
|
1560
|
+
}
|
|
1561
|
+
function me(F) {
|
|
1562
|
+
(F.ctrlKey || F.metaKey) && F.key.toLowerCase() === "s" && (F.preventDefault(), D.value && Z());
|
|
1563
|
+
}
|
|
1564
|
+
ca(me), re(S, () => {
|
|
1565
|
+
P();
|
|
1566
|
+
}), Oe(() => {
|
|
1567
|
+
P(), window.addEventListener("beforeunload", ue);
|
|
1568
|
+
}), Ue(() => {
|
|
1569
|
+
window.removeEventListener("beforeunload", ue);
|
|
1570
|
+
}), Ia(async () => !D.value || !z.value ? !0 : await $e({
|
|
1571
|
+
title: o("panel.leave-title"),
|
|
1572
|
+
message: o("panel.leave-text"),
|
|
1573
|
+
confirmText: o("panel.leave"),
|
|
1574
|
+
cancelText: o("panel.cancel"),
|
|
1575
|
+
tone: "danger"
|
|
1576
|
+
}));
|
|
1577
|
+
const be = x(
|
|
1578
|
+
() => w.value && z.value && w.value.deleted_at === null ? [
|
|
1579
|
+
{
|
|
1580
|
+
key: "delete",
|
|
1581
|
+
label: o("panel.delete"),
|
|
1582
|
+
icon: "trash",
|
|
1583
|
+
danger: !0,
|
|
1584
|
+
menu: !0,
|
|
1585
|
+
run: () => {
|
|
1586
|
+
pe();
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
] : []
|
|
1590
|
+
);
|
|
1591
|
+
return (F, A) => (d(), j("div", {
|
|
1592
|
+
class: "wx-catalog-property-editor",
|
|
1593
|
+
onKeydown: me
|
|
1594
|
+
}, [
|
|
1595
|
+
m.value || !w.value ? (d(), j(oe, { key: 0 }, [
|
|
1596
|
+
b(e(ke), {
|
|
1597
|
+
class: "wx-catalog-property-editor__ghost",
|
|
1598
|
+
title: "",
|
|
1599
|
+
rows: 1
|
|
1600
|
+
}),
|
|
1601
|
+
b(e(ka), null, {
|
|
1602
|
+
default: f(() => [
|
|
1603
|
+
b(e(ke), { rows: 6 })
|
|
1604
|
+
]),
|
|
1605
|
+
_: 1
|
|
1606
|
+
})
|
|
1607
|
+
], 64)) : (d(), j(oe, { key: 1 }, [
|
|
1608
|
+
b(e(pa), {
|
|
1609
|
+
divider: "",
|
|
1610
|
+
back: h.value,
|
|
1611
|
+
"back-label": i.value,
|
|
1612
|
+
title: v.value,
|
|
1613
|
+
subtitle: s.value,
|
|
1614
|
+
actions: be.value
|
|
1615
|
+
}, la({
|
|
1616
|
+
trail: f(() => [
|
|
1617
|
+
b(e(Va), {
|
|
1618
|
+
size: "sm",
|
|
1619
|
+
label: e(o)("panel.trail")
|
|
1620
|
+
}, {
|
|
1621
|
+
default: f(() => [
|
|
1622
|
+
b(e(Fe), {
|
|
1623
|
+
as: "router-link",
|
|
1624
|
+
to: h.value
|
|
1625
|
+
}, {
|
|
1626
|
+
default: f(() => [
|
|
1627
|
+
G(M(i.value), 1)
|
|
1628
|
+
]),
|
|
1629
|
+
_: 1
|
|
1630
|
+
}, 8, ["to"]),
|
|
1631
|
+
b(e(Fe), { current: "" }, {
|
|
1632
|
+
default: f(() => [
|
|
1633
|
+
G(M(v.value), 1)
|
|
1634
|
+
]),
|
|
1635
|
+
_: 1
|
|
1636
|
+
})
|
|
1637
|
+
]),
|
|
1638
|
+
_: 1
|
|
1639
|
+
}, 8, ["label"])
|
|
1640
|
+
]),
|
|
1641
|
+
_: 2
|
|
1642
|
+
}, [
|
|
1643
|
+
w.value.deleted_at !== null ? {
|
|
1644
|
+
name: "title-after",
|
|
1645
|
+
fn: f(() => [
|
|
1646
|
+
b(e($a), { dot: "" }, {
|
|
1647
|
+
default: f(() => [
|
|
1648
|
+
G(M(e(o)("panel.in-bin")), 1)
|
|
1649
|
+
]),
|
|
1650
|
+
_: 1
|
|
1651
|
+
})
|
|
1652
|
+
]),
|
|
1653
|
+
key: "0"
|
|
1654
|
+
} : void 0
|
|
1655
|
+
]), 1032, ["back", "back-label", "title", "subtitle", "actions"]),
|
|
1656
|
+
b(e(va), {
|
|
1657
|
+
modelValue: W.value,
|
|
1658
|
+
"onUpdate:modelValue": A[0] || (A[0] = (u) => W.value = u),
|
|
1659
|
+
name: "catalog.property-form",
|
|
1660
|
+
errors: B.value,
|
|
1661
|
+
disabled: $.value
|
|
1662
|
+
}, null, 8, ["modelValue", "errors", "disabled"]),
|
|
1663
|
+
z.value ? (d(), U(e(Pa), { key: 0 }, {
|
|
1664
|
+
state: f(() => [
|
|
1665
|
+
b(e(ma), { state: X.value }, null, 8, ["state"])
|
|
1666
|
+
]),
|
|
1667
|
+
default: f(() => [
|
|
1668
|
+
b(e(te), {
|
|
1669
|
+
type: "primary",
|
|
1670
|
+
loading: C.value,
|
|
1671
|
+
disabled: !D.value,
|
|
1672
|
+
onClick: Z
|
|
1673
|
+
}, {
|
|
1674
|
+
default: f(() => [
|
|
1675
|
+
G(M(e(o)("panel.save")), 1)
|
|
1676
|
+
]),
|
|
1677
|
+
_: 1
|
|
1678
|
+
}, 8, ["loading", "disabled"])
|
|
1679
|
+
]),
|
|
1680
|
+
_: 1
|
|
1681
|
+
})) : H("", !0)
|
|
1682
|
+
], 64))
|
|
1683
|
+
], 32));
|
|
1684
|
+
}
|
|
1685
|
+
}), _t = /* @__PURE__ */ he(bt, [["__scopeId", "data-v-256c406b"]]), wt = /* @__PURE__ */ le({
|
|
1686
|
+
name: "WxCatalogPropertyType",
|
|
1687
|
+
inheritAttrs: !1,
|
|
1688
|
+
__name: "TypeField",
|
|
1689
|
+
props: /* @__PURE__ */ Me({
|
|
1690
|
+
options: { default: () => [] }
|
|
1691
|
+
}, {
|
|
1692
|
+
modelValue: { default: null },
|
|
1693
|
+
modelModifiers: {}
|
|
1694
|
+
}),
|
|
1695
|
+
emits: ["update:modelValue"],
|
|
1696
|
+
setup(r) {
|
|
1697
|
+
const a = r, n = Se(r, "modelValue"), V = Ce(), t = x(() => (V?.property.value?.id ?? null) !== null);
|
|
1698
|
+
return (p, l) => (d(), U(e(Ve), oa(p.$attrs, {
|
|
1699
|
+
modelValue: n.value,
|
|
1700
|
+
"onUpdate:modelValue": l[0] || (l[0] = (o) => n.value = o),
|
|
1701
|
+
options: a.options,
|
|
1702
|
+
disabled: t.value || void 0
|
|
1703
|
+
}), null, 16, ["modelValue", "options", "disabled"]));
|
|
1704
|
+
}
|
|
1705
|
+
}), xt = /* @__PURE__ */ le({
|
|
1706
|
+
name: "WxCatalogPropertyMergeDialog",
|
|
1707
|
+
__name: "MergeDialog",
|
|
1708
|
+
props: {
|
|
1709
|
+
property: {},
|
|
1710
|
+
value: {}
|
|
1711
|
+
},
|
|
1712
|
+
setup(r) {
|
|
1713
|
+
const a = r, { open: n, resolve: V, dismiss: t } = De(), p = ie(), l = ce(p), o = se(ae), c = ye(), S = x(() => p.i18n.state.locale), h = x(() => Q(a.value.title, S.value, `#${a.value.id}`)), w = _([]), W = _(null), O = _(null), k = _(!1), m = _(!1), C = _(""), B = x(
|
|
1714
|
+
() => w.value.filter((i) => i.id !== a.value.id).map((i) => ({ value: i.id, label: Q(i.title, S.value, `#${i.id}`) }))
|
|
1715
|
+
), z = x(
|
|
1716
|
+
() => B.value.find((i) => i.value === W.value)?.label ?? ""
|
|
1717
|
+
);
|
|
1718
|
+
let $ = 0;
|
|
1719
|
+
async function E(i) {
|
|
1720
|
+
const v = ++$;
|
|
1721
|
+
try {
|
|
1722
|
+
const s = await l.searchValues(a.property, i.trim(), 30);
|
|
1723
|
+
v === $ && (w.value = s);
|
|
1724
|
+
} catch {
|
|
1725
|
+
v === $ && (w.value = []);
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
E(""), re(W, async (i) => {
|
|
1729
|
+
if (O.value = null, C.value = "", i !== null) {
|
|
1730
|
+
k.value = !0;
|
|
1731
|
+
try {
|
|
1732
|
+
O.value = await l.mergeValue(a.property, a.value.id, i, !0);
|
|
1733
|
+
} catch (v) {
|
|
1734
|
+
C.value = c(v);
|
|
1735
|
+
} finally {
|
|
1736
|
+
k.value = !1;
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
});
|
|
1740
|
+
function D(i) {
|
|
1741
|
+
W.value = typeof i == "number" ? i : null;
|
|
1742
|
+
}
|
|
1743
|
+
async function X() {
|
|
1744
|
+
if (!(W.value === null || m.value)) {
|
|
1745
|
+
m.value = !0, C.value = "";
|
|
1746
|
+
try {
|
|
1747
|
+
V(await l.mergeValue(a.property, a.value.id, W.value));
|
|
1748
|
+
} catch (i) {
|
|
1749
|
+
C.value = c(i);
|
|
1750
|
+
} finally {
|
|
1751
|
+
m.value = !1;
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
return (i, v) => (d(), U(e(Re), {
|
|
1756
|
+
open: e(n),
|
|
1757
|
+
"onUpdate:open": v[1] || (v[1] = (s) => ze(n) ? n.value = s : null),
|
|
1758
|
+
title: e(o)("panel.merge-title", { name: h.value }),
|
|
1759
|
+
width: 480
|
|
1760
|
+
}, {
|
|
1761
|
+
footer: f(() => [
|
|
1762
|
+
b(e(Le), { size: "sm" }, {
|
|
1763
|
+
default: f(() => [
|
|
1764
|
+
b(e(te), {
|
|
1765
|
+
variant: "outline",
|
|
1766
|
+
onClick: v[0] || (v[0] = (s) => e(t)())
|
|
1767
|
+
}, {
|
|
1768
|
+
default: f(() => [
|
|
1769
|
+
G(M(e(o)("panel.cancel")), 1)
|
|
1770
|
+
]),
|
|
1771
|
+
_: 1
|
|
1772
|
+
}),
|
|
1773
|
+
b(e(te), {
|
|
1774
|
+
type: "primary",
|
|
1775
|
+
loading: m.value || k.value,
|
|
1776
|
+
disabled: W.value === null || O.value === null,
|
|
1777
|
+
onClick: X
|
|
1778
|
+
}, {
|
|
1779
|
+
default: f(() => [
|
|
1780
|
+
G(M(e(o)("panel.merge")), 1)
|
|
1781
|
+
]),
|
|
1782
|
+
_: 1
|
|
1783
|
+
}, 8, ["loading", "disabled"])
|
|
1784
|
+
]),
|
|
1785
|
+
_: 1
|
|
1786
|
+
})
|
|
1787
|
+
]),
|
|
1788
|
+
default: f(() => [
|
|
1789
|
+
b(e(fe), {
|
|
1790
|
+
label: e(o)("panel.merge-into"),
|
|
1791
|
+
help: e(o)("panel.merge-help")
|
|
1792
|
+
}, {
|
|
1793
|
+
default: f(() => [
|
|
1794
|
+
b(e(Ve), {
|
|
1795
|
+
"model-value": W.value,
|
|
1796
|
+
options: B.value,
|
|
1797
|
+
placeholder: e(o)("panel.search"),
|
|
1798
|
+
"empty-text": e(o)("panel.nothing-found"),
|
|
1799
|
+
filterable: "",
|
|
1800
|
+
"onUpdate:modelValue": D,
|
|
1801
|
+
onSearch: E
|
|
1802
|
+
}, null, 8, ["model-value", "options", "placeholder", "empty-text"])
|
|
1803
|
+
]),
|
|
1804
|
+
_: 1
|
|
1805
|
+
}, 8, ["label", "help"]),
|
|
1806
|
+
C.value ? (d(), U(e(de), {
|
|
1807
|
+
key: 0,
|
|
1808
|
+
type: "danger",
|
|
1809
|
+
variant: "soft",
|
|
1810
|
+
description: C.value
|
|
1811
|
+
}, null, 8, ["description"])) : W.value !== null && O.value !== null ? (d(), U(e(de), {
|
|
1812
|
+
key: 1,
|
|
1813
|
+
type: "warning",
|
|
1814
|
+
variant: "soft",
|
|
1815
|
+
description: e(o)("panel.merge-confirm", { name: h.value, target: z.value, count: O.value })
|
|
1816
|
+
}, null, 8, ["description"])) : H("", !0)
|
|
1817
|
+
]),
|
|
1818
|
+
_: 1
|
|
1819
|
+
}, 8, ["open", "title"]));
|
|
1820
|
+
}
|
|
1821
|
+
}), kt = { class: "wx-catalog-value-dialog__picture" }, Vt = ["src"], $t = /* @__PURE__ */ le({
|
|
1822
|
+
name: "WxCatalogPropertyValueDialog",
|
|
1823
|
+
__name: "ValueDialog",
|
|
1824
|
+
props: {
|
|
1825
|
+
property: {},
|
|
1826
|
+
value: { default: null },
|
|
1827
|
+
parent: { default: null },
|
|
1828
|
+
title: {},
|
|
1829
|
+
color: { type: Boolean, default: !1 },
|
|
1830
|
+
image: { type: Boolean, default: !1 }
|
|
1831
|
+
},
|
|
1832
|
+
setup(r) {
|
|
1833
|
+
const a = r, { open: n, resolve: V, dismiss: t } = De(), p = ce(ie()), l = se(ae), o = ($) => $ && !Array.isArray($) ? { ...$ } : {}, c = _(o(a.value?.title)), S = _(o(a.value?.slug)), h = _(a.value?.color ?? null), w = _(
|
|
1834
|
+
a.value?.image ? { id: a.value.image.id, url: a.value.image.thumb ?? a.value.image.url } : null
|
|
1835
|
+
), W = _(!1), O = _({}), k = Je("field");
|
|
1836
|
+
Oe(async () => {
|
|
1837
|
+
await Ye(), k.value?.querySelector("input")?.focus();
|
|
1838
|
+
});
|
|
1839
|
+
function m($) {
|
|
1840
|
+
const E = Object.keys(O.value).find((D) => D === $ || D.startsWith(`${$}.`));
|
|
1841
|
+
return E === void 0 ? void 0 : O.value[E]?.[0];
|
|
1842
|
+
}
|
|
1843
|
+
const C = () => Object.values(c.value).some(($) => $.trim() !== "");
|
|
1844
|
+
async function B() {
|
|
1845
|
+
const $ = await Ua({ accept: "image" });
|
|
1846
|
+
$ && (w.value = { id: $.id, url: $.thumb ?? $.url });
|
|
1847
|
+
}
|
|
1848
|
+
async function z() {
|
|
1849
|
+
if (!C() || W.value) return;
|
|
1850
|
+
W.value = !0, O.value = {};
|
|
1851
|
+
const $ = { title: c.value, slug: S.value };
|
|
1852
|
+
a.color && ($.color = h.value), a.image && ($.image_id = w.value?.id ?? null);
|
|
1853
|
+
try {
|
|
1854
|
+
V(
|
|
1855
|
+
a.value ? await p.saveValue(a.property, a.value.id, $) : await p.createValue(a.property, { ...$, parent_id: a.parent })
|
|
1856
|
+
);
|
|
1857
|
+
} catch (E) {
|
|
1858
|
+
O.value = E.body?.errors ?? {};
|
|
1859
|
+
} finally {
|
|
1860
|
+
W.value = !1;
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
return ($, E) => (d(), U(e(Re), {
|
|
1864
|
+
open: e(n),
|
|
1865
|
+
"onUpdate:open": E[5] || (E[5] = (D) => ze(n) ? n.value = D : null),
|
|
1866
|
+
title: a.title,
|
|
1867
|
+
width: 480
|
|
1868
|
+
}, {
|
|
1869
|
+
footer: f(() => [
|
|
1870
|
+
b(e(Le), { size: "sm" }, {
|
|
1871
|
+
default: f(() => [
|
|
1872
|
+
b(e(te), {
|
|
1873
|
+
variant: "outline",
|
|
1874
|
+
onClick: E[4] || (E[4] = (D) => e(t)())
|
|
1875
|
+
}, {
|
|
1876
|
+
default: f(() => [
|
|
1877
|
+
G(M(e(l)("panel.cancel")), 1)
|
|
1878
|
+
]),
|
|
1879
|
+
_: 1
|
|
1880
|
+
}),
|
|
1881
|
+
b(e(te), {
|
|
1882
|
+
type: "primary",
|
|
1883
|
+
loading: W.value,
|
|
1884
|
+
disabled: !C(),
|
|
1885
|
+
onClick: z
|
|
1886
|
+
}, {
|
|
1887
|
+
default: f(() => [
|
|
1888
|
+
G(M(a.value ? e(l)("panel.save") : e(l)("panel.create")), 1)
|
|
1889
|
+
]),
|
|
1890
|
+
_: 1
|
|
1891
|
+
}, 8, ["loading", "disabled"])
|
|
1892
|
+
]),
|
|
1893
|
+
_: 1
|
|
1894
|
+
})
|
|
1895
|
+
]),
|
|
1896
|
+
default: f(() => [
|
|
1897
|
+
b(e(fe), {
|
|
1898
|
+
label: e(l)("value.title"),
|
|
1899
|
+
error: m("title"),
|
|
1900
|
+
required: ""
|
|
1901
|
+
}, {
|
|
1902
|
+
default: f(() => [
|
|
1903
|
+
K("div", {
|
|
1904
|
+
ref_key: "field",
|
|
1905
|
+
ref: k
|
|
1906
|
+
}, [
|
|
1907
|
+
b(e(ge), {
|
|
1908
|
+
modelValue: c.value,
|
|
1909
|
+
"onUpdate:modelValue": E[0] || (E[0] = (D) => c.value = D),
|
|
1910
|
+
localized: "",
|
|
1911
|
+
"aria-label": e(l)("value.title"),
|
|
1912
|
+
onKeyup: We(z, ["enter"])
|
|
1913
|
+
}, null, 8, ["modelValue", "aria-label"])
|
|
1914
|
+
], 512)
|
|
1915
|
+
]),
|
|
1916
|
+
_: 1
|
|
1917
|
+
}, 8, ["label", "error"]),
|
|
1918
|
+
b(e(fe), {
|
|
1919
|
+
label: e(l)("value.slug"),
|
|
1920
|
+
help: e(l)("panel.slug-help"),
|
|
1921
|
+
error: m("slug")
|
|
1922
|
+
}, {
|
|
1923
|
+
default: f(() => [
|
|
1924
|
+
b(e(ge), {
|
|
1925
|
+
modelValue: S.value,
|
|
1926
|
+
"onUpdate:modelValue": E[1] || (E[1] = (D) => S.value = D),
|
|
1927
|
+
localized: "",
|
|
1928
|
+
"aria-label": e(l)("value.slug"),
|
|
1929
|
+
onKeyup: We(z, ["enter"])
|
|
1930
|
+
}, null, 8, ["modelValue", "aria-label"])
|
|
1931
|
+
]),
|
|
1932
|
+
_: 1
|
|
1933
|
+
}, 8, ["label", "help", "error"]),
|
|
1934
|
+
a.color ? (d(), U(e(fe), {
|
|
1935
|
+
key: 0,
|
|
1936
|
+
label: e(l)("value.color"),
|
|
1937
|
+
error: m("color")
|
|
1938
|
+
}, {
|
|
1939
|
+
default: f(() => [
|
|
1940
|
+
b(e(Sa), {
|
|
1941
|
+
modelValue: h.value,
|
|
1942
|
+
"onUpdate:modelValue": E[2] || (E[2] = (D) => h.value = D),
|
|
1943
|
+
clearable: "",
|
|
1944
|
+
"aria-label": e(l)("value.color")
|
|
1945
|
+
}, null, 8, ["modelValue", "aria-label"])
|
|
1946
|
+
]),
|
|
1947
|
+
_: 1
|
|
1948
|
+
}, 8, ["label", "error"])) : H("", !0),
|
|
1949
|
+
a.image ? (d(), U(e(fe), {
|
|
1950
|
+
key: 1,
|
|
1951
|
+
label: e(l)("value.image"),
|
|
1952
|
+
error: m("image_id")
|
|
1953
|
+
}, {
|
|
1954
|
+
default: f(() => [
|
|
1955
|
+
K("div", kt, [
|
|
1956
|
+
w.value ? (d(), j("img", {
|
|
1957
|
+
key: 0,
|
|
1958
|
+
src: w.value.url,
|
|
1959
|
+
alt: ""
|
|
1960
|
+
}, null, 8, Vt)) : H("", !0),
|
|
1961
|
+
b(e(te), {
|
|
1962
|
+
size: "sm",
|
|
1963
|
+
variant: "outline",
|
|
1964
|
+
icon: "image",
|
|
1965
|
+
onClick: B
|
|
1966
|
+
}, {
|
|
1967
|
+
default: f(() => [
|
|
1968
|
+
G(M(w.value ? e(l)("panel.picture-change") : e(l)("panel.picture-pick")), 1)
|
|
1969
|
+
]),
|
|
1970
|
+
_: 1
|
|
1971
|
+
}),
|
|
1972
|
+
w.value ? (d(), U(e(te), {
|
|
1973
|
+
key: 1,
|
|
1974
|
+
size: "sm",
|
|
1975
|
+
variant: "text",
|
|
1976
|
+
onClick: E[3] || (E[3] = (D) => w.value = null)
|
|
1977
|
+
}, {
|
|
1978
|
+
default: f(() => [
|
|
1979
|
+
G(M(e(l)("panel.picture-remove")), 1)
|
|
1980
|
+
]),
|
|
1981
|
+
_: 1
|
|
1982
|
+
})) : H("", !0)
|
|
1983
|
+
])
|
|
1984
|
+
]),
|
|
1985
|
+
_: 1
|
|
1986
|
+
}, 8, ["label", "error"])) : H("", !0)
|
|
1987
|
+
]),
|
|
1988
|
+
_: 1
|
|
1989
|
+
}, 8, ["open", "title"]));
|
|
1990
|
+
}
|
|
1991
|
+
}), Pt = /* @__PURE__ */ he($t, [["__scopeId", "data-v-4c730a6b"]]), St = { class: "wx-catalog-value-row" }, Ct = ["src"], Tt = { class: "wx-catalog-value-row__title" }, Wt = {
|
|
1992
|
+
key: 2,
|
|
1993
|
+
class: "wx-catalog-value-row__slug"
|
|
1994
|
+
}, At = { class: "wx-catalog-value-row__count" }, Nt = /* @__PURE__ */ le({
|
|
1995
|
+
name: "WxCatalogPropertyValueRow",
|
|
1996
|
+
__name: "ValueRow",
|
|
1997
|
+
props: {
|
|
1998
|
+
node: {},
|
|
1999
|
+
locale: {}
|
|
2000
|
+
},
|
|
2001
|
+
setup(r) {
|
|
2002
|
+
const a = r, n = se(ae), V = x(() => {
|
|
2003
|
+
const t = a.node.slug;
|
|
2004
|
+
return t && !Array.isArray(t) ? t[a.locale] ?? "" : "";
|
|
2005
|
+
});
|
|
2006
|
+
return (t, p) => (d(), j("span", St, [
|
|
2007
|
+
a.node.image ? (d(), j("img", {
|
|
2008
|
+
key: 0,
|
|
2009
|
+
class: "wx-catalog-value-row__image",
|
|
2010
|
+
src: a.node.image.thumb ?? a.node.image.url,
|
|
2011
|
+
alt: ""
|
|
2012
|
+
}, null, 8, Ct)) : a.node.color ? (d(), j("span", {
|
|
2013
|
+
key: 1,
|
|
2014
|
+
class: "wx-catalog-value-row__swatch",
|
|
2015
|
+
style: ra({ background: a.node.color }),
|
|
2016
|
+
"aria-hidden": "true"
|
|
2017
|
+
}, null, 4)) : H("", !0),
|
|
2018
|
+
K("span", Tt, M(a.node.label), 1),
|
|
2019
|
+
V.value ? (d(), j("span", Wt, M(V.value), 1)) : H("", !0),
|
|
2020
|
+
K("span", At, M(e(n)("panel.count", { count: a.node.products_count })), 1)
|
|
2021
|
+
]));
|
|
2022
|
+
}
|
|
2023
|
+
}), Ke = /* @__PURE__ */ he(Nt, [["__scopeId", "data-v-13648e79"]]), It = { class: "wx-catalog-values" }, Ut = { class: "wx-catalog-values__bar" }, Mt = /* @__PURE__ */ le({
|
|
2024
|
+
name: "WxCatalogPropertyValues",
|
|
2025
|
+
__name: "ValuesField",
|
|
2026
|
+
setup(r) {
|
|
2027
|
+
const a = ie(), n = ce(a), V = Ce();
|
|
2028
|
+
_e();
|
|
2029
|
+
const t = se(ae), p = ye(), l = x(() => V?.property.value ?? null), o = x(() => l.value?.id ?? null), c = x(() => a.i18n.state.locale), S = x(() => V?.locked.value ?? !0), h = x(() => !!V?.values.value.has_color), w = x(() => !!V?.values.value.has_image), W = x(() => l.value?.is_tree ?? !1), O = x(() => l.value?.value_order === "manual"), k = _([]), m = _([]), C = _(!0), B = _(!1), z = _(""), $ = _(null), E = x(() => z.value.trim() !== ""), D = _(""), X = _(!1), i = x(() => !S.value && O.value && !E.value), v = Ie(Pt), s = Ie(xt);
|
|
2030
|
+
function T(g) {
|
|
2031
|
+
return {
|
|
2032
|
+
...g,
|
|
2033
|
+
label: Q(g.title, c.value, `#${g.id}`),
|
|
2034
|
+
leaf: !g.has_children,
|
|
2035
|
+
children: void 0
|
|
2036
|
+
};
|
|
2037
|
+
}
|
|
2038
|
+
async function P() {
|
|
2039
|
+
if (o.value !== null) {
|
|
2040
|
+
C.value = !0, B.value = !1;
|
|
2041
|
+
try {
|
|
2042
|
+
k.value = (await n.values(o.value)).map(T), m.value = [];
|
|
2043
|
+
} catch {
|
|
2044
|
+
B.value = !0;
|
|
2045
|
+
} finally {
|
|
2046
|
+
C.value = !1;
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
re(o, () => {
|
|
2051
|
+
P();
|
|
2052
|
+
}, { immediate: !0 }), re(
|
|
2053
|
+
() => [l.value?.value_order, l.value?.is_tree],
|
|
2054
|
+
(g, I) => {
|
|
2055
|
+
I !== void 0 && (g[0] !== I[0] || g[1] !== I[1]) && P();
|
|
2056
|
+
}
|
|
2057
|
+
);
|
|
2058
|
+
async function Z(g) {
|
|
2059
|
+
return o.value === null ? [] : (await n.values(o.value, g.id)).map(T);
|
|
2060
|
+
}
|
|
2061
|
+
let pe, ue = 0;
|
|
2062
|
+
re(z, (g) => {
|
|
2063
|
+
if (clearTimeout(pe), g.trim() === "") {
|
|
2064
|
+
$.value = null;
|
|
2065
|
+
return;
|
|
2066
|
+
}
|
|
2067
|
+
pe = setTimeout(async () => {
|
|
2068
|
+
if (o.value === null) return;
|
|
2069
|
+
const I = ++ue;
|
|
2070
|
+
try {
|
|
2071
|
+
const L = (await n.searchValues(o.value, g.trim(), 100)).map((ve) => ({
|
|
2072
|
+
...T(ve),
|
|
2073
|
+
leaf: !0
|
|
2074
|
+
}));
|
|
2075
|
+
I === ue && ($.value = L);
|
|
2076
|
+
} catch {
|
|
2077
|
+
I === ue && ($.value = []);
|
|
2078
|
+
}
|
|
2079
|
+
}, 250);
|
|
2080
|
+
}), Ue(() => clearTimeout(pe));
|
|
2081
|
+
function me(g, I = k.value) {
|
|
2082
|
+
for (const L of I)
|
|
2083
|
+
g(L), L.children && me(g, L.children);
|
|
2084
|
+
if (I === k.value && $.value) for (const L of $.value) g(L);
|
|
2085
|
+
}
|
|
2086
|
+
function be(g) {
|
|
2087
|
+
me((I) => {
|
|
2088
|
+
I.id === g.id && Object.assign(I, {
|
|
2089
|
+
...g,
|
|
2090
|
+
label: Q(g.title, c.value, `#${g.id}`),
|
|
2091
|
+
leaf: !g.has_children && !(I.children && I.children.length > 0),
|
|
2092
|
+
children: I.children
|
|
2093
|
+
});
|
|
2094
|
+
});
|
|
2095
|
+
}
|
|
2096
|
+
function F(g) {
|
|
2097
|
+
Y.danger(p(g));
|
|
2098
|
+
}
|
|
2099
|
+
async function A() {
|
|
2100
|
+
const g = D.value.trim();
|
|
2101
|
+
if (!(g === "" || o.value === null || X.value)) {
|
|
2102
|
+
X.value = !0;
|
|
2103
|
+
try {
|
|
2104
|
+
const I = T(await n.createValue(o.value, { title: { [c.value]: g } }));
|
|
2105
|
+
D.value = "", k.value = O.value ? [...k.value, I] : [...k.value, I].sort((L, ve) => L.label.localeCompare(ve.label, c.value));
|
|
2106
|
+
} catch (I) {
|
|
2107
|
+
F(I);
|
|
2108
|
+
} finally {
|
|
2109
|
+
X.value = !1;
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
async function u(g) {
|
|
2114
|
+
if (o.value === null) return;
|
|
2115
|
+
const I = await v({
|
|
2116
|
+
property: o.value,
|
|
2117
|
+
parent: g.id,
|
|
2118
|
+
title: t("panel.value-new-inside", { name: g.label }),
|
|
2119
|
+
color: h.value,
|
|
2120
|
+
image: w.value
|
|
2121
|
+
});
|
|
2122
|
+
I !== void 0 && (g.children && g.children.push(T(I)), g.has_children = !0, g.leaf = !1, m.value.includes(g.id) || (m.value = [...m.value, g.id]));
|
|
2123
|
+
}
|
|
2124
|
+
async function y(g) {
|
|
2125
|
+
if (o.value === null) return;
|
|
2126
|
+
const I = await v({
|
|
2127
|
+
property: o.value,
|
|
2128
|
+
value: g,
|
|
2129
|
+
title: g.label,
|
|
2130
|
+
color: h.value,
|
|
2131
|
+
image: w.value
|
|
2132
|
+
});
|
|
2133
|
+
I !== void 0 && be(I);
|
|
2134
|
+
}
|
|
2135
|
+
async function R(g) {
|
|
2136
|
+
if (o.value === null) return;
|
|
2137
|
+
const I = await s({ property: o.value, value: g });
|
|
2138
|
+
I !== void 0 && (Y.success(t("panel.merged", { count: I })), z.value = "", await P());
|
|
2139
|
+
}
|
|
2140
|
+
async function J(g) {
|
|
2141
|
+
if (o.value === null) return;
|
|
2142
|
+
if (g.products_count > 0) {
|
|
2143
|
+
Y.warning(t("panel.value-in-use", { count: g.products_count }));
|
|
2144
|
+
return;
|
|
2145
|
+
}
|
|
2146
|
+
if (await $e({
|
|
2147
|
+
title: t("panel.value-delete-title", { name: g.label }),
|
|
2148
|
+
message: g.has_children ? t("panel.value-delete-branch") : t("panel.value-delete-text"),
|
|
2149
|
+
confirmText: t("panel.delete"),
|
|
2150
|
+
cancelText: t("panel.cancel"),
|
|
2151
|
+
tone: "danger"
|
|
2152
|
+
}))
|
|
2153
|
+
try {
|
|
2154
|
+
await n.removeValue(o.value, g.id);
|
|
2155
|
+
const L = (ve) => ve.filter((we) => we.id !== g.id).map((we) => we.children ? Object.assign(we, { children: L(we.children) }) : we);
|
|
2156
|
+
k.value = L(k.value), $.value && ($.value = L($.value));
|
|
2157
|
+
} catch (L) {
|
|
2158
|
+
const ve = L.body?.meta?.products;
|
|
2159
|
+
ve ? Y.warning(t("panel.value-in-use", { count: ve })) : F(L);
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
function N(g) {
|
|
2163
|
+
if (S.value) return [];
|
|
2164
|
+
const I = [
|
|
2165
|
+
{ key: "edit", label: t("panel.edit"), icon: "edit", run: () => {
|
|
2166
|
+
y(g);
|
|
2167
|
+
} }
|
|
2168
|
+
];
|
|
2169
|
+
return W.value && !E.value && I.push({
|
|
2170
|
+
key: "inside",
|
|
2171
|
+
label: t("panel.value-add-inside"),
|
|
2172
|
+
icon: "plus",
|
|
2173
|
+
run: () => {
|
|
2174
|
+
u(g);
|
|
2175
|
+
}
|
|
2176
|
+
}), I.push(
|
|
2177
|
+
{ key: "merge", label: t("panel.merge-with"), icon: "copy", run: () => {
|
|
2178
|
+
R(g);
|
|
2179
|
+
} },
|
|
2180
|
+
{
|
|
2181
|
+
key: "delete",
|
|
2182
|
+
label: t("panel.delete"),
|
|
2183
|
+
icon: "trash",
|
|
2184
|
+
danger: !0,
|
|
2185
|
+
run: () => {
|
|
2186
|
+
J(g);
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
), I;
|
|
2190
|
+
}
|
|
2191
|
+
function q(g, I, L) {
|
|
2192
|
+
return W.value || L !== "inside";
|
|
2193
|
+
}
|
|
2194
|
+
async function Pe(g) {
|
|
2195
|
+
if (o.value === null) return;
|
|
2196
|
+
const L = (g.parent ? g.parent.children ?? [] : k.value)[g.index + 1] ?? null;
|
|
2197
|
+
g.parent && (g.parent.has_children = !0, g.parent.leaf = !1);
|
|
2198
|
+
try {
|
|
2199
|
+
await n.moveValue(o.value, g.node.id, g.parent?.id ?? null, L?.id ?? null);
|
|
2200
|
+
} catch (ve) {
|
|
2201
|
+
F(ve), await P();
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
return (g, I) => (d(), j("div", It, [
|
|
2205
|
+
l.value ? (d(), j(oe, { key: 1 }, [
|
|
2206
|
+
K("div", Ut, [
|
|
2207
|
+
S.value ? H("", !0) : (d(), j("form", {
|
|
2208
|
+
key: 0,
|
|
2209
|
+
class: "wx-catalog-values__add",
|
|
2210
|
+
onSubmit: na(A, ["prevent"])
|
|
2211
|
+
}, [
|
|
2212
|
+
b(e(ge), {
|
|
2213
|
+
modelValue: D.value,
|
|
2214
|
+
"onUpdate:modelValue": I[0] || (I[0] = (L) => D.value = L),
|
|
2215
|
+
placeholder: e(t)("panel.value-new"),
|
|
2216
|
+
"aria-label": e(t)("panel.value-new"),
|
|
2217
|
+
size: "sm"
|
|
2218
|
+
}, null, 8, ["modelValue", "placeholder", "aria-label"]),
|
|
2219
|
+
b(e(te), {
|
|
2220
|
+
"native-type": "submit",
|
|
2221
|
+
size: "sm",
|
|
2222
|
+
loading: X.value,
|
|
2223
|
+
disabled: D.value.trim() === ""
|
|
2224
|
+
}, {
|
|
2225
|
+
default: f(() => [
|
|
2226
|
+
G(M(e(t)("panel.add")), 1)
|
|
2227
|
+
]),
|
|
2228
|
+
_: 1
|
|
2229
|
+
}, 8, ["loading", "disabled"])
|
|
2230
|
+
], 32)),
|
|
2231
|
+
b(e(ge), {
|
|
2232
|
+
modelValue: z.value,
|
|
2233
|
+
"onUpdate:modelValue": I[1] || (I[1] = (L) => z.value = L),
|
|
2234
|
+
class: "wx-catalog-values__search",
|
|
2235
|
+
placeholder: e(t)("panel.search"),
|
|
2236
|
+
"aria-label": e(t)("panel.search"),
|
|
2237
|
+
clearable: "",
|
|
2238
|
+
size: "sm"
|
|
2239
|
+
}, null, 8, ["modelValue", "placeholder", "aria-label"])
|
|
2240
|
+
]),
|
|
2241
|
+
C.value ? (d(), U(e(ke), {
|
|
2242
|
+
key: 0,
|
|
2243
|
+
rows: 4
|
|
2244
|
+
})) : B.value ? (d(), U(e(de), {
|
|
2245
|
+
key: 1,
|
|
2246
|
+
type: "warning",
|
|
2247
|
+
variant: "soft",
|
|
2248
|
+
description: e(t)("panel.values-failed")
|
|
2249
|
+
}, null, 8, ["description"])) : E.value ? (d(), U(e(je), {
|
|
2250
|
+
key: 2,
|
|
2251
|
+
"model-value": $.value ?? [],
|
|
2252
|
+
class: "wx-catalog-values__tree",
|
|
2253
|
+
"empty-text": $.value === null ? e(t)("panel.searching") : e(t)("panel.nothing-found"),
|
|
2254
|
+
"aria-label": e(t)("property.tab-values")
|
|
2255
|
+
}, {
|
|
2256
|
+
default: f(({ node: L }) => [
|
|
2257
|
+
b(Ke, {
|
|
2258
|
+
node: L,
|
|
2259
|
+
locale: c.value
|
|
2260
|
+
}, null, 8, ["node", "locale"])
|
|
2261
|
+
]),
|
|
2262
|
+
actions: f(({ node: L }) => [
|
|
2263
|
+
S.value ? H("", !0) : (d(), U(e(Ae), {
|
|
2264
|
+
key: 0,
|
|
2265
|
+
actions: N(L),
|
|
2266
|
+
label: L.label
|
|
2267
|
+
}, null, 8, ["actions", "label"]))
|
|
2268
|
+
]),
|
|
2269
|
+
_: 1
|
|
2270
|
+
}, 8, ["model-value", "empty-text", "aria-label"])) : (d(), U(e(je), {
|
|
2271
|
+
key: 3,
|
|
2272
|
+
modelValue: k.value,
|
|
2273
|
+
"onUpdate:modelValue": I[2] || (I[2] = (L) => k.value = L),
|
|
2274
|
+
expanded: m.value,
|
|
2275
|
+
"onUpdate:expanded": I[3] || (I[3] = (L) => m.value = L),
|
|
2276
|
+
class: "wx-catalog-values__tree",
|
|
2277
|
+
lazy: "",
|
|
2278
|
+
load: Z,
|
|
2279
|
+
"leaf-key": "leaf",
|
|
2280
|
+
draggable: i.value,
|
|
2281
|
+
"allow-drop": q,
|
|
2282
|
+
"empty-text": e(t)("panel.values-empty"),
|
|
2283
|
+
"aria-label": e(t)("property.tab-values"),
|
|
2284
|
+
onDrop: Pe
|
|
2285
|
+
}, {
|
|
2286
|
+
default: f(({ node: L }) => [
|
|
2287
|
+
b(Ke, {
|
|
2288
|
+
node: L,
|
|
2289
|
+
locale: c.value
|
|
2290
|
+
}, null, 8, ["node", "locale"])
|
|
2291
|
+
]),
|
|
2292
|
+
actions: f(({ node: L }) => [
|
|
2293
|
+
S.value ? H("", !0) : (d(), U(e(Ae), {
|
|
2294
|
+
key: 0,
|
|
2295
|
+
actions: N(L),
|
|
2296
|
+
label: L.label
|
|
2297
|
+
}, null, 8, ["actions", "label"]))
|
|
2298
|
+
]),
|
|
2299
|
+
_: 1
|
|
2300
|
+
}, 8, ["modelValue", "expanded", "draggable", "empty-text", "aria-label"])),
|
|
2301
|
+
!C.value && !B.value && !E.value ? (d(), U(e(ne), {
|
|
2302
|
+
key: 4,
|
|
2303
|
+
size: "sm",
|
|
2304
|
+
tone: "muted"
|
|
2305
|
+
}, {
|
|
2306
|
+
default: f(() => [
|
|
2307
|
+
G(M(O.value ? e(t)("panel.values-order-manual") : e(t)("panel.values-order-alpha")), 1)
|
|
2308
|
+
]),
|
|
2309
|
+
_: 1
|
|
2310
|
+
})) : H("", !0)
|
|
2311
|
+
], 64)) : (d(), U(e(de), {
|
|
2312
|
+
key: 0,
|
|
2313
|
+
type: "info",
|
|
2314
|
+
variant: "soft",
|
|
2315
|
+
description: e(t)("panel.values-unsaved")
|
|
2316
|
+
}, null, 8, ["description"]))
|
|
2317
|
+
]));
|
|
2318
|
+
}
|
|
2319
|
+
}), Ot = /* @__PURE__ */ he(Mt, [["__scopeId", "data-v-7e854528"]]), zt = [
|
|
2320
|
+
"new",
|
|
2321
|
+
"empty",
|
|
2322
|
+
"empty-help",
|
|
2323
|
+
"order",
|
|
2324
|
+
"hidden",
|
|
2325
|
+
"count",
|
|
2326
|
+
"delete-blocked",
|
|
2327
|
+
"delete-text",
|
|
2328
|
+
"deleted",
|
|
2329
|
+
"saved"
|
|
2330
|
+
];
|
|
2331
|
+
function Et(r = {}) {
|
|
2332
|
+
const a = r.path ?? "/catalog";
|
|
2333
|
+
return {
|
|
2334
|
+
api: Ze,
|
|
2335
|
+
path: `${a}/properties/groups`,
|
|
2336
|
+
name: "webx.catalog-properties.groups",
|
|
2337
|
+
module: "catalog-properties",
|
|
2338
|
+
title: `${ae}::panel.groups-title`,
|
|
2339
|
+
back: { path: `${a}/properties`, label: `${ae}::module.title` },
|
|
2340
|
+
screen: "catalog.property-group-form",
|
|
2341
|
+
manage: "catalog.manage",
|
|
2342
|
+
count: "properties_count",
|
|
2343
|
+
words: Object.fromEntries(zt.map((n) => [n, `${ae}::group.${n}`]))
|
|
2344
|
+
};
|
|
2345
|
+
}
|
|
2346
|
+
function Bt(r) {
|
|
2347
|
+
const a = r.component;
|
|
2348
|
+
return a === void 0 ? r : {
|
|
2349
|
+
...r,
|
|
2350
|
+
component: le({
|
|
2351
|
+
name: "WxCatalogPropertyGroupsView",
|
|
2352
|
+
setup() {
|
|
2353
|
+
return _e(), () => sa(a);
|
|
2354
|
+
}
|
|
2355
|
+
})
|
|
2356
|
+
};
|
|
2357
|
+
}
|
|
2358
|
+
function Ht(r = {}) {
|
|
2359
|
+
const a = r.path ?? "/catalog", n = { base: a };
|
|
2360
|
+
return [
|
|
2361
|
+
{
|
|
2362
|
+
id: "catalog-properties",
|
|
2363
|
+
path: `${a}/properties`,
|
|
2364
|
+
routes: [
|
|
2365
|
+
{
|
|
2366
|
+
path: `${a}/properties`,
|
|
2367
|
+
name: "webx.catalog-properties",
|
|
2368
|
+
component: ht,
|
|
2369
|
+
props: n
|
|
2370
|
+
},
|
|
2371
|
+
{
|
|
2372
|
+
path: `${a}/properties/:id(\\d+)`,
|
|
2373
|
+
name: "webx.catalog-properties.edit",
|
|
2374
|
+
component: _t,
|
|
2375
|
+
props: n
|
|
2376
|
+
},
|
|
2377
|
+
...fa(Et(r)).map(Bt)
|
|
2378
|
+
],
|
|
2379
|
+
types: {
|
|
2380
|
+
"wx-catalog-property-type": { component: wt, kind: "field" },
|
|
2381
|
+
"wx-catalog-property-example": { component: lt, kind: "display" },
|
|
2382
|
+
"wx-catalog-property-values": { component: Ot, kind: "display" },
|
|
2383
|
+
"wx-catalog-property-intervals": { component: et, kind: "display" },
|
|
2384
|
+
"wx-catalog-category-properties": { component: Ha, kind: "display" },
|
|
2385
|
+
// Wide: a group of the card is a column of fields, and half a form is too narrow for a
|
|
2386
|
+
// combobox of values beside its label.
|
|
2387
|
+
"wx-catalog-product-properties": {
|
|
2388
|
+
component: vt,
|
|
2389
|
+
kind: "field",
|
|
2390
|
+
wide: !0
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
];
|
|
2395
|
+
}
|
|
2396
|
+
export {
|
|
2397
|
+
Ze as GROUPS_API,
|
|
2398
|
+
Ma as PROPERTIES_API,
|
|
2399
|
+
Oa as SETS_API,
|
|
2400
|
+
Ha as WxCatalogCategoryProperties,
|
|
2401
|
+
vt as WxCatalogProductProperties,
|
|
2402
|
+
ht as WxCatalogPropertiesPage,
|
|
2403
|
+
_t as WxCatalogPropertyEditor,
|
|
2404
|
+
et as WxCatalogPropertyIntervals,
|
|
2405
|
+
Ot as WxCatalogPropertyValues,
|
|
2406
|
+
Ht as catalogProperties,
|
|
2407
|
+
Da as catalogPropertiesMessages,
|
|
2408
|
+
ce as createPropertiesApi,
|
|
2409
|
+
qe as formatNumber,
|
|
2410
|
+
ea as propertyEditorKey,
|
|
2411
|
+
Et as propertyGroupsOptions,
|
|
2412
|
+
ee as propertyName,
|
|
2413
|
+
za as propertySearch,
|
|
2414
|
+
Ja as providePropertyEditor,
|
|
2415
|
+
Ce as usePropertyEditor,
|
|
2416
|
+
Q as wordsIn
|
|
2417
|
+
};
|
|
2418
|
+
//# sourceMappingURL=index.js.map
|