@feedmepos/mf-menu 0.32.3-beta.1 → 0.32.4-dev

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 (84) hide show
  1. package/dist/{App-DJBZBaaC.js → App-5YVGeojR.js} +5 -5
  2. package/dist/{ApplyProduct.vue_vue_type_script_setup_true_lang-c9SlmPp2.js → ApplyProduct.vue_vue_type_script_setup_true_lang-DhoHYIHW.js} +20 -20
  3. package/dist/{Catalog-Ct9jk3A_.js → Catalog-BTNv5n_D.js} +18 -18
  4. package/dist/{Category-Cf5KfKdv.js → Category-BE-kkKcL.js} +22 -23
  5. package/dist/{Category-CTTAtG31.js → Category-DuLhbRxE.js} +21 -22
  6. package/dist/{CookingGuide-BaNzajgf.js → CookingGuide-JtE8QMC6.js} +92 -93
  7. package/dist/{CustomAttributeChip.vue_vue_type_script_setup_true_lang-CRodr6tr.js → CustomAttributeChip.vue_vue_type_script_setup_true_lang-DdJ-o_PW.js} +1 -1
  8. package/dist/FormItem.vue_vue_type_script_setup_true_lang-B3Ixruh-.js +26 -0
  9. package/dist/{Group-BfRPCCbK.js → Group-BP-j3K6J.js} +1 -1
  10. package/dist/{Group-BJep-xq-.js → Group-DhS9e2E3.js} +3 -3
  11. package/dist/{Group.vue_vue_type_script_setup_true_lang-CoCq0edM.js → Group.vue_vue_type_script_setup_true_lang-DXUQrXXI.js} +33 -34
  12. package/dist/{GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-DviXfima.js → GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-CXzz4ClS.js} +24 -23
  13. package/dist/{ImportProductDialog.vue_vue_type_script_setup_true_lang-DSrxcKIK.js → ImportProductDialog.vue_vue_type_script_setup_true_lang-Bpt-8tbe.js} +11525 -11504
  14. package/dist/{Ingredient-BnzW69zW.js → Ingredient-NSl0x-0T.js} +5 -6
  15. package/dist/{InventoryBinding.vue_vue_type_script_setup_true_lang-D8m1pyLp.js → InventoryBinding.vue_vue_type_script_setup_true_lang-ByrNVvzs.js} +2 -2
  16. package/dist/LinkProductSideSheet-B_R_2iH6.js +692 -0
  17. package/dist/MenuSetting-C7cpv4S3.js +580 -0
  18. package/dist/{PrintRoute-CLsiDIkn.js → PrintRoute-DmP7KH58.js} +10 -11
  19. package/dist/{Product-DHE0XtX1.js → Product-B6gwN4g0.js} +1 -1
  20. package/dist/{Product.vue_vue_type_script_setup_true_lang-CVR8j-XT.js → Product.vue_vue_type_script_setup_true_lang-BKhn8Txf.js} +15 -16
  21. package/dist/{ProductInternalTools-BQOXHzYp.js → ProductInternalTools-D5xIh2j2.js} +5 -5
  22. package/dist/Products-Cxx8pJGK.js +692 -0
  23. package/dist/{Publish-BlEcoJaI.js → Publish-ZCzRBB5V.js} +21 -22
  24. package/dist/{Recipe-CkcNxf7p.js → Recipe-DcHdr_5J.js} +9 -10
  25. package/dist/RuleView.vue_vue_type_script_setup_true_lang-edNbsZTq.js +3282 -0
  26. package/dist/{Scheduler-DV0s_qkV.js → Scheduler-ZhDXk5gQ.js} +18 -19
  27. package/dist/{ServingSequence-CFd8Nwws.js → ServingSequence-DcfMbHjn.js} +15 -16
  28. package/dist/{Setting-B55IsZCX.js → Setting-fqf_sOIc.js} +45 -44
  29. package/dist/{Subcategory-BXCcVdR3.js → Subcategory-BidmfEOK.js} +18 -19
  30. package/dist/{Takeaway-BDvcwBHP.js → Takeaway-C83SKEvl.js} +1 -1
  31. package/dist/{Takeaway--U_lsgYi.js → Takeaway-p6thRg74.js} +4 -4
  32. package/dist/{Takeaway.vue_vue_type_script_setup_true_lang-DaYk2xdF.js → Takeaway.vue_vue_type_script_setup_true_lang-Dq6CjXCv.js} +48 -49
  33. package/dist/{Thumbnail.vue_vue_type_script_setup_true_lang-VBpTghy9.js → Thumbnail.vue_vue_type_script_setup_true_lang-CjLOy2k9.js} +10 -10
  34. package/dist/{TreeEditorOpenner.vue_vue_type_script_setup_true_lang-IBM6rC5M.js → TreeEditorOpenner.vue_vue_type_script_setup_true_lang-CWdsp9eo.js} +17 -16
  35. package/dist/{Unit-DkvTsQWA.js → Unit-CKIaBxVE.js} +7 -8
  36. package/dist/{Variant-tte76SbR.js → Variant-CE21vKC4.js} +38 -39
  37. package/dist/{_id_-AVMi3j91.js → _id_-BhWpg9Kj.js} +10 -10
  38. package/dist/{app-0s3jY-aE.js → app-BkcVM9nE.js} +1 -1
  39. package/dist/app-CEIhTuYG.js +363 -0
  40. package/dist/app.js +1 -1
  41. package/dist/apps/mf-menu/src/app.d.ts +250 -0
  42. package/dist/apps/mf-menu/src/components/rule_group/CatalogLinkItemRuleForm.vue.d.ts +146 -0
  43. package/dist/apps/mf-menu/src/components/rule_group/CatalogLinkItemRuleView.vue.d.ts +158 -0
  44. package/dist/apps/mf-menu/src/components/rule_group/RuleCondition.vue.d.ts +103 -0
  45. package/dist/apps/mf-menu/src/components/rule_group/RuleConditionListView.vue.d.ts +54 -0
  46. package/dist/apps/mf-menu/src/components/rule_group/RuleConditionSelector.vue.d.ts +50 -0
  47. package/dist/apps/mf-menu/src/components/rule_group/RuleForm.vue.d.ts +117 -0
  48. package/dist/apps/mf-menu/src/components/rule_group/RuleView.vue.d.ts +141 -0
  49. package/dist/apps/mf-menu/src/composable/attributes.d.ts +10 -0
  50. package/dist/apps/mf-menu/src/helper/import-export-utils.d.ts +2 -3
  51. package/dist/apps/mf-menu/src/helper/menuExport.d.ts +3 -1
  52. package/dist/apps/mf-menu/src/helper/menuImport.d.ts +3 -2
  53. package/dist/apps/mf-menu/tsconfig.app.tsbuildinfo +1 -1
  54. package/dist/assets/{linked-status-DEGoFflv.js → linked-status-CStQ46Ze.js} +2 -2
  55. package/dist/assets/{override-menu-CZe07SCm.js → override-menu-DHTQAnIJ.js} +2 -2
  56. package/dist/assets/{validate-menu-BnHfAUEN.js → validate-menu-C_kUDOhd.js} +2 -2
  57. package/dist/{catalog-YE_knev1.js → catalog-WBrPmQwl.js} +1 -1
  58. package/dist/{catalogSetting-CeVHRHOo.js → catalogSetting-BAry7I_V.js} +1 -1
  59. package/dist/{category-Dph1iWr8.js → category-bW36h16p.js} +1 -1
  60. package/dist/{currency-Byslycrk.js → currency-vVxHIVBs.js} +1 -1
  61. package/dist/{index-C0T32LLy.js → index-Ba5-dCQA.js} +1 -1
  62. package/dist/{index-CUTY6cCm.js → index-C0EV3eSc.js} +20 -20
  63. package/dist/{index-DycbrG1l.js → index-XZlEgR2k.js} +8 -7
  64. package/dist/{index-Ddt_Nw9F.js → index-pxnQHVnU.js} +4 -4
  65. package/dist/{menu-tHhzkxDL.js → index.vue_vue_type_script_setup_true_lang-CFPMPQFg.js} +18612 -18558
  66. package/dist/item-mFv0bFSn.js +7648 -0
  67. package/dist/{iteration-CcobmcUk.js → iteration-CaFp1Rtz.js} +3 -3
  68. package/dist/{jszip.min-DQrtMdm5.js → jszip.min-BkSmQKmf.js} +353 -353
  69. package/dist/{menu-DkRrqTVY.js → menu-ud-tWfIM.js} +1 -1
  70. package/dist/{menuV2-DJevKCqE.js → menuV2-xUMdUls0.js} +65 -65
  71. package/dist/mf-menu.css +1 -1
  72. package/dist/{priceTier-Bkogs1qc.js → priceTier-BVTab4k1.js} +1 -1
  73. package/dist/{scheduler-BGQ_lxUL.js → scheduler-CAt7sELO.js} +13 -12
  74. package/dist/{subcategory-DvxvLe8X.js → subcategory-DMZuedoM.js} +2 -2
  75. package/dist/{toExcel-DQ4jlZPI.js → toExcel-CczXOnKy.js} +2 -2
  76. package/dist/{unit-DoxpI5dG.js → unit-CbD3sYqC.js} +2 -2
  77. package/package.json +4 -3
  78. package/dist/LinkProductSideSheet-C4yBnJSM.js +0 -361
  79. package/dist/MenuSetting-Fxl8F6N5.js +0 -618
  80. package/dist/Products-BLvwrz9P.js +0 -689
  81. package/dist/app-CjfWVFOg.js +0 -363
  82. package/dist/customAttributes-DvbvCfOd.js +0 -180
  83. package/dist/index.vue_vue_type_script_setup_true_lang-B1_JqsYF.js +0 -57
  84. package/dist/item-x1WWjISR.js +0 -9175
@@ -1,689 +0,0 @@
1
- var le = Object.defineProperty;
2
- var ue = (k, e, i) => e in k ? le(k, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : k[e] = i;
3
- var K = (k, e, i) => ue(k, typeof e != "symbol" ? e + "" : e, i);
4
- import { defineComponent as W, computed as S, ref as te, resolveComponent as V, createBlock as D, openBlock as E, unref as l, withCtx as I, createElementVNode as M, toDisplayString as oe, createVNode as _, createCommentVNode as ae, createElementBlock as j, Fragment as B } from "vue";
5
- import { D as G } from "./iteration-CcobmcUk.js";
6
- import { m as R, A as P, f as h, a as H, b as L, e as A, n as O, w as de } from "./ImportProductDialog.vue_vue_type_script_setup_true_lang-DSrxcKIK.js";
7
- import { J as pe, F as fe } from "./jszip.min-DQrtMdm5.js";
8
- import { u as re, D as ne, A as J, G as z, z as ie, B as be, H as q, I as X } from "./menu-tHhzkxDL.js";
9
- import { useCoreStore as ge, useI18n as he } from "@feedmepos/mf-common";
10
- import { useDialog as se, useDialogChild as ye, useSnackbar as ce, useBreakpoints as _e, FmButtonVariant as U, FmButtonColorThemeVariant as N } from "@feedmepos/ui-library";
11
- import { _ as Y } from "./ResponsiveFabButton.vue_vue_type_script_setup_true_lang-Cn-3MRBO.js";
12
- import { _ as ke, a as Z } from "./BottomSheetMenuItem.vue_vue_type_script_setup_true_lang-CnCoRLDg.js";
13
- import { _ as ve } from "./PageLayout.vue_vue_type_script_setup_true_lang-vFqWGM6P.js";
14
- import { u as we, a as xe } from "./menu-DkRrqTVY.js";
15
- import { u as Ce } from "./item-x1WWjISR.js";
16
- import { _ as Q, a as Fe } from "./Product.vue_vue_type_script_setup_true_lang-CVR8j-XT.js";
17
- import { L as ee } from "./LinkProductSideSheet-C4yBnJSM.js";
18
- import { _ as Me } from "./TreeEditorOpenner.vue_vue_type_script_setup_true_lang-IBM6rC5M.js";
19
- import { u as Ie } from "./Thumbnail.vue_vue_type_script_setup_true_lang-VBpTghy9.js";
20
- import { m as Ee } from "./toExcel-DQ4jlZPI.js";
21
- const Te = { class: "space-y-24 mb-24" }, Se = ["innerHTML"], De = { class: "flex justify-end gap-8" }, Ne = /* @__PURE__ */ W({
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(k) {
29
- const e = k, i = S(() => e.message.replace("[[value]]", e.value)), a = te(""), t = se(), { emitAction: r } = ye();
30
- return (n, o) => {
31
- const m = V("FmTextField"), s = V("FmButton"), d = V("FmForm");
32
- return E(), D(d, {
33
- "on-validation-success": () => l(r)("primary"),
34
- "blame-form-child-on-validation-failed": ""
35
- }, {
36
- default: I(() => [
37
- M("div", Te, [
38
- M("div", null, oe(k.description), 1),
39
- M("div", { innerHTML: i.value }, null, 8, Se),
40
- M("div", null, [
41
- _(m, {
42
- modelValue: a.value,
43
- "onUpdate:modelValue": [
44
- o[0] || (o[0] = (c) => a.value = c),
45
- o[1] || (o[1] = () => {
46
- })
47
- ],
48
- placeholder: k.value,
49
- rules: [(c) => c === k.value || "Value does not match"]
50
- }, null, 8, ["modelValue", "placeholder", "rules"])
51
- ]),
52
- M("div", De, [
53
- _(s, {
54
- label: "Cancel",
55
- variant: "secondary",
56
- onClick: o[2] || (o[2] = (c) => l(t).close())
57
- }),
58
- _(s, {
59
- label: "Confirm",
60
- type: "submit"
61
- })
62
- ])
63
- ])
64
- ]),
65
- _: 1
66
- }, 8, ["on-validation-success"]);
67
- };
68
- }
69
- }), Ke = /* @__PURE__ */ W({
70
- __name: "Migrate",
71
- setup(k) {
72
- const e = re(), i = ge(), a = ce(), { minor: t } = ne(a), r = te(!1), n = se();
73
- async function o() {
74
- m.value || r.value || n.open({
75
- title: "Migrate to new version",
76
- contentComponent: Ne,
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
- n.close(), await t(
83
- async () => {
84
- await e.migrate(), setTimeout(() => {
85
- window.location.reload();
86
- }, 2e3);
87
- },
88
- {
89
- isLoading: r,
90
- customId: e.state.menu._id,
91
- message: "Migrating menu",
92
- successMessage: "Migration completed"
93
- }
94
- );
95
- });
96
- }
97
- const m = S(() => {
98
- const s = i.restaurants.value;
99
- if (!s.length) return "Required at least one restaurant to migrate";
100
- const d = s.filter((u) => !u.posVersion || !J.Pos.canUse({ feature: z.F_FEATURE.enum.menuV4, posVersion: u.posVersion }));
101
- return d.length ? `Upgrade POS to V${J.Pos.minVersionToUse(z.F_FEATURE.enum.menuV4)} to use new menu: ${d.map((u) => u.profile.name).join(", ")}` : null;
102
- });
103
- return S(() => m.value ? m.value : "Migrate your menu to new version to enjoy more features. Content of new menu will remain the same as current."), (s, d) => {
104
- const c = V("FmSnackbar");
105
- return !m.value && l(e).version !== l(ie.F_MENU_VERSION).enum.v4 ? (E(), D(c, {
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: o
114
- })) : ae("", !0);
115
- };
116
- }
117
- });
118
- class Ge {
119
- constructor(e) {
120
- K(this, "menu");
121
- K(this, "categoryMap");
122
- K(this, "takeawayMap");
123
- K(this, "subCategoryMap");
124
- this.menu = e, this.categoryMap = e.modules.category.reduce((a, t) => (a[t._id] = t, a), {}), this.takeawayMap = e.modules.takeaway.reduce((a, t) => (a[t._id] = t, a), {});
125
- const i = e.modules.subCategory || [];
126
- this.subCategoryMap = i.reduce((a, t) => (a[t._id] = t, a), {});
127
- }
128
- transformData() {
129
- let e = [], i = [];
130
- return this.menu.modules.item.forEach((a) => {
131
- var m;
132
- const t = a.variant ? R(this.menu, a.variant.variantGroupIds) : {}, r = this.transformProductToDataRow(a, t), o = (((m = a.variant) == null ? void 0 : m.variantCombinations) ?? []).reduce(
133
- (s, d) => {
134
- const c = this.transformProductToDataRow(
135
- a,
136
- t,
137
- d.combinationKey
138
- );
139
- return s.push(c), s;
140
- },
141
- [r]
142
- );
143
- i = [...i, ...o.flatMap((s) => Object.keys(s.tag))], e = [...e, ...o];
144
- }), {
145
- rows: e,
146
- metaData: {
147
- tags: [...new Set(i)],
148
- priceTiers: []
149
- }
150
- };
151
- }
152
- transformOverrideData(e) {
153
- let i = [], a = [], t = [];
154
- const r = e.reduce(
155
- (n, o) => (n[o._id] || (n[o._id] = []), o.combinationKey && n[o._id].push(o.combinationKey), n),
156
- {}
157
- );
158
- for (let n = 0; n < e.length; n++) {
159
- const o = e[n], m = this.menu.modules.item.find((s) => s._id === o._id);
160
- if (m && m.variant) {
161
- const s = m.variant.variantCombinations.map(
162
- (p) => p.combinationKey
163
- ), d = r[o._id] || [], c = s.filter((p) => !d.includes(p)), u = [];
164
- if (c.forEach((p) => {
165
- const v = m.variant.variantCombinations.find(
166
- (g) => g.combinationKey === p
167
- );
168
- v && (u.push({
169
- _id: o._id,
170
- combinationKey: p,
171
- price: v.price,
172
- orderFrom: v.orderFrom
173
- }), r[o._id].push(p));
174
- }), u.length > 0) {
175
- const p = e.findIndex((g) => g._id === o._id && !g.combinationKey), v = p >= 0 ? p + 1 : n + 1;
176
- e.splice(v, 0, ...u), n += u.length;
177
- }
178
- }
179
- }
180
- for (let n = 0; n < e.length; n++) {
181
- const o = e[n], m = this.menu.modules.item.find((u) => u._id === o._id);
182
- if (!m)
183
- throw new Error(`Invalid item ${o._id} in catalog`);
184
- const s = m.variant ? R(this.menu, m.variant.variantGroupIds) : {}, c = [this.transformOverrideDataToRow(o, s)];
185
- t = [...t, ...c.flatMap((u) => Object.keys(u.priceTier))], a = [...a, ...c.flatMap((u) => Object.keys(u.tag))], i = [...i, ...c];
186
- }
187
- return {
188
- rows: i,
189
- metaData: {
190
- tags: [...new Set(a)],
191
- priceTiers: []
192
- }
193
- };
194
- }
195
- getSubCategoryNames(e, i) {
196
- return i || !e.subCategories ? "" : e.subCategories.map((a) => {
197
- var t;
198
- return ((t = this.subCategoryMap[a]) == null ? void 0 : t.name) || "";
199
- }).filter((a) => a).join(",");
200
- }
201
- transformProductToDataRow(e, i, a) {
202
- var m, s, d;
203
- const t = (m = e.variant) == null ? void 0 : m.variantCombinations.find(
204
- (c) => c.combinationKey === a
205
- );
206
- if (a && !t)
207
- throw new Error(`Invalid combination key ${a}`);
208
- const r = e.category ? (s = this.categoryMap[e.category]) == null ? void 0 : s.name : P;
209
- let n;
210
- if (t ? n = t.takeawayUsed ? this.takeawayMap[t.takeawayUsed] : void 0 : n = e.takeawayUsed ? this.takeawayMap[e.takeawayUsed] : void 0, !r)
211
- throw new Error(`Invalid category ${e.category}`);
212
- const o = this.getSubCategoryNames(e, !!t);
213
- return {
214
- _id: e._id,
215
- code: t && t.code || e.code,
216
- name: e.name,
217
- variantKey: (t == null ? void 0 : t.combinationKey) ?? "",
218
- variantName: t ? i[t.combinationKey] : "",
219
- category: r,
220
- subCategories: o,
221
- orderFrom: t ? t.orderFrom ?? e.orderFrom : e.orderFrom,
222
- perXUnit: e.perXUnit || "",
223
- unit: e.unit || "",
224
- openPrice: e.openPrice === !0 ? "T" : "",
225
- price: t ? t.price ? parseFloat(h(t.price)) : parseFloat(h(e.price)) : parseFloat(h(e.price)),
226
- priceTier: e.priceTiers || {},
227
- trackingCost: e.costing ? parseFloat(h(e.costing)) : "",
228
- minPrice: e.minPrice ? parseFloat(h(e.minPrice)) : "",
229
- groupByParent: ((d = e.print) == null ? void 0 : d.toRoot) === !0 ? "" : "T",
230
- takeawayName: (n == null ? void 0 : n.name) || "",
231
- takeawayPrice: n != null && n.price ? parseFloat(h(n == null ? void 0 : n.price)) : "",
232
- tag: e.customAttributes || {}
233
- };
234
- }
235
- transformOverrideDataToRow(e, i, a) {
236
- var s, d;
237
- const t = this.menu.modules.item.find((c) => c._id === e._id);
238
- if (!t)
239
- throw new Error(`Invalid item ${e._id} in catelog`);
240
- const r = (s = t.variant) == null ? void 0 : s.variantCombinations.find(
241
- (c) => c.combinationKey === e.combinationKey
242
- );
243
- if (a && !r)
244
- throw new Error(`Invalid combination key ${a}`);
245
- const n = () => {
246
- var c, u;
247
- return e.category ? e.category ? (u = this.categoryMap[e.category]) == null ? void 0 : u.name : P : t.category ? (c = this.categoryMap[t.category]) == null ? void 0 : c.name : P;
248
- };
249
- let o;
250
- r ? e.takeawayUsed ? o = e.takeawayUsed ? this.takeawayMap[e.takeawayUsed] : void 0 : o = r.takeawayUsed ? this.takeawayMap[r.takeawayUsed] : void 0 : e.takeawayUsed ? o = e.takeawayUsed ? this.takeawayMap[e.takeawayUsed] : void 0 : o = t.takeawayUsed ? this.takeawayMap[t.takeawayUsed] : void 0;
251
- const m = this.getSubCategoryNames(e, !!r);
252
- return {
253
- _id: e._id,
254
- code: e.code ? e.code : r && r.code || t.code,
255
- name: t.name,
256
- variantKey: e.combinationKey ? e.combinationKey : (r == null ? void 0 : r.combinationKey) ?? "",
257
- variantName: r ? i[r.combinationKey] : "",
258
- category: n(),
259
- subCategories: m,
260
- orderFrom: e.orderFrom ? e.orderFrom : r ? r.orderFrom ?? t.orderFrom : t.orderFrom,
261
- perXUnit: t.perXUnit || "",
262
- unit: t.unit || "",
263
- openPrice: t.openPrice === !0 ? "T" : "",
264
- price: e.price ? parseFloat(h(e.price)) : r ? r.price ? parseFloat(h(r.price)) : parseFloat(h(t.price)) : parseFloat(h(t.price)),
265
- priceTier: t.priceTiers || {},
266
- trackingCost: t.costing ? parseFloat(h(t.costing)) : "",
267
- minPrice: e.minPrice ? parseFloat(h(e.minPrice)) : t.minPrice ? parseFloat(h(t.minPrice)) : "",
268
- groupByParent: ((d = t.print) == null ? void 0 : d.toRoot) === !0 ? "" : "T",
269
- takeawayName: (o == null ? void 0 : o.name) || "",
270
- takeawayPrice: o != null && o.price ? parseFloat(h(o == null ? void 0 : o.price)) : "",
271
- tag: t.customAttributes || {}
272
- };
273
- }
274
- transformAddonGroup() {
275
- return this.mapAddonGroup(this.menu.modules.group);
276
- }
277
- transformOverrideAddonGroup(e) {
278
- return this.mapCatalogAddonGroup(e);
279
- }
280
- mapCatalogAddonGroup(e) {
281
- const i = this.menu.modules.group.map((t) => t._id), a = e.map((t) => t._id);
282
- return i.forEach((t) => {
283
- if (!a.includes(t)) {
284
- const r = this.menu.modules.group.find((n) => n._id === t);
285
- e.push({
286
- ...r,
287
- groupKey: ""
288
- });
289
- }
290
- }), e.sort((t, r) => i.indexOf(t._id) - i.indexOf(r._id)), e.flatMap((t) => {
291
- const r = this.menu.modules.group.find((o) => o._id === t._id);
292
- if (!r)
293
- throw new Error("Invalid addon group id");
294
- const n = {};
295
- return r.items.map((o, m) => {
296
- var g, x, C;
297
- const s = this.menu.modules.item.find((y) => y._id === o._id);
298
- if (!s)
299
- throw new Error("Invalid item id");
300
- let d;
301
- o.combinationKey && (d = (g = s.variant) == null ? void 0 : g.variantCombinations.find(
302
- (y) => y.combinationKey === o.combinationKey
303
- ));
304
- const c = (x = t.items) == null ? void 0 : x.find(
305
- (y) => y._id === o._id && y.combinationKey === o.combinationKey
306
- ), u = s.name, p = R(
307
- this.menu,
308
- ((C = s.variant) == null ? void 0 : C.variantGroupIds) ?? []
309
- ), v = (c == null ? void 0 : c.price) ?? o.price ?? (d == null ? void 0 : d.price) ?? s.price;
310
- return o.name && !o.combinationKey && (n[o._id] = o.name), {
311
- id: t._id,
312
- name: r.name,
313
- min: r.min,
314
- max: r.max,
315
- stackable: r.stackable === !0 ? "T" : "",
316
- itemId: o._id,
317
- itemCode: s.code || "",
318
- itemName: u,
319
- itemNameOverrider: n[o._id] || "",
320
- combinationKey: o.combinationKey ?? "",
321
- combinationName: o.combinationKey ? p[o.combinationKey] : "",
322
- price: parseFloat(h(v)),
323
- priceTier: o.priceTiers || {},
324
- orderFrom: (c == null ? void 0 : c.orderFrom) ?? o.orderFrom ?? s.orderFrom ?? "ALL",
325
- isDefault: o.isDefault === !0 ? "T" : "",
326
- index: m
327
- };
328
- });
329
- });
330
- }
331
- mapAddonGroup(e) {
332
- return e.flatMap((i) => {
333
- let a = {};
334
- return a = i.items.reduce((t, r) => (t[r._id] || r.name && !r.combinationKey && (t[r._id] = r.name), t), {}), i.items.map((t, r) => {
335
- var d, c;
336
- const n = this.menu.modules.item.find((u) => u._id === t._id);
337
- if (!n)
338
- throw new Error("Invalid item id");
339
- let o;
340
- t.combinationKey && (o = (d = n.variant) == null ? void 0 : d.variantCombinations.find(
341
- (u) => u.combinationKey === t.combinationKey
342
- ));
343
- const m = t.price ?? (o == null ? void 0 : o.price) ?? n.price, s = R(
344
- this.menu,
345
- ((c = n.variant) == null ? void 0 : c.variantGroupIds) ?? []
346
- );
347
- return {
348
- id: i._id,
349
- name: i.name,
350
- min: i.min,
351
- max: i.max,
352
- stackable: i.stackable === !0 ? "T" : "",
353
- itemId: t._id,
354
- itemCode: n.code || "",
355
- itemName: n.name,
356
- itemNameOverrider: a[t._id] || "",
357
- combinationKey: t.combinationKey ?? "",
358
- combinationName: t.combinationKey ? s[t.combinationKey] : "",
359
- price: parseFloat(h(m)),
360
- priceTier: t.priceTiers || {},
361
- orderFrom: t.orderFrom ?? n.orderFrom,
362
- isDefault: t.isDefault === !0 ? "T" : "",
363
- index: r
364
- };
365
- });
366
- });
367
- }
368
- transformItemsLinkWithGroup() {
369
- const e = {}, i = this.menu.modules.item.reduce((a, t) => (a[t._id] = {
370
- itemId: t._id,
371
- itemName: t.name,
372
- defaultCatalog: ""
373
- }, a), {});
374
- return this.menu.modules.group.forEach((a) => {
375
- e[a._id] = JSON.parse(JSON.stringify(i));
376
- }), this.menu.modules.item.forEach((a) => {
377
- a.groups.length > 0 && a.groups.forEach((t) => {
378
- e[t._id][a._id] = {
379
- ...e[t._id][a._id],
380
- defaultCatalog: "T"
381
- };
382
- });
383
- }), e;
384
- }
385
- exportToExcel() {
386
- var v;
387
- const e = [], { rows: i, metaData: a } = this.transformData();
388
- a.priceTiers = ((v = this.menu.priceTierSettings) == null ? void 0 : v.map((g) => g.key)) || [];
389
- const t = i.map(({ priceTier: g, tag: x, ...C }) => {
390
- const y = Object.entries(C), F = y.findIndex(([b]) => b === "price");
391
- return [
392
- ...y.slice(0, F + 1).map(([, b]) => b),
393
- ...a.priceTiers.map(
394
- (b) => parseFloat(h(g[b])) || ""
395
- ),
396
- ...y.slice(F + 1).map(([, b]) => b),
397
- ...a.tags.map((b) => x[b] || "")
398
- ];
399
- }), r = this.createWorkbookExcelJS(
400
- t,
401
- "Default Catalog",
402
- this.exportCatalogToExcelExcelJS()
403
- ), n = r.worksheets[0];
404
- H(n, a.tags, a.priceTiers), this.formatWorkbookCell(r);
405
- const m = this.transformAddonGroup().map(({ priceTier: g, ...x }) => {
406
- const { index: C, ...y } = x, F = Object.entries(y), b = F.findIndex(([f]) => f === "price");
407
- return [
408
- ...F.slice(0, b + 1).map(([, f]) => f),
409
- ...a.priceTiers.map(
410
- (f) => parseFloat(h(g[f])) || ""
411
- ),
412
- ...F.slice(b + 1).map(([, f]) => f)
413
- ];
414
- }), s = this.createWorkbookExcelJS(
415
- m,
416
- "Default AddonGroup",
417
- this.exportCatalogAddonToExcelExcelJS()
418
- ), d = s.worksheets[0];
419
- L(d, a.priceTiers), this.formatWorkbookCell(s);
420
- const c = this.transformItemsLinkWithGroup(), u = Object.keys(c), p = new A.Workbook();
421
- if (u.length > 0)
422
- u.forEach((g, x) => {
423
- const C = Object.values(c[g]), y = this.menu.modules.group.find((f) => f._id === g);
424
- if (!y) throw new Error(`Group not found for id: ${g}`);
425
- const F = O(`${x + 1}. ${y.name}`), b = p.addWorksheet(F);
426
- b.columns = [
427
- { header: "Group ID", key: "groupId" },
428
- { header: "Item ID", key: "itemId" },
429
- { header: "Item Name", key: "itemName" },
430
- { header: "Default Catalog", key: "defaultCatalog" }
431
- ], C.forEach((f) => {
432
- b.addRow({
433
- groupId: g,
434
- itemId: f.itemId,
435
- itemName: f.itemName,
436
- defaultCatalog: f.defaultCatalog
437
- });
438
- });
439
- });
440
- else {
441
- const g = p.addWorksheet("Group Name");
442
- g.columns = [
443
- { header: "Group ID", key: "groupId" },
444
- { header: "Item ID", key: "itemId" },
445
- { header: "Item Name", key: "itemName" },
446
- { header: "Default Catalog", key: "defaultCatalog" }
447
- ];
448
- }
449
- return this.formatWorkbookCell(p), e.push(r, s, p), e;
450
- }
451
- createWorkbookExcelJS(e, i, a) {
452
- const t = new A.Workbook(), r = t.addWorksheet(i);
453
- return e.forEach((n) => {
454
- r.addRow(n);
455
- }), a && a.worksheets.forEach((n) => {
456
- const o = t.addWorksheet(n.name);
457
- n.eachRow({ includeEmpty: !0 }, (m) => {
458
- const s = m.values;
459
- o.addRow(s.slice(1));
460
- });
461
- }), t;
462
- }
463
- formatWorkbookCell(e) {
464
- e.eachSheet((i) => {
465
- i.eachRow({ includeEmpty: !0 }, (t) => {
466
- t.eachCell({ includeEmpty: !0 }, (r) => {
467
- r.font = {
468
- name: "Calibri",
469
- size: 12
470
- }, t.number === 1 && (r.fill = {
471
- type: "pattern",
472
- pattern: "solid",
473
- fgColor: { argb: "FABF8F" }
474
- }, r.alignment = { horizontal: "center", vertical: "middle" });
475
- });
476
- });
477
- const a = i.getRow(1);
478
- i.autoFilter = {
479
- from: {
480
- row: 1,
481
- column: 1
482
- },
483
- to: {
484
- row: 1,
485
- column: a.cellCount
486
- }
487
- };
488
- });
489
- }
490
- exportCatalogToExcelExcelJS() {
491
- const e = new A.Workbook();
492
- return this.menu.modules.catalog.forEach((i) => {
493
- const a = Object.values(i.override.items).flatMap((s) => s), { rows: t, metaData: r } = this.transformOverrideData(a), n = t.map(({ priceTier: s, tag: d, ...c }) => [
494
- ...Object.entries(c).map(([, p]) => p),
495
- ...r.tags.map((p) => d[p] || "")
496
- ]), o = O(i.name), m = e.addWorksheet(o);
497
- n.forEach((s) => {
498
- m.addRow(s);
499
- }), H(m, r.tags, r.priceTiers, i);
500
- }), e;
501
- }
502
- exportCatalogAddonToExcelExcelJS() {
503
- const e = new A.Workbook();
504
- return this.menu.modules.catalog.forEach((i) => {
505
- const a = Object.values(i.override.groups).flatMap(
506
- (m) => m
507
- ), r = this.transformOverrideAddonGroup(a).map(({ priceTier: m, ...s }) => {
508
- const { index: d, ...c } = s;
509
- return [...Object.entries(c).map(([, p]) => p)];
510
- }), n = O(i.name), o = e.addWorksheet(n);
511
- r.forEach((m) => {
512
- o.addRow(m);
513
- }), L(o);
514
- }), e;
515
- }
516
- }
517
- const Ve = { class: "flex-1 flex justify-between gap-8 pl-8" }, $e = { class: "flex items-center" }, Re = { class: "bg-fm-color-neutral-gray-100 rounded-md px-8 py-4" }, Ae = { class: "fm-typo-en-body-md-600 font-semibold" }, Pe = { class: "flex gap-8" }, rt = /* @__PURE__ */ W({
518
- __name: "Products",
519
- setup(k) {
520
- const { t: e } = he(), i = ne(ce()), a = re(), t = S(() => a.rules.item), r = Ce(), n = S(() => !a.state.currentSchedulerId), { selectedCategories: o } = we(), m = S(() => ({
521
- ...be.menuV4ToV3(q(a.state.menu)),
522
- _id: a.state.menu._id,
523
- _rev: a.state.menu._rev
524
- })), s = S(() => {
525
- const b = X.flatten(o.value.map((f) => f.items));
526
- return X.uniqBy(b, (f) => f._id).length;
527
- });
528
- async function d(b, f) {
529
- const T = new pe();
530
- for (let $ = 0; $ < b.length; $++) {
531
- const me = await b[$].xlsx.writeBuffer();
532
- T.file(`${f[$]}.xlsx`, me);
533
- }
534
- const w = await T.generateAsync({ type: "blob" });
535
- fe.saveAs(w, `books_${G().format("DD-MM-YYYY_HH-mm")}.zip`);
536
- }
537
- async function c() {
538
- await i.minor(
539
- async () => {
540
- if (await a.readMenu(), a.version === ie.F_MENU_VERSION.enum.v4) {
541
- const b = q(a.state.menu), f = new Ge(b).exportToExcel(), T = [
542
- `menu_${G().format("DD-MM-YYYY_HH-mm")}`,
543
- `addonGroup_${G().format("DD-MM-YYYY_HH-mm")}`,
544
- `itemLinkedAddon${G().format("DD-MM-YYYY_HH-mm")}`
545
- ];
546
- d(f, T);
547
- } else {
548
- const b = Ee(m.value), f = `menu_${G().format("DD-MM-YYYY_HH-mm")}`;
549
- await de(b, `${f}.xlsx`, {
550
- bookType: "xlsx",
551
- bookSST: !1,
552
- type: "array"
553
- });
554
- }
555
- },
556
- { successMessage: "Menu exported", customId: a.state.menu._id }
557
- );
558
- }
559
- const {
560
- menuItems: u,
561
- categories: p,
562
- linkItemRules: v,
563
- handleSubmit: g,
564
- catalogManager: x,
565
- schedulerManager: C
566
- } = Ie(!1), y = _e(), F = S(() => y.breakpoints.value.xs);
567
- return xe().resetOnMount(), (b, f) => {
568
- const T = V("fm-button");
569
- return E(), D(ve, {
570
- heading: l(e)("menu.products.title")
571
- }, {
572
- default: I(() => [
573
- _(Ke),
574
- _(Fe)
575
- ]),
576
- "append-heading": I(() => [
577
- M("div", Ve, [
578
- M("div", $e, [
579
- M("div", Re, [
580
- M("p", Ae, oe(s.value), 1)
581
- ])
582
- ]),
583
- M("div", Pe, [
584
- F.value ? (E(), D(Q, { key: 1 }, {
585
- default: I(({ trigger: w }) => [
586
- _(ke, null, {
587
- default: I(() => [
588
- _(Z, {
589
- label: l(e)("menu.products.actions.export"),
590
- onClick: c
591
- }, null, 8, ["label"]),
592
- _(Z, {
593
- label: l(e)("menu.products.actions.import"),
594
- onClick: w
595
- }, null, 8, ["label", "onClick"])
596
- ]),
597
- _: 2
598
- }, 1024)
599
- ]),
600
- _: 1
601
- })) : (E(), j(B, { key: 0 }, [
602
- _(Me, null, {
603
- default: I(({ trigger: w }) => [
604
- _(T, {
605
- label: l(e)("menu.tree_editor.title"),
606
- "bg-color": l(N).NeutralGray100,
607
- "text-color": l(N).TypoSecondary,
608
- variant: l(U).Primary,
609
- onClick: w
610
- }, null, 8, ["label", "bg-color", "text-color", "variant", "onClick"])
611
- ]),
612
- _: 1
613
- }),
614
- _(T, {
615
- "bg-color": l(N).NeutralGray100,
616
- "text-color": l(N).TypoSecondary,
617
- variant: l(U).Primary,
618
- label: l(e)("menu.products.actions.export"),
619
- onClick: c
620
- }, null, 8, ["bg-color", "text-color", "variant", "label"]),
621
- _(Q, null, {
622
- default: I(({ trigger: w }) => [
623
- _(T, {
624
- "bg-color": l(N).NeutralGray100,
625
- "text-color": l(N).TypoSecondary,
626
- variant: l(U).Primary,
627
- label: l(e)("menu.products.actions.import"),
628
- onClick: w
629
- }, null, 8, ["bg-color", "text-color", "variant", "label", "onClick"])
630
- ]),
631
- _: 1
632
- })
633
- ], 64)),
634
- s.value > 0 ? (E(), j(B, { key: 2 }, [
635
- t.value.create ? (E(), D(Y, {
636
- key: 0,
637
- label: l(e)("menu.products.actions.add"),
638
- "prepend-icon": "add",
639
- onClick: f[0] || (f[0] = (w) => l(r).create(null))
640
- }, null, 8, ["label"])) : n.value ? (E(), D(ee, {
641
- key: 1,
642
- "categorized-items": l(x).linkableItems.value,
643
- "initial-value": l(x).currentItems.value,
644
- "show-variant": !1,
645
- "menu-items": l(u),
646
- categories: l(p),
647
- "link-item-rules": l(v),
648
- "no-scheduler": n.value,
649
- onSubmit: l(g)
650
- }, {
651
- default: I(({ trigger: w }) => [
652
- _(Y, {
653
- label: l(e)("menu.products.actions.link"),
654
- "prepend-icon": "link",
655
- onClick: w
656
- }, null, 8, ["label", "onClick"])
657
- ]),
658
- _: 1
659
- }, 8, ["categorized-items", "initial-value", "menu-items", "categories", "link-item-rules", "no-scheduler", "onSubmit"])) : (E(), D(ee, {
660
- key: 2,
661
- "categorized-items": l(C).linkableItems.value,
662
- "initial-value": l(C).currentItems.value,
663
- "show-variant": !1,
664
- "menu-items": l(u),
665
- categories: l(p),
666
- "link-item-rules": l(v),
667
- "no-scheduler": n.value,
668
- onSubmit: l(g)
669
- }, {
670
- default: I(({ trigger: w }) => [
671
- _(Y, {
672
- label: l(e)("menu.products.actions.apply_scheduler"),
673
- onClick: w
674
- }, null, 8, ["label", "onClick"])
675
- ]),
676
- _: 1
677
- }, 8, ["categorized-items", "initial-value", "menu-items", "categories", "link-item-rules", "no-scheduler", "onSubmit"]))
678
- ], 64)) : ae("", !0)
679
- ])
680
- ])
681
- ]),
682
- _: 1
683
- }, 8, ["heading"]);
684
- };
685
- }
686
- });
687
- export {
688
- rt as default
689
- };