@feedmepos/mf-inventory-portal 1.3.16-dev.1 → 1.3.16-dev.2

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 (91) hide show
  1. package/dist/{App-BPrgeKO5.js → App-BckRpjrE.js} +4 -4
  2. package/dist/{ApprovalView-BP21UP2s.js → ApprovalView-C5rVI_O7.js} +7 -7
  3. package/dist/{BindingsDialog-ZMUmkLSC.js → BindingsDialog-Y530TN7D.js} +2 -2
  4. package/dist/{BindingsPicker-f640U3jk.js → BindingsPicker-BbQ9Ygep.js} +2 -2
  5. package/dist/{BindingsTable-BoTU8_ii.js → BindingsTable-ClHmMFLP.js} +3 -3
  6. package/dist/{ClosingDraftView-DeFODFRH.js → ClosingDraftView-Dn16j97_.js} +14 -14
  7. package/dist/{ClosingHistoryView-LmrCMCuz.js → ClosingHistoryView-BK7KJbbf.js} +5 -5
  8. package/dist/{ClosingTemplateView-5ioCcZTW.js → ClosingTemplateView-D2petgop.js} +14 -14
  9. package/dist/{DefaultView-hYmDl5l-.js → DefaultView-CdCpGT5n.js} +2 -2
  10. package/dist/{DeliveryOrderPrintPreview-CDYDvv7K.js → DeliveryOrderPrintPreview-C_S4SG8h.js} +2 -2
  11. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-GT5YUrJz.js +76 -0
  12. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-wuP2HuXh.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-q8fQfbEV.js} +2 -2
  13. package/dist/{FmMultiselectDialog-DQk_uhPT.js → FmMultiselectDialog-6JADZ5xC.js} +1 -1
  14. package/dist/{FmMultiselectDialog-DEwvnps8.js → FmMultiselectDialog-BEkAAZZp.js} +2 -2
  15. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-biGUrxMi.js → FmUnitInput.vue_vue_type_script_setup_true_lang-kaW8FwP5.js} +6 -5
  16. package/dist/{ImportView-9vzXeSDH.js → ImportView-D8i5_GO9.js} +6 -6
  17. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-CH_nyzm6.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-baV8qK0P.js} +1 -1
  18. package/dist/{IngredientGroupView-Ca68TCys.js → IngredientGroupView-BiqFuJx0.js} +5 -5
  19. package/dist/{IngredientsView-D8LmfmXW.js → IngredientsView-CQHobUvF.js} +15 -15
  20. package/dist/{IntegrationExplorerView-j5pZ09cq.js → IntegrationExplorerView-BFbGH5-S.js} +5 -5
  21. package/dist/{IntegrationView-CXFeCPyP.js → IntegrationView-UF8UwPNk.js} +13 -13
  22. package/dist/{InventoryBindingForm-jjWc7yWv.js → InventoryBindingForm-DB4LwgzC.js} +1 -1
  23. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-q7PsPAqr.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-Dc0sxYMV.js} +5 -5
  24. package/dist/{InventoryBindingSummary-D_n2JHgj.js → InventoryBindingSummary-Bwn4HZy5.js} +1 -1
  25. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CSOT60hU.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BvBOo5wi.js} +1 -1
  26. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-B5xzpwF7.js → PremiumBadge.vue_vue_type_script_setup_true_lang-D2wiVygJ.js} +1 -1
  27. package/dist/{PublishView-bEPdlxEE.js → PublishView-BFac9M5C.js} +3 -3
  28. package/dist/{PurchaseOrderPrintPreview-DLDFWJht.js → PurchaseOrderPrintPreview-tree07u5.js} +2 -2
  29. package/dist/{ReceiveRequestView-CG24mmXP.js → ReceiveRequestView-DLERk28I.js} +30 -29
  30. package/dist/RecipeView-DDgN0DkI.js +2898 -0
  31. package/dist/{SettingsView-Vf1neo5W.js → SettingsView-BWw7AhqT.js} +4 -4
  32. package/dist/{StockView-DkHv_yE_.js → StockView-D0wW54eN.js} +19 -19
  33. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-DdsxuASV.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Btor1W6X.js} +1 -1
  34. package/dist/{SupplierView-D94us1xa.js → SupplierView-Bd_PLuYt.js} +12 -12
  35. package/dist/{SurchargeView-BDqzJFZS.js → SurchargeView-F1B_fcv-.js} +6 -6
  36. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-RxH4R9vD.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-95m2qnoM.js} +2 -2
  37. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-B_9ugyP_.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-DHKDRFgr.js} +1 -1
  38. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-BWldDVB8.js → TransferDetails.vue_vue_type_script_setup_true_lang-BC0PNCtM.js} +20 -20
  39. package/dist/{TransferTemplateView-CFJmOt0_.js → TransferTemplateView-DM8qOCpO.js} +20 -19
  40. package/dist/{UnitCostHistoryView-BjvxX6t4.js → UnitCostHistoryView-Bzocbij3.js} +4 -4
  41. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-BBeCcEqZ.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-BDzz91rl.js} +4 -4
  42. package/dist/{UnitView-CL-RHEwm.js → UnitView-EndrhMnI.js} +7 -7
  43. package/dist/{WarehouseView-CV2kfNlj.js → WarehouseView-BJZELae1.js} +5 -5
  44. package/dist/{WastageTemplateView-vYiPpr4f.js → WastageTemplateView-s6ZiQR8E.js} +14 -14
  45. package/dist/{app-Xm6qpWfd.js → app-CaGW5ogt.js} +3812 -3624
  46. package/dist/app.d.ts +126 -0
  47. package/dist/app.js +1 -1
  48. package/dist/{closing-template-B47iC5cb.js → closing-template-CUgXd6Na.js} +1 -1
  49. package/dist/{date2-Ctgy0LHT.js → date2-fQDP1Rtk.js} +1 -1
  50. package/dist/{dayjs.min-Di6FEjRq.js → dayjs.min-UwaUKDHA.js} +1 -1
  51. package/dist/{decimal-DeqyFu05.js → decimal-CKysiOcn.js} +2 -2
  52. package/dist/{defineDeepModel-QsJ5Tk5R.js → defineDeepModel-CwM7TJuT.js} +1 -1
  53. package/dist/{duplicate-template-DrS-BtlB.js → duplicate-template-Bb5b_40t.js} +1 -1
  54. package/dist/{export-nGe-IrFm.js → export-nbyx5EYR.js} +1 -1
  55. package/dist/{feature-D5-0IKeC.js → feature-Dqme8-Xr.js} +2 -2
  56. package/dist/{format-time-from-id-BS0-ljoa.js → format-time-from-id-DsRN_JB-.js} +1 -1
  57. package/dist/{format-unit-display-D3BJr6xW.js → format-unit-display-Df1v6CMC.js} +11 -11
  58. package/dist/{import-export.helper-yU7r8SD1.js → import-export.helper-QInnTLhY.js} +6 -6
  59. package/dist/{index-YO20Idcz.js → index-BCwp1fKe.js} +3 -3
  60. package/dist/{index-3tmEl1Vx.js → index-CbwjQK_M.js} +1 -1
  61. package/dist/{index-DwOhoIIj.js → index-Cij7rBSm.js} +1 -1
  62. package/dist/{inventory-core-dart.default-qV8YW8oe.js → inventory-core-dart.default-Bgq3Sd7C.js} +1 -1
  63. package/dist/{lodash-B1y84Me_.js → lodash-B15PREHg.js} +1 -1
  64. package/dist/{lz-string-BSdU_fLB.js → lz-string-DdnEcXDA.js} +1 -1
  65. package/dist/{netsuite-DuIW6Lx3.js → netsuite-NcBlI9QO.js} +3 -3
  66. package/dist/{number-DKpiml_w.js → number-DQ-rkxYN.js} +3 -3
  67. package/dist/{predefined-templates-DfBT39uu.js → predefined-templates-zYAuXO9-.js} +1 -1
  68. package/dist/{purchase-order-template-bUCzYwIP.js → purchase-order-template-DcoKKoiW.js} +1 -1
  69. package/dist/{recalculationUtils-B5vtjJ7Z.js → recalculationUtils-MW6hf5oz.js} +1 -1
  70. package/dist/{rules-CX1NVdUi.js → rules-CxC7ePEb.js} +2 -2
  71. package/dist/{stock-sMY18eio.js → stock-Bly2vXJq.js} +1 -1
  72. package/dist/{stock-mwCadSfs.js → stock-Bqk5_C4b.js} +3 -3
  73. package/dist/{supplier-CV7wbbgo.js → supplier-B0yIc028.js} +2 -2
  74. package/dist/{surcharge-DfkPrRWG.js → surcharge-BZa9y16I.js} +1 -1
  75. package/dist/tsconfig.app.tsbuildinfo +1 -1
  76. package/dist/{use-ingredient-select-dialog-DMxSzgr4.js → use-ingredient-select-dialog-BGPPfGO-.js} +2 -2
  77. package/dist/{use-inventory-binding-dialog-BfdHj5zx.js → use-inventory-binding-dialog-DUsjKdNr.js} +2 -2
  78. package/dist/{use-template-enabled-locations-cQuWrkpb.js → use-template-enabled-locations-D2EWKhWK.js} +2 -2
  79. package/dist/use-transfer-locations-BRQbfZYI.js +116 -0
  80. package/dist/{useHrmPermission-Dr1JvOPF.js → useHrmPermission-BZSfcBwi.js} +1 -1
  81. package/dist/{useNavigationMenu-w9DyVemK.js → useNavigationMenu-C7F5h-H5.js} +2 -2
  82. package/dist/views/recipe/components/recipe-bulk-editor/RecipeBulkEditorDialog.vue.d.ts +19 -0
  83. package/dist/views/recipe/components/recipe-bulk-editor/RecipeBulkEditorQueryStep.vue.d.ts +2 -0
  84. package/dist/views/recipe/components/recipe-bulk-editor/RecipeBulkEditorSummaryStep.vue.d.ts +2 -0
  85. package/dist/views/recipe/composables/use-recipe-bulk-editor.d.ts +634 -0
  86. package/dist/{vue-i18n-DWiVQ_sJ.js → vue-i18n-BuXEP0EQ.js} +242 -242
  87. package/dist/{xlsx-Bvjg71OX.js → xlsx-C0BSmeBh.js} +1 -1
  88. package/dist/{xlsx.util-CZKwClH8.js → xlsx.util-CyLHh8k-.js} +1 -1
  89. package/package.json +4 -4
  90. package/dist/FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CC5AemGX.js +0 -188
  91. package/dist/RecipeView-DMn3M9SP.js +0 -1692
@@ -1,1692 +0,0 @@
1
- import { defineComponent as W, ref as G, onMounted as Ce, resolveComponent as A, openBlock as x, createElementBlock as R, Fragment as oe, createElementVNode as y, toDisplayString as z, createVNode as V, createCommentVNode as E, computed as S, watch as le, unref as d, normalizeClass as he, withCtx as K, h as O, createBlock as D, renderList as ae, isRef as ve, normalizeStyle as Ie, Teleport as Ae, normalizeProps as Re, guardReactiveProps as Se } from "vue";
2
- import { a as Y, c as me, S as $e, F as ie, t as Ee, v as Te, i as ye, u as Ue } from "./app-Xm6qpWfd.js";
3
- import { useDialog as ce, useSnackbar as pe, components as ee, useProxiedModel as be, useBreakpoints as Pe } from "@feedmepos/ui-library";
4
- import { i as De, _ as Ge } from "./is-linked-ingredient-error-fJ2TJb3z.js";
5
- import { F as N } from "./form-mode.enum-BKiNVH6A.js";
6
- import { _ as Ve } from "./IngredientBindedItem.vue_vue_type_script_setup_true_lang-CH_nyzm6.js";
7
- import { defineStore as Me, storeToRefs as Ne } from "pinia";
8
- import { D as ge, R as te } from "./row-action.enum-DQ9bJ_uv.js";
9
- import { c as ze } from "./component-kqxARxvM.js";
10
- import { a as j, c as ke } from "./number-DKpiml_w.js";
11
- import { useI18n as Q, useCoreStore as Ke } from "@feedmepos/mf-common";
12
- import { u as Le, _ as Oe } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-sUxHOj47.js";
13
- import { b as xe, c as fe, I as je, A as de, U as Be, R as Ye } from "./rules-CX1NVdUi.js";
14
- import { _ as qe } from "./InventoryBindingForm.vue_vue_type_script_setup_true_lang-q7PsPAqr.js";
15
- import { a as re } from "./FmMultiselectDialog-DEwvnps8.js";
16
- import { d as we } from "./defineDeepModel-QsJ5Tk5R.js";
17
- import { L as He, P as Je, D as We } from "./app-DiX-EfV6.js";
18
- import { _ as Qe, c as Xe, d as Ze } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-biGUrxMi.js";
19
- import { u as en } from "./FmMultiselectDialog-DQk_uhPT.js";
20
- import { u as nn } from "./vue-i18n-DWiVQ_sJ.js";
21
- import { F as tn } from "./inventory-core-dart.default-qV8YW8oe.js";
22
- import { _ as on } from "./FmCustomAttribute.vue_vue_type_script_setup_true_lang-D-IWRjRD.js";
23
- import { u as ln } from "./feature-D5-0IKeC.js";
24
- import { _ as sn, F as _e } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-Ca_eYa8-.js";
25
- import { b as an, d as rn } from "./xlsx.util-CZKwClH8.js";
26
- import { f as dn } from "./date2-Ctgy0LHT.js";
27
- import { _ as un } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-wuP2HuXh.js";
28
- const mn = {
29
- key: 0,
30
- class: "flex flex-col items-center w-full h-full gap-24"
31
- }, cn = { key: 1 }, pn = { key: 0 }, fn = /* @__PURE__ */ W({
32
- __name: "DeleteDialog",
33
- props: {
34
- type: {},
35
- data: {},
36
- message: {},
37
- bindedItems: {}
38
- },
39
- setup(f) {
40
- const B = f, b = G(B.bindedItems || []), c = G(!1);
41
- Ce(() => {
42
- a();
43
- });
44
- async function a() {
45
- var u, _;
46
- !c.value && ((u = B.data) != null && u._id) && (c.value = !0, b.value = await Y().getAffectedMenu((_ = B.data) == null ? void 0 : _._id), c.value = !1);
47
- }
48
- return (u, _) => {
49
- const t = A("FmSpacer"), n = A("FmCircularProgress");
50
- return x(), R(oe, null, [
51
- y("p", null, z(u.message), 1),
52
- c.value ? (x(), R("div", mn, [
53
- V(t),
54
- y("div", null, [
55
- V(n, { size: "xl" })
56
- ]),
57
- _[0] || (_[0] = y("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary pl-8" }, "Loading...", -1)),
58
- V(t)
59
- ])) : (x(), R("div", cn, [
60
- _[2] || (_[2] = y("br", null, null, -1)),
61
- b.value.length > 0 ? (x(), R("div", pn, [
62
- _[1] || (_[1] = y("p", { class: "fm-typo-en-body-lg-600" }, "Affected menu items:", -1)),
63
- V(Ve, {
64
- name: "Menu",
65
- bindings: b.value
66
- }, null, 8, ["bindings"])
67
- ])) : E("", !0)
68
- ]))
69
- ], 64);
70
- };
71
- }
72
- }), ue = Me("recipeForm", function() {
73
- const B = ce(), b = pe(), c = Y(), a = G(!1), u = G();
74
- function _() {
75
- const e = {
76
- recipe: {},
77
- mode: N.CREATE,
78
- show: !0,
79
- "onUpdate:show"(i) {
80
- u.value.show = i;
81
- }
82
- };
83
- u.value = e;
84
- }
85
- async function t(e) {
86
- const i = {
87
- recipe: me(e),
88
- mode: N.UPDATE,
89
- show: !0,
90
- "onUpdate:show"(r) {
91
- u.value.show = r;
92
- }
93
- };
94
- u.value = i;
95
- }
96
- async function n(e) {
97
- a.value = !0;
98
- try {
99
- await c.deleteRecipe(e), b.open({
100
- title: "Success",
101
- message: `Deleted ${e.name}`,
102
- type: "success"
103
- });
104
- } catch (i) {
105
- i instanceof $e && De(i) ? B.open({
106
- title: "Cannot delete recipe",
107
- contentComponent: Ge,
108
- contentComponentProps: {
109
- subject: (e == null ? void 0 : e.name) ?? "",
110
- items: i.errorResponse.message
111
- },
112
- secondaryActions: {
113
- text: "Close",
114
- close: !0
115
- }
116
- }) : console.log("unable to delete recipe", i), b.open({
117
- title: `Cannot delete ${e == null ? void 0 : e.name}`,
118
- message: "Please try again.",
119
- type: "error"
120
- }), console.error("failed to delete recipe", i);
121
- } finally {
122
- a.value = !1;
123
- }
124
- }
125
- function o(e) {
126
- B.open({
127
- title: `Delete ${(e == null ? void 0 : e.name) ?? "recipe"}?`,
128
- closeButton: !1,
129
- primaryActions: {
130
- text: "Delete",
131
- close: !0,
132
- variant: "destructive"
133
- },
134
- secondaryActions: {
135
- text: "Cancel",
136
- close: !0
137
- },
138
- contentComponent: fn,
139
- contentComponentProps: {
140
- type: "menu",
141
- data: e,
142
- message: "You may not be able to delete this recipe if it is linked in any of the inventory modules."
143
- }
144
- }).onPrimary(() => n(e));
145
- }
146
- return {
147
- createRecipe: _,
148
- updateRecipe: t,
149
- deleteRecipe: o,
150
- recipeDialogProps: u,
151
- recipeViewLoading: a
152
- };
153
- });
154
- function vn() {
155
- const { updateRecipe: f, deleteRecipe: B } = ue(), b = Y(), { t: c } = Q();
156
- async function a(n, o) {
157
- const e = me(o);
158
- if (n === te.Edit) {
159
- await f(e);
160
- return;
161
- }
162
- if (n === te.Delete) {
163
- await B(e);
164
- return;
165
- }
166
- }
167
- function u(n, o) {
168
- const e = n.filter((g) => g.type === ie.enum.SKU), i = n.filter(
169
- (g) => g.type === ie.enum.SKU_GROUP
170
- ), r = n.filter((g) => g.type === ie.enum.RECIPE);
171
- return [
172
- ...e.map((g) => ({ ...g, recipeIds: [...o] })),
173
- ...i.map((g) => ({ ...g, isGroup: !0, recipeIds: [...o] })),
174
- ...r.filter((g) => b.recipeById[g.id] && !o.has(g.id)).flatMap(
175
- (g) => u(b.recipeById[g.id].contains, /* @__PURE__ */ new Set([...o, g.id]))
176
- )
177
- ];
178
- }
179
- const _ = [
180
- {
181
- accessorKey: "recipe",
182
- header: () => c("inventory.recipe.name"),
183
- size: 400
184
- },
185
- {
186
- accessorKey: "ingredients",
187
- header: () => c("inventory.recipe.ingredients"),
188
- size: "auto"
189
- },
190
- {
191
- id: "action",
192
- header: "",
193
- cell(n) {
194
- return ze(
195
- [ge[te.Edit], ge[te.Delete]],
196
- (o) => {
197
- a(o, n.row.original.original);
198
- }
199
- );
200
- },
201
- enableSorting: !1,
202
- size: 40,
203
- meta: {
204
- cellClass: "",
205
- headerClass: ""
206
- }
207
- }
208
- ];
209
- function t(n) {
210
- const o = Y();
211
- return n.map((e) => ({
212
- recipe: e.name,
213
- ingredients: u(e.contains, /* @__PURE__ */ new Set([e._id])).map((i) => {
214
- var g, m, l, s, k, C;
215
- if (i.isGroup) {
216
- const I = o.skuGroupById[i.id];
217
- return i.recipeIds.slice(1).length ? `(${(g = o.recipeById[i.recipeIds.at(-1) ?? ""]) == null ? void 0 : g.name}) ${I.name} (x ${j(i.amount)})` : `${I.name} (x${j(i.amount)})`;
218
- }
219
- const r = o.skuById[i.id];
220
- return r ? i.recipeIds.slice(1).length ? `(${(m = o.recipeById[i.recipeIds.at(-1) ?? ""]) == null ? void 0 : m.name}) ${r.name} (${j(i.amount)}${((l = i.measurement) == null ? void 0 : l.abbrev) ?? ((s = r == null ? void 0 : r.unit) == null ? void 0 : s.abbrev)})` : `${r.name} (${j(i.amount)}${((k = i.measurement) == null ? void 0 : k.abbrev) ?? ((C = r == null ? void 0 : r.unit) == null ? void 0 : C.abbrev)})` : null;
221
- }).filter((i) => i).join(", "),
222
- original: e
223
- }));
224
- }
225
- return { columnDefs: _, formatRowData: t };
226
- }
227
- function yn() {
228
- const f = Y(), B = ce();
229
- async function b(u, _, t, n = []) {
230
- var m, l;
231
- const o = u.filter((s) => s.type === "SKU"), e = u.filter((s) => s.type !== "SKU"), i = /* @__PURE__ */ new Set();
232
- if (t)
233
- for (const s of f.skus)
234
- !n.some((C) => C === s._id) && s._id !== t && !((l = (m = s.convert) == null ? void 0 : m.inventoryBindings) != null && l.some((C) => C.id === t)) || i.add(s._id);
235
- const r = f.skus.map((s) => ({
236
- label: s.name,
237
- sublabel: `${s.code}${i.has(s._id) ? " (Cannot bind, will cause recursive binding)" : ""}`,
238
- value: s,
239
- disabled: i.has(s._id)
240
- })), g = r.filter(
241
- (s) => o.find((k) => k.id === s.value._id) && !i.has(s.value._id)
242
- ).map((s) => s.value);
243
- B.open({
244
- title: "Select ingredients",
245
- contentComponent: re,
246
- contentComponentProps: {
247
- items: r,
248
- modelValue: g,
249
- virtualScroll: !0
250
- },
251
- primaryActions: {
252
- text: "Confirm",
253
- close: !0
254
- },
255
- secondaryActions: {
256
- text: "Close",
257
- close: !0,
258
- variant: "tertiary"
259
- }
260
- }).onPrimary((s) => {
261
- const k = [
262
- ...e,
263
- ...u.filter((C) => s.find((I) => I._id === C.id)),
264
- ...s.filter((C) => !u.find((I) => I.id === C._id)).map((C) => ({
265
- type: "SKU",
266
- id: C._id,
267
- amount: {
268
- amount: 1,
269
- precision: 0
270
- }
271
- }))
272
- ];
273
- _(k);
274
- });
275
- }
276
- async function c(u, _, t = []) {
277
- var g;
278
- const n = u.filter((m) => m.type === "RECIPE"), o = u.filter((m) => m.type !== "RECIPE"), e = /* @__PURE__ */ new Set();
279
- if (t.length)
280
- for (const m of f.recipes) {
281
- const l = ((g = f.recipeBindingFlattenCache[m._id]) == null ? void 0 : g.inventoryBindings) ?? [], s = l.some(
282
- (I) => I.bindingPaths.some((M) => t.some((H) => H === M.id))
283
- ), k = l.some(
284
- (I) => "success" in I && t.includes(I.ingredient._id)
285
- );
286
- (t.some((I) => I === m._id) || s || k) && e.add(m._id);
287
- }
288
- const i = f.recipes.filter((m) => !t.includes(m._id)).map((m) => ({
289
- label: m.name,
290
- sublabel: e.has(m._id) ? "(Cannot bind, will cause recursive binding)" : `${m.contains.length} inventory bindings`,
291
- value: m,
292
- disabled: e.has(m._id)
293
- })), r = i.filter(
294
- (m) => n.find((l) => l.id === m.value._id) && !e.has(m.value._id)
295
- ).map((m) => m.value);
296
- B.open({
297
- title: "Select recipes",
298
- contentComponent: re,
299
- contentComponentProps: {
300
- items: i,
301
- modelValue: r,
302
- virtualScroll: !0
303
- },
304
- primaryActions: {
305
- text: "Confirm",
306
- close: !0
307
- },
308
- secondaryActions: {
309
- text: "Close",
310
- close: !0,
311
- variant: "tertiary"
312
- }
313
- }).onPrimary((m) => {
314
- const l = [
315
- ...u.filter((s) => m.find((k) => k._id === s.id)),
316
- ...m.filter((s) => !u.find((k) => k.id === s._id)).map((s) => ({
317
- type: "RECIPE",
318
- id: s._id,
319
- amount: {
320
- amount: 1,
321
- precision: 0
322
- }
323
- })),
324
- ...o
325
- ];
326
- _(l);
327
- });
328
- }
329
- async function a(u, _, t = []) {
330
- const n = u.filter((r) => r.type === "SKU_GROUP"), o = u.filter((r) => r.type !== "SKU_GROUP"), e = f.skuGroups.filter((r) => !t.includes(r._id)).map((r) => ({
331
- label: r.name,
332
- value: r
333
- })), i = e.filter((r) => n.find((g) => g.id === r.value._id)).map((r) => r.value);
334
- B.open({
335
- title: "Select ingredient group",
336
- contentComponent: re,
337
- contentComponentProps: {
338
- items: e,
339
- modelValue: i,
340
- virtualScroll: !0
341
- },
342
- primaryActions: {
343
- text: "Confirm",
344
- close: !0
345
- },
346
- secondaryActions: {
347
- text: "Close",
348
- close: !0,
349
- variant: "tertiary"
350
- }
351
- }).onPrimary((r) => {
352
- const g = [
353
- ...u.filter((m) => r.find((l) => l._id === m.id)),
354
- ...r.filter((m) => !u.find((l) => l.id === m._id)).map((m) => ({
355
- type: "SKU_GROUP",
356
- id: m._id,
357
- amount: {
358
- amount: 1,
359
- precision: 0
360
- }
361
- })),
362
- ...o
363
- ];
364
- _(g);
365
- });
366
- }
367
- return {
368
- promptIngredientsBinding: b,
369
- promptRecipesBinding: c,
370
- promptIngredientGroupsBinding: a
371
- };
372
- }
373
- const bn = { class: "flex flex-col" }, gn = { class: "flex flex-col gap-4" }, Fe = /* @__PURE__ */ W({
374
- __name: "InventoryBindingRule",
375
- props: {
376
- disabled: { type: Boolean },
377
- modelValue: {},
378
- minCount: {},
379
- maxCount: {}
380
- },
381
- emits: ["update:modelValue"],
382
- setup(f, { emit: B }) {
383
- const b = f, c = B, { t: a } = Q(), u = Ke(), _ = S(() => {
384
- var r;
385
- const e = /* @__PURE__ */ new Map(), i = u.restaurants.value.map((g) => g.customAttributes ?? {});
386
- for (const g of i)
387
- for (const [m, l] of Object.entries(g))
388
- e.has(m) || e.set(m, /* @__PURE__ */ new Set()), l && ((r = e.get(m)) == null || r.add(l));
389
- return e;
390
- }), t = S(() => [
391
- ...[..._.value.entries()].map(([i, r]) => ({
392
- type: "string",
393
- key: i,
394
- entity: "restaurant",
395
- values: [...r]
396
- }))
397
- ]), n = G(null);
398
- let o = null;
399
- return le(
400
- () => b.modelValue,
401
- (e) => {
402
- JSON.stringify(e) !== JSON.stringify(o) && (n.value = e ? He.build(e) : null);
403
- },
404
- { immediate: !0 }
405
- ), le(
406
- n,
407
- (e) => {
408
- o = e ? Je.build(e) : null, c("update:modelValue", o);
409
- },
410
- { deep: !0 }
411
- ), (e, i) => {
412
- const r = A("FmLabel"), g = A("FmFormGroup");
413
- return x(), R("div", bn, [
414
- y("div", gn, [
415
- V(r, {
416
- label: d(a)("inventory.ingredientGroup.form.rules.title"),
417
- required: e.minCount != null && e.minCount > 0
418
- }, null, 8, ["label", "required"]),
419
- V(d(We), {
420
- modelValue: n.value,
421
- "onUpdate:modelValue": i[0] || (i[0] = (m) => n.value = m),
422
- attributes: t.value
423
- }, null, 8, ["modelValue", "attributes"])
424
- ]),
425
- V(g, {
426
- "model-value": n.value,
427
- rules: [
428
- (m) => {
429
- const l = m ? 1 : 0;
430
- return b.minCount !== void 0 && l < b.minCount ? d(a)("inventory.ingredientGroup.form.rules.validation.minCount", {
431
- count: b.minCount
432
- }) : b.maxCount !== void 0 && l > b.maxCount ? d(a)("inventory.ingredientGroup.form.rules.validation.maxCount", {
433
- count: b.maxCount
434
- }) : !0;
435
- }
436
- ]
437
- }, null, 8, ["model-value", "rules"])
438
- ]);
439
- };
440
- }
441
- }), _n = { class: "border-1 mx-3 my-1 rounded-md" }, hn = { class: "flex flex-col w-full border-b border-fm-color-neutral-gray-100" }, Vn = {
442
- class: "flex items-center",
443
- style: { "min-height": "48px" }
444
- }, kn = { class: "flex-1 fm-typo-en-body-md-400 py-8 px-12" }, xn = { class: "flex flex-col" }, Bn = { class: "line-clamp-1" }, wn = { class: "w-[200px]" }, Fn = {
445
- key: 0,
446
- class: "w-[52px]"
447
- }, Cn = {
448
- key: 0,
449
- class: "flex gap-4 text-fm-color-system-error-400 fm-typo-en-body-sm-400 px-8"
450
- }, In = { class: "px-12 pb-4" }, An = /* @__PURE__ */ W({
451
- __name: "InventoryRecipeBindingV2Field",
452
- props: {
453
- disabled: { type: Boolean },
454
- readonly: { type: Boolean },
455
- modelValue: {},
456
- displayName: {},
457
- showError: { type: Boolean }
458
- },
459
- emits: ["update:modelValue", "delete", "settings"],
460
- setup(f, { emit: B }) {
461
- const b = B, { t: c } = Q(), a = we("modelValue"), u = G(""), _ = S(() => +j(a.amount));
462
- le(
463
- () => a.amount,
464
- (o) => {
465
- const e = j(o);
466
- u.value !== e && (u.value = e);
467
- },
468
- { immediate: !0 }
469
- );
470
- let t = null;
471
- function n(o) {
472
- u.value = o, t && clearTimeout(t), t = setTimeout(() => {
473
- const e = +o;
474
- o.length > 0 && isFinite(e) ? a.amount = ke(e) : a.amount = { amount: 0, precision: 0 };
475
- }, 300);
476
- }
477
- return (o, e) => {
478
- const i = A("FmTooltip"), r = A("FmTextField"), g = A("FmButton"), m = A("FmIcon"), l = A("FmFormGroup");
479
- return x(), R("div", _n, [
480
- V(l, {
481
- class: he(["mb-2"]),
482
- disabled: o.disabled,
483
- modelValue: _.value,
484
- rules: [d(xe)(0), d(fe)(-1)]
485
- }, {
486
- default: K(({ invalid: s }) => [
487
- y("div", hn, [
488
- y("div", Vn, [
489
- y("div", kn, [
490
- y("div", xn, [
491
- V(i, {
492
- zIndex: 51,
493
- variant: "plain",
494
- placement: "top",
495
- content: o.displayName
496
- }, {
497
- default: K(() => [
498
- y("span", Bn, z(o.displayName), 1)
499
- ]),
500
- _: 1
501
- }, 8, ["content"])
502
- ])
503
- ]),
504
- y("div", wn, [
505
- V(r, {
506
- class: "w-full",
507
- disabled: o.disabled,
508
- modelValue: u.value,
509
- "onUpdate:modelValue": e[0] || (e[0] = (k) => n(k)),
510
- invalid: s
511
- }, null, 8, ["disabled", "modelValue", "invalid"])
512
- ]),
513
- o.readonly ? E("", !0) : (x(), R("div", Fn, [
514
- V(g, {
515
- disabled: o.disabled,
516
- type: "button",
517
- variant: "plain",
518
- icon: "delete",
519
- "icon-color": "#000000",
520
- onClick: e[1] || (e[1] = () => b("delete", d(a).id))
521
- }, null, 8, ["disabled"])
522
- ]))
523
- ]),
524
- o.showError ? (x(), R("div", Cn, [
525
- V(m, {
526
- name: "error",
527
- color: "system-error-300",
528
- size: "sm"
529
- }),
530
- y("div", null, z(d(c)("inventory.inventoryBindings.circularError")), 1)
531
- ])) : E("", !0)
532
- ])
533
- ]),
534
- _: 1
535
- }, 8, ["disabled", "modelValue", "rules"]),
536
- y("div", In, [
537
- V(Fe, {
538
- modelValue: d(a).rules,
539
- "onUpdate:modelValue": e[2] || (e[2] = (s) => d(a).rules = s),
540
- disabled: o.disabled
541
- }, null, 8, ["modelValue", "disabled"])
542
- ])
543
- ]);
544
- };
545
- }
546
- });
547
- function Rn(f) {
548
- const B = en(), { t: b } = nn(), c = Y(), a = S(() => [
549
- {
550
- id: "delete",
551
- header: "",
552
- cell(t) {
553
- const n = t.row.original;
554
- return O(
555
- "div",
556
- { class: "w-full flex justify-end" },
557
- O(ee.FmButton, {
558
- class: "delete-button",
559
- key: n._id,
560
- type: "button",
561
- icon: "delete",
562
- variant: "tertiary",
563
- size: "md",
564
- disabled: f.disabled ?? !1,
565
- onClick: () => {
566
- f.bindingAlternatives = f.bindingAlternatives.filter(
567
- (o) => o._id !== n._id
568
- );
569
- }
570
- })
571
- );
572
- },
573
- enableSorting: !1,
574
- size: 40,
575
- meta: {
576
- cellClass: "",
577
- headerClass: ""
578
- }
579
- },
580
- {
581
- id: "alternative",
582
- header: () => b("inventory.inventoryBindings.alternativeTable.ingredient"),
583
- accessorFn: (t) => {
584
- var n, o;
585
- return `${((n = c.skuById[t._id]) == null ? void 0 : n.name) ?? ""} (${((o = c.skuById[t._id]) == null ? void 0 : o.code) ?? ""})`;
586
- },
587
- cell: ({ row: t }) => {
588
- const n = c.skuById[t.original._id];
589
- return O(
590
- "div",
591
- {
592
- class: "w-full flex flex-col"
593
- },
594
- [
595
- O("div", { class: "fm-typo-en-body-lg-400 line-clamp-1" }, n.name),
596
- O(
597
- "div",
598
- { class: "fm-typo-en-body-md-400 line-clamp-1 text-fm-color-typo-secondary" },
599
- n.code
600
- )
601
- ]
602
- );
603
- },
604
- size: "auto",
605
- enableSorting: !1
606
- },
607
- {
608
- id: "unit",
609
- header: () => b("inventory.inventoryBindings.alternativeTable.unit"),
610
- accessorFn: (t) => {
611
- const n = c.skuById[t._id];
612
- return n.unit.measurements.computeFirst(
613
- (o) => o.id === t.trackingMeasurement ? o.name : null
614
- ) ?? n.unit.name;
615
- },
616
- enableSorting: !1
617
- },
618
- {
619
- id: "unitOption",
620
- header: () => b("inventory.inventoryBindings.alternativeTable.unit"),
621
- accessorKey: "trackingMeasurement",
622
- cell(t) {
623
- const n = c.skuById[t.row.original._id];
624
- if (!n) return null;
625
- const o = [
626
- {
627
- label: n.unit.name,
628
- sublabel: n.unit.abbrev,
629
- value: null
630
- },
631
- ...n.unit.measurements.map((e) => ({
632
- label: `${e.name} (${e.abbrev})`,
633
- sublabel: b("inventory.inventoryBindings.alternativeTable.measurementOption"),
634
- value: e.id
635
- }))
636
- ].filter((e) => !e.label.toLowerCase().includes("inactive"));
637
- return O(ee.FmSelect, {
638
- modelValue: t.row.original.trackingMeasurement ?? null,
639
- items: o,
640
- disabled: f.disabled ?? !1,
641
- "onUpdate:modelValue": (e) => {
642
- f.bindingAlternatives = f.bindingAlternatives.map((i) => i._id === t.row.original._id ? { ...i, trackingMeasurement: e } : i);
643
- }
644
- });
645
- },
646
- enableSorting: !1
647
- },
648
- {
649
- id: "priority",
650
- header: () => b("inventory.inventoryBindings.alternativeTable.priority"),
651
- accessorKey: "priority",
652
- enableSorting: !0,
653
- cell(t) {
654
- const n = t.row.original;
655
- return O(ee.FmTextField, {
656
- modelValue: n.priority ?? t.row.index + 1,
657
- rules: [
658
- je(),
659
- de(1),
660
- Be(
661
- f.bindingAlternatives.filter((o) => o._id !== n._id).map((o) => {
662
- const e = c.skuById[o._id];
663
- return {
664
- label: e == null ? void 0 : e.name,
665
- value: o.priority
666
- };
667
- })
668
- )
669
- ],
670
- "onUpdate:modelValue": (o) => {
671
- const e = Number(o);
672
- isNaN(e) || (f.bindingAlternatives = f.bindingAlternatives.map((i) => i._id === t.row.original._id ? { ...i, priority: e } : i));
673
- }
674
- });
675
- }
676
- },
677
- {
678
- id: "default",
679
- header: () => "",
680
- accessorKey: "default",
681
- cell(t) {
682
- const n = c.skuById[t.row.original._id];
683
- return n ? O(ee.FmCheckbox, {
684
- modelValue: t.row.original.default ?? !1,
685
- value: n._id,
686
- disabled: f.disabled ?? !1,
687
- "onUpdate:modelValue": () => {
688
- f.bindingAlternatives = f.bindingAlternatives.map((o) => o._id === t.row.original._id ? { ...o, default: !0 } : { ...o, default: !1 });
689
- }
690
- }) : null;
691
- },
692
- enableSorting: !1,
693
- size: 40,
694
- meta: {
695
- cellClass: "",
696
- headerClass: ""
697
- }
698
- },
699
- {
700
- id: "move",
701
- header: "",
702
- cell(t) {
703
- const n = t.row.original;
704
- return O("div", { class: "w-full flex justify-end" }, [
705
- O(ee.FmButton, {
706
- key: n._id,
707
- type: "button",
708
- icon: "keyboard_arrow_up",
709
- variant: "tertiary",
710
- size: "md",
711
- disabled: f.disabled ?? !1,
712
- onClick: () => {
713
- const o = [...f.bindingAlternatives], e = o.findIndex((i) => i._id === n._id);
714
- if (e > 0) {
715
- const i = o[e - 1];
716
- o[e - 1] = n, o[e] = i;
717
- }
718
- f.bindingAlternatives = [...o];
719
- }
720
- }),
721
- O(ee.FmButton, {
722
- key: n._id,
723
- type: "button",
724
- icon: "keyboard_arrow_down",
725
- variant: "tertiary",
726
- size: "md",
727
- disabled: f.disabled ?? !1,
728
- onClick: () => {
729
- const o = [...f.bindingAlternatives], e = o.findIndex((i) => i._id === n._id);
730
- if (e < o.length - 1) {
731
- const i = o[e + 1];
732
- o[e + 1] = n, o[e] = i;
733
- }
734
- f.bindingAlternatives = [...o];
735
- }
736
- })
737
- ]);
738
- },
739
- enableSorting: !1,
740
- size: 40,
741
- meta: {
742
- cellClass: "",
743
- headerClass: ""
744
- }
745
- }
746
- ]);
747
- return {
748
- get columnDefs() {
749
- return a.value;
750
- },
751
- promptAddIngredient: async (_) => {
752
- const t = [];
753
- for (const e of c.skus)
754
- _.includes(e._id) || t.push({
755
- label: e.name,
756
- sublabel: e.code,
757
- value: e._id,
758
- disabled: _.includes(e._id)
759
- });
760
- const n = (f.bindingAlternatives ?? []).map((e) => e._id), o = await B.multiSelect(t, n, (e) => {
761
- var r, g, m, l, s, k;
762
- const i = (r = f.bindingAlternatives) == null ? void 0 : r.findIndex((C) => C._id === e);
763
- return {
764
- _id: e,
765
- trackingMeasurement: typeof i != "number" || i == -1 ? (g = c.skuById[e]) == null ? void 0 : g.trackingMeasurement : (l = (m = f.bindingAlternatives) == null ? void 0 : m[i]) == null ? void 0 : l.trackingMeasurement,
766
- priority: ((k = (s = f.bindingAlternatives) == null ? void 0 : s[i]) == null ? void 0 : k.priority) ?? f.bindingAlternatives.length,
767
- default: !1
768
- };
769
- });
770
- f.bindingAlternatives = o ?? f.bindingAlternatives;
771
- },
772
- columnVisibility: {
773
- delete: !0,
774
- unit: !1,
775
- unitOption: !0,
776
- default: !1,
777
- // previous demo: sort priority by moving sku element in the array,
778
- // new demo: sort priority using priority field.
779
- // can reenable if this use case is requested to be restored
780
- move: !1
781
- }
782
- };
783
- }
784
- const Sn = { class: "flex flex-col gap-16" }, $n = { class: "flex flex-col" }, En = { class: "flex justify-between items-center px-2" }, Tn = /* @__PURE__ */ W({
785
- __name: "InventoryBindingAlternative",
786
- props: {
787
- disabled: { type: Boolean },
788
- modelValue: {},
789
- filterIngredientIds: {}
790
- },
791
- emits: ["update:modelValue"],
792
- setup(f, { emit: B }) {
793
- const b = f, c = B, { t: a } = Q(), u = Rn({
794
- get disabled() {
795
- return b.disabled ?? !1;
796
- },
797
- get bindingAlternatives() {
798
- return b.modelValue ?? [];
799
- },
800
- set bindingAlternatives(n) {
801
- c("update:modelValue", n);
802
- }
803
- }), _ = (n) => n && n.some((o) => b.filterIngredientIds.includes(o._id)) ? "Contains invalid ingredient" : !0, t = (n) => n && n.length > 5 ? a("inventory.binding.alternative.maximumExceeded", { max: 5 }) : !0;
804
- return (n, o) => {
805
- var m;
806
- const e = A("FmLabel"), i = A("FmButton"), r = A("FmFormGroup"), g = A("FmTable");
807
- return x(), R("div", Sn, [
808
- y("div", $n, [
809
- y("div", En, [
810
- V(e, {
811
- label: d(a)("inventory.alternatives")
812
- }, null, 8, ["label"]),
813
- V(i, {
814
- disabled: n.disabled,
815
- "prepend-icon": "link",
816
- variant: "primary",
817
- class: "border-1 rounded-lg border-fm-color-primary",
818
- onClick: o[0] || (o[0] = (l) => d(u).promptAddIngredient(n.filterIngredientIds)),
819
- size: "md"
820
- }, null, 8, ["disabled"])
821
- ]),
822
- V(r, {
823
- "model-value": n.modelValue,
824
- rules: [_, t]
825
- }, null, 8, ["model-value", "rules"])
826
- ]),
827
- V(g, {
828
- "row-data": n.modelValue ?? [],
829
- "column-defs": d(u).columnDefs,
830
- "page-size": ((m = n.modelValue) == null ? void 0 : m.length) || 0,
831
- "shrink-at": 9999,
832
- "column-visibility": d(u).columnVisibility,
833
- "hide-footer": ""
834
- }, null, 8, ["row-data", "column-defs", "page-size", "column-visibility"])
835
- ]);
836
- };
837
- }
838
- }), Un = { class: "border-1 mx-3 my-1 rounded-md" }, Pn = { class: "flex flex-col border-b border-fm-color-neutral-gray-100" }, Dn = {
839
- class: "flex items-center w-full",
840
- style: { "min-height": "48px" }
841
- }, Gn = { class: "flex-1 fm-typo-en-body-md-400 py-8 px-12" }, Mn = { class: "line-clamp-1 w-full" }, Nn = { class: "w-[150px]" }, zn = {
842
- key: 0,
843
- class: "w-[52px]"
844
- }, Kn = { class: "flex flex-col px-12 pb-4" }, Ln = /* @__PURE__ */ W({
845
- __name: "InventorySkuBindingV2Field",
846
- props: {
847
- disabled: { type: Boolean },
848
- readonly: { type: Boolean },
849
- modelValue: {},
850
- displayName: {},
851
- unit: {},
852
- showError: { type: Boolean },
853
- ableToConfigureAlternative: { type: Boolean },
854
- ableToApplyRules: { type: Boolean }
855
- },
856
- emits: ["update:modelValue", "delete", "settings"],
857
- setup(f, { emit: B }) {
858
- const b = B, { t: c } = Q(), a = we("modelValue");
859
- function u(t) {
860
- t && (a.amount = t.amount, a.measurement = t.measurement);
861
- }
862
- function _() {
863
- return {
864
- modelValue: {
865
- amount: a.amount,
866
- measurement: a.measurement
867
- },
868
- amountAsString: tn.toFormatString({
869
- value: a.amount
870
- })
871
- };
872
- }
873
- return (t, n) => {
874
- const o = A("FmTooltip"), e = A("FmButton"), i = A("FmFormGroup");
875
- return x(), R("div", Un, [
876
- y("div", Pn, [
877
- y("div", Dn, [
878
- y("div", Gn, [
879
- V(o, {
880
- zIndex: 51,
881
- variant: "plain",
882
- placement: "top",
883
- content: t.displayName
884
- }, {
885
- default: K(() => [
886
- y("span", Mn, z(t.displayName), 1)
887
- ]),
888
- _: 1
889
- }, 8, ["content"])
890
- ]),
891
- y("div", Nn, [
892
- V(Qe, {
893
- "model-value": { amount: d(a).amount, measurement: d(a).measurement },
894
- "onUpdate:modelValue": u,
895
- unit: t.unit,
896
- placement: "bottom",
897
- "convert-amount-on-change-unit": "",
898
- disabled: t.readonly
899
- }, null, 8, ["model-value", "unit", "disabled"])
900
- ]),
901
- t.readonly ? E("", !0) : (x(), R("div", zn, [
902
- V(e, {
903
- disabled: t.disabled,
904
- type: "button",
905
- variant: "tertiary",
906
- icon: "delete",
907
- onClick: n[0] || (n[0] = () => b("delete", d(a).id))
908
- }, null, 8, ["disabled"])
909
- ]))
910
- ]),
911
- y("div", Kn, [
912
- V(i, {
913
- modelValue: d(a).amount,
914
- rules: [d(fe)(0)]
915
- }, null, 8, ["modelValue", "rules"]),
916
- V(i, {
917
- modelValue: _(),
918
- rules: [
919
- d(Xe)(),
920
- d(Ze)(t.unit),
921
- () => t.showError ? d(c)("inventory.inventoryBindings.invalidWarning") : !0
922
- ]
923
- }, null, 8, ["modelValue", "rules"])
924
- ]),
925
- t.ableToApplyRules ? (x(), D(Fe, {
926
- key: 0,
927
- modelValue: d(a).rules,
928
- "onUpdate:modelValue": n[1] || (n[1] = (r) => d(a).rules = r),
929
- disabled: t.disabled
930
- }, null, 8, ["modelValue", "disabled"])) : E("", !0),
931
- t.ableToConfigureAlternative ? (x(), D(Tn, {
932
- key: 1,
933
- modelValue: d(a).alternatives,
934
- "onUpdate:modelValue": n[2] || (n[2] = (r) => d(a).alternatives = r),
935
- disabled: t.disabled,
936
- filterIngredientIds: [d(a).id]
937
- }, null, 8, ["modelValue", "disabled", "filterIngredientIds"])) : E("", !0)
938
- ])
939
- ]);
940
- };
941
- }
942
- });
943
- exports.FfCalculator;
944
- const On = { class: "flex flex-col gap-24" }, jn = {
945
- key: 0,
946
- class: "flex flex-col gap-16"
947
- }, Yn = { class: "flex items-center" }, qn = { class: "flex-1 fm-typo-en-title-sm-600" }, Hn = { class: "flex flex-col" }, Jn = { class: "flex py-8 px-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 h-[44px] items-center" }, Wn = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Qn = {
948
- key: 0,
949
- class: "w-[52px]"
950
- }, Xn = {
951
- key: 1,
952
- class: "w-[52px]"
953
- }, Zn = {
954
- key: 1,
955
- class: "flex flex-col gap-16"
956
- }, et = { class: "flex items-center" }, nt = { class: "flex-1 fm-typo-en-title-sm-600" }, tt = { class: "flex flex-col" }, ot = { class: "flex py-8 px-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 h-[44px] items-center" }, it = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, lt = { class: "flex flex-col w-full border-b border-fm-color-neutral-gray-100" }, st = {
957
- key: 0,
958
- class: "flex gap-4 text-fm-color-system-error-400 fm-typo-en-body-sm-400"
959
- }, at = {
960
- class: "flex items-center",
961
- style: { "min-height": "48px" }
962
- }, rt = { class: "flex-1 fm-typo-en-body-md-400 py-8 px-12" }, dt = { class: "flex flex-col" }, ut = { class: "w-[200px]" }, mt = {
963
- key: 0,
964
- class: "w-[52px]"
965
- }, ct = { class: "flex flex-col gap-16" }, pt = { class: "flex items-center" }, ft = { class: "flex-1 fm-typo-en-title-sm-600" }, vt = { class: "flex flex-col" }, yt = { class: "flex py-8 px-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 h-[44px] items-center" }, bt = { class: "flex-1 fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, gt = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary w-[150px] px-16" }, _t = {
966
- key: 0,
967
- class: "w-[52px]"
968
- }, ht = /* @__PURE__ */ W({
969
- __name: "InventoryBindingFormV2",
970
- props: {
971
- id: {},
972
- modelValue: { default: () => [] },
973
- excludeBindingId: {},
974
- rules: { default: () => [] },
975
- iframeMode: { type: Boolean },
976
- disabled: { type: Boolean },
977
- readonly: { type: Boolean },
978
- recipeBindingConfig: { default: () => ({ enabled: !0, ableToApplyRules: !1 }) },
979
- skuBindingConfig: { default: () => ({
980
- enabled: !0,
981
- ableToApplyRules: !1,
982
- ableToConfigureAlternative: !1
983
- }) },
984
- enableIngredientGroup: { type: Boolean }
985
- },
986
- emits: ["update:modelValue", "click:pick-inventory-bindings"],
987
- setup(f, { emit: B }) {
988
- const { t: b } = Q(), c = Y(), a = S(() => c.recipeById), u = S(() => c.skuById), _ = S(() => c.skuGroupById), t = f, n = B, o = S(() => Ee({
989
- parentId: t.id,
990
- bindings: t.modelValue,
991
- recipes: c.recipes.map((F) => F._id === t.id ? {
992
- ...F,
993
- contains: t.modelValue
994
- } : F),
995
- skus: c.skus.map((F) => F._id === t.id ? {
996
- ...F,
997
- convert: {
998
- inventoryBindings: t.modelValue
999
- }
1000
- } : F),
1001
- skuGroups: c.skuGroups
1002
- }).inventoryBindings.filter((F) => "error" in F && F.error).map((F) => F).filter((F) => F.reason === Te.enum.circularDependency)), e = S(
1003
- () => new Set(o.value.map((v) => {
1004
- var w;
1005
- return (w = v.bindingPaths[0]) == null ? void 0 : w.id;
1006
- }))
1007
- ), i = S(() => t.modelValue.filter((v) => v.type === "RECIPE")), { promptIngredientsBinding: r, promptRecipesBinding: g, promptIngredientGroupsBinding: m } = yn();
1008
- async function l() {
1009
- if (t.iframeMode) {
1010
- n("click:pick-inventory-bindings", "RECIPE");
1011
- return;
1012
- }
1013
- g(
1014
- t.modelValue,
1015
- (v) => n("update:modelValue", v),
1016
- t.id ? [t.id] : []
1017
- );
1018
- }
1019
- const s = S(() => t.modelValue.filter((v) => v.type === "SKU_GROUP"));
1020
- async function k() {
1021
- m(
1022
- t.modelValue,
1023
- (v) => n("update:modelValue", v),
1024
- t.id ? [t.id] : []
1025
- );
1026
- }
1027
- function C(v, w, F) {
1028
- const T = +w;
1029
- let q = F;
1030
- w.length > 0 && isFinite(T) ? q = F.map((P) => (P.id !== v || (P.amount = ke(T)), P)) : q = F.map((P) => (P.id !== v || (P.amount = { amount: 0, precision: 0 }), P)), n("update:modelValue", q);
1031
- }
1032
- const I = S(() => t.modelValue.filter((v) => v.type === "SKU") ?? []);
1033
- async function M() {
1034
- if (t.iframeMode) {
1035
- n("click:pick-inventory-bindings", "SKU");
1036
- return;
1037
- }
1038
- r(
1039
- t.modelValue,
1040
- (v) => n("update:modelValue", v),
1041
- t.excludeBindingId,
1042
- t.id ? [t.id] : []
1043
- );
1044
- }
1045
- function H(v) {
1046
- const w = t.modelValue.map((F) => F.id === v.id ? v : F);
1047
- n("update:modelValue", w);
1048
- }
1049
- function p(v) {
1050
- const w = t.modelValue.filter((F) => F.id !== v);
1051
- n("update:modelValue", w);
1052
- }
1053
- function h(v) {
1054
- var F, T;
1055
- if (v.type !== ie.enum.SKU)
1056
- throw new Error("Non-SKU binding does not have unit");
1057
- if (!((F = u.value[v.id]) == null ? void 0 : F.unit))
1058
- throw new Error(`Cannot find ingredient: ${v.id}`);
1059
- return (T = u.value[v.id]) == null ? void 0 : T.unit;
1060
- }
1061
- return (v, w) => {
1062
- var U, X, L;
1063
- const F = A("FmFormGroup"), T = A("FmButton"), q = A("FmIcon"), P = A("FmTextField");
1064
- return x(), R("div", On, [
1065
- V(F, {
1066
- disabled: v.disabled,
1067
- "model-value": v.modelValue,
1068
- rules: [
1069
- ...v.rules,
1070
- () => o.value.length ? "There is a binding error in your configuration" : !0
1071
- ]
1072
- }, {
1073
- label: K(() => w[4] || (w[4] = [
1074
- y("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Define the inventory bindings for this recipe or ingredient. ", -1)
1075
- ])),
1076
- _: 1
1077
- }, 8, ["disabled", "model-value", "rules"]),
1078
- ((U = v.recipeBindingConfig) == null ? void 0 : U.enabled) !== !1 ? (x(), R("div", jn, [
1079
- y("div", Yn, [
1080
- y("div", qn, z(d(b)("inventory.inventoryBindings.recipe")), 1),
1081
- v.readonly ? E("", !0) : (x(), D(T, {
1082
- key: 0,
1083
- variant: "secondary",
1084
- "text-color": "primary",
1085
- "border-color": "primary",
1086
- label: d(b)("inventory.inventoryBindings.linkRecipe"),
1087
- "prepend-icon": "link",
1088
- onClick: l
1089
- }, null, 8, ["label"]))
1090
- ]),
1091
- y("div", Hn, [
1092
- y("div", Jn, [
1093
- y("div", Wn, z(d(b)("inventory.inventoryBindings.recipe")), 1),
1094
- w[5] || (w[5] = y("div", { class: "w-[200px]" }, null, -1)),
1095
- v.recipeBindingConfig.ableToApplyRules ? (x(), R("div", Qn)) : E("", !0),
1096
- v.readonly ? E("", !0) : (x(), R("div", Xn))
1097
- ]),
1098
- (x(!0), R(oe, null, ae(i.value, ($) => {
1099
- var Z;
1100
- return x(), D(An, {
1101
- key: $.id,
1102
- "model-value": $,
1103
- "display-name": (Z = a.value[$.id]) == null ? void 0 : Z.name,
1104
- "show-error": e.value.has($.id),
1105
- readonly: v.readonly,
1106
- disabled: v.disabled,
1107
- "onUpdate:modelValue": w[0] || (w[0] = (J) => H(J)),
1108
- onDelete: w[1] || (w[1] = (J) => p(J))
1109
- }, null, 8, ["model-value", "display-name", "show-error", "readonly", "disabled"]);
1110
- }), 128))
1111
- ])
1112
- ])) : E("", !0),
1113
- v.enableIngredientGroup ? (x(), R("div", Zn, [
1114
- y("div", et, [
1115
- y("div", nt, z(d(b)("inventory.inventoryBindings.ingredientGroup")), 1),
1116
- v.readonly ? E("", !0) : (x(), D(T, {
1117
- key: 0,
1118
- variant: "secondary",
1119
- "text-color": "primary",
1120
- "border-color": "primary",
1121
- label: d(b)("inventory.inventoryBindings.linkIngredientGroup"),
1122
- "prepend-icon": "link",
1123
- onClick: k
1124
- }, null, 8, ["label"]))
1125
- ]),
1126
- y("div", tt, [
1127
- y("div", ot, [
1128
- y("div", it, z(d(b)("inventory.inventoryBindings.ingredientGroup")), 1),
1129
- w[6] || (w[6] = y("div", { class: "w-[200px]" }, null, -1)),
1130
- w[7] || (w[7] = y("div", { class: "w-[52px]" }, null, -1))
1131
- ]),
1132
- (x(!0), R(oe, null, ae(s.value, ($) => (x(), D(F, {
1133
- key: $.id,
1134
- disabled: v.disabled,
1135
- modelValue: +d(j)($.amount ?? { amount: 1, precision: 0 }),
1136
- rules: [d(xe)(0), d(fe)(0)]
1137
- }, {
1138
- default: K(({ invalid: Z }) => {
1139
- var J;
1140
- return [
1141
- y("div", lt, [
1142
- e.value.has($.id) ? (x(), R("div", st, [
1143
- V(q, {
1144
- name: "error",
1145
- color: "system-error-300",
1146
- size: "sm"
1147
- }),
1148
- y("div", null, z(d(b)("inventory.inventoryBindings.circularError")), 1)
1149
- ])) : E("", !0),
1150
- y("div", at, [
1151
- y("div", rt, [
1152
- y("div", dt, z((J = _.value[$.id]) == null ? void 0 : J.name), 1)
1153
- ]),
1154
- y("div", ut, [
1155
- V(P, {
1156
- class: "w-full",
1157
- disabled: v.disabled,
1158
- modelValue: +d(j)($.amount ?? { amount: 1, precision: 0 }),
1159
- "onUpdate:modelValue": (ne) => C($.id, ne, v.modelValue),
1160
- invalid: Z
1161
- }, null, 8, ["disabled", "modelValue", "onUpdate:modelValue", "invalid"])
1162
- ]),
1163
- v.readonly ? E("", !0) : (x(), R("div", mt, [
1164
- V(T, {
1165
- disabled: v.disabled,
1166
- type: "button",
1167
- variant: "plain",
1168
- icon: "delete",
1169
- "icon-color": "#000000",
1170
- onClick: (ne) => p($.id)
1171
- }, null, 8, ["disabled", "onClick"])
1172
- ]))
1173
- ])
1174
- ])
1175
- ];
1176
- }),
1177
- _: 2
1178
- }, 1032, ["disabled", "modelValue", "rules"]))), 128))
1179
- ])
1180
- ])) : E("", !0),
1181
- y("div", ct, [
1182
- y("div", pt, [
1183
- y("div", ft, z(d(b)("inventory.inventoryBindings.ingredient")), 1),
1184
- v.readonly ? E("", !0) : (x(), D(T, {
1185
- key: 0,
1186
- variant: "secondary",
1187
- "text-color": "primary",
1188
- "border-color": "primary",
1189
- label: d(b)("inventory.inventoryBindings.linkIngredient"),
1190
- "prepend-icon": "link",
1191
- onClick: M
1192
- }, null, 8, ["label"]))
1193
- ]),
1194
- y("div", vt, [
1195
- y("div", yt, [
1196
- y("div", bt, z(d(b)("inventory.inventoryBindings.ingredient")), 1),
1197
- y("div", gt, z(d(b)("inventory.inventoryBindings.amount")), 1),
1198
- w[8] || (w[8] = y("div", { class: "w-[52px]" }, null, -1)),
1199
- (X = v.skuBindingConfig) != null && X.ableToApplyRules || (L = v.skuBindingConfig) != null && L.ableToConfigureAlternative ? (x(), R("div", _t)) : E("", !0)
1200
- ]),
1201
- (x(!0), R(oe, null, ae(I.value, ($) => {
1202
- var Z, J, ne;
1203
- return x(), D(Ln, {
1204
- key: $.id,
1205
- "model-value": $,
1206
- "display-name": (Z = u.value[$.id]) == null ? void 0 : Z.name,
1207
- unit: h($),
1208
- "show-error": e.value.has($.id),
1209
- "able-to-apply-rules": ((J = v.skuBindingConfig) == null ? void 0 : J.ableToApplyRules) === !0,
1210
- "able-to-configure-alternative": ((ne = v.skuBindingConfig) == null ? void 0 : ne.ableToConfigureAlternative) === !0,
1211
- readonly: v.readonly,
1212
- disabled: v.disabled,
1213
- "onUpdate:modelValue": w[2] || (w[2] = (se) => H(se)),
1214
- onDelete: w[3] || (w[3] = (se) => p(se))
1215
- }, null, 8, ["model-value", "display-name", "unit", "show-error", "able-to-apply-rules", "able-to-configure-alternative", "readonly", "disabled"]);
1216
- }), 128))
1217
- ])
1218
- ])
1219
- ]);
1220
- };
1221
- }
1222
- }), Vt = { class: "flex flex-col gap-40" }, kt = {
1223
- key: 0,
1224
- class: "flex flex-col gap-16"
1225
- }, xt = {
1226
- key: 0,
1227
- class: "col-span-2 mt-16 border-1 border-fm-color-neutral-gray-200 fm-corner-radius-lg flex flex-col p-16 gap-16"
1228
- }, Bt = {
1229
- key: 0,
1230
- class: "flex flex-col items-center w-full h-full gap-24"
1231
- }, wt = { key: 1 }, Ft = { class: "mt-32" }, Ct = /* @__PURE__ */ W({
1232
- __name: "RecipeForm",
1233
- props: {
1234
- mode: {},
1235
- modelValue: {},
1236
- disabled: { type: Boolean }
1237
- },
1238
- emits: ["update:modelValue", "click:submit"],
1239
- setup(f, { expose: B, emit: b }) {
1240
- var H;
1241
- const c = f, a = b, u = ln(), { t: _ } = Q(), t = S({
1242
- get() {
1243
- var p;
1244
- return ((p = c.modelValue) == null ? void 0 : p.name) ?? "";
1245
- },
1246
- set(p) {
1247
- const h = c.modelValue ?? {};
1248
- h.name = p, a("update:modelValue", h);
1249
- }
1250
- }), n = S({
1251
- get() {
1252
- var p;
1253
- return ((p = c.modelValue) == null ? void 0 : p.contains) ?? [];
1254
- },
1255
- set(p) {
1256
- const h = c.modelValue ?? {};
1257
- h.contains = p, a("update:modelValue", h);
1258
- }
1259
- }), o = S({
1260
- get() {
1261
- var p;
1262
- return ((p = c.modelValue) == null ? void 0 : p.customAttributes) ?? {};
1263
- },
1264
- set(p) {
1265
- const h = c.modelValue ? {
1266
- ...c.modelValue
1267
- } : {};
1268
- h.customAttributes = p, a("update:modelValue", h);
1269
- }
1270
- }), e = S({
1271
- get() {
1272
- var p;
1273
- return ((p = c.modelValue) == null ? void 0 : p.version) ?? null;
1274
- },
1275
- set(p) {
1276
- const h = c.modelValue ? { ...c.modelValue } : {};
1277
- h.version = p, a("update:modelValue", h);
1278
- }
1279
- }), i = S({
1280
- get() {
1281
- return e.value === "v2";
1282
- },
1283
- set(p) {
1284
- e.value = p ? "v2" : null;
1285
- }
1286
- });
1287
- function r() {
1288
- a("click:submit");
1289
- }
1290
- const g = G();
1291
- B({
1292
- validateInputs: () => {
1293
- var p, h;
1294
- (h = (p = g.value) == null ? void 0 : p.validateInputs) == null || h.call(p);
1295
- },
1296
- resetInputsValidation: () => {
1297
- var p, h;
1298
- (h = (p = g.value) == null ? void 0 : p.resetInputsValidation) == null || h.call(p);
1299
- },
1300
- resetInputs: () => {
1301
- var p, h;
1302
- (h = (p = g.value) == null ? void 0 : p.resetInputs) == null || h.call(p);
1303
- }
1304
- });
1305
- const m = Y(), l = G([]), s = G(!1), k = G(!1);
1306
- le(s, async (p) => {
1307
- C(p);
1308
- });
1309
- async function C(p) {
1310
- var h, v;
1311
- p && !k.value && ((h = c.modelValue) != null && h._id) && (k.value = !0, l.value = await m.getAffectedMenu((v = c.modelValue) == null ? void 0 : v._id).delayed(500), k.value = !1);
1312
- }
1313
- const I = S(
1314
- () => m.recipes.map((p) => ({ label: p.name, value: p.name }))
1315
- ), M = G((H = c.modelValue) == null ? void 0 : H.name);
1316
- return (p, h) => {
1317
- const v = A("FmTextField"), w = A("FmSwitch"), F = A("FmCard"), T = A("FmSpacer"), q = A("FmCircularProgress"), P = A("FmForm");
1318
- return x(), D(P, {
1319
- ref_key: "formRef",
1320
- ref: g,
1321
- onValidationSuccess: r
1322
- }, {
1323
- default: K(() => [
1324
- y("div", Vt, [
1325
- V(v, {
1326
- disabled: p.disabled,
1327
- label: d(_)("inventory.recipe.name"),
1328
- "model-value": t.value,
1329
- "onUpdate:modelValue": h[0] || (h[0] = (U) => t.value = U),
1330
- rules: [
1331
- d(Ye)(),
1332
- d(Be)(I.value, M.value, (U) => `[${U.value}] already exists`)
1333
- ],
1334
- "label-mark": "required"
1335
- }, null, 8, ["disabled", "label", "model-value", "rules"]),
1336
- d(u).enableRecipeV2 ? (x(), R("div", kt, [
1337
- V(w, {
1338
- modelValue: i.value,
1339
- "onUpdate:modelValue": h[1] || (h[1] = (U) => i.value = U),
1340
- value: !0,
1341
- label: d(_)("inventory.recipe.enableRecipeV2"),
1342
- "label-placement": "right",
1343
- disabled: p.disabled,
1344
- sublabel: d(_)("inventory.recipe.recipeV2Warning")
1345
- }, null, 8, ["modelValue", "label", "disabled", "sublabel"])
1346
- ])) : E("", !0),
1347
- V(F, {
1348
- variant: "outlined",
1349
- class: "p-16"
1350
- }, {
1351
- default: K(() => {
1352
- var U, X;
1353
- return [
1354
- d(u).enableRecipeV2 ? (x(), D(ht, {
1355
- key: 0,
1356
- id: (U = p.modelValue) == null ? void 0 : U._id,
1357
- disabled: p.disabled,
1358
- "model-value": n.value,
1359
- "onUpdate:modelValue": h[2] || (h[2] = (L) => n.value = L),
1360
- rules: [d(de)(1)],
1361
- "enable-ingredient-group": d(u).enableIngredientGroup,
1362
- "recipe-binding-config": { enabled: !i.value, ableToApplyRules: i.value },
1363
- "sku-binding-config": {
1364
- ableToConfigureAlternative: i.value
1365
- }
1366
- }, null, 8, ["id", "disabled", "model-value", "rules", "enable-ingredient-group", "recipe-binding-config", "sku-binding-config"])) : (x(), D(qe, {
1367
- key: 1,
1368
- id: (X = p.modelValue) == null ? void 0 : X._id,
1369
- disabled: p.disabled,
1370
- "model-value": n.value,
1371
- "onUpdate:modelValue": h[3] || (h[3] = (L) => n.value = L),
1372
- rules: [d(de)(1)],
1373
- "enable-ingredient-group": d(u).enableIngredientGroup
1374
- }, null, 8, ["id", "disabled", "model-value", "rules", "enable-ingredient-group"]))
1375
- ];
1376
- }),
1377
- _: 1
1378
- })
1379
- ]),
1380
- p.mode !== d(N).CREATE ? (x(), R("div", xt, [
1381
- V(w, {
1382
- label: "Show binded items",
1383
- modelValue: s.value,
1384
- "onUpdate:modelValue": h[4] || (h[4] = (U) => s.value = U),
1385
- "label-placement": "right",
1386
- disabled: k.value
1387
- }, null, 8, ["modelValue", "disabled"]),
1388
- k.value ? (x(), R("div", Bt, [
1389
- V(T),
1390
- y("div", null, [
1391
- V(q, { size: "xl" })
1392
- ]),
1393
- h[6] || (h[6] = y("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary pl-8" }, "Loading...", -1)),
1394
- V(T)
1395
- ])) : s.value && l.value.length ? (x(), R("div", wt, [
1396
- V(Ve, {
1397
- name: "Menu",
1398
- bindings: l.value
1399
- }, null, 8, ["bindings"])
1400
- ])) : E("", !0)
1401
- ])) : E("", !0),
1402
- y("div", Ft, [
1403
- V(on, {
1404
- entity: "inventoryRecipe",
1405
- modelValue: o.value,
1406
- "onUpdate:modelValue": h[5] || (h[5] = (U) => o.value = U)
1407
- }, null, 8, ["modelValue"])
1408
- ])
1409
- ]),
1410
- _: 1
1411
- }, 512);
1412
- };
1413
- }
1414
- }), It = { class: "flex gap-4" }, At = /* @__PURE__ */ W({
1415
- __name: "RecipeDialog",
1416
- props: {
1417
- show: { type: Boolean },
1418
- recipe: {},
1419
- mode: { default: N.READ }
1420
- },
1421
- emits: ["update:show"],
1422
- setup(f) {
1423
- const B = f, b = Y(), c = pe(), { t: a } = Q(), u = be(B, "show"), _ = be(B, "recipe"), t = S(() => {
1424
- switch (B.mode) {
1425
- case N.READ:
1426
- return "";
1427
- case N.UPDATE:
1428
- return a("inventory.recipe.update.title");
1429
- case N.CREATE:
1430
- return a("inventory.recipe.create.title");
1431
- }
1432
- return "";
1433
- }), n = S(() => {
1434
- switch (B.mode) {
1435
- case N.READ:
1436
- return "";
1437
- case N.UPDATE:
1438
- return a("common.save");
1439
- case N.CREATE:
1440
- return a("common.add");
1441
- }
1442
- return "";
1443
- }), o = G(), e = G(!1);
1444
- async function i() {
1445
- e.value = !0;
1446
- try {
1447
- const l = me(_.value);
1448
- l.precision ?? (l.precision = 0), l.measurements ?? (l.measurements = []), await b.createRecipe(l), u.value = !1, c.open({
1449
- title: a("inventory.common.success"),
1450
- message: a("inventory.recipe.create.success", { name: _.value.name }),
1451
- type: "success"
1452
- });
1453
- } catch (l) {
1454
- l instanceof ye || c.open({
1455
- title: a("inventory.recipe.create.error.title"),
1456
- message: a("inventory.recipe.create.error.message"),
1457
- type: "error"
1458
- });
1459
- } finally {
1460
- e.value = !1;
1461
- }
1462
- }
1463
- async function r() {
1464
- e.value = !0;
1465
- try {
1466
- await b.updateRecipe(_.value), u.value = !1, c.open({
1467
- title: a("inventory.common.success"),
1468
- message: a("inventory.recipe.update.success", { name: _.value.name }),
1469
- type: "success"
1470
- });
1471
- } catch (l) {
1472
- l instanceof ye || c.open({
1473
- title: a("inventory.recipe.update.error.title"),
1474
- message: a("inventory.recipe.update.error.message"),
1475
- type: "error"
1476
- });
1477
- } finally {
1478
- e.value = !1;
1479
- }
1480
- }
1481
- function g() {
1482
- var l, s;
1483
- (s = (l = o.value) == null ? void 0 : l.validateInputs) == null || s.call(l);
1484
- }
1485
- function m() {
1486
- switch (B.mode) {
1487
- case N.READ:
1488
- return;
1489
- case N.UPDATE:
1490
- return r();
1491
- case N.CREATE:
1492
- return i();
1493
- }
1494
- }
1495
- return (l, s) => {
1496
- const k = A("FmButton"), C = A("FmSideSheet");
1497
- return x(), D(C, {
1498
- "model-value": d(u),
1499
- "onUpdate:modelValue": s[3] || (s[3] = (I) => ve(u) ? u.value = I : null),
1500
- header: t.value,
1501
- "close-button": "",
1502
- "dismiss-away": "",
1503
- "max-width": 800
1504
- }, {
1505
- "side-sheet-footer": K(() => [
1506
- y("div", It, [
1507
- V(k, {
1508
- loading: e.value,
1509
- label: n.value,
1510
- onClick: g
1511
- }, null, 8, ["loading", "label"]),
1512
- V(k, {
1513
- disabled: e.value,
1514
- label: d(a)("common.close"),
1515
- variant: "tertiary",
1516
- onClick: s[2] || (s[2] = (I) => u.value = !1)
1517
- }, null, 8, ["disabled", "label"])
1518
- ])
1519
- ]),
1520
- default: K(() => [
1521
- V(Ct, {
1522
- class: "w-full",
1523
- ref_key: "hasValidationExpose",
1524
- ref: o,
1525
- modelValue: d(_),
1526
- "onUpdate:modelValue": s[0] || (s[0] = (I) => ve(_) ? _.value = I : null),
1527
- mode: l.mode,
1528
- disabled: e.value,
1529
- "onClick:submit": s[1] || (s[1] = (I) => m())
1530
- }, null, 8, ["modelValue", "mode", "disabled"])
1531
- ]),
1532
- _: 1
1533
- }, 8, ["model-value", "header"]);
1534
- };
1535
- }
1536
- });
1537
- function Rt(f) {
1538
- return !f || Object.keys(f).length === 0 ? "" : Object.entries(f).map(([B, b]) => `${B}: ${b}`).join(", ");
1539
- }
1540
- function St() {
1541
- const f = Y(), B = f.recipes, b = f.recipeById, c = f.skuById, a = f.skuGroupById, u = B.flatMap((n, o) => {
1542
- var i;
1543
- const e = Rt(n.customAttributes);
1544
- if ((i = n.contains) != null && i.length) {
1545
- const r = n.contains.filter((l) => l.type === "RECIPE"), g = n.contains.filter((l) => l.type === "SKU"), m = n.contains.filter((l) => l.type === "SKU_GROUP");
1546
- return [
1547
- ...o === 0 ? [] : [["", "", "", "", "", "", ""]],
1548
- ...r.map(
1549
- (l, s) => {
1550
- var k;
1551
- return [
1552
- s === 0 ? n.name : "",
1553
- "RECIPE",
1554
- "",
1555
- (k = b[l.id]) == null ? void 0 : k.name,
1556
- j(l.amount),
1557
- "UNIT",
1558
- s === 0 ? e : ""
1559
- ];
1560
- }
1561
- ),
1562
- ...g.map(
1563
- (l, s) => {
1564
- var k, C, I, M;
1565
- return [
1566
- !r.length && s === 0 ? n.name : "",
1567
- "INGREDIENT",
1568
- (k = c[l.id]) == null ? void 0 : k.code,
1569
- (C = c[l.id]) == null ? void 0 : C.name,
1570
- j(l.amount),
1571
- l.measurement ? l.measurement.abbrev : (M = (I = c[l.id]) == null ? void 0 : I.unit) == null ? void 0 : M.abbrev,
1572
- !r.length && s === 0 ? e : ""
1573
- ];
1574
- }
1575
- ),
1576
- ...m.map(
1577
- (l, s) => {
1578
- var k, C;
1579
- return [
1580
- r.length === 0 && g.length === 0 && s === 0 ? n.name : "",
1581
- "SKU_GROUP",
1582
- ((k = a[l.id]) == null ? void 0 : k.ref) || "",
1583
- (C = a[l.id]) == null ? void 0 : C.name,
1584
- j(l.amount),
1585
- "UNIT",
1586
- r.length === 0 && g.length === 0 && s === 0 ? e : ""
1587
- ];
1588
- }
1589
- )
1590
- ];
1591
- }
1592
- return [
1593
- ...o === 0 ? [] : [["", "", "", "", "", "", ""]],
1594
- [n.name, "No bindings", "", "", "", "", e]
1595
- ];
1596
- }), t = an(u, ["Name", "Type", "Code", "Item", "Amount", "Unit", "Custom Attributes"]);
1597
- rn(t, `RECIPE_${dn(/* @__PURE__ */ new Date(), "-", "-")}.xlsx`);
1598
- }
1599
- const $t = { class: "flex flex-col py-8" }, Et = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Tt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ro = /* @__PURE__ */ W({
1600
- __name: "RecipeView",
1601
- setup(f) {
1602
- const B = Y(), b = S(() => B.recipes), c = Ue(), { createRecipe: a, updateRecipe: u } = ue(), { recipeDialogProps: _, recipeViewLoading: t } = Ne(ue()), { columnDefs: n, formatRowData: o } = vn(), e = S(() => o(b.value));
1603
- ce(), pe(), G(!1);
1604
- function i(I) {
1605
- if (I === "add")
1606
- return a();
1607
- if (I === "export")
1608
- return St();
1609
- }
1610
- const r = G(""), g = S(() => t.value), { breakpoints: m } = Pe(), l = S(() => m.value.xs || m.value.sm), s = S(() => l.value ? 10 : 20), k = Le(), { t: C } = Q();
1611
- return (I, M) => {
1612
- const H = A("FmTable");
1613
- return x(), D(Oe, {
1614
- title: d(C)("inventory.recipe.title"),
1615
- actions: [
1616
- {
1617
- label: d(C)("inventory.recipe.create.title"),
1618
- value: "add",
1619
- isPrimary: !0,
1620
- prependIcon: "add"
1621
- },
1622
- { label: d(C)("common.export"), value: "export", isPrimary: !1 }
1623
- ],
1624
- "onClick:action": i
1625
- }, {
1626
- default: K(() => [
1627
- y("div", {
1628
- class: he([
1629
- "flex flex-col gap-8 max-h-full",
1630
- {
1631
- "p-0": l.value,
1632
- "px-24 ": !l.value
1633
- }
1634
- ])
1635
- }, [
1636
- V(un, {
1637
- searchable: "",
1638
- search: r.value,
1639
- "onUpdate:search": M[0] || (M[0] = (p) => r.value = p)
1640
- }, null, 8, ["search"]),
1641
- (x(), D(H, {
1642
- style: Ie(d(k).tableHeight),
1643
- "column-defs": d(n),
1644
- "row-data": e.value,
1645
- "search-value": r.value,
1646
- loading: !d(c)._currentLocation || g.value,
1647
- onRowClick: M[1] || (M[1] = (p) => d(u)(p.original.original)),
1648
- key: b.value.length,
1649
- "page-size": s.value
1650
- }, {
1651
- "list-row": K((p) => [
1652
- V(sn, {
1653
- row: p,
1654
- onRowClick: (h) => d(u)(h.original)
1655
- }, {
1656
- default: K((h) => {
1657
- var v, w, F, T, q, P, U, X, L, $;
1658
- return [
1659
- y("div", $t, [
1660
- y("div", Et, [
1661
- V(d(_e), {
1662
- render: (F = (w = (v = h.recipe) == null ? void 0 : v.column) == null ? void 0 : w.columnDef) == null ? void 0 : F.cell,
1663
- props: (q = (T = h.recipe) == null ? void 0 : T.getContext) == null ? void 0 : q.call(T)
1664
- }, null, 8, ["render", "props"])
1665
- ]),
1666
- y("div", Tt, [
1667
- V(d(_e), {
1668
- render: (X = (U = (P = h.ingredients) == null ? void 0 : P.column) == null ? void 0 : U.columnDef) == null ? void 0 : X.cell,
1669
- props: ($ = (L = h.ingredients) == null ? void 0 : L.getContext) == null ? void 0 : $.call(L)
1670
- }, null, 8, ["render", "props"])
1671
- ])
1672
- ])
1673
- ];
1674
- }),
1675
- _: 2
1676
- }, 1032, ["row", "onRowClick"])
1677
- ]),
1678
- _: 1
1679
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
1680
- ], 2),
1681
- (x(), D(Ae, { to: "body" }, [
1682
- V(At, Re(Se(d(_))), null, 16)
1683
- ]))
1684
- ]),
1685
- _: 1
1686
- }, 8, ["title", "actions"]);
1687
- };
1688
- }
1689
- });
1690
- export {
1691
- ro as default
1692
- };