@feedmepos/mf-menu 0.31.33-beta.1 → 0.31.33-beta.6

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 (89) hide show
  1. package/dist/{App-B4rnpCXN.js → App-Dt6RQiUh.js} +6 -6
  2. package/dist/{ApplyProduct.vue_vue_type_script_setup_true_lang-LtwWMoPW.js → ApplyProduct.vue_vue_type_script_setup_true_lang-B_SQpWg7.js} +2 -2
  3. package/dist/{Catalog-Cd7J8de0.js → Catalog-CFx7t_Nu.js} +79 -79
  4. package/dist/{Category-p8UUDEiv.js → Category-CPMx86rY.js} +23 -19
  5. package/dist/{Category-D3WDm9Fe.js → Category-OjK-v--G.js} +5 -5
  6. package/dist/{CookingGuide-hFtxmtGj.js → CookingGuide-ANnXKBjc.js} +3 -3
  7. package/dist/CustomAttributeChip.vue_vue_type_script_setup_true_lang-D-1OzZ-i.js +113 -0
  8. package/dist/{Group-Bv0dyi8v.js → Group--DJjkGab.js} +1 -1
  9. package/dist/{Group-BTrqZgFd.js → Group-K4925_bP.js} +3 -3
  10. package/dist/Group.vue_vue_type_script_setup_true_lang-36O78xv0.js +684 -0
  11. package/dist/GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-BIX-gPUO.js +372 -0
  12. package/dist/{ImportProductDialog.vue_vue_type_script_setup_true_lang-CxPaVLVu.js → ImportProductDialog.vue_vue_type_script_setup_true_lang-C-z1m3jh.js} +13987 -13378
  13. package/dist/{Ingredient-BCostN4Y.js → Ingredient-G4Txx6_0.js} +3 -3
  14. package/dist/{InventoryBinding.vue_vue_type_script_setup_true_lang-MAqpI7ZD.js → InventoryBinding.vue_vue_type_script_setup_true_lang-HgHBlflo.js} +2 -2
  15. package/dist/{LinkProductSideSheet-abzVzmo3.js → LinkProductSideSheet-CWNarCEs.js} +1 -1
  16. package/dist/{MenuSetting-TfAo82-E.js → MenuSetting-Cx-EHG-6.js} +4 -4
  17. package/dist/{PrintRoute-B43rP5A9.js → PrintRoute-IxHGvGzF.js} +3 -3
  18. package/dist/{Product-C7cYyDHH.js → Product-D1gqn5J6.js} +1 -1
  19. package/dist/Product.vue_vue_type_script_setup_true_lang-BCQd-ks4.js +1641 -0
  20. package/dist/{ProductInternalTools-CkswVuAF.js → ProductInternalTools-GJ2OE5gU.js} +5 -5
  21. package/dist/Products-DJqgSe-Y.js +270 -0
  22. package/dist/{Publish-DIKqaH2f.js → Publish-C86rd413.js} +3 -3
  23. package/dist/{Recipe-_ApT00c_.js → Recipe-BbQKou9p.js} +4 -4
  24. package/dist/{Scheduler-DWY1kKHO.js → Scheduler-DUeTkyGQ.js} +3 -3
  25. package/dist/{ServingSequence-Z1S9zOTO.js → ServingSequence-BROo5rC_.js} +3 -3
  26. package/dist/Setting-D-ueTlwO.js +259 -0
  27. package/dist/{Subcategory-Lqq6XHz2.js → Subcategory-DVewA8HX.js} +4 -4
  28. package/dist/{Takeaway-DiGzrarg.js → Takeaway-B4lDGQDh.js} +4 -4
  29. package/dist/{Takeaway-DGvM9SBP.js → Takeaway-DyPjHuCl.js} +1 -1
  30. package/dist/{Takeaway.vue_vue_type_script_setup_true_lang-BfWy217t.js → Takeaway.vue_vue_type_script_setup_true_lang-BTDlzYuX.js} +6 -6
  31. package/dist/{TreeEditorOpenner.vue_vue_type_script_setup_true_lang-B2wC_Mf0.js → TreeEditorOpenner.vue_vue_type_script_setup_true_lang-B5BAKDRP.js} +642 -642
  32. package/dist/{Unit-D11rRFAf.js → Unit-CVF0dom4.js} +2 -2
  33. package/dist/{Variant-LaKYPxDe.js → Variant-DmccAgFU.js} +3 -3
  34. package/dist/_id_-CWtK62Fy.js +178 -0
  35. package/dist/{app-C5UXrJGj.js → app-CV_q8OdE.js} +75 -75
  36. package/dist/{app-Br9mC24D.js → app-ClinzawZ.js} +1 -1
  37. package/dist/app-DvG3mOom.js +8024 -0
  38. package/dist/app.js +1 -1
  39. package/dist/apps/mf-menu/src/app.d.ts +60 -1
  40. package/dist/apps/mf-menu/src/components/feature/AttributesSelector.vue.d.ts +2 -0
  41. package/dist/apps/mf-menu/src/components/feature/LinkProduct/LinkProductUnifiedSideSheet.vue.d.ts +12 -0
  42. package/dist/apps/mf-menu/src/components/feature/PriceTier/LinkPriceTierSection.vue.d.ts +24 -0
  43. package/dist/apps/mf-menu/src/components/feature/PriceTier/PriceTierRuleEditor.vue.d.ts +30 -0
  44. package/dist/apps/mf-menu/src/components/feature/TreeEditor/store/menuV2.d.ts +77 -0
  45. package/dist/apps/mf-menu/src/composable/customAttributes.d.ts +88 -0
  46. package/dist/apps/mf-menu/src/helper/{menuImport.d.ts → import-export.d.ts} +204 -3
  47. package/dist/apps/mf-menu/src/helper/menu.d.ts +77 -0
  48. package/dist/apps/mf-menu/src/helper/setting/catalogSetting.d.ts +11 -2
  49. package/dist/apps/mf-menu/src/manager/menu/item.d.ts +77 -0
  50. package/dist/apps/mf-menu/src/stores/manager/catalog.d.ts +2 -0
  51. package/dist/apps/mf-menu/src/stores/menu.d.ts +79 -0
  52. package/dist/apps/mf-menu/src/views/Publish/UpdateCatalogDialog.vue.d.ts +82 -0
  53. package/dist/apps/mf-menu/tsconfig.app.tsbuildinfo +1 -1
  54. package/dist/assets/linked-status-fZD691Js.js +24 -0
  55. package/dist/assets/override-menu-Cjy1BJuz.js +24 -0
  56. package/dist/assets/validate-menu-uwysUwDP.js +24 -0
  57. package/dist/{catalog-BDyG_i9q.js → catalog-Wx88K6iI.js} +1 -1
  58. package/dist/catalogSetting-DTEHDSAd.js +71 -0
  59. package/dist/{category-Bi6gpIYU.js → category-BRTw76Vf.js} +1 -1
  60. package/dist/{currency-DDseyYg1.js → currency-562bPc2l.js} +1 -1
  61. package/dist/customAttributes-CXzd5ud1.js +33 -0
  62. package/dist/{dayjs.min-DoQgN0KD.js → dayjs.min-Cnfm8bQm.js} +1 -1
  63. package/dist/{index-DxrEwDTr.js → index-4hf9vONw.js} +2 -2
  64. package/dist/{index-C-zLHAG1.js → index-Crs_eZ0i.js} +28 -28
  65. package/dist/{index-DTUmry92.js → index-DJXrJdeQ.js} +3 -3
  66. package/dist/{item-DqXzPUy9.js → item-CuIxc9FT.js} +377 -377
  67. package/dist/{jszip.min-iAC5WNVU.js → jszip.min-C9xLIvo4.js} +245 -245
  68. package/dist/menu-ILWxqJQe.js +133263 -0
  69. package/dist/{menu-D6df9rcz.js → menu-Mkzv9c8C.js} +4 -4
  70. package/dist/{priceTier-C56BYecC.js → priceTier-D4joq_kN.js} +1 -1
  71. package/dist/{scheduler-DCSpt65t.js → scheduler-DuxWoNVb.js} +3 -3
  72. package/dist/{subcategory-CydaPy_X.js → subcategory-CLLMagXY.js} +43 -43
  73. package/dist/{toExcel-Bil8CwJs.js → toExcel-hGfpS_Uo.js} +2 -2
  74. package/dist/{unit-8DyuBx-X.js → unit-9fycj1fu.js} +1 -1
  75. package/package.json +4 -4
  76. package/dist/CustomAttributeChip.vue_vue_type_script_setup_true_lang-Cf17Iy5i.js +0 -7949
  77. package/dist/Group.vue_vue_type_script_setup_true_lang-vk1J9IxK.js +0 -698
  78. package/dist/GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-B1wrLnf6.js +0 -206
  79. package/dist/Product.vue_vue_type_script_setup_true_lang-BOq8wMzq.js +0 -1560
  80. package/dist/Products-C7BtAjhB.js +0 -659
  81. package/dist/Setting-Bfuf26Gc.js +0 -258
  82. package/dist/_id_-Q_Tyhr4U.js +0 -200
  83. package/dist/apps/mf-menu/src/helper/import-export-utils.d.ts +0 -123
  84. package/dist/apps/mf-menu/src/helper/menuExport.d.ts +0 -32
  85. package/dist/assets/linked-status-BhGrXd73.js +0 -24
  86. package/dist/assets/override-menu-CUNDHOWA.js +0 -24
  87. package/dist/assets/validate-menu-BqOizHsX.js +0 -24
  88. package/dist/catalogSetting-C33p_dck.js +0 -65
  89. package/dist/menu-Cir-22ei.js +0 -108039
@@ -1,659 +0,0 @@
1
- var ie = Object.defineProperty;
2
- var se = (F, e, i) => e in F ? ie(F, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : F[e] = i;
3
- var K = (F, e, i) => se(F, typeof e != "symbol" ? e + "" : e, i);
4
- import { defineComponent as O, computed as I, ref as Z, resolveComponent as N, createBlock as T, openBlock as E, unref as u, withCtx as M, createElementVNode as C, toDisplayString as Q, createVNode as w, createCommentVNode as ee, createElementBlock as U, Fragment as Y } from "vue";
5
- import { D } from "./dayjs.min-DoQgN0KD.js";
6
- import { m as G, A as $, f as v, a as W, b as j, e as V, n as P, u as ce, c as me, w as le } from "./ImportProductDialog.vue_vue_type_script_setup_true_lang-CxPaVLVu.js";
7
- import { J as ue, F as de } from "./jszip.min-iAC5WNVU.js";
8
- import { u as oe, D as te, A as B, e as H, G as ae, B as pe, H as J, I as L } from "./menu-Cir-22ei.js";
9
- import { useCoreStore as fe, useI18n as ye } from "@feedmepos/mf-common";
10
- import { useDialog as re, useDialogChild as be, useSnackbar as ne, useBreakpoints as he, FmButtonVariant as A, FmButtonColorThemeVariant as S } from "@feedmepos/ui-library";
11
- import { _ as R } from "./ResponsiveFabButton.vue_vue_type_script_setup_true_lang-Cn-3MRBO.js";
12
- import { _ as ge, a as z } from "./BottomSheetMenuItem.vue_vue_type_script_setup_true_lang-DhrXKy3b.js";
13
- import { _ as _e } from "./PageLayout.vue_vue_type_script_setup_true_lang-2f0QfweQ.js";
14
- import { u as ve, a as ke } from "./menu-D6df9rcz.js";
15
- import { u as we } from "./item-DqXzPUy9.js";
16
- import { _ as q, a as xe } from "./Product.vue_vue_type_script_setup_true_lang-BOq8wMzq.js";
17
- import { L as X } from "./LinkProductSideSheet-abzVzmo3.js";
18
- import { _ as Fe } from "./TreeEditorOpenner.vue_vue_type_script_setup_true_lang-B2wC_Mf0.js";
19
- import { m as Ce } from "./toExcel-Bil8CwJs.js";
20
- const Me = { class: "space-y-24 mb-24" }, Ee = ["innerHTML"], Ie = { class: "flex justify-end gap-8" }, Te = /* @__PURE__ */ O({
21
- __name: "ConfirmActionDialog",
22
- props: {
23
- description: {},
24
- value: {},
25
- message: { default: "To confirm your action, type <b>[[value]]</b> in the text field." }
26
- },
27
- setup(F) {
28
- const e = F, i = I(() => e.message.replace("[[value]]", e.value)), a = Z(""), o = re(), { emitAction: r } = be();
29
- return (n, t) => {
30
- const c = N("FmTextField"), s = N("FmButton"), l = N("FmForm");
31
- return E(), T(l, {
32
- "on-validation-success": () => u(r)("primary"),
33
- "blame-form-child-on-validation-failed": ""
34
- }, {
35
- default: M(() => [
36
- C("div", Me, [
37
- C("div", null, Q(n.description), 1),
38
- C("div", { innerHTML: i.value }, null, 8, Ee),
39
- C("div", null, [
40
- w(c, {
41
- modelValue: a.value,
42
- "onUpdate:modelValue": [
43
- t[0] || (t[0] = (m) => a.value = m),
44
- t[1] || (t[1] = () => {
45
- })
46
- ],
47
- placeholder: n.value,
48
- rules: [(m) => m === n.value || "Value does not match"]
49
- }, null, 8, ["modelValue", "placeholder", "rules"])
50
- ]),
51
- C("div", Ie, [
52
- w(s, {
53
- label: "Cancel",
54
- variant: "secondary",
55
- onClick: t[2] || (t[2] = (m) => u(o).close())
56
- }),
57
- w(s, {
58
- label: "Confirm",
59
- type: "submit"
60
- })
61
- ])
62
- ])
63
- ]),
64
- _: 1
65
- }, 8, ["on-validation-success"]);
66
- };
67
- }
68
- }), Se = /* @__PURE__ */ O({
69
- __name: "Migrate",
70
- setup(F) {
71
- const e = oe(), i = fe(), a = ne(), { minor: o } = te(a), r = Z(!1), n = re();
72
- async function t() {
73
- c.value || r.value || n.open({
74
- title: "Migrate to new version",
75
- contentComponent: Te,
76
- contentComponentProps: {
77
- value: "MIGRATE",
78
- description: "Do you want to migrate to new version? Once migrate it will unable to revert to the older version."
79
- }
80
- }).onPrimary(async () => {
81
- n.close(), await o(
82
- async () => {
83
- await e.migrate(), setTimeout(() => {
84
- window.location.reload();
85
- }, 2e3);
86
- },
87
- {
88
- isLoading: r,
89
- customId: e.state.menu._id,
90
- message: "Migrating menu",
91
- successMessage: "Migration completed"
92
- }
93
- );
94
- });
95
- }
96
- const c = I(() => {
97
- const s = i.restaurants.value;
98
- if (!s.length) return "Required at least one restaurant to migrate";
99
- const l = s.filter((d) => !d.posVersion || !B.Pos.canUse({ feature: H.F_FEATURE.enum.menuV4, posVersion: d.posVersion }));
100
- return l.length ? `Upgrade POS to V${B.Pos.minVersionToUse(H.F_FEATURE.enum.menuV4)} to use new menu: ${l.map((d) => d.profile.name).join(", ")}` : null;
101
- });
102
- return I(() => c.value ? c.value : "Migrate your menu to new version to enjoy more features. Content of new menu will remain the same as current."), (s, l) => {
103
- const m = N("FmSnackbar");
104
- return !c.value && u(e).version !== u(ae.F_MENU_VERSION).enum.v4 ? (E(), T(m, {
105
- key: 0,
106
- class: "!max-w-full",
107
- title: "New version of menu is out now!",
108
- 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.",
109
- variant: "info",
110
- action: "Migrate",
111
- "z-index": 0,
112
- onOnAction: t
113
- })) : ee("", !0);
114
- };
115
- }
116
- });
117
- class De {
118
- constructor(e) {
119
- K(this, "menu");
120
- K(this, "categoryMap");
121
- K(this, "takeawayMap");
122
- this.menu = e, this.categoryMap = e.modules.category.reduce((i, a) => (i[a._id] = a, i), {}), this.takeawayMap = e.modules.takeaway.reduce((i, a) => (i[a._id] = a, i), {});
123
- }
124
- transformData() {
125
- let e = [], i = [];
126
- return this.menu.modules.item.forEach((a) => {
127
- var c;
128
- const o = a.variant ? G(this.menu, a.variant.variantGroupIds) : {}, r = this.transformProductToDataRow(a, o), t = (((c = a.variant) == null ? void 0 : c.variantCombinations) ?? []).reduce(
129
- (s, l) => {
130
- const m = this.transformProductToDataRow(
131
- a,
132
- o,
133
- l.combinationKey
134
- );
135
- return s.push(m), s;
136
- },
137
- [r]
138
- );
139
- i = [...i, ...t.flatMap((s) => Object.keys(s.tag))], e = [...e, ...t];
140
- }), {
141
- rows: e,
142
- metaData: {
143
- tags: [...new Set(i)],
144
- priceTiers: []
145
- }
146
- };
147
- }
148
- transformOverrideData(e) {
149
- let i = [], a = [], o = [];
150
- const r = e.reduce(
151
- (n, t) => (n[t._id] || (n[t._id] = []), t.combinationKey && n[t._id].push(t.combinationKey), n),
152
- {}
153
- );
154
- for (let n = 0; n < e.length; n++) {
155
- const t = e[n], c = this.menu.modules.item.find((s) => s._id === t._id);
156
- if (c && c.variant) {
157
- const s = c.variant.variantCombinations.map(
158
- (p) => p.combinationKey
159
- ), l = r[t._id] || [], m = s.filter((p) => !l.includes(p)), d = [];
160
- if (m.forEach((p) => {
161
- const x = c.variant.variantCombinations.find(
162
- (g) => g.combinationKey === p
163
- );
164
- x && (d.push({
165
- _id: t._id,
166
- combinationKey: p,
167
- price: x.price,
168
- orderFrom: x.orderFrom
169
- }), r[t._id].push(p));
170
- }), d.length > 0) {
171
- const p = e.findIndex((g) => g._id === t._id && !g.combinationKey), x = p >= 0 ? p + 1 : n + 1;
172
- e.splice(x, 0, ...d), n += d.length;
173
- }
174
- }
175
- }
176
- for (let n = 0; n < e.length; n++) {
177
- const t = e[n], c = this.menu.modules.item.find((d) => d._id === t._id);
178
- if (!c)
179
- throw new Error(`Invalid item ${t._id} in catalog`);
180
- const s = c.variant ? G(this.menu, c.variant.variantGroupIds) : {}, m = [this.transformOverrideDataToRow(t, s)];
181
- o = [...o, ...m.flatMap((d) => Object.keys(d.priceTier))], a = [...a, ...m.flatMap((d) => Object.keys(d.tag))], i = [...i, ...m];
182
- }
183
- return {
184
- rows: i,
185
- metaData: {
186
- tags: [...new Set(a)],
187
- priceTiers: []
188
- }
189
- };
190
- }
191
- transformProductToDataRow(e, i, a) {
192
- var t, c, s;
193
- const o = (t = e.variant) == null ? void 0 : t.variantCombinations.find(
194
- (l) => l.combinationKey === a
195
- );
196
- if (a && !o)
197
- throw new Error(`Invalid combination key ${a}`);
198
- const r = e.category ? (c = this.categoryMap[e.category]) == null ? void 0 : c.name : $;
199
- let n;
200
- if (o ? n = o.takeawayUsed ? this.takeawayMap[o.takeawayUsed] : void 0 : n = e.takeawayUsed ? this.takeawayMap[e.takeawayUsed] : void 0, !r)
201
- throw new Error(`Invalid category ${e.category}`);
202
- return {
203
- _id: e._id,
204
- code: o && o.code || e.code,
205
- name: e.name,
206
- variantKey: (o == null ? void 0 : o.combinationKey) ?? "",
207
- variantName: o ? i[o.combinationKey] : "",
208
- category: r,
209
- orderFrom: o ? o.orderFrom ?? e.orderFrom : e.orderFrom,
210
- perXUnit: e.perXUnit || "",
211
- unit: e.unit || "",
212
- openPrice: e.openPrice === !0 ? "T" : "",
213
- price: o ? o.price ? parseFloat(v(o.price)) : parseFloat(v(e.price)) : parseFloat(v(e.price)),
214
- priceTier: e.priceTiers || {},
215
- trackingCost: e.costing ? parseFloat(v(e.costing)) : "",
216
- minPrice: e.minPrice ? parseFloat(v(e.minPrice)) : "",
217
- groupByParent: ((s = e.print) == null ? void 0 : s.toRoot) === !0 ? "" : "T",
218
- takeawayName: (n == null ? void 0 : n.name) || "",
219
- takeawayPrice: n != null && n.price ? parseFloat(v(n == null ? void 0 : n.price)) : "",
220
- tag: e.customAttributes || {}
221
- };
222
- }
223
- transformOverrideDataToRow(e, i, a) {
224
- var c, s;
225
- const o = this.menu.modules.item.find((l) => l._id === e._id);
226
- if (!o)
227
- throw new Error(`Invalid item ${e._id} in catelog`);
228
- const r = (c = o.variant) == null ? void 0 : c.variantCombinations.find(
229
- (l) => l.combinationKey === e.combinationKey
230
- );
231
- if (a && !r)
232
- throw new Error(`Invalid combination key ${a}`);
233
- const n = () => {
234
- var l, m;
235
- return e.category ? e.category ? (m = this.categoryMap[e.category]) == null ? void 0 : m.name : $ : o.category ? (l = this.categoryMap[o.category]) == null ? void 0 : l.name : $;
236
- };
237
- let t;
238
- return r ? e.takeawayUsed ? t = e.takeawayUsed ? this.takeawayMap[e.takeawayUsed] : void 0 : t = r.takeawayUsed ? this.takeawayMap[r.takeawayUsed] : void 0 : e.takeawayUsed ? t = e.takeawayUsed ? this.takeawayMap[e.takeawayUsed] : void 0 : t = o.takeawayUsed ? this.takeawayMap[o.takeawayUsed] : void 0, {
239
- _id: e._id,
240
- code: e.code ? e.code : r && r.code || o.code,
241
- name: o.name,
242
- variantKey: e.combinationKey ? e.combinationKey : (r == null ? void 0 : r.combinationKey) ?? "",
243
- variantName: r ? i[r.combinationKey] : "",
244
- category: n(),
245
- orderFrom: e.orderFrom ? e.orderFrom : r ? r.orderFrom ?? o.orderFrom : o.orderFrom,
246
- perXUnit: o.perXUnit || "",
247
- unit: o.unit || "",
248
- openPrice: o.openPrice === !0 ? "T" : "",
249
- price: e.price ? parseFloat(v(e.price)) : r ? r.price ? parseFloat(v(r.price)) : parseFloat(v(o.price)) : parseFloat(v(o.price)),
250
- priceTier: o.priceTiers || {},
251
- trackingCost: o.costing ? parseFloat(v(o.costing)) : "",
252
- minPrice: e.minPrice ? parseFloat(v(e.minPrice)) : o.minPrice ? parseFloat(v(o.minPrice)) : "",
253
- groupByParent: ((s = o.print) == null ? void 0 : s.toRoot) === !0 ? "" : "T",
254
- takeawayName: (t == null ? void 0 : t.name) || "",
255
- takeawayPrice: t != null && t.price ? parseFloat(v(t == null ? void 0 : t.price)) : "",
256
- tag: o.customAttributes || {}
257
- };
258
- }
259
- transformAddonGroup() {
260
- return this.mapAddonGroup(this.menu.modules.group);
261
- }
262
- transformOverrideAddonGroup(e) {
263
- return this.mapCatalogAddonGroup(e);
264
- }
265
- mapCatalogAddonGroup(e) {
266
- const i = this.menu.modules.group.map((o) => o._id), a = e.map((o) => o._id);
267
- return i.forEach((o) => {
268
- if (!a.includes(o)) {
269
- const r = this.menu.modules.group.find((n) => n._id === o);
270
- e.push({
271
- ...r,
272
- groupKey: ""
273
- });
274
- }
275
- }), e.sort((o, r) => i.indexOf(o._id) - i.indexOf(r._id)), e.flatMap((o) => {
276
- const r = this.menu.modules.group.find((t) => t._id === o._id);
277
- if (!r)
278
- throw new Error("Invalid addon group id");
279
- const n = {};
280
- return r.items.map((t, c) => {
281
- var g, _, y;
282
- const s = this.menu.modules.item.find((b) => b._id === t._id);
283
- if (!s)
284
- throw new Error("Invalid item id");
285
- let l;
286
- t.combinationKey && (l = (g = s.variant) == null ? void 0 : g.variantCombinations.find(
287
- (b) => b.combinationKey === t.combinationKey
288
- ));
289
- const m = (_ = o.items) == null ? void 0 : _.find(
290
- (b) => b._id === t._id && b.combinationKey === t.combinationKey
291
- ), d = s.name, p = G(
292
- this.menu,
293
- ((y = s.variant) == null ? void 0 : y.variantGroupIds) ?? []
294
- ), x = (m == null ? void 0 : m.price) ?? t.price ?? (l == null ? void 0 : l.price) ?? s.price;
295
- return t.name && !t.combinationKey && (n[t._id] = t.name), {
296
- id: o._id,
297
- name: r.name,
298
- min: r.min,
299
- max: r.max,
300
- stackable: r.stackable === !0 ? "T" : "",
301
- itemId: t._id,
302
- itemCode: s.code || "",
303
- itemName: d,
304
- itemNameOverrider: n[t._id] || "",
305
- combinationKey: t.combinationKey ?? "",
306
- combinationName: t.combinationKey ? p[t.combinationKey] : "",
307
- price: parseFloat(v(x)),
308
- priceTier: t.priceTiers || {},
309
- orderFrom: (m == null ? void 0 : m.orderFrom) ?? t.orderFrom ?? s.orderFrom ?? "ALL",
310
- isDefault: t.isDefault === !0 ? "T" : "",
311
- index: c
312
- };
313
- });
314
- });
315
- }
316
- mapAddonGroup(e) {
317
- return e.flatMap((i) => {
318
- let a = {};
319
- return a = i.items.reduce((o, r) => (o[r._id] || r.name && !r.combinationKey && (o[r._id] = r.name), o), {}), i.items.map((o, r) => {
320
- var l, m;
321
- const n = this.menu.modules.item.find((d) => d._id === o._id);
322
- if (!n)
323
- throw new Error("Invalid item id");
324
- let t;
325
- o.combinationKey && (t = (l = n.variant) == null ? void 0 : l.variantCombinations.find(
326
- (d) => d.combinationKey === o.combinationKey
327
- ));
328
- const c = o.price ?? (t == null ? void 0 : t.price) ?? n.price, s = G(
329
- this.menu,
330
- ((m = n.variant) == null ? void 0 : m.variantGroupIds) ?? []
331
- );
332
- return {
333
- id: i._id,
334
- name: i.name,
335
- min: i.min,
336
- max: i.max,
337
- stackable: i.stackable === !0 ? "T" : "",
338
- itemId: o._id,
339
- itemCode: n.code || "",
340
- itemName: n.name,
341
- itemNameOverrider: a[o._id] || "",
342
- combinationKey: o.combinationKey ?? "",
343
- combinationName: o.combinationKey ? s[o.combinationKey] : "",
344
- price: parseFloat(v(c)),
345
- priceTier: o.priceTiers || {},
346
- orderFrom: o.orderFrom ?? n.orderFrom,
347
- isDefault: o.isDefault === !0 ? "T" : "",
348
- index: r
349
- };
350
- });
351
- });
352
- }
353
- transformItemsLinkWithGroup() {
354
- const e = {}, i = this.menu.modules.item.reduce((a, o) => (a[o._id] = {
355
- itemId: o._id,
356
- itemName: o.name,
357
- defaultCatalog: ""
358
- }, a), {});
359
- return this.menu.modules.group.forEach((a) => {
360
- e[a._id] = JSON.parse(JSON.stringify(i));
361
- }), this.menu.modules.item.forEach((a) => {
362
- a.groups.length > 0 && a.groups.forEach((o) => {
363
- e[o._id][a._id] = {
364
- ...e[o._id][a._id],
365
- defaultCatalog: "T"
366
- };
367
- });
368
- }), e;
369
- }
370
- exportToExcel() {
371
- var x;
372
- const e = [], { rows: i, metaData: a } = this.transformData();
373
- a.priceTiers = ((x = this.menu.priceTierSettings) == null ? void 0 : x.map((g) => g.key)) || [];
374
- const o = i.map(({ priceTier: g, tag: _, ...y }) => {
375
- const b = Object.entries(y), f = b.findIndex(([h]) => h === "price");
376
- return [
377
- ...b.slice(0, f + 1).map(([, h]) => h),
378
- ...a.priceTiers.map(
379
- (h) => parseFloat(v(g[h])) || ""
380
- ),
381
- ...b.slice(f + 1).map(([, h]) => h),
382
- ...a.tags.map((h) => _[h] || "")
383
- ];
384
- }), r = this.createWorkbookExcelJS(
385
- o,
386
- "Default Catalog",
387
- this.exportCatalogToExcelExcelJS()
388
- ), n = r.worksheets[0];
389
- W(n, a.tags, a.priceTiers), this.formatWorkbookCell(r);
390
- const c = this.transformAddonGroup().map(({ priceTier: g, ..._ }) => {
391
- const { index: y, ...b } = _, f = Object.entries(b), h = f.findIndex(([k]) => k === "price");
392
- return [
393
- ...f.slice(0, h + 1).map(([, k]) => k),
394
- ...a.priceTiers.map(
395
- (k) => parseFloat(v(g[k])) || ""
396
- ),
397
- ...f.slice(h + 1).map(([, k]) => k)
398
- ];
399
- }), s = this.createWorkbookExcelJS(
400
- c,
401
- "Default AddonGroup",
402
- this.exportCatalogAddonToExcelExcelJS()
403
- ), l = s.worksheets[0];
404
- j(l, a.priceTiers), this.formatWorkbookCell(s);
405
- const m = this.transformItemsLinkWithGroup(), d = Object.keys(m), p = new V.Workbook();
406
- if (d.length > 0)
407
- d.forEach((g, _) => {
408
- const y = Object.values(m[g]), b = this.menu.modules.group.find((k) => k._id === g);
409
- if (!b) throw new Error(`Group not found for id: ${g}`);
410
- const f = P(`${_ + 1}. ${b.name}`), h = p.addWorksheet(f);
411
- h.columns = [
412
- { header: "Group ID", key: "groupId" },
413
- { header: "Item ID", key: "itemId" },
414
- { header: "Item Name", key: "itemName" },
415
- { header: "Default Catalog", key: "defaultCatalog" }
416
- ], y.forEach((k) => {
417
- h.addRow({
418
- groupId: g,
419
- itemId: k.itemId,
420
- itemName: k.itemName,
421
- defaultCatalog: k.defaultCatalog
422
- });
423
- });
424
- });
425
- else {
426
- const g = p.addWorksheet("Group Name");
427
- g.columns = [
428
- { header: "Group ID", key: "groupId" },
429
- { header: "Item ID", key: "itemId" },
430
- { header: "Item Name", key: "itemName" },
431
- { header: "Default Catalog", key: "defaultCatalog" }
432
- ];
433
- }
434
- return this.formatWorkbookCell(p), e.push(r, s, p), e;
435
- }
436
- createWorkbookExcelJS(e, i, a) {
437
- const o = new V.Workbook(), r = o.addWorksheet(i);
438
- return e.forEach((n) => {
439
- r.addRow(n);
440
- }), a && a.worksheets.forEach((n) => {
441
- const t = o.addWorksheet(n.name);
442
- n.eachRow({ includeEmpty: !0 }, (c) => {
443
- const s = c.values;
444
- t.addRow(s.slice(1));
445
- });
446
- }), o;
447
- }
448
- formatWorkbookCell(e) {
449
- e.eachSheet((i) => {
450
- i.eachRow({ includeEmpty: !0 }, (o) => {
451
- o.eachCell({ includeEmpty: !0 }, (r) => {
452
- r.font = {
453
- name: "Calibri",
454
- size: 12
455
- }, o.number === 1 && (r.fill = {
456
- type: "pattern",
457
- pattern: "solid",
458
- fgColor: { argb: "FABF8F" }
459
- }, r.alignment = { horizontal: "center", vertical: "middle" });
460
- });
461
- });
462
- const a = i.getRow(1);
463
- i.autoFilter = {
464
- from: {
465
- row: 1,
466
- column: 1
467
- },
468
- to: {
469
- row: 1,
470
- column: a.cellCount
471
- }
472
- };
473
- });
474
- }
475
- exportCatalogToExcelExcelJS() {
476
- const e = new V.Workbook();
477
- return this.menu.modules.catalog.forEach((i) => {
478
- const a = Object.values(i.override.items).flatMap((s) => s), { rows: o, metaData: r } = this.transformOverrideData(a), n = o.map(({ priceTier: s, tag: l, ...m }) => [
479
- ...Object.entries(m).map(([, p]) => p),
480
- ...r.tags.map((p) => l[p] || "")
481
- ]), t = P(i.name), c = e.addWorksheet(t);
482
- n.forEach((s) => {
483
- c.addRow(s);
484
- }), W(c, r.tags, r.priceTiers, i);
485
- }), e;
486
- }
487
- exportCatalogAddonToExcelExcelJS() {
488
- const e = new V.Workbook();
489
- return this.menu.modules.catalog.forEach((i) => {
490
- const a = Object.values(i.override.groups).flatMap(
491
- (c) => c
492
- ), r = this.transformOverrideAddonGroup(a).map(({ priceTier: c, ...s }) => {
493
- const { index: l, ...m } = s;
494
- return [...Object.entries(m).map(([, p]) => p)];
495
- }), n = P(i.name), t = e.addWorksheet(n);
496
- r.forEach((c) => {
497
- t.addRow(c);
498
- }), j(t);
499
- }), e;
500
- }
501
- }
502
- const Ne = { class: "flex-1 flex justify-between gap-8 pl-8" }, Ke = { class: "flex items-center" }, Ge = { class: "bg-fm-color-neutral-gray-100 rounded-md px-8 py-4" }, Ve = { class: "fm-typo-en-body-md-600 font-semibold" }, $e = { class: "flex gap-8" }, eo = /* @__PURE__ */ O({
503
- __name: "Products",
504
- setup(F) {
505
- const { t: e } = ye(), i = te(ne()), a = oe(), o = I(() => a.rules.item), r = we(), n = I(() => !a.state.currentSchedulerId), t = ce(), c = me(), { selectedCategories: s } = ve(), l = I(() => ({
506
- ...pe.menuV4ToV3(J(a.state.menu)),
507
- _id: a.state.menu._id,
508
- _rev: a.state.menu._rev
509
- })), m = I(() => {
510
- const _ = L.flatten(s.value.map((y) => y.items));
511
- return L.uniqBy(_, (y) => y._id).length;
512
- });
513
- async function d(_, y) {
514
- const b = new ue();
515
- for (let h = 0; h < _.length; h++) {
516
- const k = await _[h].xlsx.writeBuffer();
517
- b.file(`${y[h]}.xlsx`, k);
518
- }
519
- const f = await b.generateAsync({ type: "blob" });
520
- de.saveAs(f, `books_${D().format("DD-MM-YYYY_HH-mm")}.zip`);
521
- }
522
- async function p() {
523
- await i.minor(
524
- async () => {
525
- if (await a.readMenu(), a.version === ae.F_MENU_VERSION.enum.v4) {
526
- const _ = J(a.state.menu), y = new De(_).exportToExcel(), b = [
527
- `menu_${D().format("DD-MM-YYYY_HH-mm")}`,
528
- `addonGroup_${D().format("DD-MM-YYYY_HH-mm")}`,
529
- `itemLinkedAddon${D().format("DD-MM-YYYY_HH-mm")}`
530
- ];
531
- d(y, b);
532
- } else {
533
- const _ = Ce(l.value), y = `menu_${D().format("DD-MM-YYYY_HH-mm")}`;
534
- await le(_, `${y}.xlsx`, {
535
- bookType: "xlsx",
536
- bookSST: !1,
537
- type: "array"
538
- });
539
- }
540
- },
541
- { successMessage: "Menu exported", customId: a.state.menu._id }
542
- );
543
- }
544
- const x = he(), g = I(() => x.breakpoints.value.xs);
545
- return ke().resetOnMount(), (_, y) => {
546
- const b = N("fm-button");
547
- return E(), T(_e, {
548
- heading: u(e)("menu.products.title")
549
- }, {
550
- default: M(() => [
551
- w(Se),
552
- w(xe)
553
- ]),
554
- "append-heading": M(() => [
555
- C("div", Ne, [
556
- C("div", Ke, [
557
- C("div", Ge, [
558
- C("p", Ve, Q(m.value), 1)
559
- ])
560
- ]),
561
- C("div", $e, [
562
- g.value ? (E(), T(q, { key: 1 }, {
563
- default: M(({ trigger: f }) => [
564
- w(ge, null, {
565
- default: M(() => [
566
- w(z, {
567
- label: u(e)("menu.products.actions.export"),
568
- onClick: p
569
- }, null, 8, ["label"]),
570
- w(z, {
571
- label: u(e)("menu.products.actions.import"),
572
- onClick: f
573
- }, null, 8, ["label", "onClick"])
574
- ]),
575
- _: 2
576
- }, 1024)
577
- ]),
578
- _: 1
579
- })) : (E(), U(Y, { key: 0 }, [
580
- w(Fe, null, {
581
- default: M(({ trigger: f }) => [
582
- w(b, {
583
- label: u(e)("menu.tree_editor.title"),
584
- "bg-color": u(S).NeutralGray100,
585
- "text-color": u(S).TypoSecondary,
586
- variant: u(A).Primary,
587
- onClick: f
588
- }, null, 8, ["label", "bg-color", "text-color", "variant", "onClick"])
589
- ]),
590
- _: 1
591
- }),
592
- w(b, {
593
- "bg-color": u(S).NeutralGray100,
594
- "text-color": u(S).TypoSecondary,
595
- variant: u(A).Primary,
596
- label: u(e)("menu.products.actions.export"),
597
- onClick: p
598
- }, null, 8, ["bg-color", "text-color", "variant", "label"]),
599
- w(q, null, {
600
- default: M(({ trigger: f }) => [
601
- w(b, {
602
- "bg-color": u(S).NeutralGray100,
603
- "text-color": u(S).TypoSecondary,
604
- variant: u(A).Primary,
605
- label: u(e)("menu.products.actions.import"),
606
- onClick: f
607
- }, null, 8, ["bg-color", "text-color", "variant", "label", "onClick"])
608
- ]),
609
- _: 1
610
- })
611
- ], 64)),
612
- m.value > 0 ? (E(), U(Y, { key: 2 }, [
613
- o.value.create ? (E(), T(R, {
614
- key: 0,
615
- label: u(e)("menu.products.actions.add"),
616
- "prepend-icon": "add",
617
- onClick: y[0] || (y[0] = (f) => u(r).create(null))
618
- }, null, 8, ["label"])) : n.value ? (E(), T(X, {
619
- key: 1,
620
- "categorized-items": u(t).linkableItems.value,
621
- "initial-value": u(t).currentItems.value,
622
- "show-variant": !1,
623
- onSubmit: y[1] || (y[1] = (f) => u(t).applyProduct(f.map((h) => h._id)))
624
- }, {
625
- default: M(({ trigger: f }) => [
626
- w(R, {
627
- label: u(e)("menu.products.actions.link"),
628
- "prepend-icon": "link",
629
- onClick: f
630
- }, null, 8, ["label", "onClick"])
631
- ]),
632
- _: 1
633
- }, 8, ["categorized-items", "initial-value"])) : (E(), T(X, {
634
- key: 2,
635
- "categorized-items": u(c).linkableItems.value,
636
- "initial-value": u(c).currentItems.value,
637
- "show-variant": !1,
638
- onSubmit: y[2] || (y[2] = (f) => u(c).applyProduct(f.map((h) => h._id)))
639
- }, {
640
- default: M(({ trigger: f }) => [
641
- w(R, {
642
- label: u(e)("menu.products.actions.apply_scheduler"),
643
- onClick: f
644
- }, null, 8, ["label", "onClick"])
645
- ]),
646
- _: 1
647
- }, 8, ["categorized-items", "initial-value"]))
648
- ], 64)) : ee("", !0)
649
- ])
650
- ])
651
- ]),
652
- _: 1
653
- }, 8, ["heading"]);
654
- };
655
- }
656
- });
657
- export {
658
- eo as default
659
- };