@feedmepos/mf-menu 0.31.33 → 0.31.34-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{App-DNDOc3bV.js → App-CaKDbV0S.js} +6 -6
- package/dist/{ApplyProduct.vue_vue_type_script_setup_true_lang-BvrfcWHU.js → ApplyProduct.vue_vue_type_script_setup_true_lang-gY18sRMg.js} +20 -20
- package/dist/{Catalog-Zhi-3W6T.js → Catalog-B0zMoi7e.js} +80 -80
- package/dist/{Category-BU0bkAGd.js → Category-Dyou6Q17.js} +31 -27
- package/dist/{Category-CE9ixFkD.js → Category-rMN8037Q.js} +19 -19
- package/dist/{CookingGuide-eghVaeEY.js → CookingGuide-DT2XxaWa.js} +4 -4
- package/dist/CustomAttributeChip.vue_vue_type_script_setup_true_lang-Cv9LNAfi.js +113 -0
- package/dist/{Group-DWrtP9Au.js → Group-CYSIOe3D.js} +1 -1
- package/dist/{Group-DDZPf6LY.js → Group-M4WPAAYz.js} +3 -3
- package/dist/Group.vue_vue_type_script_setup_true_lang-B-BH-2WN.js +686 -0
- package/dist/GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-TQWka93A.js +367 -0
- package/dist/{ImportProductDialog.vue_vue_type_script_setup_true_lang-Cus0YKUt.js → ImportProductDialog.vue_vue_type_script_setup_true_lang-DgSO7SQW.js} +4982 -5081
- package/dist/{Ingredient-BJgvOyV9.js → Ingredient-DNvr30pW.js} +3 -3
- package/dist/{InventoryBinding.vue_vue_type_script_setup_true_lang-CF99abLi.js → InventoryBinding.vue_vue_type_script_setup_true_lang-G44luws0.js} +1052 -1052
- package/dist/LinkProductSideSheet-Cp0HFoP2.js +297 -0
- package/dist/LinkProductSideSheet.vue_vue_type_style_index_0_scoped_97fa9d58_lang-DvG3mOom.js +8024 -0
- package/dist/{MenuSetting-gkwORUX0.js → MenuSetting-UeQ2NyVm.js} +4 -4
- package/dist/{PrintRoute-Cda6sFlL.js → PrintRoute-5uX9ymJY.js} +89 -88
- package/dist/{Product-61AAh5L-.js → Product-Dxqf8_iq.js} +1 -1
- package/dist/Product.vue_vue_type_script_setup_true_lang-DUtGVRCH.js +1578 -0
- package/dist/{ProductInternalTools-o8cVZXCT.js → ProductInternalTools-BCF9q0i_.js} +5 -5
- package/dist/Products--adhOQ8n.js +283 -0
- package/dist/{Publish-BRgJUzoA.js → Publish-CRaoaFxc.js} +3 -3
- package/dist/{Recipe-CV8lvryp.js → Recipe-DPkzZMJi.js} +4 -4
- package/dist/{Scheduler-B_ptvb82.js → Scheduler-BuwjNHHj.js} +3 -3
- package/dist/{ServingSequence-DABGnLbT.js → ServingSequence-Cdf_Zmat.js} +3 -3
- package/dist/Setting-Vr3Thttm.js +259 -0
- package/dist/{Subcategory-BiqlAvMs.js → Subcategory-DoXmjcg1.js} +4 -4
- package/dist/{Takeaway-BBdkzEiP.js → Takeaway-BRTQu8VT.js} +1 -1
- package/dist/{Takeaway-nIjrDu5C.js → Takeaway-t3il54Bd.js} +4 -4
- package/dist/{Takeaway.vue_vue_type_script_setup_true_lang-D_M2PFO-.js → Takeaway.vue_vue_type_script_setup_true_lang-DtHABSgp.js} +6 -6
- package/dist/Thumbnail.vue_vue_type_script_setup_true_lang-D_ACNj_Z.js +431 -0
- package/dist/TreeEditorOpenner.vue_vue_type_script_setup_true_lang-DAoGiRV-.js +5990 -0
- package/dist/{Unit-Di5sUbhV.js → Unit-C_QY3IX_.js} +2 -2
- package/dist/{Variant-CiZCtZk9.js → Variant-CR4IEm-Q.js} +3 -3
- package/dist/_id_-DOU7ieGB.js +202 -0
- package/dist/{app-B63V5b4I.js → app--fRC3N4C.js} +1 -1
- package/dist/{app-DuD_IPou.js → app-CrXLAKdw.js} +95 -97
- package/dist/app.js +6 -7
- package/dist/apps/mf-menu/src/app.d.ts +62 -3
- package/dist/apps/mf-menu/src/components/feature/PriceTier/LinkPriceTierSection.vue.d.ts +24 -0
- package/dist/apps/mf-menu/src/components/feature/PriceTier/PriceTierRuleEditor.vue.d.ts +30 -0
- package/dist/apps/mf-menu/src/components/feature/RestaurantAttributesSelector.vue.d.ts +33 -0
- package/dist/apps/mf-menu/src/components/feature/TreeEditor/composable/catalog.d.ts +2 -0
- package/dist/apps/mf-menu/src/components/feature/TreeEditor/store/menuV2.d.ts +80 -1
- package/dist/apps/mf-menu/src/composable/linkProducts.d.ts +1276 -0
- package/dist/apps/mf-menu/src/helper/import-export.d.ts +77 -0
- package/dist/apps/mf-menu/src/helper/menu.d.ts +77 -0
- package/dist/apps/mf-menu/src/helper/setting/catalogSetting.d.ts +11 -2
- package/dist/apps/mf-menu/src/manager/menu/item.d.ts +77 -0
- package/dist/apps/mf-menu/src/router/shared.d.ts +0 -1
- package/dist/apps/mf-menu/src/stores/manager/catalog.d.ts +2 -0
- package/dist/apps/mf-menu/src/stores/menu.d.ts +79 -0
- package/dist/apps/mf-menu/src/types/linkProducts.d.ts +21 -0
- package/dist/apps/mf-menu/src/views/PrintRoute/PrintDepartmentDialog.vue.d.ts +5 -3
- package/dist/apps/mf-menu/src/views/Publish/UpdateCatalogDialog.vue.d.ts +82 -0
- package/dist/apps/mf-menu/tsconfig.app.tsbuildinfo +1 -1
- package/dist/assets/linked-status-BTF_dm9R.js +24 -0
- package/dist/assets/override-menu-BPu7TVCy.js +24 -0
- package/dist/assets/validate-menu-BQpDfHbr.js +24 -0
- package/dist/{catalog-DfYSMjLc.js → catalog-BGiDWODL.js} +1 -1
- package/dist/catalogSetting-C34kIcYn.js +71 -0
- package/dist/{category-mmjX_QdF.js → category-CayMSpUc.js} +1 -1
- package/dist/{currency-3ugQtBPt.js → currency-BggoZpJv.js} +1 -1
- package/dist/{dayjs.min-CkV4mNm8.js → dayjs.min-BKDTLohL.js} +1 -1
- package/dist/{index-Cztb2LVZ.js → index-BPcRbiW0.js} +3 -3
- package/dist/{index-BboaHtmY.js → index-CLFhXi0y.js} +3 -3
- package/dist/index-D7yR1j9C.js +215 -0
- package/dist/{index-BZaKuDcN.js → index-f9kzXNPD.js} +28 -28
- package/dist/{item-CVnDeXhJ.js → item-C51o9ejv.js} +547 -545
- package/dist/{jszip.min-GxfcHBC5.js → jszip.min-m57vowh9.js} +353 -353
- package/dist/{menu-sGVv4bhQ.js → menu-DHfLxvzU.js} +4 -4
- package/dist/menu-DK7wG3S5.js +133287 -0
- package/dist/menuV2-B-0V65cx.js +707 -0
- package/dist/mf-menu.css +1 -1
- package/dist/{priceTier-CHTA0ZEb.js → priceTier-DD-24pkj.js} +1 -1
- package/dist/{scheduler-CaMxCHZ0.js → scheduler-NjDv_P4c.js} +16 -17
- package/dist/subcategory-DLdBwjHV.js +148 -0
- package/dist/{toExcel-WorodvP1.js → toExcel-coJ5igRV.js} +15 -15
- package/dist/{unit-DtKZZYL6.js → unit-C7XUV0EW.js} +5 -4
- package/package.json +5 -5
- package/dist/CustomAttributeChip.vue_vue_type_script_setup_true_lang-BiF8rW4M.js +0 -7949
- package/dist/FormItem.vue_vue_type_script_setup_true_lang-BmPAVphe.js +0 -26
- package/dist/Group.vue_vue_type_script_setup_true_lang-DyqGsRAW.js +0 -698
- package/dist/GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-BmRUg94d.js +0 -206
- package/dist/LinkProductSideSheet-CTT4oGUY.js +0 -112
- package/dist/Product.vue_vue_type_script_setup_true_lang-Cy4uok1E.js +0 -1560
- package/dist/Products-D0rrANT6.js +0 -270
- package/dist/Setting-3ISlMXOA.js +0 -258
- package/dist/Thumbnail.vue_vue_type_script_setup_true_lang-DzQ8_6Bi.js +0 -71
- package/dist/TreeEditorOpenner.vue_vue_type_script_setup_true_lang-y0n5hTLk.js +0 -6149
- package/dist/_id_-DY8himeL.js +0 -200
- package/dist/apps/mf-menu/src/components/feature/LinkProduct/LinkProductSideSheet.vue.d.ts +0 -70
- package/dist/assets/linked-status-CkBKnMXs.js +0 -24
- package/dist/assets/override-menu-XZ7XfcfS.js +0 -24
- package/dist/assets/validate-menu-Bomogq01.js +0 -24
- package/dist/catalogSetting-_4Z0s3_Q.js +0 -65
- package/dist/index-Ce4v8o7D.js +0 -106
- package/dist/menu-IGORh0Ik.js +0 -108039
- package/dist/subcategory-CmVttqlG.js +0 -817
- /package/dist/{apps/mf-menu/src/components → packages/shared/src/components/info}/CustomAttributeChip.vue.d.ts +0 -0
|
@@ -0,0 +1,707 @@
|
|
|
1
|
+
import { H as R, B as k, ao as L, G as J, ap as q, J as U, I as Y, a9 as w, c as x, X as E, aj as z, aq as Me, ar as Ee, A as Re, ab as ke, as as Ie, at as Te, a8 as Fe } from "./menu-DK7wG3S5.js";
|
|
2
|
+
import { defineStore as Ae } from "pinia";
|
|
3
|
+
import { shallowRef as X, ref as D, computed as h, shallowReactive as Ve, effectScope as Ke, watch as Oe } from "vue";
|
|
4
|
+
import { useCoreStore as G } from "@feedmepos/mf-common";
|
|
5
|
+
import { useSnackbar as Ne } from "@feedmepos/ui-library";
|
|
6
|
+
const xe = "/assets/linked-status-BTF_dm9R.js", Pe = "/assets/override-menu-BPu7TVCy.js";
|
|
7
|
+
function $e(e) {
|
|
8
|
+
var a;
|
|
9
|
+
const n = R(e), o = (a = n.variant) == null ? void 0 : a.variantCombinations;
|
|
10
|
+
return delete n.variant, delete n.thumbnail, [n, ...o || []];
|
|
11
|
+
}
|
|
12
|
+
function Ue(e, n, o, a) {
|
|
13
|
+
const r = R(n), l = o ? r.modules.catalog.find((g) => g._id === o) : null, d = a ? r.modules.scheduler.find((g) => g._id === a) : null, i = l ? R(l) : void 0, c = o ? r.modules.catalog.filter((g) => g._id !== o) : [], m = d ? R(d) : void 0, f = e.reduce((g, y) => (g[y._id] = $e(y), g), {});
|
|
14
|
+
function v(g = []) {
|
|
15
|
+
const y = e.map((b) => b._id);
|
|
16
|
+
return [
|
|
17
|
+
...g.filter((b) => !y.includes(b._id)),
|
|
18
|
+
...Object.values(f).flatMap((b) => b)
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
return i && a ? (i.override.scheduler = {
|
|
22
|
+
...i.override.scheduler,
|
|
23
|
+
[a]: {
|
|
24
|
+
...i.override.scheduler[a],
|
|
25
|
+
_id: a,
|
|
26
|
+
items: v(m == null ? void 0 : m.items).map((g) => ({
|
|
27
|
+
...g,
|
|
28
|
+
orderFrom: J.F_ORDER_FROM.enum.ALL
|
|
29
|
+
}))
|
|
30
|
+
}
|
|
31
|
+
}, r.modules.catalog = [...c, i], r) : i ? (i.override.items = {
|
|
32
|
+
...i.override.items,
|
|
33
|
+
...f
|
|
34
|
+
}, r.modules.catalog = [...c, i], r) : m ? (m.items = v(m.items), r.modules.scheduler = [
|
|
35
|
+
...r.modules.scheduler.filter((g) => g._id !== a),
|
|
36
|
+
m
|
|
37
|
+
], r) : {
|
|
38
|
+
...q(),
|
|
39
|
+
modules: {
|
|
40
|
+
...q().modules,
|
|
41
|
+
catalog: r.modules.catalog,
|
|
42
|
+
item: r.modules.item,
|
|
43
|
+
group: r.modules.group,
|
|
44
|
+
scheduler: r.modules.scheduler
|
|
45
|
+
},
|
|
46
|
+
_id: r._id
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function T(e, n, o) {
|
|
50
|
+
var l;
|
|
51
|
+
if (o >= 3) return e;
|
|
52
|
+
const a = n.modules.item.find((d) => d._id === e._id);
|
|
53
|
+
if (!a)
|
|
54
|
+
throw new Error(`_insertItemOverriders - Item not found - ${e._id}`);
|
|
55
|
+
const r = (l = a.groups) == null ? void 0 : l.map((d) => {
|
|
56
|
+
var m, f, v;
|
|
57
|
+
const i = (m = e == null ? void 0 : e.groups) == null ? void 0 : m.find((g) => g._id === d._id);
|
|
58
|
+
let c;
|
|
59
|
+
return i ? c = ((f = d.items) == null ? void 0 : f.map((g) => {
|
|
60
|
+
var b;
|
|
61
|
+
const y = (b = i.items) == null ? void 0 : b.find(
|
|
62
|
+
(I) => I._id === g._id && I.combinationKey === g.combinationKey
|
|
63
|
+
);
|
|
64
|
+
return T(y || g, n, o + 1);
|
|
65
|
+
})) ?? [] : c = ((v = d.items) == null ? void 0 : v.map((g) => T(g, n, o + 1))) ?? [], {
|
|
66
|
+
...d,
|
|
67
|
+
items: c
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
_id: a._id,
|
|
72
|
+
name: e.name || a.name,
|
|
73
|
+
code: e.code || a.code,
|
|
74
|
+
combinationKey: e.combinationKey,
|
|
75
|
+
groups: r
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function De(e, n) {
|
|
79
|
+
const o = e.groups.map((l) => {
|
|
80
|
+
const d = n.modules.group.find((c) => c._id === l._id), i = ((d == null ? void 0 : d.items) || []).map((c) => {
|
|
81
|
+
var v;
|
|
82
|
+
const m = (v = l.items) == null ? void 0 : v.find(
|
|
83
|
+
(g) => g._id === c._id && g.combinationKey === c.combinationKey
|
|
84
|
+
);
|
|
85
|
+
if (m)
|
|
86
|
+
return T(m, n, 1);
|
|
87
|
+
const f = {
|
|
88
|
+
...k.generator.initMenuV4ItemOverrider(),
|
|
89
|
+
_id: c._id,
|
|
90
|
+
combinationKey: c.combinationKey
|
|
91
|
+
};
|
|
92
|
+
return T(f, n, 1);
|
|
93
|
+
});
|
|
94
|
+
return { ...l, items: i };
|
|
95
|
+
}), a = e.variant ? e.variant.variantCombinations.map((l) => T(l, n, 1)) : [], r = {
|
|
96
|
+
...k.generator.initMenuV4ItemOverrider(),
|
|
97
|
+
_id: e._id,
|
|
98
|
+
name: e.name,
|
|
99
|
+
code: e.code,
|
|
100
|
+
groups: o
|
|
101
|
+
};
|
|
102
|
+
return [...a, r];
|
|
103
|
+
}
|
|
104
|
+
function H(e, n) {
|
|
105
|
+
var a;
|
|
106
|
+
if (!n)
|
|
107
|
+
return e;
|
|
108
|
+
const o = { ...e, code: n.code };
|
|
109
|
+
return o.groups = (a = o.groups) == null ? void 0 : a.map((r) => {
|
|
110
|
+
var d, i;
|
|
111
|
+
const l = (d = n.groups) == null ? void 0 : d.find((c) => c._id === r._id);
|
|
112
|
+
return r.items = (i = r.items) == null ? void 0 : i.map((c) => {
|
|
113
|
+
var f;
|
|
114
|
+
const m = (f = l == null ? void 0 : l.items) == null ? void 0 : f.find(
|
|
115
|
+
(v) => v._id === c._id && v.combinationKey === c.combinationKey
|
|
116
|
+
);
|
|
117
|
+
return H(c, m);
|
|
118
|
+
}), r;
|
|
119
|
+
}), o;
|
|
120
|
+
}
|
|
121
|
+
function He(e, n) {
|
|
122
|
+
const o = e.items[n._id];
|
|
123
|
+
n.variant && (n.variant = {
|
|
124
|
+
...n.variant,
|
|
125
|
+
variantCombinations: n.variant.variantCombinations.map((r) => {
|
|
126
|
+
const l = o.find(
|
|
127
|
+
(d) => d._id === r._id && d.combinationKey === r.combinationKey
|
|
128
|
+
);
|
|
129
|
+
if (!l)
|
|
130
|
+
throw new Error(`Item overrider not found - ${r._id} - ${r.combinationKey}`);
|
|
131
|
+
return H(l, r);
|
|
132
|
+
})
|
|
133
|
+
});
|
|
134
|
+
const a = o.find((r) => !r.combinationKey);
|
|
135
|
+
if (!a)
|
|
136
|
+
throw new Error(`Base item overrider not found - ${n._id}`);
|
|
137
|
+
return n.groups = (a.groups || []).map((r) => {
|
|
138
|
+
var d;
|
|
139
|
+
const l = n.groups.find((i) => i._id === r._id);
|
|
140
|
+
return r.items = (d = r.items) == null ? void 0 : d.map((i) => {
|
|
141
|
+
var m;
|
|
142
|
+
const c = (m = l == null ? void 0 : l.items) == null ? void 0 : m.find(
|
|
143
|
+
(f) => f._id === i._id && f.combinationKey === i.combinationKey
|
|
144
|
+
);
|
|
145
|
+
return H(i, c);
|
|
146
|
+
}), r;
|
|
147
|
+
}), {
|
|
148
|
+
...n,
|
|
149
|
+
price: (a == null ? void 0 : a.price) || n.price
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
async function et(e, n, o, a, r, l = !0) {
|
|
153
|
+
const d = R(o), i = l ? Ue(n, d, a, r) : d, c = n.reduce((v, g) => (v[g._id] = i.modules.item.find((y) => y._id === g._id), v), {}), m = n.reduce((v, g) => {
|
|
154
|
+
const y = g._id;
|
|
155
|
+
return v[y] = De(c[y], e), v;
|
|
156
|
+
}, {}), f = k.getFallbackPrices({
|
|
157
|
+
rawMenu: i,
|
|
158
|
+
items: m,
|
|
159
|
+
catalogId: a || void 0,
|
|
160
|
+
schedulerId: r
|
|
161
|
+
});
|
|
162
|
+
return n.map((v) => {
|
|
163
|
+
const g = v._id, y = c[g];
|
|
164
|
+
return {
|
|
165
|
+
...He(f, y),
|
|
166
|
+
category: a || r ? y == null ? void 0 : y.category : null
|
|
167
|
+
};
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function tt(e, n) {
|
|
171
|
+
if (e.length === 0) return "";
|
|
172
|
+
const o = e == null ? void 0 : e.split("variant");
|
|
173
|
+
return ((o == null ? void 0 : o.reduce((r, l) => {
|
|
174
|
+
if (l && l.length > 0) {
|
|
175
|
+
const d = `variant${l.split("/")[0]}`, i = l.split("/")[1], m = n.find(
|
|
176
|
+
({ _id: f }) => f === d
|
|
177
|
+
).options.find(({ _id: f }) => f === i);
|
|
178
|
+
r.push(((m == null ? void 0 : m.name) || "").trim());
|
|
179
|
+
}
|
|
180
|
+
return r;
|
|
181
|
+
}, [])) || []).join(" / ");
|
|
182
|
+
}
|
|
183
|
+
const P = /* @__PURE__ */ new Map();
|
|
184
|
+
async function nt(e, n) {
|
|
185
|
+
const o = `${e._id}-${e.updatedAt}-${n}`;
|
|
186
|
+
if (P.has(o))
|
|
187
|
+
return P.get(o);
|
|
188
|
+
const a = await L(
|
|
189
|
+
xe,
|
|
190
|
+
JSON.stringify({
|
|
191
|
+
menu: e,
|
|
192
|
+
itemId: n
|
|
193
|
+
})
|
|
194
|
+
);
|
|
195
|
+
return P.set(o, a), a;
|
|
196
|
+
}
|
|
197
|
+
async function Q(e, n, o) {
|
|
198
|
+
return await L(Pe, {
|
|
199
|
+
menu: e,
|
|
200
|
+
catalogId: n,
|
|
201
|
+
schedulerId: o
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function rt(e, n, o) {
|
|
205
|
+
const a = /* @__PURE__ */ new Set();
|
|
206
|
+
function r(l, d) {
|
|
207
|
+
if (!e || !l || !d || a.has(d)) return !1;
|
|
208
|
+
a.add(d);
|
|
209
|
+
const i = e.modules.item.find((c) => c._id === d);
|
|
210
|
+
return !i || !i.groups ? !1 : i.groups.some((c) => c._id === l) ? !0 : i.groups.some((c) => {
|
|
211
|
+
const m = e.modules.group.find((f) => f._id === c._id);
|
|
212
|
+
for (const f of (m == null ? void 0 : m.items) || [])
|
|
213
|
+
if (r(l, f._id)) return !0;
|
|
214
|
+
return !1;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return r(n, o);
|
|
218
|
+
}
|
|
219
|
+
function ot(e, n, o) {
|
|
220
|
+
const a = /* @__PURE__ */ new Set();
|
|
221
|
+
function r(l, d) {
|
|
222
|
+
if (!e || !l || !d || a.has(l)) return !1;
|
|
223
|
+
a.add(l);
|
|
224
|
+
const i = e.modules.group.find((c) => c._id === l);
|
|
225
|
+
return !i || !i.items ? !1 : i.items.some((c) => c._id === d) ? !0 : i.items.some((c) => {
|
|
226
|
+
const m = e.modules.item.find((f) => f._id === c._id);
|
|
227
|
+
for (const f of (m == null ? void 0 : m.groups) || [])
|
|
228
|
+
if (r(f._id, d)) return !0;
|
|
229
|
+
return !1;
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return r(n, o);
|
|
233
|
+
}
|
|
234
|
+
const $ = /* @__PURE__ */ new Map();
|
|
235
|
+
async function Be(e, n, o) {
|
|
236
|
+
const a = `${e._id}-${e.updatedAt}-${n || "null"}-${o || "null"}`;
|
|
237
|
+
if ($.has(a))
|
|
238
|
+
return $.get(a);
|
|
239
|
+
const r = await Q(e, n, o);
|
|
240
|
+
return $.set(a, r), r;
|
|
241
|
+
}
|
|
242
|
+
async function st(e, n, o) {
|
|
243
|
+
var d, i;
|
|
244
|
+
const a = await Be(e, n, null), r = [], l = (c, m) => {
|
|
245
|
+
const f = R(c);
|
|
246
|
+
for (const v in m)
|
|
247
|
+
m[v] && (f[v] = m[v]);
|
|
248
|
+
return f;
|
|
249
|
+
};
|
|
250
|
+
for (const c of a.modules.group) {
|
|
251
|
+
const m = (d = c.items) == null ? void 0 : d.find((v) => v._id === o && !v.combinationKey), f = e.modules.item.find((v) => v._id === o);
|
|
252
|
+
if (m) {
|
|
253
|
+
const v = (i = c.items) == null ? void 0 : i.filter((y) => y._id === o && y.combinationKey), g = [m, ...v].map((y) => {
|
|
254
|
+
var F, A;
|
|
255
|
+
const b = y.combinationKey ? (A = (F = f == null ? void 0 : f.variant) == null ? void 0 : F.variantCombinations) == null ? void 0 : A.find(
|
|
256
|
+
(V) => V.combinationKey === y.combinationKey
|
|
257
|
+
) : f, I = b && f ? l(f, b) : y;
|
|
258
|
+
return l(I, y);
|
|
259
|
+
});
|
|
260
|
+
r.push({
|
|
261
|
+
group: c,
|
|
262
|
+
items: g
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return r;
|
|
267
|
+
}
|
|
268
|
+
function We({
|
|
269
|
+
maxHistorySize: e = 50
|
|
270
|
+
}) {
|
|
271
|
+
const n = X([]), o = D(-1), a = h(() => o.value > 0), r = h(() => o.value < n.value.length - 1);
|
|
272
|
+
function l(m) {
|
|
273
|
+
n.value.push(m), o.value++, n.value.length > e && (n.value.shift(), o.value--);
|
|
274
|
+
}
|
|
275
|
+
function d() {
|
|
276
|
+
if (a.value)
|
|
277
|
+
return o.value--, n.value[o.value];
|
|
278
|
+
}
|
|
279
|
+
function i() {
|
|
280
|
+
if (r.value)
|
|
281
|
+
return o.value++, n.value[o.value];
|
|
282
|
+
}
|
|
283
|
+
function c() {
|
|
284
|
+
n.value = [], o.value = -1;
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
push: l,
|
|
288
|
+
canUndo: a,
|
|
289
|
+
canRedo: r,
|
|
290
|
+
undo: d,
|
|
291
|
+
redo: i,
|
|
292
|
+
clear: c
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
const je = {
|
|
296
|
+
async updateMenuModule(e, n) {
|
|
297
|
+
const o = U.RequestRunner.operation(n, e.modules);
|
|
298
|
+
if (o.validateError.length > 0)
|
|
299
|
+
throw new Error(o.validateError.join(`
|
|
300
|
+
`));
|
|
301
|
+
const a = {
|
|
302
|
+
...e,
|
|
303
|
+
modules: o.result || e.modules,
|
|
304
|
+
_rev: o.id ?? ""
|
|
305
|
+
};
|
|
306
|
+
return Y.cloneDeep({ menu: a, updateId: o.id ?? null });
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
function Z() {
|
|
310
|
+
return {
|
|
311
|
+
_id: "",
|
|
312
|
+
masterCatalogSetting: { inclusiveTaxes: [] },
|
|
313
|
+
modules: {
|
|
314
|
+
catalog: [],
|
|
315
|
+
category: [],
|
|
316
|
+
group: [],
|
|
317
|
+
item: [],
|
|
318
|
+
printDepartment: [],
|
|
319
|
+
scheduler: [],
|
|
320
|
+
takeaway: [],
|
|
321
|
+
variant: [],
|
|
322
|
+
sku: [],
|
|
323
|
+
recipe: [],
|
|
324
|
+
unit: [],
|
|
325
|
+
cookingGuide: [],
|
|
326
|
+
serveSequence: [],
|
|
327
|
+
subCategory: []
|
|
328
|
+
},
|
|
329
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
function qe() {
|
|
333
|
+
return {
|
|
334
|
+
restaurants: [],
|
|
335
|
+
menu: { ...Z(), _rev: "" },
|
|
336
|
+
currentCatalogId: null,
|
|
337
|
+
currentCategoryIds: null,
|
|
338
|
+
currentSchedulerId: "",
|
|
339
|
+
currentRestaurantCustomAttributes: null
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
const at = Ae(
|
|
343
|
+
"mf-menu-store-v2",
|
|
344
|
+
() => {
|
|
345
|
+
const e = Ve(qe()), n = G(), o = Ne(), a = h(() => e.menu.modules.serveSequence ? w(e.menu.modules.serveSequence, {
|
|
346
|
+
selector: "position"
|
|
347
|
+
}) : []), r = h(() => {
|
|
348
|
+
var t;
|
|
349
|
+
return ((t = n.currentBusiness.value) == null ? void 0 : t.menuVersion) || x.F_MENU_VERSION.v3;
|
|
350
|
+
}), l = h(() => r.value === x.F_MENU_VERSION.v4), d = h(() => {
|
|
351
|
+
const t = e.menu.modules.catalog;
|
|
352
|
+
return w(t, { selector: "name" });
|
|
353
|
+
}), i = h(() => {
|
|
354
|
+
var s;
|
|
355
|
+
let t = e.menu.modules.catalog.find(
|
|
356
|
+
(u) => u._id === e.currentCatalogId
|
|
357
|
+
);
|
|
358
|
+
return t && ((s = t.linkItemRules) != null && s.length) && (t = k.populateCatalog({
|
|
359
|
+
catalog: t,
|
|
360
|
+
items: e.menu.modules.item,
|
|
361
|
+
restaurantCustomAttributes: e.currentRestaurantCustomAttributes || {}
|
|
362
|
+
})), t;
|
|
363
|
+
}), c = h(() => w(v.value.modules.scheduler, { selector: "name" })), m = h(() => e.menu.modules.scheduler.find(
|
|
364
|
+
(t) => t._id === e.currentSchedulerId
|
|
365
|
+
));
|
|
366
|
+
function f(t, s = !0) {
|
|
367
|
+
e.menu = { ...t, _rev: e.menu._rev }, s && M.push(e.menu);
|
|
368
|
+
}
|
|
369
|
+
const v = X(Z()), g = D(!1), y = D(1);
|
|
370
|
+
async function b() {
|
|
371
|
+
var u;
|
|
372
|
+
g.value = !0;
|
|
373
|
+
let t = e.menu.modules.catalog;
|
|
374
|
+
if (i.value && ((u = i.value.linkItemRules) != null && u.length)) {
|
|
375
|
+
const p = k.populateCatalog({
|
|
376
|
+
catalog: i.value,
|
|
377
|
+
items: e.menu.modules.item,
|
|
378
|
+
restaurantCustomAttributes: e.currentRestaurantCustomAttributes || {}
|
|
379
|
+
});
|
|
380
|
+
t = e.menu.modules.catalog.map((_) => _._id === (p == null ? void 0 : p._id) ? p : _);
|
|
381
|
+
}
|
|
382
|
+
const s = await Q(
|
|
383
|
+
{
|
|
384
|
+
...e.menu,
|
|
385
|
+
modules: {
|
|
386
|
+
...e.menu.modules,
|
|
387
|
+
catalog: t
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
e.currentCatalogId,
|
|
391
|
+
e.currentSchedulerId
|
|
392
|
+
);
|
|
393
|
+
if (e.currentSchedulerId != null) {
|
|
394
|
+
const p = e.menu.modules.catalog.find(
|
|
395
|
+
(S) => S._id === e.currentCatalogId
|
|
396
|
+
), _ = p ? p.override.scheduler[e.currentSchedulerId] : e.menu.modules.scheduler.find(
|
|
397
|
+
(S) => S._id === e.currentSchedulerId
|
|
398
|
+
), C = new Set(((_ == null ? void 0 : _.items) || []).map((S) => S._id));
|
|
399
|
+
s.modules.item = s.modules.item.filter((S) => C.has(S._id));
|
|
400
|
+
}
|
|
401
|
+
return v.value = s, g.value = !1, y.value = y.value + 1, s;
|
|
402
|
+
}
|
|
403
|
+
const F = Y.debounce(b, 200);
|
|
404
|
+
Ke(!0).run(() => {
|
|
405
|
+
Oe(
|
|
406
|
+
() => [e.menu, e.currentCatalogId, e.currentSchedulerId],
|
|
407
|
+
() => {
|
|
408
|
+
g.value || F();
|
|
409
|
+
}
|
|
410
|
+
);
|
|
411
|
+
});
|
|
412
|
+
const V = h(() => [
|
|
413
|
+
{
|
|
414
|
+
label: "Main",
|
|
415
|
+
value: null
|
|
416
|
+
},
|
|
417
|
+
...d.value.map((t) => ({
|
|
418
|
+
label: t.name,
|
|
419
|
+
value: t._id
|
|
420
|
+
}))
|
|
421
|
+
]), B = h(() => {
|
|
422
|
+
const t = v.value.modules.category;
|
|
423
|
+
return [
|
|
424
|
+
...O.value.item.addon ? [
|
|
425
|
+
{
|
|
426
|
+
_id: e.currentCatalogId ? "" : null,
|
|
427
|
+
name: "Addon",
|
|
428
|
+
position: 0
|
|
429
|
+
}
|
|
430
|
+
] : [],
|
|
431
|
+
...E(t, (s) => s.name)
|
|
432
|
+
];
|
|
433
|
+
}), ee = h(() => {
|
|
434
|
+
const t = v.value.modules.subCategory || [];
|
|
435
|
+
return E(t, (s) => s.name);
|
|
436
|
+
}), W = h(() => {
|
|
437
|
+
var s;
|
|
438
|
+
let t = v.value.modules.item;
|
|
439
|
+
if (i.value) {
|
|
440
|
+
const u = (s = i.value) == null ? void 0 : s.override.items;
|
|
441
|
+
t = t.filter((p) => {
|
|
442
|
+
var C;
|
|
443
|
+
const _ = (C = u == null ? void 0 : u[p._id]) == null ? void 0 : C.find(
|
|
444
|
+
(S) => !S.combinationKey
|
|
445
|
+
);
|
|
446
|
+
return (_ == null ? void 0 : _.orderFrom) !== J.F_ORDER_FROM.enum.NONE;
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
return E(t, (u) => u.code || u.name);
|
|
450
|
+
}), te = h(() => {
|
|
451
|
+
const t = e.menu.modules.category, s = E(t, (p) => p.name).reduce(
|
|
452
|
+
(p, _, C) => (p[_._id] = C, p),
|
|
453
|
+
{ "": 0 }
|
|
454
|
+
), u = e.menu.modules.item;
|
|
455
|
+
return E(
|
|
456
|
+
u,
|
|
457
|
+
(p) => p.code || p.name
|
|
458
|
+
).reduce((p, _, C) => (p[_._id] = C + s[_.category || ""], p), {});
|
|
459
|
+
}), ne = h(() => z(K.value, B.value, W.value)), re = h(() => {
|
|
460
|
+
const t = O.value.item.addon ? [
|
|
461
|
+
{
|
|
462
|
+
_id: e.currentCatalogId ? "" : null,
|
|
463
|
+
name: "Addon",
|
|
464
|
+
position: 0
|
|
465
|
+
},
|
|
466
|
+
...e.menu.modules.category
|
|
467
|
+
] : e.menu.modules.category;
|
|
468
|
+
return z(
|
|
469
|
+
e.menu.modules.variant,
|
|
470
|
+
t,
|
|
471
|
+
e.menu.modules.item
|
|
472
|
+
);
|
|
473
|
+
}), K = h(() => {
|
|
474
|
+
const t = v.value.modules.variant;
|
|
475
|
+
return w(t, { selector: "name" });
|
|
476
|
+
});
|
|
477
|
+
function oe(t = []) {
|
|
478
|
+
const s = t.map((p) => K.value.find((_) => _._id === p)).filter((p) => !!p);
|
|
479
|
+
return k.fullVariantCombination(s).reduce((p, _) => (p[_.combinationKey] = _.selectionName.join(" / "), p), {});
|
|
480
|
+
}
|
|
481
|
+
const se = h(() => E(v.value.modules.group, (t) => t.name)), ae = h(() => w(v.value.modules.takeaway, { selector: "name" })), ue = h(() => w(e.menu.modules.printDepartment || [], {
|
|
482
|
+
selector: "name"
|
|
483
|
+
})), ie = h(() => w(e.menu.modules.unit, { selector: "name" })), ce = h(() => w(Me(e.menu.modules.recipe, e.menu.modules.sku), {
|
|
484
|
+
selector: "name"
|
|
485
|
+
})), le = h(() => e.menu.modules.cookingGuide), de = h(() => {
|
|
486
|
+
const t = Ee(e.menu.modules.sku);
|
|
487
|
+
return w(t, { selector: "code" });
|
|
488
|
+
}), O = h(() => {
|
|
489
|
+
const t = !e.currentCatalogId, s = r.value === x.F_MENU_VERSION.v4, u = !e.currentSchedulerId, p = {
|
|
490
|
+
create: t && u,
|
|
491
|
+
edit: t && u,
|
|
492
|
+
delete: t && u
|
|
493
|
+
};
|
|
494
|
+
return {
|
|
495
|
+
item: {
|
|
496
|
+
...p,
|
|
497
|
+
edit: s || u,
|
|
498
|
+
sort: s && t && u,
|
|
499
|
+
addon: s,
|
|
500
|
+
code: u,
|
|
501
|
+
name: t && u,
|
|
502
|
+
description: t && u,
|
|
503
|
+
category: u,
|
|
504
|
+
thumbnail: t && u,
|
|
505
|
+
orderFrom: (s || t) && u,
|
|
506
|
+
orderFromNone: t,
|
|
507
|
+
orderFromActiveOnly: !s,
|
|
508
|
+
openPrice: t && u,
|
|
509
|
+
unit: t && u,
|
|
510
|
+
price: t,
|
|
511
|
+
editPrice: t,
|
|
512
|
+
minPrice: s && u,
|
|
513
|
+
costing: s && t && u,
|
|
514
|
+
tax: t && u,
|
|
515
|
+
variant: t && u,
|
|
516
|
+
maxVariant: s ? 4 : 2,
|
|
517
|
+
group: t && u,
|
|
518
|
+
overrideProductGroup: s && u,
|
|
519
|
+
inventory: (s || t) && u,
|
|
520
|
+
bindToVariant: s,
|
|
521
|
+
print: t && u,
|
|
522
|
+
toRoot: s && u,
|
|
523
|
+
takeaway: (_) => !!_ && (s || t) && u,
|
|
524
|
+
multiScheduler: s,
|
|
525
|
+
canRearrange: s,
|
|
526
|
+
printConfig: s
|
|
527
|
+
},
|
|
528
|
+
category: {
|
|
529
|
+
...p,
|
|
530
|
+
sort: t
|
|
531
|
+
},
|
|
532
|
+
group: {
|
|
533
|
+
...p,
|
|
534
|
+
edit: s || u,
|
|
535
|
+
sort: t,
|
|
536
|
+
applyProduct: t,
|
|
537
|
+
showAppliedProduct: u,
|
|
538
|
+
type: !s,
|
|
539
|
+
insertRawItems: !s,
|
|
540
|
+
multiScheduler: s
|
|
541
|
+
},
|
|
542
|
+
scheduler: {
|
|
543
|
+
override: s
|
|
544
|
+
},
|
|
545
|
+
takeaway: {
|
|
546
|
+
...p,
|
|
547
|
+
edit: (s || t) && u,
|
|
548
|
+
name: t
|
|
549
|
+
},
|
|
550
|
+
catalog: {
|
|
551
|
+
name: !t,
|
|
552
|
+
defaultOrderFrom: s,
|
|
553
|
+
markup: s
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
});
|
|
557
|
+
function N(t) {
|
|
558
|
+
return `${t.systemCode}/${t.taxCode}`;
|
|
559
|
+
}
|
|
560
|
+
function me(t) {
|
|
561
|
+
const [s, u] = t.split("/");
|
|
562
|
+
return { systemCode: s, taxCode: u };
|
|
563
|
+
}
|
|
564
|
+
function fe(t, s, u) {
|
|
565
|
+
return (t ?? s ?? []).map((p) => N(p)).find((p) => u.some((_) => _.value === p));
|
|
566
|
+
}
|
|
567
|
+
const pe = h(() => {
|
|
568
|
+
var p;
|
|
569
|
+
const t = ["SV5", "SV10"], s = Re.Country.getCountryFlattenTaxes(
|
|
570
|
+
G().currentCountry.value
|
|
571
|
+
), u = s.filter((_) => l.value || !t.includes(_.taxCode)).map((_) => ({
|
|
572
|
+
label: `${_.name} (${ke(_.rate)}%)`,
|
|
573
|
+
value: N(_),
|
|
574
|
+
meta: {
|
|
575
|
+
rate: _.rate
|
|
576
|
+
}
|
|
577
|
+
}));
|
|
578
|
+
return u.sort((_, C) => _.label.localeCompare(C.label, void 0, { numeric: !0 })), {
|
|
579
|
+
systemCode: (p = s[0]) == null ? void 0 : p.systemCode,
|
|
580
|
+
countryTaxOptions: u
|
|
581
|
+
};
|
|
582
|
+
}), ve = async () => {
|
|
583
|
+
const t = await Fe.readMenu();
|
|
584
|
+
e.menu = t ?? e.menu, j(null);
|
|
585
|
+
}, _e = async () => {
|
|
586
|
+
const { fetchAllRestaurants: t } = Te();
|
|
587
|
+
await t({
|
|
588
|
+
onBatchEnd: (s) => {
|
|
589
|
+
e.restaurants = s;
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
}, j = (t) => {
|
|
593
|
+
e.currentCatalogId = t;
|
|
594
|
+
}, ge = (t) => {
|
|
595
|
+
e.currentSchedulerId = t;
|
|
596
|
+
}, ye = (t) => {
|
|
597
|
+
e.currentCategoryIds = t;
|
|
598
|
+
}, he = (t) => {
|
|
599
|
+
e.currentRestaurantCustomAttributes = t;
|
|
600
|
+
}, Ce = async (t, s) => {
|
|
601
|
+
const u = Array.isArray(t) ? t : [t];
|
|
602
|
+
if (!u.length) return;
|
|
603
|
+
const p = u.map((_) => ({
|
|
604
|
+
..._,
|
|
605
|
+
_id: e.menu._id,
|
|
606
|
+
_rev: e.menu._rev
|
|
607
|
+
}));
|
|
608
|
+
try {
|
|
609
|
+
if (s || p.some(
|
|
610
|
+
(C) => [U.F_OPERATION_TYPE.delete, U.F_OPERATION_TYPE.deleteMany].includes(C.operation)
|
|
611
|
+
)) {
|
|
612
|
+
const C = await Ie(p, e.menu.modules);
|
|
613
|
+
if (C !== !0) throw new Error(C);
|
|
614
|
+
}
|
|
615
|
+
const _ = await je.updateMenuModule(e.menu, p);
|
|
616
|
+
return f(_.menu), _;
|
|
617
|
+
} catch (_) {
|
|
618
|
+
o.open({
|
|
619
|
+
type: "error",
|
|
620
|
+
title: "Failed to update menu",
|
|
621
|
+
message: _
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
}, be = async (t) => {
|
|
625
|
+
const s = {
|
|
626
|
+
...e.menu,
|
|
627
|
+
masterCatalogSetting: t.masterCatalogSetting,
|
|
628
|
+
lowStockThreshold: t.lowStockThreshold,
|
|
629
|
+
priceTierSettings: t.priceTierSettings
|
|
630
|
+
};
|
|
631
|
+
return f(s), s;
|
|
632
|
+
}, M = We({ maxHistorySize: 50 }), Se = h(() => M.canUndo.value), we = h(() => M.canRedo.value);
|
|
633
|
+
return {
|
|
634
|
+
state: e,
|
|
635
|
+
// loading state
|
|
636
|
+
workerIsComputing: g,
|
|
637
|
+
mergedMenuChangeId: y,
|
|
638
|
+
// async computed state
|
|
639
|
+
mergedMenu: v,
|
|
640
|
+
// Computed
|
|
641
|
+
version: r,
|
|
642
|
+
isV4: l,
|
|
643
|
+
serveSequence: a,
|
|
644
|
+
catalogs: d,
|
|
645
|
+
currentCatalog: i,
|
|
646
|
+
schedulers: c,
|
|
647
|
+
currentScheduler: m,
|
|
648
|
+
catalogOptions: V,
|
|
649
|
+
categories: B,
|
|
650
|
+
subcategories: ee,
|
|
651
|
+
items: W,
|
|
652
|
+
sortedItems: te,
|
|
653
|
+
categorizedItems: ne,
|
|
654
|
+
categorizedRawMenuItems: re,
|
|
655
|
+
variants: K,
|
|
656
|
+
groups: se,
|
|
657
|
+
takeaways: ae,
|
|
658
|
+
printDepartments: ue,
|
|
659
|
+
units: ie,
|
|
660
|
+
recipes: ce,
|
|
661
|
+
cookingGuide: le,
|
|
662
|
+
skus: de,
|
|
663
|
+
rules: O,
|
|
664
|
+
taxSetting: pe,
|
|
665
|
+
// Action
|
|
666
|
+
setMenu: f,
|
|
667
|
+
readMenu: ve,
|
|
668
|
+
readRestaurants: _e,
|
|
669
|
+
selectCatalog: j,
|
|
670
|
+
selectScheduler: ge,
|
|
671
|
+
selectCategory: ye,
|
|
672
|
+
setRestaurantCustomAttributes: he,
|
|
673
|
+
updateMenu: Ce,
|
|
674
|
+
updateMenuSetting: be,
|
|
675
|
+
computeMergedMenu: b,
|
|
676
|
+
// helper
|
|
677
|
+
encodeTax: N,
|
|
678
|
+
decodeTax: me,
|
|
679
|
+
getSelectedTax: fe,
|
|
680
|
+
mapVariant: oe,
|
|
681
|
+
// history
|
|
682
|
+
canUndoHistory: Se,
|
|
683
|
+
canRedoHistory: we,
|
|
684
|
+
undoHistory: () => {
|
|
685
|
+
const t = M.undo();
|
|
686
|
+
t && f(t, !1);
|
|
687
|
+
},
|
|
688
|
+
redoHistory: () => {
|
|
689
|
+
const t = M.redo();
|
|
690
|
+
t && f(t, !1);
|
|
691
|
+
},
|
|
692
|
+
clearHistory: () => {
|
|
693
|
+
M.clear();
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
);
|
|
698
|
+
export {
|
|
699
|
+
nt as a,
|
|
700
|
+
rt as b,
|
|
701
|
+
ot as c,
|
|
702
|
+
st as f,
|
|
703
|
+
tt as g,
|
|
704
|
+
et as m,
|
|
705
|
+
Be as o,
|
|
706
|
+
at as u
|
|
707
|
+
};
|