@feedmepos/mf-menu 0.19.12 → 0.19.13

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.
Files changed (51) hide show
  1. package/dist/{ApplyProduct.vue_vue_type_script_setup_true_lang-DetNZI3I.js → ApplyProduct.vue_vue_type_script_setup_true_lang-Bvkr0nD3.js} +2 -2
  2. package/dist/{ApplyProducts.vue_vue_type_script_setup_true_lang-CwAUrR4F.js → ApplyProducts.vue_vue_type_script_setup_true_lang-Hx8MMYfJ.js} +2 -2
  3. package/dist/{Catalog-DIm2_Pve.js → Catalog-C3Cx3sFF.js} +3 -3
  4. package/dist/{Category-Bj7VMtJ-.js → Category-C_5RCWZ_.js} +6 -6
  5. package/dist/{CookingGuide-DDV0xBos.js → CookingGuide-BzLjzKZI.js} +3 -3
  6. package/dist/{Group-DLh05bcU.js → Group-DJm-Mk3u.js} +4 -4
  7. package/dist/{Group-DZo7HAf2.js → Group-DjTfdOWl.js} +1 -1
  8. package/dist/{Group.vue_vue_type_script_setup_true_lang-ooVmvatG.js → Group.vue_vue_type_script_setup_true_lang-DBk_yau1.js} +127 -127
  9. package/dist/{GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-B3FXm_t8.js → GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-By61Cx0K.js} +2 -2
  10. package/dist/{Ingredient-N8t1Zg1B.js → Ingredient-CN3KCmFG.js} +4 -4
  11. package/dist/{LinkProductSideSheet-DfPSfCPO.js → LinkProductSideSheet-DBx4NpGw.js} +2 -2
  12. package/dist/{PrintRoute-COjWuW4S.js → PrintRoute-DMUblGYw.js} +3 -3
  13. package/dist/{Product-CcSZnVtx.js → Product-BVAvSbra.js} +1 -1
  14. package/dist/Product.vue_vue_type_script_setup_true_lang-D5gHIGvK.js +841 -0
  15. package/dist/{Products-DC50oMNz.js → Products-CM4pI3iG.js} +8 -8
  16. package/dist/{Publish-C7wZimbw.js → Publish-MLYmwkhU.js} +2 -2
  17. package/dist/{Recipe-KeudfKx-.js → Recipe-CtY40lpO.js} +4 -4
  18. package/dist/{Scheduler-Ci0qqmD0.js → Scheduler-DDL5yw94.js} +2 -2
  19. package/dist/SchedulerSelector.vue_vue_type_script_setup_true_lang-DkzeDjf4.js +61 -0
  20. package/dist/ServingSequence-OCghftu3.js +4 -0
  21. package/dist/{Setting-R8hJKnp6.js → Setting-B9VYv_FV.js} +1 -1
  22. package/dist/{Setting.vue_vue_type_script_setup_true_lang-C8YEErhA.js → Setting.vue_vue_type_script_setup_true_lang-q4SDPU1B.js} +3 -3
  23. package/dist/{Takeaway-DfZUEYul.js → Takeaway-BNKH3pYw.js} +4 -4
  24. package/dist/{Takeaway-D1YJ51Pm.js → Takeaway-CDQjt5mB.js} +1 -1
  25. package/dist/{Takeaway.vue_vue_type_script_setup_true_lang-CxrKOffq.js → Takeaway.vue_vue_type_script_setup_true_lang-DLs6tg28.js} +4 -4
  26. package/dist/{TaxSetting-Cyx64cle.js → TaxSetting-LXV73pLm.js} +4 -4
  27. package/dist/{Unit-CSw2nzb3.js → Unit-YqlS_aYJ.js} +2 -2
  28. package/dist/{Variant-BexkJbX8.js → Variant-Cfec4-WR.js} +2 -2
  29. package/dist/{_id_-DL_--BAT.js → _id_-B3cTaq5i.js} +6 -6
  30. package/dist/{app-DBSpCrEz.js → app-r8ZKmdn1.js} +28 -28
  31. package/dist/app.js +2 -2
  32. package/dist/assets/{linked-status-BbVXICkq.js → linked-status-CWjLtoRl.js} +3 -3
  33. package/dist/assets/{validate-menu-xvp-KAet.js → validate-menu-3nJfxanr.js} +3 -3
  34. package/dist/{catalog-DIgmR7H0.js → catalog-CIHro4Q-.js} +432 -432
  35. package/dist/{catalog-BAExZa6M.js → catalog-Gpaw0veN.js} +1 -1
  36. package/dist/{category--Ezee0GQ.js → category-C1Nv2k2C.js} +1 -1
  37. package/dist/{currency-Cab-BTrJ.js → currency-CWaEAteR.js} +1 -1
  38. package/dist/{index-crmsscjz.js → index-DiPpC8uS.js} +3 -3
  39. package/dist/{index-Doj4vOci.js → index-q8vb7C-b.js} +2 -2
  40. package/dist/{item-C3RFNcK2.js → item-DF8-obPB.js} +11 -11
  41. package/dist/{lodash-Cag9qz8o.js → lodash-DT3SfcPy.js} +1 -1
  42. package/dist/{menu-Baw4oOOx.js → menu-BtnsqPSW.js} +1 -1
  43. package/dist/{object-D4QR8YOW.js → object-GEcPWoWM.js} +1 -1
  44. package/dist/{scheduler-Dmy-SRLI.js → scheduler-Cdw2OBBp.js} +125 -125
  45. package/dist/{takeaway-BVcxbDAX.js → takeaway-5q1fUkoY.js} +4 -4
  46. package/dist/{toExcel-CkwPnj8n.js → toExcel-D59bd39T.js} +2 -2
  47. package/dist/{unit-D7o6p3IX.js → unit-DYZD3TgN.js} +2 -2
  48. package/package.json +3 -3
  49. package/dist/Product.vue_vue_type_script_setup_true_lang-BZL3JDpp.js +0 -826
  50. package/dist/SchedulerSelector.vue_vue_type_script_setup_true_lang-6gxIvwfz.js +0 -49
  51. package/dist/ServingSequence-DsBZhvaK.js +0 -4
@@ -1,826 +0,0 @@
1
- import { ref as A, computed as g, defineComponent as ce, resolveComponent as Y, openBlock as v, createBlock as G, withCtx as M, createVNode as i, createElementVNode as b, toDisplayString as J, unref as l, createElementBlock as z, Fragment as xe, renderList as Ne, createTextVNode as He, mergeModels as Ze, useModel as Je, renderSlot as he, watch as pe, h as U, withModifiers as Ve, createCommentVNode as ue, resolveDynamicComponent as Qe, normalizeStyle as Xe, normalizeClass as re, nextTick as et, watchEffect as tt } from "vue";
2
- import { u as ye, a as De, c as ve, y as fe, F as lt, z as at, k as ie, g as ot, A as Fe, i as je } from "./app-DBSpCrEz.js";
3
- import { _ as $e } from "./SchedulerSelector.vue_vue_type_script_setup_true_lang-6gxIvwfz.js";
4
- import { useI18n as Ce, useCoreStore as nt } from "@feedmepos/mf-common";
5
- import { useSnackbar as Be, useDialog as Ue, components as ne, FmButtonVariant as W, FmButtonColorThemeVariant as L, useBreakpoints as Ae } from "@feedmepos/ui-library";
6
- import "vue-router";
7
- import { u as ge } from "./menu-Baw4oOOx.js";
8
- import { u as Ee } from "./category--Ezee0GQ.js";
9
- import "./vuedraggable-WU01qJgi.js";
10
- import { _ as rt, c as Ie, a as st, u as ut } from "./catalog-DIgmR7H0.js";
11
- import { _ as it } from "./takeaway-BVcxbDAX.js";
12
- import { f as ct } from "./currency-Cab-BTrJ.js";
13
- import { l as be } from "./lodash-Cag9qz8o.js";
14
- import { u as Ke, m as dt } from "./item-C3RFNcK2.js";
15
- import { w as mt } from "./InfoBasic.vue_vue_type_script_setup_true_lang-DxQBDu16.js";
16
- import { F as pt } from "./object-D4QR8YOW.js";
17
- import { _ as Te } from "./TextChip.vue_vue_type_script_setup_true_lang-CNp85hoQ.js";
18
- import { L as Me } from "./LinkProductSideSheet-DfPSfCPO.js";
19
- function vt(O, c) {
20
- const d = A(!0), n = g(() => {
21
- var f, y;
22
- return !d.value && (!c.value || ((f = c.value) == null ? void 0 : f.length) === ((y = O.value) == null ? void 0 : y.length));
23
- }), V = g(() => {
24
- var f, y, N, _;
25
- return !!((f = c.value) != null && f.length && ((y = c.value) == null ? void 0 : y.length) > 0 && ((N = c.value) == null ? void 0 : N.length) < ((_ = O.value) == null ? void 0 : _.length));
26
- });
27
- return { allCleared: d, allSelected: n, indeterminate: V, toggleAll: () => {
28
- c.value = void 0, d.value = !d.value;
29
- }, toggleOption: (f) => {
30
- var N, _, E;
31
- let y;
32
- c.value === void 0 && d.value ? y = [f] : c.value === void 0 && !d.value ? y = (N = O.value.map((I) => I.value)) == null ? void 0 : N.filter((I) => I !== f) : (_ = c.value) != null && _.includes(f) ? y = (E = c.value) == null ? void 0 : E.filter((I) => I !== f) : y = [...c.value || [], f], y.length === 0 ? (c.value = void 0, d.value = !0) : y.length === O.value.length ? (c.value = void 0, d.value = !1) : c.value = y;
33
- } };
34
- }
35
- const Oe = /* @__PURE__ */ ce({
36
- __name: "CategorySelector",
37
- setup(O) {
38
- const c = ye(), { categories: d, selectedCategories: n } = ge(), V = g(() => c.state.currentCategoryIds), r = g(
39
- () => d.value.map((w) => ({ label: w.name, value: w.id }))
40
- ), { t: H } = Ce(), f = g(() => {
41
- var w, F, D;
42
- return d.value.length === ((w = n.value) == null ? void 0 : w.length) ? H("menu.category.selector.all") : ((F = n.value) == null ? void 0 : F.length) === 1 ? n.value[0].name : `${(D = n.value) == null ? void 0 : D.length}`;
43
- }), y = g({
44
- get: () => V.value,
45
- set: (w) => {
46
- c.selectCategory(w);
47
- }
48
- }), { allCleared: N, allSelected: _, toggleAll: E, toggleOption: I, indeterminate: Z } = vt(r, y);
49
- return (w, F) => {
50
- const D = Y("FmIcon"), m = Y("FmChip"), q = Y("FmMenuItem"), K = Y("FmMenu");
51
- return v(), G(K, { "close-on-click": !1 }, {
52
- "menu-button": M(() => [
53
- i(m, {
54
- label: f.value,
55
- class: "fm-typo-en-body-md-600 text-fm-color-neutral-gray-400"
56
- }, {
57
- default: M(() => [
58
- b("p", null, J(l(H)("menu.category.selector.title", { label: f.value })), 1),
59
- i(D, { name: "expand_more" })
60
- ]),
61
- _: 1
62
- }, 8, ["label"])
63
- ]),
64
- default: M(() => [
65
- i(q, {
66
- label: "All",
67
- "has-checkbox": "",
68
- "model-value": l(_),
69
- indeterminate: l(Z),
70
- onClick: l(E)
71
- }, null, 8, ["model-value", "indeterminate", "onClick"]),
72
- (v(!0), z(xe, null, Ne(r.value, (j) => {
73
- var te;
74
- return v(), G(q, {
75
- key: j.value || "",
76
- label: j.label,
77
- "has-checkbox": "",
78
- "model-value": l(_) || ((te = y.value) == null ? void 0 : te.includes(j.value)),
79
- onClick: (le) => l(I)(j.value)
80
- }, null, 8, ["label", "model-value", "onClick"]);
81
- }), 128))
82
- ]),
83
- _: 1
84
- });
85
- };
86
- }
87
- }), Pe = (O) => i("div", {
88
- class: "flex flex-1 justify-end"
89
- }, [i("span", null, [O, He(" ")])]), ft = /* @__PURE__ */ ce({
90
- __name: "CategorySelectorSingle",
91
- props: /* @__PURE__ */ Ze({
92
- disabled: { type: Boolean, default: !1 }
93
- }, {
94
- modelValue: {},
95
- modelModifiers: {}
96
- }),
97
- emits: ["update:modelValue"],
98
- setup(O) {
99
- const c = ye(), d = Je(O, "modelValue"), n = g(() => c.categories.map((V) => ({
100
- label: V.name,
101
- value: V._id || null
102
- })));
103
- return (V, r) => {
104
- const H = Y("FmSelect");
105
- return v(), G(H, {
106
- items: n.value,
107
- modelValue: d.value,
108
- "onUpdate:modelValue": r[0] || (r[0] = (f) => d.value = f),
109
- disabled: V.disabled
110
- }, null, 8, ["items", "modelValue", "disabled"]);
111
- };
112
- }
113
- }), ze = /* @__PURE__ */ ce({
114
- __name: "ImportButton",
115
- setup(O) {
116
- const c = A(!1);
117
- function d() {
118
- c.value = !c.value;
119
- }
120
- return (n, V) => (v(), z(xe, null, [
121
- i(rt, {
122
- modelValue: c.value,
123
- "onUpdate:modelValue": V[0] || (V[0] = (r) => c.value = r)
124
- }, null, 8, ["modelValue"]),
125
- he(n.$slots, "default", { trigger: d })
126
- ], 64));
127
- }
128
- }), bt = {
129
- class: "flex justify-between items-center space-x-8"
130
- }, gt = {
131
- class: "flex space-x-8"
132
- }, yt = {
133
- class: "w-[320px]"
134
- }, _t = {
135
- key: 0,
136
- class: /* @__PURE__ */ re(["flex-1 flex flex-col", "divide-y divide-fm-color-neutral-gray-100", "overflow-hidden"])
137
- }, ht = {
138
- key: 0,
139
- class: "flex items-center p-4"
140
- }, xt = {
141
- class: /* @__PURE__ */ re(["mr-8", "fm-typo-en-body-md-400"])
142
- }, Ct = {
143
- key: 1,
144
- class: "px-16 py-4 space-x-8 flex justify-end"
145
- }, kt = {
146
- key: 1
147
- }, St = {
148
- class: "flex space-x-8"
149
- }, wt = {
150
- key: 1,
151
- class: "pt-8 flex flex-col flex-1 overflow-hidden"
152
- }, Vt = {
153
- class: "space-y-8 pb-8"
154
- }, Ft = {
155
- class: "w-full px-8"
156
- }, $t = {
157
- class: "flex space-x-8 px-8"
158
- }, It = {
159
- key: 0,
160
- class: /* @__PURE__ */ re(["flex flex-col flex-1", "overflow-scroll", "divide-y divide-fm-color-neutral-gray-100", "pb-64"])
161
- }, Tt = ["onClick"], Mt = {
162
- class: "min-w-0 flex flex-1 items-center justify-start space-x-16"
163
- }, Ot = {
164
- class: "flex-1 min-w-0"
165
- }, Pt = {
166
- class: "flex justify-between items-center gap-8 pb-4"
167
- }, zt = {
168
- class: "flex-1 min-w-0 fm-typo-en-body-lg-600 line-clamp-2"
169
- }, Nt = {
170
- class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
171
- }, Dt = {
172
- class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
173
- }, jt = {
174
- class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary"
175
- }, Bt = {
176
- key: 1
177
- }, Ut = {
178
- class: "flex space-x-8"
179
- }, At = /* @__PURE__ */ ce({
180
- __name: "ProductTable",
181
- props: {
182
- modelValue: {},
183
- originalValue: {},
184
- isCalculating: {
185
- type: Boolean
186
- }
187
- },
188
- emits: ["update:model-value", "reset:model-value", "update:editing", "update:search-key"],
189
- setup(O, {
190
- emit: c
191
- }) {
192
- const d = O, {
193
- t: n
194
- } = Ce(), V = nt(), r = ye(), H = Be(), f = Ue(), y = De(H), N = je(y);
195
- Ee({
196
- dialog: f,
197
- menuLoader: N
198
- });
199
- const _ = Ke();
200
- g(() => !r.state.currentSchedulerId);
201
- const E = V.currentCountry, I = g(() => E.value ? ve.Country.getCountry(E.value) : null), Z = g(() => r.rules.item);
202
- g(() => w.value.length === 1 && w.value[0].id === null);
203
- const {
204
- selectedCategories: w
205
- } = ge(), F = g(() => be.flatten(w.value.map((e) => e.items))), D = c, m = A(!1);
206
- pe(() => m.value, (e) => {
207
- D("update:editing", e);
208
- });
209
- const q = (e) => {
210
- ot.isBoolean(e) ? m.value = e : m.value = !m.value;
211
- }, K = A(""), j = g(() => F.value.filter((e) => {
212
- var o;
213
- return !K.value || !K.value.trim() ? !0 : `${e.code} ${e.name} ${ke(e)} ${le(e.category || null)} ${(o = fe()[e.orderFrom]) == null ? void 0 : o.label}`.toLowerCase().includes(K.value.toLowerCase());
214
- })), {
215
- categories: te
216
- } = ge(), le = (e) => {
217
- const t = te.value.find((o) => o.id === e || e === null && o.id === "");
218
- return t == null ? void 0 : t.name;
219
- }, se = (e, t, o) => {
220
- let a = be.clone(d.modelValue);
221
- const u = a[e];
222
- u && (a[e] = {
223
- ...u,
224
- [t]: o
225
- }, D("update:model-value", a));
226
- }, T = be.debounce(se, 300), R = (e) => (t) => !!t || n("menu.product.table.validation.name_required", {
227
- field: e
228
- }), k = (e) => e >= 0 || n("menu.product.table.validation.price_min"), S = [R("Name")], h = () => [(e) => k(typeof e == "number" ? e : Number(e) ?? 0)], P = fe(), B = A([{
229
- accessorKey: "thumbnail",
230
- header: "",
231
- size: 64,
232
- meta: {
233
- cellClass: "px-0",
234
- headerContentClass: "px-0"
235
- },
236
- cell: (e) => {
237
- var t, o;
238
- return U(Ie, {
239
- src: e.getValue(),
240
- alt: (o = (t = e == null ? void 0 : e.row) == null ? void 0 : t.original) == null ? void 0 : o.name,
241
- className: "my-8 mx-12",
242
- size: 72
243
- });
244
- },
245
- enableSorting: !1
246
- }, {
247
- accessorKey: "code",
248
- header: () => n("menu.product.table.columns.code"),
249
- enableSorting: !1,
250
- size: 100,
251
- cell: (e) => {
252
- const t = e.row.original, o = e.getValue() || "--";
253
- if (!m.value) return o;
254
- const a = _e(t._id);
255
- return U(ne.FmTextField, {
256
- disabled: !Z.value.code,
257
- modelValue: a == null ? void 0 : a.code,
258
- placeholder: d.modelValue[t._id].fallbackCode,
259
- "onUpdate:modelValue": (u) => {
260
- T(t._id, "code", u);
261
- }
262
- });
263
- }
264
- }, {
265
- accessorKey: "name",
266
- header: () => n("menu.product.table.columns.name"),
267
- enableSorting: !1,
268
- size: 240,
269
- cell: (e) => {
270
- const t = e.row.original, o = e.getValue();
271
- return m.value ? U(ne.FmTextField, {
272
- disabled: !Z.value.name,
273
- modelValue: t.name,
274
- "onUpdate:modelValue": (a) => {
275
- T(t._id, "name", a);
276
- },
277
- rules: S,
278
- placeholder: t.fallbackName
279
- }) : o;
280
- }
281
- }, {
282
- accessorKey: "price",
283
- header: () => {
284
- var e;
285
- return Pe(n("menu.product.table.columns.price", {
286
- currency: (e = I.value) == null ? void 0 : e.currency.symbol
287
- }));
288
- },
289
- enableSorting: !1,
290
- size: 140,
291
- meta: {
292
- textAlign: "right"
293
- },
294
- cell: (e) => {
295
- var u;
296
- const t = e.getValue();
297
- if (!m.value) return ve.Dinero.fromFdoDinero(t).toFormat();
298
- const o = d.modelValue[e.row.original._id], a = o.fallbackPrice;
299
- return U(it, {
300
- min: 0,
301
- disabled: !o.editPrice,
302
- // @ts-ignore
303
- placeholder: a ? ct(a, !1) : void 0,
304
- modelValue: (u = _e(o._id)) == null ? void 0 : u.price,
305
- // @ts-ignore
306
- "onUpdate:modelValue": (C) => {
307
- se(o._id, "price", C);
308
- },
309
- rules: h()
310
- });
311
- }
312
- }, {
313
- accessorKey: "taxes",
314
- header: () => Pe("SST"),
315
- size: 62,
316
- enableSorting: !1,
317
- meta: {
318
- textAlign: "right"
319
- },
320
- cell: (e) => {
321
- const t = e.getValue(), o = e.row.original, a = r.taxSetting.countryTaxOptions, u = r.getSelectedTax(t, o.fallbackTaxes, r.taxSetting.countryTaxOptions), C = a.find((ee) => ee.value === u);
322
- if (!m.value)
323
- return `${C != null && C.meta.rate ? lt(C.meta.rate) : 0}%`;
324
- const s = r.getSelectedTax(t, o.fallbackTaxes, r.taxSetting.countryTaxOptions);
325
- return U(ne.FmSelect, {
326
- disabled: !Z.value.tax,
327
- items: r.taxSetting.countryTaxOptions,
328
- modelValue: s,
329
- "onUpdate:modelValue": async (ee) => {
330
- const me = r.decodeTax(ee);
331
- T(o._id, "taxes", [me]);
332
- }
333
- });
334
- }
335
- }, {
336
- accessorKey: "category",
337
- header: () => n("menu.product.table.columns.category"),
338
- enableSorting: !1,
339
- size: 140,
340
- cell: (e) => {
341
- const t = e.row.original;
342
- return m.value ? U(ft, {
343
- "model-value": d.modelValue[t._id].category,
344
- disabled: !!(r.state.currentCatalogId || r.state.currentSchedulerId),
345
- "onUpdate:modelValue": async (o) => {
346
- T(t._id, "category", o);
347
- }
348
- }) : le(t.category || null);
349
- }
350
- }, {
351
- accessorKey: "orderFrom",
352
- header: () => n("menu.product.table.columns.order_from"),
353
- enableSorting: !0,
354
- sortingFn: (e, t) => {
355
- const [o, a] = [e, t].map((u) => P[u.original.orderFrom].sortingIndex);
356
- return o - a;
357
- },
358
- size: 110,
359
- cell: (e) => {
360
- var u, C;
361
- const t = e.getValue(), o = e.row.original, a = fe();
362
- return m.value ? U(ne.FmSelect, {
363
- disabled: !Z.value.orderFrom,
364
- items: Object.values(fe()),
365
- modelValue: t,
366
- "onUpdate:modelValue": async (s) => {
367
- se(o._id, "orderFrom", s);
368
- }
369
- }) : U(Te, {
370
- label: (u = a[t]) == null ? void 0 : u.label,
371
- variant: (C = a[t]) == null ? void 0 : C.variant
372
- });
373
- }
374
- }, {
375
- id: "actions",
376
- size: 52,
377
- meta: {
378
- cellClass: "pl-16",
379
- headerClass: "py-4",
380
- textAlign: "right"
381
- },
382
- header: () => U("div", {
383
- class: "w-full px-4 flex justify-end"
384
- }, [mt(U(ne.FmButton, {
385
- variant: W.Tertiary,
386
- textColor: L.NeutralGray400,
387
- prependIcon: "edit",
388
- class: "flex justify-end",
389
- onClick: q,
390
- type: "button"
391
- }), "Bulk edit")]),
392
- cell: (e) => {
393
- const t = e.row.original;
394
- return U("div", {
395
- class: "px-4 flex justify-end"
396
- }, [U(ne.FmButton, {
397
- icon: "delete",
398
- variant: "tertiary",
399
- textColor: L.NeutralGray400,
400
- onClick: Ve(async () => {
401
- await _.deleteItem([{
402
- _id: t._id,
403
- name: t.name,
404
- thumbnail: t.thumbnail
405
- }]);
406
- }, ["stop", "prevent"])
407
- })]);
408
- }
409
- }]);
410
- r.taxSetting.systemCode || B.value.splice(4, 1);
411
- const x = A({}), p = A([]);
412
- pe(() => x.value, (e) => {
413
- let t = [];
414
- Object.keys(e).forEach((o) => {
415
- e[o] ? t.push(F.value[parseInt(o)]) : p.value = t.filter((u) => u !== F.value[parseInt(o)]);
416
- }), p.value = t;
417
- }), pe(() => F.value, () => {
418
- x.value = {}, p.value = [];
419
- }), pe(() => m.value, () => {
420
- x.value = {}, p.value = [];
421
- });
422
- const Q = () => {
423
- x.value = {};
424
- };
425
- async function $() {
426
- await et();
427
- const e = () => !!r.currentCatalog || !!r.state.currentSchedulerId, t = (a) => a === "" || a === null ? e() ? "" : null : a, o = Object.values(d.modelValue).filter((a) => {
428
- const u = Object.values(d.originalValue).find((C) => C._id === a._id);
429
- return Fe(u, a);
430
- }).map((a) => ({
431
- _id: a._id,
432
- name: a.name,
433
- code: a.code,
434
- price: a.price,
435
- orderFrom: a.orderFrom ?? null,
436
- taxes: a.taxes,
437
- category: t(a.category || null)
438
- }));
439
- await _.updateMany(o), q(!1);
440
- }
441
- const ae = async () => {
442
- await _.deleteItem(p.value.map((e) => ({
443
- _id: e._id,
444
- name: e.name,
445
- thumbnail: e.thumbnail
446
- })));
447
- }, X = () => {
448
- D("reset:model-value");
449
- }, oe = () => {
450
- Object.entries(d.modelValue).some(([t, o]) => Fe(o, d.originalValue[t])) ? f.open({
451
- title: "You have unsaved changes!",
452
- message: "Are you sure you want to discard? You will lose all the changes if discard edit.",
453
- primaryActions: {
454
- text: "Discard",
455
- close: !0,
456
- variant: W.Destructive
457
- },
458
- secondaryActions: {
459
- text: "Cancel",
460
- close: !0
461
- }
462
- }).onPrimary(() => {
463
- X(), q(!1);
464
- }) : (q(!1), X());
465
- }, de = g(() => ({
466
- thumbnail: !m.value,
467
- actions: !m.value
468
- })), Re = (e) => {
469
- _.update(e._id);
470
- };
471
- async function Le(e) {
472
- await _.update(e.original._id);
473
- }
474
- function ke(e) {
475
- var C;
476
- const t = e.price ?? // TODO: fix type error
477
- // @ts-ignore
478
- e.fallbackPrice ?? ve.Dinero.fromNumber({
479
- number: 0
480
- }).toObject(), o = e.taxes;
481
- r.taxSetting.countryTaxOptions;
482
- const a = ve.Dinero.fromFdoDinero(t).toFormat(), u = (C = I.value) == null ? void 0 : C.currency.symbol;
483
- return r.getSelectedTax(
484
- o,
485
- // TODO: fix type error
486
- // @ts-ignore
487
- e.fallbackTaxes,
488
- r.taxSetting.countryTaxOptions
489
- ), `${u == null ? void 0 : u.toUpperCase()}${a}`;
490
- }
491
- function _e(e) {
492
- var a;
493
- const t = r.currentCatalog, o = r.state.currentSchedulerId;
494
- if (t && o) {
495
- const u = t.override.scheduler[o] ?? {
496
- _id: o
497
- };
498
- return ((a = u == null ? void 0 : u.items) == null ? void 0 : a.filter((s) => s._id === e))[0];
499
- } else return t ? t.override.items[e][0] : o ? r.schedulers.find((s) => s._id === o).items.filter((s) => s._id === e)[0] : F.value.find((u) => u._id === e);
500
- }
501
- const Ge = Ae(), qe = g(() => Ge.breakpoints.value.xs), Se = A(null), We = at(Se), Ye = g(() => {
502
- var t;
503
- return {
504
- height: `calc(100vh - ${((t = We.value) == null ? void 0 : t.top) + 24}px)`
505
- };
506
- });
507
- return (e, t) => {
508
- const o = Y("fm-search"), a = Y("fm-button"), u = Y("fm-table"), C = Y("fm-form");
509
- return qe.value ? (v(), z("div", wt, [b("div", Vt, [b("div", Ft, [i(o, {
510
- "model-value": K.value,
511
- "onUpdate:modelValue": t[4] || (t[4] = (s) => K.value = s),
512
- autofocus: "",
513
- placeholder: l(n)("menu.product.table.search.placeholder")
514
- }, null, 8, ["model-value", "placeholder"])]), t[6] || (t[6] = b("div", {
515
- class: "w-full h-[1px] bg-fm-color-neutral-gray-100"
516
- }, null, -1)), b("div", $t, [he(e.$slots, "filter")])]), F.value.length ? (v(), z("div", It, [(v(!0), z(xe, null, Ne(j.value, (s) => {
517
- var ee, me, we;
518
- return v(), z("div", {
519
- key: s._id,
520
- class: "max-w-full py-12 px-16 space-x-16 flex items-center",
521
- onClick: () => Re(s)
522
- }, [b("div", Mt, [i(Ie, {
523
- alt: s.name,
524
- size: 72,
525
- src: s.thumbnail
526
- }, null, 8, ["alt", "src"]), b("div", Ot, [b("div", Pt, [b("p", zt, J(s.name), 1), i(Te, {
527
- label: (ee = l(P)[s.orderFrom || ""]) == null ? void 0 : ee.label,
528
- variant: (me = l(P)[s.orderFrom || ""]) == null ? void 0 : me.variant
529
- }, null, 8, ["label", "variant"])]), b("p", Nt, J(ke(s)), 1), b("p", Dt, J(l(n)("menu.product.table.columns.code")) + ": " + J(((we = _e(s._id)) == null ? void 0 : we.code) || "--"), 1), b("p", jt, J(l(n)("menu.product.table.columns.category")) + ": " + J(le(s.category || null)), 1)])]), i(a, {
530
- "text-color": l(L).NeutralGray400,
531
- variant: l(W).Tertiary,
532
- "prepend-icon": "delete",
533
- onClick: Ve(() => l(_).deleteItem([{
534
- _id: s._id,
535
- name: s.name,
536
- thumbnail: s.thumbnail
537
- }]), ["stop"])
538
- }, null, 8, ["text-color", "variant", "onClick"])], 8, Tt);
539
- }), 128))])) : (v(), z("div", Bt, [i(ie, {
540
- subtitle: l(n)("menu.product.table.empty.subtitle"),
541
- title: l(n)("menu.product.table.empty.title")
542
- }, {
543
- action: M(() => [b("div", Ut, [i(a, {
544
- variant: l(W).Primary,
545
- label: l(n)("menu.product.table.empty.actions.add"),
546
- "prepend-icon": "add",
547
- onClick: t[5] || (t[5] = (s) => l(_).create(null))
548
- }, null, 8, ["variant", "label"]), i(ze, null, {
549
- default: M(({
550
- trigger: s
551
- }) => [i(a, {
552
- "bg-color": l(L).NeutralGray100,
553
- "text-color": l(L).NeutralGray400,
554
- variant: l(W).Primary,
555
- label: l(n)("menu.product.table.empty.actions.import"),
556
- "prepend-icon": "download",
557
- onClick: s
558
- }, null, 8, ["bg-color", "text-color", "variant", "label", "onClick"])]),
559
- _: 1
560
- })])]),
561
- _: 1
562
- }, 8, ["subtitle", "title"])]))])) : (v(), G(C, {
563
- key: 0,
564
- "blame-form-child-on-validation-failed": "",
565
- class: "flex flex-col flex-1 space-y-8 overflow-hidden",
566
- onValidationSuccess: $
567
- }, {
568
- default: M(() => [b("div", bt, [b("div", gt, [he(e.$slots, "filter")]), b("div", yt, [i(o, {
569
- "model-value": K.value,
570
- "onUpdate:modelValue": t[0] || (t[0] = (s) => K.value = s),
571
- autofocus: "",
572
- placeholder: l(n)("menu.product.table.search.placeholder")
573
- }, null, 8, ["model-value", "placeholder"])])]), F.value.length ? (v(), z("div", _t, [p.value.length && !m.value ? (v(), z("div", ht, [b("p", xt, J(l(n)("menu.product.table.selection.count", {
574
- count: p.value.length
575
- })), 1), i(a, {
576
- label: l(n)("menu.product.table.selection.actions.deselect_all"),
577
- type: "button",
578
- variant: "plain",
579
- onClick: Q
580
- }, null, 8, ["label"]), i(a, {
581
- "border-color": l(L).SystemError300,
582
- "text-color": l(L).SystemError300,
583
- class: "ml-auto",
584
- label: l(n)("menu.product.table.selection.actions.remove"),
585
- "prepend-icon": "delete",
586
- variant: "secondary",
587
- onClick: ae
588
- }, null, 8, ["border-color", "text-color", "label"])])) : ue("", !0), m.value ? (v(), z("div", Ct, [i(a, {
589
- variant: l(W).Tertiary,
590
- label: l(n)("menu.product.table.bulk_edit.actions.reset_all"),
591
- onClick: X
592
- }, null, 8, ["variant", "label"]), i(a, {
593
- variant: l(W).Tertiary,
594
- label: l(n)("menu.common.actions.cancel"),
595
- onClick: oe
596
- }, null, 8, ["variant", "label"]), i(a, {
597
- borderColor: l(L).ColorPrimary,
598
- textColor: l(L).ColorPrimary,
599
- variant: l(W).Secondary,
600
- label: l(n)("menu.product.table.bulk_edit.actions.save"),
601
- type: "submit"
602
- }, null, 8, ["borderColor", "textColor", "variant", "label"])])) : ue("", !0), b("div", {
603
- ref_key: "tableWrapper",
604
- ref: Se
605
- }, [(v(), G(Qe(m.value ? pt : "div"), {
606
- title: l(n)("menu.product.table.bulk_edit.title"),
607
- show: m.value,
608
- "primary-action": {
609
- label: l(n)("menu.product.table.bulk_edit.actions.save")
610
- },
611
- "secondary-actions": [{
612
- label: l(n)("menu.product.table.bulk_edit.actions.reset_all"),
613
- click: X
614
- }, {
615
- label: l(n)("menu.common.actions.cancel"),
616
- click: oe
617
- }],
618
- class: "overflow-hidden",
619
- style: Xe(Ye.value),
620
- onOnPrimary: $,
621
- onOnCancel: oe
622
- }, {
623
- default: M(() => [i(u, {
624
- class: re({
625
- "mt-24": m.value
626
- }),
627
- modelValue: x.value,
628
- "onUpdate:modelValue": t[1] || (t[1] = (s) => x.value = s),
629
- "column-defs": B.value,
630
- "column-visibility": de.value,
631
- loading: e.isCalculating,
632
- "page-size": F.value.length,
633
- "row-data": j.value,
634
- selection: m.value ? void 0 : "multiple",
635
- "shrink-at": !1,
636
- "hide-footer": "",
637
- "pin-header-row": "",
638
- onRowClick: t[2] || (t[2] = (s) => m.value ? void 0 : Le(s))
639
- }, null, 8, ["class", "modelValue", "column-defs", "column-visibility", "loading", "page-size", "row-data", "selection"])]),
640
- _: 1
641
- }, 40, ["title", "show", "primary-action", "secondary-actions", "style"]))], 512)])) : (v(), z("div", kt, [i(ie, {
642
- subtitle: l(n)("menu.product.table.empty.subtitle"),
643
- title: l(n)("menu.product.table.empty.title")
644
- }, {
645
- action: M(() => [b("div", St, [i(a, {
646
- variant: l(W).Primary,
647
- label: l(n)("menu.product.table.empty.actions.add"),
648
- "prepend-icon": "add",
649
- onClick: t[3] || (t[3] = (s) => l(_).create(null))
650
- }, null, 8, ["variant", "label"]), i(ze, null, {
651
- default: M(({
652
- trigger: s
653
- }) => [i(a, {
654
- "bg-color": l(L).NeutralGray100,
655
- "text-color": l(L).NeutralGray400,
656
- variant: l(W).Primary,
657
- label: l(n)("menu.product.table.empty.actions.import"),
658
- "prepend-icon": "download",
659
- onClick: s
660
- }, null, 8, ["bg-color", "text-color", "variant", "label", "onClick"])]),
661
- _: 1
662
- })])]),
663
- _: 1
664
- }, 8, ["subtitle", "title"])]))]),
665
- _: 3
666
- }));
667
- };
668
- }
669
- }), Et = {
670
- key: 0,
671
- class: /* @__PURE__ */ re(["flex flex-col", "flex-1", "overflow-hidden"])
672
- }, Kt = {
673
- class: /* @__PURE__ */ re(["pt-16 xs:pt-0", "flex xs:flex-col", "flex-1", "w-full", "overflow-hidden"])
674
- }, Rt = { class: "flex flex-col flex-1 overflow-hidden" }, Lt = {
675
- key: 1,
676
- class: "pt-16 xs:pt-8 space-y-24"
677
- }, Gt = { class: "flex items-center gap-8 px-16" }, cl = /* @__PURE__ */ ce({
678
- __name: "Product",
679
- setup(O) {
680
- const c = Ue(), d = Be(), n = De(d), V = je(n);
681
- Ee({
682
- dialog: c,
683
- menuLoader: V
684
- });
685
- const r = ye(), H = g(() => r.rules.item), f = st(), y = Ke(), N = ut(), _ = g(() => !r.state.currentCatalogId), E = g(() => r.rules.item), I = g(() => !r.state.currentSchedulerId), Z = A(!1), w = A(!1), F = g(() => {
686
- var k, S, h, P;
687
- if (_.value && I.value) return;
688
- if (I.value) {
689
- const B = (k = r.currentCatalog) == null ? void 0 : k.override.items;
690
- return B ? Object.entries(B).reduce((x, [p, Q]) => {
691
- const $ = Q.find((ae) => !ae.combinationKey);
692
- return $ && (x[p] = $), x;
693
- }, {}) : {};
694
- }
695
- return ((_.value ? (S = r.currentScheduler) == null ? void 0 : S.items : (P = (h = r.currentCatalog) == null ? void 0 : h.override.scheduler[r.state.currentSchedulerId]) == null ? void 0 : P.items) ?? []).reduce((B, x) => (x.combinationKey || (B[x._id] = x), B), {});
696
- }), D = A({}), m = A({}), q = async () => {
697
- var P, B;
698
- w.value = !0;
699
- const R = !!F.value, k = be.flatten(j.value.map((x) => x.items)), S = R && Z.value ? await dt(
700
- r.mergedMenu,
701
- k,
702
- r.state.menu,
703
- (P = r.currentCatalog) == null ? void 0 : P._id,
704
- (B = r.currentScheduler) == null ? void 0 : B._id,
705
- !1
706
- ) : void 0, h = k.reduce((x, p, Q) => {
707
- var ae, X, oe, de;
708
- const $ = (ae = F.value) == null ? void 0 : ae[p._id];
709
- return x[p._id] = {
710
- _id: p._id,
711
- name: p.name,
712
- code: R ? $ == null ? void 0 : $.code : p == null ? void 0 : p.code,
713
- category: p.category,
714
- price: R && E.value.editPrice ? $ == null ? void 0 : $.price : p.price,
715
- orderFrom: R ? $ == null ? void 0 : $.orderFrom : p.orderFrom,
716
- taxes: R ? null : p.taxes,
717
- thumbnail: p.thumbnail,
718
- fallbackPrice: (X = S == null ? void 0 : S[Q]) == null ? void 0 : X.price,
719
- fallbackName: R ? p.name : void 0,
720
- fallbackCode: (oe = S == null ? void 0 : S[Q]) == null ? void 0 : oe.code,
721
- fallbackOrder: (de = S == null ? void 0 : S[Q]) == null ? void 0 : de.orderFrom,
722
- fallbackTaxes: R ? p.taxes : null
723
- }, x;
724
- }, {});
725
- D.value = h, m.value = { ...h }, w.value = !1;
726
- }, { categories: K, selectedCategories: j } = ge();
727
- tt(async () => {
728
- j.value && await q();
729
- });
730
- function te() {
731
- y.create(null);
732
- }
733
- const le = () => {
734
- j.value && q();
735
- }, se = Ae();
736
- g(() => se.breakpoints.value.xs);
737
- const { t: T } = Ce();
738
- return (R, k) => {
739
- const S = Y("fm-button");
740
- return l(K).length ? (v(), z("div", Et, [
741
- b("div", Kt, [
742
- b("div", Rt, [
743
- l(j) ? (v(), G(At, {
744
- key: 0,
745
- "is-calculating": w.value,
746
- "model-value": D.value,
747
- "original-value": m.value,
748
- "onUpdate:modelValue": k[0] || (k[0] = (h) => D.value = h),
749
- "onReset:modelValue": le,
750
- "onUpdate:editing": k[1] || (k[1] = (h) => Z.value = h)
751
- }, {
752
- filter: M(() => [
753
- i(Oe),
754
- E.value.multiScheduler ? (v(), G($e, { key: 0 })) : ue("", !0)
755
- ]),
756
- _: 1
757
- }, 8, ["is-calculating", "model-value", "original-value"])) : ue("", !0)
758
- ])
759
- ])
760
- ])) : (v(), z("div", Lt, [
761
- b("div", Gt, [
762
- i(Oe),
763
- E.value.multiScheduler ? (v(), G($e, { key: 0 })) : ue("", !0)
764
- ]),
765
- H.value.create ? (v(), G(ie, {
766
- key: 0,
767
- action: {
768
- text: l(T)("menu.product.empty.with_create.action"),
769
- callback: te
770
- },
771
- subtitle: l(T)("menu.product.empty.with_create.subtitle"),
772
- title: l(T)("menu.product.empty.with_create.title")
773
- }, null, 8, ["action", "subtitle", "title"])) : I.value ? (v(), G(ie, {
774
- key: 1,
775
- subtitle: l(T)("menu.product.empty.no_scheduler.subtitle"),
776
- title: l(T)("menu.product.empty.no_scheduler.title")
777
- }, {
778
- action: M(() => [
779
- i(Me, {
780
- "categorized-items": l(N).linkableItems.value,
781
- "initial-value": l(N).currentItems.value,
782
- "show-variant": !1,
783
- onSubmit: k[2] || (k[2] = (h) => l(N).applyProduct(h.map((P) => P._id)))
784
- }, {
785
- default: M(({ trigger: h }) => [
786
- i(S, {
787
- label: l(T)("menu.common.actions.link_product"),
788
- "prepend-icon": "link",
789
- onClick: h
790
- }, null, 8, ["label", "onClick"])
791
- ]),
792
- _: 1
793
- }, 8, ["categorized-items", "initial-value"])
794
- ]),
795
- _: 1
796
- }, 8, ["subtitle", "title"])) : (v(), G(ie, {
797
- key: 2,
798
- subtitle: l(T)("menu.product.empty.with_scheduler.subtitle"),
799
- title: l(T)("menu.product.empty.with_scheduler.title")
800
- }, {
801
- action: M(() => [
802
- i(Me, {
803
- "categorized-items": l(f).linkableItems.value,
804
- "initial-value": l(f).currentItems.value,
805
- "show-variant": !1,
806
- onSubmit: k[3] || (k[3] = (h) => l(f).applyProduct(h.map((P) => P._id)))
807
- }, {
808
- default: M(({ trigger: h }) => [
809
- i(S, {
810
- label: l(T)("menu.common.actions.apply_product"),
811
- onClick: h
812
- }, null, 8, ["label", "onClick"])
813
- ]),
814
- _: 1
815
- }, 8, ["categorized-items", "initial-value"])
816
- ]),
817
- _: 1
818
- }, 8, ["subtitle", "title"]))
819
- ]));
820
- };
821
- }
822
- });
823
- export {
824
- cl as _,
825
- ze as a
826
- };