@feedmepos/mf-menu 0.32.12-dev → 0.32.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 (64) hide show
  1. package/dist/{App-D0JZMDPU.js → App-D70-FH5L.js} +7 -7
  2. package/dist/{ApplyProduct.vue_vue_type_script_setup_true_lang-C5fI7pDt.js → ApplyProduct.vue_vue_type_script_setup_true_lang-BJdja2N0.js} +3 -3
  3. package/dist/{Catalog-BIVVmu4F.js → Catalog-WMpN3a0p.js} +6 -6
  4. package/dist/{Category-Cmf6dD5G.js → Category-BwHhFTZ-.js} +6 -6
  5. package/dist/{Category-DoEzIDPA.js → Category-C_VsQIHU.js} +4 -4
  6. package/dist/{CookingGuide-DxQ5vDF5.js → CookingGuide-D9RNkYDL.js} +4 -4
  7. package/dist/{CustomAttributeChip.vue_vue_type_script_setup_true_lang-BQscJC6_.js → CustomAttributeChip.vue_vue_type_script_setup_true_lang-DtmrxDZm.js} +1 -1
  8. package/dist/{Group-EAACXFDr.js → Group-DexONgr2.js} +1 -1
  9. package/dist/{Group-l59a7MQy.js → Group-qRZlg5ST.js} +3 -3
  10. package/dist/{Group.vue_vue_type_script_setup_true_lang-CdIKM2jO.js → Group.vue_vue_type_script_setup_true_lang-DtPY9uUt.js} +7 -7
  11. package/dist/{GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-CendqbFI.js → GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-B5Qpmj2f.js} +5 -5
  12. package/dist/{ImportProductDialog.vue_vue_type_script_setup_true_lang-B3I3jPxC.js → ImportProductDialog.vue_vue_type_script_setup_true_lang-BqhNkaw_.js} +27456 -27454
  13. package/dist/{Ingredient-B7kPk3oV.js → Ingredient-BuOS_Wvm.js} +3 -3
  14. package/dist/{InventoryBinding.vue_vue_type_script_setup_true_lang-CzpY9mWg.js → InventoryBinding.vue_vue_type_script_setup_true_lang-DFvXklj9.js} +2 -2
  15. package/dist/{LinkProductSideSheet-CeXhbGnn.js → LinkProductSideSheet-DJj8Nn4X.js} +3 -3
  16. package/dist/{MenuSetting-CCtL2qui.js → MenuSetting-D6B0gCGV.js} +5 -5
  17. package/dist/{PrintRoute-DMLRAZJg.js → PrintRoute-B7G8f1iC.js} +4 -4
  18. package/dist/{Product-BAcGhIEf.js → Product-DpS5EepJ.js} +1 -1
  19. package/dist/{Product.vue_vue_type_script_setup_true_lang-V8-_F7WQ.js → Product.vue_vue_type_script_setup_true_lang-CdIukLqA.js} +12 -12
  20. package/dist/{ProductInternalTools-BrQwrwyG.js → ProductInternalTools-CBCyWHOS.js} +6 -6
  21. package/dist/Products-CcyGNlUl.js +794 -0
  22. package/dist/{Publish-CtKo19_y.js → Publish-rZLHFaJ5.js} +54 -52
  23. package/dist/{Recipe-ORx3rnvx.js → Recipe-D14rkATU.js} +4 -4
  24. package/dist/{RuleView.vue_vue_type_script_setup_true_lang-biTDrokQ.js → RuleView.vue_vue_type_script_setup_true_lang-CdH2ius3.js} +134 -134
  25. package/dist/{Scheduler-B7v3W8eG.js → Scheduler-DWZqa-jf.js} +3 -3
  26. package/dist/{ServingSequence-DczYH8BU.js → ServingSequence-Mx7ovvJ1.js} +3 -3
  27. package/dist/{Setting-fNLED9R0.js → Setting-DmHuVXVn.js} +5 -5
  28. package/dist/{Subcategory-DjK1PTao.js → Subcategory-DixZPdnT.js} +4 -4
  29. package/dist/{Takeaway-LjEJbd4e.js → Takeaway-BVIymFV_.js} +4 -4
  30. package/dist/{Takeaway-ChMYycO_.js → Takeaway-DDKeDEbV.js} +1 -1
  31. package/dist/{Takeaway.vue_vue_type_script_setup_true_lang-CMdZM60P.js → Takeaway.vue_vue_type_script_setup_true_lang-CTaCQgRv.js} +5 -5
  32. package/dist/{Thumbnail.vue_vue_type_script_setup_true_lang-Yh_aUxqS.js → Thumbnail.vue_vue_type_script_setup_true_lang-DveI9xvU.js} +4 -4
  33. package/dist/{TreeEditorOpenner.vue_vue_type_script_setup_true_lang-CEmOkHc5.js → TreeEditorOpenner.vue_vue_type_script_setup_true_lang-2nBbq_Yk.js} +14 -14
  34. package/dist/{Unit-DGZ9xVpM.js → Unit-utuaNZBw.js} +2 -2
  35. package/dist/{Variant-CUasE1B5.js → Variant-CzuJNwen.js} +3 -3
  36. package/dist/{_id_-CXV1a1UW.js → _id_-DMDhPQCr.js} +9 -9
  37. package/dist/{app--9ZjQ_dH.js → app-BQUkvrAS.js} +26 -26
  38. package/dist/{app-E7mszfIB.js → app-Bqj3cAPJ.js} +1 -1
  39. package/dist/app.js +1 -1
  40. package/dist/apps/mf-menu/src/helper/menuExport.d.ts +22 -0
  41. package/dist/apps/mf-menu/tsconfig.app.tsbuildinfo +1 -1
  42. package/dist/assets/{validate-menu-BS4T4zZm.js → linked-status-ILQVL8r9.js} +7 -7
  43. package/dist/assets/{override-menu-BWkFILg4.js → override-menu-DVkGhbA9.js} +2 -2
  44. package/dist/assets/{linked-status-Doclb1U6.js → validate-menu-y_NQUL02.js} +7 -7
  45. package/dist/{catalog-PkvD9BV_.js → catalog-BYzITAmC.js} +1 -1
  46. package/dist/{catalogSetting-Cd9aIJs2.js → catalogSetting-DAo5tN3P.js} +1 -1
  47. package/dist/{category-1NLh1OVo.js → category-D4x8r_lY.js} +1 -1
  48. package/dist/{currency-J1RZcMOx.js → currency-CvoBdMM2.js} +1 -1
  49. package/dist/{dayjs.min-CXjOYO85.js → dayjs.min-C6xioui7.js} +1 -1
  50. package/dist/{index-BPpNi-Hh.js → index-6lju0f3r.js} +3 -3
  51. package/dist/{index-BiCSP8Fy.js → index-BLUIaanj.js} +1 -1
  52. package/dist/{index-D9h3wl03.js → index-LuH6PJzW.js} +4 -4
  53. package/dist/{index.vue_vue_type_script_setup_true_lang-B3Eku0Ig.js → index.vue_vue_type_script_setup_true_lang-DxF14kn9.js} +2664 -2664
  54. package/dist/{item-Ctnd-m_D.js → item-lXMLaKOb.js} +13 -13
  55. package/dist/{jszip.min-Bwz_vC7R.js → jszip.min-CdZ-wY5m.js} +2 -2
  56. package/dist/{menu-DpTANxng.js → menu-PJc2dQHQ.js} +1 -1
  57. package/dist/{menuV2-BBMwj4p0.js → menuV2-DinFmdTL.js} +131 -131
  58. package/dist/{priceTier-DAG2W_y3.js → priceTier-CzKIo11g.js} +1 -1
  59. package/dist/{scheduler-DYuLkKsc.js → scheduler-DQjxnoCk.js} +4 -4
  60. package/dist/{subcategory-BJ0oG92x.js → subcategory-CLkDImEU.js} +2 -2
  61. package/dist/{toExcel-C5_3G21q.js → toExcel-DPh8DaM0.js} +2 -2
  62. package/dist/{unit-CNwmGzjU.js → unit-QYkVoC6_.js} +2 -2
  63. package/package.json +1 -1
  64. package/dist/Products-O5YVYdlT.js +0 -692
@@ -1,692 +0,0 @@
1
- var de = Object.defineProperty;
2
- var pe = (C, e, n) => e in C ? de(C, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : C[e] = n;
3
- var K = (C, e, n) => pe(C, typeof e != "symbol" ? e + "" : e, n);
4
- import { defineComponent as j, computed as D, ref as oe, resolveComponent as $, createBlock as N, openBlock as T, unref as l, withCtx as E, createElementVNode as S, toDisplayString as ae, createVNode as _, createCommentVNode as re, createElementBlock as B, Fragment as H } from "vue";
5
- import { D as V } from "./dayjs.min-CXjOYO85.js";
6
- import { m as A, A as O, f as g, a as J, b as L, e as P, n as U, w as fe } from "./ImportProductDialog.vue_vue_type_script_setup_true_lang-B3I3jPxC.js";
7
- import { J as be, F as he } from "./jszip.min-Bwz_vC7R.js";
8
- import { u as ne, G as ie, B as z, H as q, A as se, D as ge, I as X, J as Z } from "./index.vue_vue_type_script_setup_true_lang-B3Eku0Ig.js";
9
- import { useCoreStore as ce, useI18n as ye } from "@feedmepos/mf-common";
10
- import { useDialog as me, useDialogChild as _e, useSnackbar as le, useBreakpoints as ke, FmButtonVariant as Y, FmButtonColorThemeVariant as G } from "@feedmepos/ui-library";
11
- import { _ as W } from "./ResponsiveFabButton.vue_vue_type_script_setup_true_lang-Cn-3MRBO.js";
12
- import { _ as ve, a as Q } from "./BottomSheetMenuItem.vue_vue_type_script_setup_true_lang-DhrXKy3b.js";
13
- import { _ as we } from "./PageLayout.vue_vue_type_script_setup_true_lang-2f0QfweQ.js";
14
- import { u as xe, a as Ce } from "./menu-DpTANxng.js";
15
- import { u as Fe } from "./item-Ctnd-m_D.js";
16
- import { _ as ee, a as Me } from "./Product.vue_vue_type_script_setup_true_lang-V8-_F7WQ.js";
17
- import { L as te } from "./LinkProductSideSheet-CeXhbGnn.js";
18
- import { _ as Ie } from "./TreeEditorOpenner.vue_vue_type_script_setup_true_lang-CEmOkHc5.js";
19
- import { u as Se } from "./Thumbnail.vue_vue_type_script_setup_true_lang-Yh_aUxqS.js";
20
- import { m as Ee } from "./toExcel-C5_3G21q.js";
21
- const Te = { class: "space-y-24 mb-24" }, De = ["innerHTML"], Ne = { class: "flex justify-end gap-8" }, Ke = /* @__PURE__ */ j({
22
- __name: "ConfirmActionDialog",
23
- props: {
24
- description: {},
25
- value: {},
26
- message: { default: "To confirm your action, type <b>[[value]]</b> in the text field." }
27
- },
28
- setup(C) {
29
- const e = C, n = D(() => e.message.replace("[[value]]", e.value)), i = oe(""), t = me(), { emitAction: o } = _e();
30
- return (r, a) => {
31
- const m = $("FmTextField"), c = $("FmButton"), u = $("FmForm");
32
- return T(), N(u, {
33
- "on-validation-success": () => l(o)("primary"),
34
- "blame-form-child-on-validation-failed": ""
35
- }, {
36
- default: E(() => [
37
- S("div", Te, [
38
- S("div", null, ae(r.description), 1),
39
- S("div", { innerHTML: n.value }, null, 8, De),
40
- S("div", null, [
41
- _(m, {
42
- modelValue: i.value,
43
- "onUpdate:modelValue": [
44
- a[0] || (a[0] = (s) => i.value = s),
45
- a[1] || (a[1] = () => {
46
- })
47
- ],
48
- placeholder: r.value,
49
- rules: [(s) => s === r.value || "Value does not match"]
50
- }, null, 8, ["modelValue", "placeholder", "rules"])
51
- ]),
52
- S("div", Ne, [
53
- _(c, {
54
- label: "Cancel",
55
- variant: "secondary",
56
- onClick: a[2] || (a[2] = (s) => l(t).close())
57
- }),
58
- _(c, {
59
- label: "Confirm",
60
- type: "submit"
61
- })
62
- ])
63
- ])
64
- ]),
65
- _: 1
66
- }, 8, ["on-validation-success"]);
67
- };
68
- }
69
- }), Ge = /* @__PURE__ */ j({
70
- __name: "Migrate",
71
- setup(C) {
72
- const e = ne(), n = ce(), i = le(), { minor: t } = ie(i), o = oe(!1), r = me();
73
- async function a() {
74
- m.value || o.value || r.open({
75
- title: "Migrate to new version",
76
- contentComponent: Ke,
77
- contentComponentProps: {
78
- value: "MIGRATE",
79
- description: "Do you want to migrate to new version? Once migrate it will unable to revert to the older version."
80
- }
81
- }).onPrimary(async () => {
82
- r.close(), await t(
83
- async () => {
84
- await e.migrate(), setTimeout(() => {
85
- window.location.reload();
86
- }, 2e3);
87
- },
88
- {
89
- isLoading: o,
90
- customId: e.state.menu._id,
91
- message: "Migrating menu",
92
- successMessage: "Migration completed"
93
- }
94
- );
95
- });
96
- }
97
- const m = D(() => {
98
- const c = n.restaurants.value;
99
- if (!c.length) return "Required at least one restaurant to migrate";
100
- const u = c.filter((d) => !d.posVersion || !z.Pos.canUse({ feature: q.F_FEATURE.enum.menuV4, posVersion: d.posVersion }));
101
- return u.length ? `Upgrade POS to V${z.Pos.minVersionToUse(q.F_FEATURE.enum.menuV4)} to use new menu: ${u.map((d) => d.profile.name).join(", ")}` : null;
102
- });
103
- return D(() => m.value ? m.value : "Migrate your menu to new version to enjoy more features. Content of new menu will remain the same as current."), (c, u) => {
104
- const s = $("FmSnackbar");
105
- return !m.value && l(e).version !== l(se.F_MENU_VERSION).enum.v4 ? (T(), N(s, {
106
- key: 0,
107
- class: "!max-w-full",
108
- title: "New version of menu is out now!",
109
- description: "Migrate your current menu version to the latest to enjoy more features such as product sequential dispatch, serving sequence, scheduler and more! Your content and current setting will be preserved.",
110
- variant: "info",
111
- action: "Migrate",
112
- "z-index": 0,
113
- onOnAction: a
114
- })) : re("", !0);
115
- };
116
- }
117
- });
118
- class Ve {
119
- constructor(e, n) {
120
- K(this, "menu");
121
- K(this, "categoryMap");
122
- K(this, "takeawayMap");
123
- K(this, "subCategoryMap");
124
- K(this, "attributeSettings");
125
- this.menu = e, this.attributeSettings = n, this.categoryMap = e.modules.category.reduce((t, o) => (t[o._id] = o, t), {}), this.takeawayMap = e.modules.takeaway.reduce((t, o) => (t[o._id] = o, t), {});
126
- const i = e.modules.subCategory || [];
127
- this.subCategoryMap = i.reduce((t, o) => (t[o._id] = o, t), {});
128
- }
129
- transformData() {
130
- let e = [];
131
- return this.menu.modules.item.forEach((n) => {
132
- var a;
133
- const i = n.variant ? A(this.menu, n.variant.variantGroupIds) : {}, t = this.transformProductToDataRow(n, i), r = (((a = n.variant) == null ? void 0 : a.variantCombinations) ?? []).reduce(
134
- (m, c) => {
135
- const u = this.transformProductToDataRow(
136
- n,
137
- i,
138
- c.combinationKey
139
- );
140
- return m.push(u), m;
141
- },
142
- [t]
143
- );
144
- e = [...e, ...r];
145
- }), {
146
- rows: e,
147
- metaData: {
148
- priceTiers: []
149
- }
150
- };
151
- }
152
- transformOverrideData(e) {
153
- let n = [], i = [];
154
- const t = e.reduce(
155
- (o, r) => (o[r._id] || (o[r._id] = []), r.combinationKey && o[r._id].push(r.combinationKey), o),
156
- {}
157
- );
158
- for (let o = 0; o < e.length; o++) {
159
- const r = e[o], a = this.menu.modules.item.find((m) => m._id === r._id);
160
- if (a && a.variant) {
161
- const m = a.variant.variantCombinations.map(
162
- (d) => d.combinationKey
163
- ), c = t[r._id] || [], u = m.filter((d) => !c.includes(d)), s = [];
164
- if (u.forEach((d) => {
165
- const f = a.variant.variantCombinations.find(
166
- (v) => v.combinationKey === d
167
- );
168
- f && (s.push({
169
- _id: r._id,
170
- combinationKey: d,
171
- price: f.price,
172
- orderFrom: f.orderFrom
173
- }), t[r._id].push(d));
174
- }), s.length > 0) {
175
- const d = e.findIndex((v) => v._id === r._id && !v.combinationKey), f = d >= 0 ? d + 1 : o + 1;
176
- e.splice(f, 0, ...s), o += s.length;
177
- }
178
- }
179
- }
180
- for (let o = 0; o < e.length; o++) {
181
- const r = e[o], a = this.menu.modules.item.find((s) => s._id === r._id);
182
- if (!a)
183
- throw new Error(`Invalid item ${r._id} in catalog`);
184
- const m = a.variant ? A(this.menu, a.variant.variantGroupIds) : {}, u = [this.transformOverrideDataToRow(r, m)];
185
- i = [...i, ...u.flatMap((s) => Object.keys(s.priceTier))], n = [...n, ...u];
186
- }
187
- return {
188
- rows: n,
189
- metaData: {
190
- priceTiers: []
191
- }
192
- };
193
- }
194
- getSubCategoryNames(e, n) {
195
- return n || !e.subCategories ? "" : e.subCategories.map((i) => {
196
- var t;
197
- return ((t = this.subCategoryMap[i]) == null ? void 0 : t.name) || "";
198
- }).filter((i) => i).join(",");
199
- }
200
- transformProductToDataRow(e, n, i) {
201
- var m, c, u;
202
- const t = (m = e.variant) == null ? void 0 : m.variantCombinations.find(
203
- (s) => s.combinationKey === i
204
- );
205
- if (i && !t)
206
- throw new Error(`Invalid combination key ${i}`);
207
- const o = e.category ? (c = this.categoryMap[e.category]) == null ? void 0 : c.name : O;
208
- let r;
209
- if (t ? r = t.takeawayUsed ? this.takeawayMap[t.takeawayUsed] : void 0 : r = e.takeawayUsed ? this.takeawayMap[e.takeawayUsed] : void 0, !o)
210
- throw new Error(`Invalid category ${e.category}`);
211
- const a = this.getSubCategoryNames(e, !!t);
212
- return {
213
- _id: e._id,
214
- code: t && t.code || e.code,
215
- name: e.name,
216
- variantKey: (t == null ? void 0 : t.combinationKey) ?? "",
217
- variantName: t ? n[t.combinationKey] : "",
218
- category: o,
219
- subCategories: a,
220
- orderFrom: t ? t.orderFrom ?? e.orderFrom : e.orderFrom,
221
- perXUnit: e.perXUnit || "",
222
- unit: e.unit || "",
223
- openPrice: e.openPrice === !0 ? "T" : "",
224
- price: t ? t.price ? parseFloat(g(t.price)) : parseFloat(g(e.price)) : parseFloat(g(e.price)),
225
- priceTier: e.priceTiers || {},
226
- trackingCost: e.costing ? parseFloat(g(e.costing)) : "",
227
- minPrice: e.minPrice ? parseFloat(g(e.minPrice)) : "",
228
- groupByParent: ((u = e.print) == null ? void 0 : u.toRoot) === !0 ? "" : "T",
229
- takeawayName: (r == null ? void 0 : r.name) || "",
230
- takeawayPrice: r != null && r.price ? parseFloat(g(r == null ? void 0 : r.price)) : "",
231
- tag: e.customAttributes || {}
232
- };
233
- }
234
- transformOverrideDataToRow(e, n, i) {
235
- var c, u;
236
- const t = this.menu.modules.item.find((s) => s._id === e._id);
237
- if (!t)
238
- throw new Error(`Invalid item ${e._id} in catelog`);
239
- const o = (c = t.variant) == null ? void 0 : c.variantCombinations.find(
240
- (s) => s.combinationKey === e.combinationKey
241
- );
242
- if (i && !o)
243
- throw new Error(`Invalid combination key ${i}`);
244
- const r = () => {
245
- var s, d;
246
- return e.category ? e.category ? (d = this.categoryMap[e.category]) == null ? void 0 : d.name : O : t.category ? (s = this.categoryMap[t.category]) == null ? void 0 : s.name : O;
247
- };
248
- let a;
249
- o ? e.takeawayUsed ? a = e.takeawayUsed ? this.takeawayMap[e.takeawayUsed] : void 0 : a = o.takeawayUsed ? this.takeawayMap[o.takeawayUsed] : void 0 : e.takeawayUsed ? a = e.takeawayUsed ? this.takeawayMap[e.takeawayUsed] : void 0 : a = t.takeawayUsed ? this.takeawayMap[t.takeawayUsed] : void 0;
250
- const m = this.getSubCategoryNames(e, !!o);
251
- return {
252
- _id: e._id,
253
- code: e.code ? e.code : o && o.code || t.code,
254
- name: t.name,
255
- variantKey: e.combinationKey ? e.combinationKey : (o == null ? void 0 : o.combinationKey) ?? "",
256
- variantName: o ? n[o.combinationKey] : "",
257
- category: r(),
258
- subCategories: m,
259
- orderFrom: e.orderFrom ? e.orderFrom : o ? o.orderFrom ?? t.orderFrom : t.orderFrom,
260
- perXUnit: t.perXUnit || "",
261
- unit: t.unit || "",
262
- openPrice: t.openPrice === !0 ? "T" : "",
263
- price: e.price ? parseFloat(g(e.price)) : o ? o.price ? parseFloat(g(o.price)) : parseFloat(g(t.price)) : parseFloat(g(t.price)),
264
- priceTier: t.priceTiers || {},
265
- trackingCost: t.costing ? parseFloat(g(t.costing)) : "",
266
- minPrice: e.minPrice ? parseFloat(g(e.minPrice)) : t.minPrice ? parseFloat(g(t.minPrice)) : "",
267
- groupByParent: ((u = t.print) == null ? void 0 : u.toRoot) === !0 ? "" : "T",
268
- takeawayName: (a == null ? void 0 : a.name) || "",
269
- takeawayPrice: a != null && a.price ? parseFloat(g(a == null ? void 0 : a.price)) : "",
270
- tag: t.customAttributes || {}
271
- };
272
- }
273
- transformAddonGroup() {
274
- return this.mapAddonGroup(this.menu.modules.group);
275
- }
276
- transformOverrideAddonGroup(e) {
277
- return this.mapCatalogAddonGroup(e);
278
- }
279
- mapCatalogAddonGroup(e) {
280
- const n = this.menu.modules.group.map((t) => t._id), i = e.map((t) => t._id);
281
- return n.forEach((t) => {
282
- if (!i.includes(t)) {
283
- const o = this.menu.modules.group.find((r) => r._id === t);
284
- e.push({
285
- ...o,
286
- groupKey: ""
287
- });
288
- }
289
- }), e.sort((t, o) => n.indexOf(t._id) - n.indexOf(o._id)), e.flatMap((t) => {
290
- const o = this.menu.modules.group.find((a) => a._id === t._id);
291
- if (!o)
292
- throw new Error("Invalid addon group id");
293
- const r = {};
294
- return o.items.map((a, m) => {
295
- var b, x, F;
296
- const c = this.menu.modules.item.find((h) => h._id === a._id);
297
- if (!c)
298
- throw new Error("Invalid item id");
299
- let u;
300
- a.combinationKey && (u = (b = c.variant) == null ? void 0 : b.variantCombinations.find(
301
- (h) => h.combinationKey === a.combinationKey
302
- ));
303
- const s = (x = t.items) == null ? void 0 : x.find(
304
- (h) => h._id === a._id && h.combinationKey === a.combinationKey
305
- ), d = c.name, f = A(
306
- this.menu,
307
- ((F = c.variant) == null ? void 0 : F.variantGroupIds) ?? []
308
- ), v = (s == null ? void 0 : s.price) ?? a.price ?? (u == null ? void 0 : u.price) ?? c.price;
309
- return a.name && !a.combinationKey && (r[a._id] = a.name), {
310
- id: t._id,
311
- name: o.name,
312
- min: o.min,
313
- max: o.max,
314
- stackable: o.stackable === !0 ? "T" : "",
315
- itemId: a._id,
316
- itemCode: c.code || "",
317
- itemName: d,
318
- itemNameOverrider: r[a._id] || "",
319
- combinationKey: a.combinationKey ?? "",
320
- combinationName: a.combinationKey ? f[a.combinationKey] : "",
321
- price: parseFloat(g(v)),
322
- priceTier: a.priceTiers || {},
323
- orderFrom: (s == null ? void 0 : s.orderFrom) ?? a.orderFrom ?? c.orderFrom ?? "ALL",
324
- isDefault: a.isDefault === !0 ? "T" : "",
325
- index: m
326
- };
327
- });
328
- });
329
- }
330
- mapAddonGroup(e) {
331
- return e.flatMap((n) => {
332
- let i = {};
333
- return i = n.items.reduce((t, o) => (t[o._id] || o.name && !o.combinationKey && (t[o._id] = o.name), t), {}), n.items.map((t, o) => {
334
- var u, s;
335
- const r = this.menu.modules.item.find((d) => d._id === t._id);
336
- if (!r)
337
- throw new Error("Invalid item id");
338
- let a;
339
- t.combinationKey && (a = (u = r.variant) == null ? void 0 : u.variantCombinations.find(
340
- (d) => d.combinationKey === t.combinationKey
341
- ));
342
- const m = t.price ?? (a == null ? void 0 : a.price) ?? r.price, c = A(
343
- this.menu,
344
- ((s = r.variant) == null ? void 0 : s.variantGroupIds) ?? []
345
- );
346
- return {
347
- id: n._id,
348
- name: n.name,
349
- min: n.min,
350
- max: n.max,
351
- stackable: n.stackable === !0 ? "T" : "",
352
- itemId: t._id,
353
- itemCode: r.code || "",
354
- itemName: r.name,
355
- itemNameOverrider: i[t._id] || "",
356
- combinationKey: t.combinationKey ?? "",
357
- combinationName: t.combinationKey ? c[t.combinationKey] : "",
358
- price: parseFloat(g(m)),
359
- priceTier: t.priceTiers || {},
360
- orderFrom: t.orderFrom ?? r.orderFrom,
361
- isDefault: t.isDefault === !0 ? "T" : "",
362
- index: o
363
- };
364
- });
365
- });
366
- }
367
- transformItemsLinkWithGroup() {
368
- const e = {}, n = this.menu.modules.item.reduce((i, t) => (i[t._id] = {
369
- itemId: t._id,
370
- itemName: t.name,
371
- defaultCatalog: ""
372
- }, i), {});
373
- return this.menu.modules.group.forEach((i) => {
374
- e[i._id] = JSON.parse(JSON.stringify(n));
375
- }), this.menu.modules.item.forEach((i) => {
376
- i.groups.length > 0 && i.groups.forEach((t) => {
377
- e[t._id][i._id] = {
378
- ...e[t._id][i._id],
379
- defaultCatalog: "T"
380
- };
381
- });
382
- }), e;
383
- }
384
- exportToExcel() {
385
- var v;
386
- const e = [], { rows: n, metaData: i } = this.transformData();
387
- i.priceTiers = ((v = this.menu.priceTierSettings) == null ? void 0 : v.map((b) => b.key)) || [];
388
- const t = n.map(({ priceTier: b, tag: x, ...F }) => {
389
- const h = Object.entries(F), M = h.findIndex(([y]) => y === "price");
390
- return [
391
- ...h.slice(0, M + 1).map(([, y]) => y),
392
- ...i.priceTiers.map(
393
- (y) => parseFloat(g(b[y])) || ""
394
- ),
395
- ...h.slice(M + 1).map(([, y]) => y),
396
- ...this.attributeSettings.map((y) => x[y.key] || "")
397
- ];
398
- }), o = this.createWorkbookExcelJS(
399
- t,
400
- "Default Catalog",
401
- this.exportCatalogToExcelExcelJS()
402
- ), r = o.worksheets[0];
403
- J(r, this.attributeSettings, i.priceTiers), this.formatWorkbookCell(o);
404
- const m = this.transformAddonGroup().map(({ priceTier: b, ...x }) => {
405
- const { index: F, ...h } = x, M = Object.entries(h), y = M.findIndex(([p]) => p === "price");
406
- return [
407
- ...M.slice(0, y + 1).map(([, p]) => p),
408
- ...i.priceTiers.map(
409
- (p) => parseFloat(g(b[p])) || ""
410
- ),
411
- ...M.slice(y + 1).map(([, p]) => p)
412
- ];
413
- }), c = this.createWorkbookExcelJS(
414
- m,
415
- "Default AddonGroup",
416
- this.exportCatalogAddonToExcelExcelJS()
417
- ), u = c.worksheets[0];
418
- L(u, i.priceTiers), this.formatWorkbookCell(c);
419
- const s = this.transformItemsLinkWithGroup(), d = Object.keys(s), f = new P.Workbook();
420
- if (d.length > 0)
421
- d.forEach((b, x) => {
422
- const F = Object.values(s[b]), h = this.menu.modules.group.find((p) => p._id === b);
423
- if (!h) throw new Error(`Group not found for id: ${b}`);
424
- const M = U(`${x + 1}. ${h.name}`), y = f.addWorksheet(M);
425
- y.columns = [
426
- { header: "Group ID", key: "groupId" },
427
- { header: "Item ID", key: "itemId" },
428
- { header: "Item Name", key: "itemName" },
429
- { header: "Default Catalog", key: "defaultCatalog" }
430
- ], F.forEach((p) => {
431
- y.addRow({
432
- groupId: b,
433
- itemId: p.itemId,
434
- itemName: p.itemName,
435
- defaultCatalog: p.defaultCatalog
436
- });
437
- });
438
- });
439
- else {
440
- const b = f.addWorksheet("Group Name");
441
- b.columns = [
442
- { header: "Group ID", key: "groupId" },
443
- { header: "Item ID", key: "itemId" },
444
- { header: "Item Name", key: "itemName" },
445
- { header: "Default Catalog", key: "defaultCatalog" }
446
- ];
447
- }
448
- return this.formatWorkbookCell(f), e.push(o, c, f), e;
449
- }
450
- createWorkbookExcelJS(e, n, i) {
451
- const t = new P.Workbook(), o = t.addWorksheet(n);
452
- return e.forEach((r) => {
453
- o.addRow(r);
454
- }), i && i.worksheets.forEach((r) => {
455
- const a = t.addWorksheet(r.name);
456
- r.eachRow({ includeEmpty: !0 }, (m) => {
457
- const c = m.values;
458
- a.addRow(c.slice(1));
459
- });
460
- }), t;
461
- }
462
- formatWorkbookCell(e) {
463
- e.eachSheet((n) => {
464
- n.eachRow({ includeEmpty: !0 }, (t) => {
465
- t.eachCell({ includeEmpty: !0 }, (o) => {
466
- o.font = {
467
- name: "Calibri",
468
- size: 12
469
- }, t.number === 1 && (o.fill = {
470
- type: "pattern",
471
- pattern: "solid",
472
- fgColor: { argb: "FABF8F" }
473
- }, o.alignment = { horizontal: "center", vertical: "middle" });
474
- });
475
- });
476
- const i = n.getRow(1);
477
- n.autoFilter = {
478
- from: {
479
- row: 1,
480
- column: 1
481
- },
482
- to: {
483
- row: 1,
484
- column: i.cellCount
485
- }
486
- };
487
- });
488
- }
489
- exportCatalogToExcelExcelJS() {
490
- const e = new P.Workbook();
491
- return this.menu.modules.catalog.forEach((n) => {
492
- const i = Object.values(n.override.items).flatMap((c) => c), { rows: t, metaData: o } = this.transformOverrideData(i), r = t.map(({ priceTier: c, tag: u, ...s }) => [
493
- ...Object.entries(s).map(([, f]) => f),
494
- ...this.attributeSettings.map((f) => u[f.key] || "")
495
- ]), a = U(n.name), m = e.addWorksheet(a);
496
- r.forEach((c) => {
497
- m.addRow(c);
498
- }), J(m, this.attributeSettings, o.priceTiers, n);
499
- }), e;
500
- }
501
- exportCatalogAddonToExcelExcelJS() {
502
- const e = new P.Workbook();
503
- return this.menu.modules.catalog.forEach((n) => {
504
- const i = Object.values(n.override.groups).flatMap(
505
- (m) => m
506
- ), o = this.transformOverrideAddonGroup(i).map(({ priceTier: m, ...c }) => {
507
- const { index: u, ...s } = c;
508
- return [...Object.entries(s).map(([, f]) => f)];
509
- }), r = U(n.name), a = e.addWorksheet(r);
510
- o.forEach((m) => {
511
- a.addRow(m);
512
- }), L(a);
513
- }), e;
514
- }
515
- }
516
- const $e = { class: "flex-1 flex justify-between gap-8 pl-8" }, Re = { class: "flex items-center" }, Ae = { class: "bg-fm-color-neutral-gray-100 rounded-md px-8 py-4" }, Pe = { class: "fm-typo-en-body-md-600 font-semibold" }, Oe = { class: "flex gap-8" }, nt = /* @__PURE__ */ j({
517
- __name: "Products",
518
- setup(C) {
519
- const { t: e } = ye(), n = ce(), i = ie(le()), t = ne(), o = D(() => t.rules.item), r = Fe(), a = D(() => !t.state.currentSchedulerId), { selectedCategories: m } = xe(), c = D(() => ({
520
- ...ge.menuV4ToV3(X(t.state.menu)),
521
- _id: t.state.menu._id,
522
- _rev: t.state.menu._rev
523
- })), u = D(() => {
524
- const p = Z.flatten(m.value.map((w) => w.items));
525
- return Z.uniqBy(p, (w) => w._id).length;
526
- });
527
- async function s(p, w) {
528
- const I = new be();
529
- for (let R = 0; R < p.length; R++) {
530
- const ue = await p[R].xlsx.writeBuffer();
531
- I.file(`${w[R]}.xlsx`, ue);
532
- }
533
- const k = await I.generateAsync({ type: "blob" });
534
- he.saveAs(k, `books_${V().format("DD-MM-YYYY_HH-mm")}.zip`);
535
- }
536
- async function d() {
537
- await i.minor(
538
- async () => {
539
- var p;
540
- if (await t.readMenu(), t.version === se.F_MENU_VERSION.enum.v4) {
541
- const w = X(t.state.menu), I = new Ve(
542
- w,
543
- ((p = n.currentBusiness.value) == null ? void 0 : p.attributeSettings) ?? []
544
- ).exportToExcel(), k = [
545
- `menu_${V().format("DD-MM-YYYY_HH-mm")}`,
546
- `addonGroup_${V().format("DD-MM-YYYY_HH-mm")}`,
547
- `itemLinkedAddon${V().format("DD-MM-YYYY_HH-mm")}`
548
- ];
549
- s(I, k);
550
- } else {
551
- const w = Ee(c.value), I = `menu_${V().format("DD-MM-YYYY_HH-mm")}`;
552
- await fe(w, `${I}.xlsx`, {
553
- bookType: "xlsx",
554
- bookSST: !1,
555
- type: "array"
556
- });
557
- }
558
- },
559
- { successMessage: "Menu exported", customId: t.state.menu._id }
560
- );
561
- }
562
- const {
563
- menuItems: f,
564
- categories: v,
565
- linkItemRules: b,
566
- handleSubmit: x,
567
- catalogManager: F,
568
- schedulerManager: h
569
- } = Se(!1), M = ke(), y = D(() => M.breakpoints.value.xs);
570
- return Ce().resetOnMount(), (p, w) => {
571
- const I = $("fm-button");
572
- return T(), N(we, {
573
- heading: l(e)("menu.products.title")
574
- }, {
575
- default: E(() => [
576
- _(Ge),
577
- _(Me)
578
- ]),
579
- "append-heading": E(() => [
580
- S("div", $e, [
581
- S("div", Re, [
582
- S("div", Ae, [
583
- S("p", Pe, ae(u.value), 1)
584
- ])
585
- ]),
586
- S("div", Oe, [
587
- y.value ? (T(), N(ee, { key: 1 }, {
588
- default: E(({ trigger: k }) => [
589
- _(ve, null, {
590
- default: E(() => [
591
- _(Q, {
592
- label: l(e)("menu.products.actions.export"),
593
- onClick: d
594
- }, null, 8, ["label"]),
595
- _(Q, {
596
- label: l(e)("menu.products.actions.import"),
597
- onClick: k
598
- }, null, 8, ["label", "onClick"])
599
- ]),
600
- _: 2
601
- }, 1024)
602
- ]),
603
- _: 1
604
- })) : (T(), B(H, { key: 0 }, [
605
- _(Ie, null, {
606
- default: E(({ trigger: k }) => [
607
- _(I, {
608
- label: l(e)("menu.tree_editor.title"),
609
- "bg-color": l(G).NeutralGray100,
610
- "text-color": l(G).TypoSecondary,
611
- variant: l(Y).Primary,
612
- onClick: k
613
- }, null, 8, ["label", "bg-color", "text-color", "variant", "onClick"])
614
- ]),
615
- _: 1
616
- }),
617
- _(I, {
618
- "bg-color": l(G).NeutralGray100,
619
- "text-color": l(G).TypoSecondary,
620
- variant: l(Y).Primary,
621
- label: l(e)("menu.products.actions.export"),
622
- onClick: d
623
- }, null, 8, ["bg-color", "text-color", "variant", "label"]),
624
- _(ee, null, {
625
- default: E(({ trigger: k }) => [
626
- _(I, {
627
- "bg-color": l(G).NeutralGray100,
628
- "text-color": l(G).TypoSecondary,
629
- variant: l(Y).Primary,
630
- label: l(e)("menu.products.actions.import"),
631
- onClick: k
632
- }, null, 8, ["bg-color", "text-color", "variant", "label", "onClick"])
633
- ]),
634
- _: 1
635
- })
636
- ], 64)),
637
- u.value > 0 ? (T(), B(H, { key: 2 }, [
638
- o.value.create ? (T(), N(W, {
639
- key: 0,
640
- label: l(e)("menu.products.actions.add"),
641
- "prepend-icon": "add",
642
- onClick: w[0] || (w[0] = (k) => l(r).create(null))
643
- }, null, 8, ["label"])) : a.value ? (T(), N(te, {
644
- key: 1,
645
- "categorized-items": l(F).linkableItems.value,
646
- "initial-value": l(F).currentItems.value,
647
- "show-variant": !1,
648
- "menu-items": l(f),
649
- categories: l(v),
650
- "link-item-rules": l(b),
651
- "no-scheduler": a.value,
652
- onSubmit: l(x)
653
- }, {
654
- default: E(({ trigger: k }) => [
655
- _(W, {
656
- label: l(e)("menu.products.actions.link"),
657
- "prepend-icon": "link",
658
- onClick: k
659
- }, null, 8, ["label", "onClick"])
660
- ]),
661
- _: 1
662
- }, 8, ["categorized-items", "initial-value", "menu-items", "categories", "link-item-rules", "no-scheduler", "onSubmit"])) : (T(), N(te, {
663
- key: 2,
664
- "categorized-items": l(h).linkableItems.value,
665
- "initial-value": l(h).currentItems.value,
666
- "show-variant": !1,
667
- "menu-items": l(f),
668
- categories: l(v),
669
- "link-item-rules": l(b),
670
- "no-scheduler": a.value,
671
- onSubmit: l(x)
672
- }, {
673
- default: E(({ trigger: k }) => [
674
- _(W, {
675
- label: l(e)("menu.products.actions.apply_scheduler"),
676
- onClick: k
677
- }, null, 8, ["label", "onClick"])
678
- ]),
679
- _: 1
680
- }, 8, ["categorized-items", "initial-value", "menu-items", "categories", "link-item-rules", "no-scheduler", "onSubmit"]))
681
- ], 64)) : re("", !0)
682
- ])
683
- ])
684
- ]),
685
- _: 1
686
- }, 8, ["heading"]);
687
- };
688
- }
689
- });
690
- export {
691
- nt as default
692
- };