@feedmepos/mf-inventory-portal 1.3.7 → 1.3.9-dev.1

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