@feedmepos/mf-inventory-portal 1.8.0-dev.19 → 1.8.0-dev.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{App-BXDscpMf.js → App-5GYyCfFq.js} +9 -9
- package/dist/{ApprovalView-CbP2H_8q.js → ApprovalView-DY1ayl1W.js} +9 -9
- package/dist/{BindingsDialog-C7OFDUAr.js → BindingsDialog-Dm7uKMfV.js} +2 -2
- package/dist/{BindingsPicker-BQjHQWPl.js → BindingsPicker-DhnMlj4x.js} +2 -2
- package/dist/{BindingsTable-grJZdI5F.js → BindingsTable-Cxibcjka.js} +4 -4
- package/dist/{BulkReceiveRequestPage-jZtPq5XF.js → BulkReceiveRequestPage-w4AA6BxB.js} +21 -21
- package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-DOgwkHnO.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-B3ESPbQp.js} +1 -1
- package/dist/{ClosingDraftView-UmNAyX_s.js → ClosingDraftView-DMaONEZ7.js} +19 -19
- package/dist/{ClosingHistoryView-CZcOYK98.js → ClosingHistoryView-BBYruOux.js} +7 -7
- package/dist/{ClosingTemplateView-CP2-ib2S.js → ClosingTemplateView-DcwgokRl.js} +18 -18
- package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-DYZjiuAH.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-a72IldDO.js} +1 -1
- package/dist/{DefaultView-DOa4PWSU.js → DefaultView-BVr_7JDn.js} +2 -2
- package/dist/{DeliveryOrderPrintPreview-DtFuSUby.js → DeliveryOrderPrintPreview-BXZFD3D5.js} +2 -2
- package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-CxsxIwZm.js → EmailDialog.vue_vue_type_script_setup_true_lang-Dne_9P3j.js} +25 -25
- package/dist/{FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-B3mPB7-O.js → FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-CYkPbFSA.js} +1 -1
- package/dist/FeatureCapabilityGate-DK_rTVyJ.js +82 -0
- package/dist/{FeaturePageGate.vue_vue_type_script_setup_true_lang-O58GGptu.js → FeaturePageGate.vue_vue_type_script_setup_true_lang-DIhV51l7.js} +1 -1
- package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-CCrEBis5.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-B80EHMBT.js} +1 -1
- package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-YGOFZ7uY.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-C94IFGoH.js} +2 -2
- package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-F36jHbKZ.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-COZPDuAM.js} +2 -2
- package/dist/{FmMultiselectDialog-BDCQmCSh.js → FmMultiselectDialog-C1P22sj2.js} +2 -2
- package/dist/{FmMultiselectDialog-Dd9oKz5m.js → FmMultiselectDialog-Kb3IftHf.js} +2 -2
- package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-CUmlLKDV.js → FmUnitInput.vue_vue_type_script_setup_true_lang-BqB71yfu.js} +5 -5
- package/dist/ImportView-EJ4u8NHM.js +1540 -0
- package/dist/{IngredientsView-Bcxo5AlS.js → IngredientsView-Bxsgm4E7.js} +15 -15
- package/dist/{IntegrationExplorerView-C2jsPi_3.js → IntegrationExplorerView-owEaOVeG.js} +6 -6
- package/dist/{IntegrationPlatformView-Cr7Fyt4p.js → IntegrationPlatformView-BuptPyjg.js} +2 -2
- package/dist/{IntegrationView-BTcnK-_q.js → IntegrationView-DAcdY_d_.js} +14 -14
- package/dist/{InventoryBindingForm-e1rSW4FA.js → InventoryBindingForm-BvjY4zrn.js} +1 -1
- package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-BjDz4LFE.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DhbF-jgN.js} +4 -4
- package/dist/{InventoryBindingSummary-CAGMRuy4.js → InventoryBindingSummary-DPqm94GX.js} +1 -1
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-eygCK9vN.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DDsigNJ4.js} +2 -2
- package/dist/{ProductionRunDetailPage-CQz-U7Sw.js → ProductionRunDetailPage-BaPCJUqT.js} +4 -4
- package/dist/{ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-BtnKFZy2.js → ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-CNRX3MYt.js} +8 -8
- package/dist/{ProductionRunPage-BZnmoyLo.js → ProductionRunPage-B6Jsv9Hh.js} +4 -4
- package/dist/{PublishView-BJFoRmsD.js → PublishView-DonUv6nP.js} +3 -3
- package/dist/{PurchaseOrderPrintPreview-BQExGk_A.js → PurchaseOrderPrintPreview-CK3Cqdwp.js} +2 -2
- package/dist/{ReceiveRequestView-C4XUYhl5.js → ReceiveRequestView-CMAnKxzm.js} +13 -13
- package/dist/RecipeView-Bx13Bckq.js +3272 -0
- package/dist/{SettingsView-BDogzqxV.js → SettingsView-D1MiAkD8.js} +397 -425
- package/dist/StockView-CsxTjVEd.js +3003 -0
- package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Ce82k1-V.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BT73j9SA.js} +1 -1
- package/dist/{SupplierView-DRSh4m07.js → SupplierView-CFACoZya.js} +13 -13
- package/dist/{SurchargeView-gNIDCY22.js → SurchargeView-CShhZa3x.js} +7 -7
- package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-DrP1vAZX.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-B2OdmdI_.js} +2 -2
- package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-Cxpc2Wtp.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-x3N2Oypo.js} +1 -1
- package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-D4kpyIAQ.js → TransferDetails.vue_vue_type_script_setup_true_lang-BISmGBJE.js} +517 -517
- package/dist/{TransferTemplateView-adEB_aZg.js → TransferTemplateView-kx2IPqEv.js} +19 -19
- package/dist/{UnitCostHistoryView-ClgafUAg.js → UnitCostHistoryView-DgPWsXaB.js} +4 -4
- package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-DpN-7H9P.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-BtfJJgIP.js} +4 -4
- package/dist/{UnitView-DU-Kim1r.js → UnitView-aupXLRMk.js} +7 -7
- package/dist/{WarehouseView-Dw1xkcrx.js → WarehouseView-MTvbY4n4.js} +8 -8
- package/dist/{WastageTemplateView-CQj821yg.js → WastageTemplateView-Bs9HL-LK.js} +15 -15
- package/dist/api/bill.d.ts +4 -2
- package/dist/api/bill.spec.d.ts +1 -0
- package/dist/api/closing.d.ts +1 -0
- package/dist/api/feature-flags.d.ts +2 -0
- package/dist/api/license.d.ts +0 -1
- package/dist/api/stock.d.ts +1 -1
- package/dist/{app--e70sT_h.js → app-D38sV2ls.js} +2286 -2147
- package/dist/app.d.ts +92 -8
- package/dist/app.js +1 -1
- package/dist/bulk-edit-simulation.helper-DgniL8FN.js +178 -0
- package/dist/{closing-template-i0bDCk-x.js → closing-template-D_NAj_mU.js} +1 -1
- package/dist/{date2-CXI-d_rQ.js → date2-CvgxwuM1.js} +1 -1
- package/dist/{dayjs.min-Ivf4HAC3.js → dayjs.min-BOKV8T5Q.js} +1 -1
- package/dist/{decimal-d3XWw4d_.js → decimal-5xyg1WLu.js} +2 -2
- package/dist/{defineDeepModel-DrQmqGvi.js → defineDeepModel-BwB9XcMu.js} +1 -1
- package/dist/{duplicate-template-yVd6JWGz.js → duplicate-template-DvIgjm4K.js} +1 -1
- package/dist/{feature-CBrHj9bO.js → feature-CsPbMoeJ.js} +231 -221
- package/dist/{format-time-from-id-DpFUCBGw.js → format-time-from-id-DD6Ik9EK.js} +1 -1
- package/dist/{format-unit-display-CICNepRU.js → format-unit-display-DG564AN3.js} +12 -12
- package/dist/helper/country.spec.d.ts +1 -0
- package/dist/{id-to-date-BicEvFx1.js → id-to-date-DoN7OM21.js} +1 -1
- package/dist/{import-export.helper-Cy-nm8Ao.js → import-export.helper-CevBRFTZ.js} +6 -5
- package/dist/{index-CiWNQMAX.js → index-BIh1oTQH.js} +3 -3
- package/dist/{index-BfY6L-3r.js → index-BP3Avix6.js} +1 -1
- package/dist/{index-W7Q7cZGV.js → index-mzXhLwrZ.js} +1 -1
- package/dist/{lz-string-ClJ0qg4U.js → lz-string-DMjWYCk6.js} +1 -1
- package/dist/{netsuite-jSt2nlwO.js → netsuite-ZtoZBFBX.js} +2 -2
- package/dist/{netsuite-explorer-BWrO3KfB.js → netsuite-explorer-h_vID_ao.js} +1 -1
- package/dist/{predefined-templates-DKiqLY6F.js → predefined-templates-CdurFRJ4.js} +1 -1
- package/dist/{purchase-order-template-D-NkhbNh.js → purchase-order-template-BVdCftEo.js} +1 -1
- package/dist/{recalculationUtils-Bbe1w-wj.js → recalculationUtils-DBG8HGiJ.js} +1 -1
- package/dist/{row-action.enum-C8JhgYiR.js → row-action.enum-CGyAg4dC.js} +1 -1
- package/dist/{rules-CrAeAKSS.js → rules-DbFiOzUd.js} +3 -3
- package/dist/{stock-x072pQVW.js → stock-BATH4SoA.js} +1 -1
- package/dist/{stock-B27nWQ5z.js → stock-DXxsDPEO.js} +2 -2
- package/dist/stores/feature.d.ts +4 -0
- package/dist/style.css +1 -1
- package/dist/{supplier-sh98cdAW.js → supplier-CKXQmBZn.js} +2 -2
- package/dist/{surcharge-DsF53Jiz.js → surcharge-qupRJjjO.js} +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{uom-rules-DuYrxEZK.js → uom-rules-ALtgjANX.js} +1 -1
- package/dist/{use-ingredient-select-dialog-DZJPaYJX.js → use-ingredient-select-dialog-C1sJpjfV.js} +2 -2
- package/dist/{use-inventory-binding-dialog-CEr-Nctj.js → use-inventory-binding-dialog-tl7-epun.js} +2 -2
- package/dist/{use-template-enabled-locations-h-1Om4op.js → use-template-enabled-locations-DWk2ndDC.js} +2 -2
- package/dist/{use-transfer-locations-CuCYcO6G.js → use-transfer-locations-CsdYY996.js} +2 -2
- package/dist/{useHrmPermission-Db-rrPU-.js → useHrmPermission-BtuqUrwj.js} +1 -1
- package/dist/{useNavigationMenu-DJCT15IW.js → useNavigationMenu-DKxKXykI.js} +4 -4
- package/dist/{useSseClient-B2_SvHJ2.js → useSseClient-CRfpltKK.js} +1 -1
- package/dist/views/import/helper/submit-rows.d.ts +1 -1
- package/dist/views/integration/components/IntegrationCard.vue.d.ts +3 -3
- package/dist/views/production-run/features/detail/ProductionRunItemsTable.vue.d.ts +2 -2
- package/dist/views/recipe/helper/import-recipe.d.ts +30 -0
- package/dist/views/settings/PlanLicenseDisplay.vue.d.ts +1 -14
- package/dist/views/stock/components/StockRecordCard.spec.d.ts +1 -0
- package/dist/views/stock/components/StockRecordCard.vue.d.ts +3 -863
- package/dist/views/stock/components/dialog/BillInventoryInfoDialog.spec.d.ts +1 -0
- package/dist/views/stock/components/dialog/BillInventoryInfoDialog.vue.d.ts +36 -0
- package/dist/views/stock/composables/use-last-closing-summary.d.ts +4 -0
- package/dist/views/stock/composables/use-last-closing-summary.spec.d.ts +1 -0
- package/dist/{vue-Co39mHJn.js → vue-CVco8McV.js} +2 -2
- package/dist/{vue-i18n-C2pkD_vQ.js → vue-i18n-C443zpcA.js} +280 -280
- package/dist/{xlsx.util-CLUjDX2E.js → xlsx.util-5_47Kslf.js} +2 -2
- package/package.json +2 -2
- package/dist/FeatureCapabilityGate-Dp_SfIlO.js +0 -77
- package/dist/ImportView-CbRrxlrW.js +0 -1290
- package/dist/RecipeView-Bd5--ENI.js +0 -3440
- package/dist/StockView-BCWwamwk.js +0 -2756
|
@@ -0,0 +1,3272 @@
|
|
|
1
|
+
import { defineComponent as ne, ref as O, onMounted as dt, resolveComponent as M, createElementBlock as I, openBlock as m, Fragment as J, createElementVNode as y, toDisplayString as U, createVNode as _, createCommentVNode as R, h as le, computed as C, watch as de, unref as e, withCtx as Y, createBlock as W, renderList as me, isRef as Ae, mergeProps as Ee, createTextVNode as ut, withModifiers as ct, normalizeClass as Te, normalizeStyle as pt, Teleport as mt, normalizeProps as ft, guardReactiveProps as vt } from "vue";
|
|
2
|
+
import { a as ee, c as ze, S as yt, F as Ue, u as Je, s as Qe, v as bt, w as gt, j as Ge } from "./app-D38sV2ls.js";
|
|
3
|
+
import { useDialog as Ne, useSnackbar as Le, components as ye, useProxiedModel as Me, useBreakpoints as _t } from "@feedmepos/ui-library";
|
|
4
|
+
import { i as kt, _ as ht, m as xt } from "./menu-usage-module-Bq_KLsO4.js";
|
|
5
|
+
import { F as ae } from "./form-mode.enum-BKiNVH6A.js";
|
|
6
|
+
import { _ as Xe, u as wt } from "./FmMultiselectDialog-Kb3IftHf.js";
|
|
7
|
+
import { defineStore as Ze, storeToRefs as Et } from "pinia";
|
|
8
|
+
import { D as qe, R as Ie } from "./row-action.enum-CGyAg4dC.js";
|
|
9
|
+
import { c as $t } from "./component-BmLAdDiY.js";
|
|
10
|
+
import { a as ie, I as Se, e as It, f as et, A as Pe, U as tt, R as Vt } from "./rules-DbFiOzUd.js";
|
|
11
|
+
import { useI18n as te, useCoreStore as St } from "@feedmepos/mf-common";
|
|
12
|
+
import { u as Ct, _ as Ft } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-DpwneGOV.js";
|
|
13
|
+
import { a as Bt, _ as Rt } from "./InventoryBindingForm.vue_vue_type_script_setup_true_lang-DhbF-jgN.js";
|
|
14
|
+
import { a as We } from "./FmMultiselectDialog-C1P22sj2.js";
|
|
15
|
+
import { d as nt } from "./defineDeepModel-BwB9XcMu.js";
|
|
16
|
+
import { L as At, P as Tt, D as Ut } from "./app-C39bYJmq.js";
|
|
17
|
+
import { _ as Ce, c as Mt, d as Pt, e as be } from "./FmUnitInput.vue_vue_type_script_setup_true_lang-BqB71yfu.js";
|
|
18
|
+
import { u as Dt } from "./vue-i18n-C443zpcA.js";
|
|
19
|
+
import { F as zt, u as je } from "./feature-CsPbMoeJ.js";
|
|
20
|
+
import { _ as Nt } from "./FmCustomAttribute.vue_vue_type_script_setup_true_lang-CG1m-B2p.js";
|
|
21
|
+
import { F as Fe } from "./decimal-5xyg1WLu.js";
|
|
22
|
+
import { f as we, i as Ye, s as Lt, d as jt } from "./bulk-edit-simulation.helper-DgniL8FN.js";
|
|
23
|
+
import { _ as Be } from "./FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-C94IFGoH.js";
|
|
24
|
+
import { b as ot, d as lt } from "./xlsx.util-5_47Kslf.js";
|
|
25
|
+
import { f as it } from "./date2-CvgxwuM1.js";
|
|
26
|
+
import { _ as Ot } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-gJQQKKAC.js";
|
|
27
|
+
import { F as He } from "./index-eGvSlWMU.js";
|
|
28
|
+
import { _ as Kt } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-COZPDuAM.js";
|
|
29
|
+
const Gt = {
|
|
30
|
+
key: 0,
|
|
31
|
+
class: "flex flex-col items-center w-full h-full gap-24"
|
|
32
|
+
}, qt = { key: 1 }, Wt = { key: 0 }, Yt = /* @__PURE__ */ ne({
|
|
33
|
+
__name: "DeleteDialog",
|
|
34
|
+
props: {
|
|
35
|
+
type: {},
|
|
36
|
+
data: {},
|
|
37
|
+
message: {},
|
|
38
|
+
bindedItems: {}
|
|
39
|
+
},
|
|
40
|
+
setup(V) {
|
|
41
|
+
const c = V, p = O(c.bindedItems || []), r = O(!1);
|
|
42
|
+
dt(() => {
|
|
43
|
+
t();
|
|
44
|
+
});
|
|
45
|
+
async function t() {
|
|
46
|
+
var w, k;
|
|
47
|
+
!r.value && ((w = c.data) != null && w._id) && (r.value = !0, p.value = await ee().getAffectedMenu((k = c.data) == null ? void 0 : k._id), r.value = !1);
|
|
48
|
+
}
|
|
49
|
+
return (w, k) => {
|
|
50
|
+
const v = M("FmSpacer"), a = M("FmCircularProgress");
|
|
51
|
+
return m(), I(J, null, [
|
|
52
|
+
y("p", null, U(w.message), 1),
|
|
53
|
+
r.value ? (m(), I("div", Gt, [
|
|
54
|
+
_(v),
|
|
55
|
+
y("div", null, [
|
|
56
|
+
_(a, { size: "xl" })
|
|
57
|
+
]),
|
|
58
|
+
k[0] || (k[0] = y("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary pl-8" }, "Loading...", -1)),
|
|
59
|
+
_(v)
|
|
60
|
+
])) : (m(), I("div", qt, [
|
|
61
|
+
k[2] || (k[2] = y("br", null, null, -1)),
|
|
62
|
+
p.value.length > 0 ? (m(), I("div", Wt, [
|
|
63
|
+
k[1] || (k[1] = y("p", { class: "fm-typo-en-body-lg-600" }, "Affected menu items:", -1)),
|
|
64
|
+
_(Xe, {
|
|
65
|
+
name: "Menu",
|
|
66
|
+
bindings: p.value
|
|
67
|
+
}, null, 8, ["bindings"])
|
|
68
|
+
])) : R("", !0)
|
|
69
|
+
]))
|
|
70
|
+
], 64);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}), De = Ze("recipeForm", function() {
|
|
74
|
+
const c = Ne(), p = Le(), r = ee(), t = O(!1), w = O();
|
|
75
|
+
function k() {
|
|
76
|
+
const n = {
|
|
77
|
+
recipe: {},
|
|
78
|
+
mode: ae.CREATE,
|
|
79
|
+
show: !0,
|
|
80
|
+
"onUpdate:show"(f) {
|
|
81
|
+
w.value.show = f;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
w.value = n;
|
|
85
|
+
}
|
|
86
|
+
async function v(n) {
|
|
87
|
+
const f = {
|
|
88
|
+
recipe: ze(n),
|
|
89
|
+
mode: ae.UPDATE,
|
|
90
|
+
show: !0,
|
|
91
|
+
"onUpdate:show"(h) {
|
|
92
|
+
w.value.show = h;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
w.value = f;
|
|
96
|
+
}
|
|
97
|
+
async function a(n) {
|
|
98
|
+
t.value = !0;
|
|
99
|
+
try {
|
|
100
|
+
await r.deleteRecipe(n), p.open({
|
|
101
|
+
title: "Success",
|
|
102
|
+
message: `Deleted ${n.name}`,
|
|
103
|
+
type: "success"
|
|
104
|
+
});
|
|
105
|
+
} catch (f) {
|
|
106
|
+
if (f instanceof yt && kt(f)) {
|
|
107
|
+
c.open({
|
|
108
|
+
title: "Cannot delete recipe",
|
|
109
|
+
contentComponent: ht,
|
|
110
|
+
contentComponentProps: {
|
|
111
|
+
subject: (n == null ? void 0 : n.name) ?? "",
|
|
112
|
+
items: f.errorResponse.errors.map((h) => {
|
|
113
|
+
var b;
|
|
114
|
+
return {
|
|
115
|
+
chain: [
|
|
116
|
+
{
|
|
117
|
+
itemName: h.name,
|
|
118
|
+
moduleKey: (b = h.message) != null && b.startsWith("modules.") ? xt(h.message) : h.module
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
};
|
|
122
|
+
})
|
|
123
|
+
},
|
|
124
|
+
secondaryActions: {
|
|
125
|
+
text: "Close",
|
|
126
|
+
close: !0
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
p.open({
|
|
132
|
+
title: `Cannot delete ${n == null ? void 0 : n.name}`,
|
|
133
|
+
message: "Please try again.",
|
|
134
|
+
type: "error"
|
|
135
|
+
}), console.error("failed to delete recipe", f);
|
|
136
|
+
} finally {
|
|
137
|
+
t.value = !1;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function d(n) {
|
|
141
|
+
c.open({
|
|
142
|
+
title: `Delete ${(n == null ? void 0 : n.name) ?? "recipe"}?`,
|
|
143
|
+
closeButton: !1,
|
|
144
|
+
primaryActions: {
|
|
145
|
+
text: "Delete",
|
|
146
|
+
close: !0,
|
|
147
|
+
variant: "destructive"
|
|
148
|
+
},
|
|
149
|
+
secondaryActions: {
|
|
150
|
+
text: "Cancel",
|
|
151
|
+
close: !0
|
|
152
|
+
},
|
|
153
|
+
contentComponent: Yt,
|
|
154
|
+
contentComponentProps: {
|
|
155
|
+
type: "menu",
|
|
156
|
+
data: n,
|
|
157
|
+
message: "You may not be able to delete this recipe if it is linked in any of the inventory modules."
|
|
158
|
+
}
|
|
159
|
+
}).onPrimary(() => a(n));
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
createRecipe: k,
|
|
163
|
+
updateRecipe: v,
|
|
164
|
+
deleteRecipe: d,
|
|
165
|
+
recipeDialogProps: w,
|
|
166
|
+
recipeViewLoading: t
|
|
167
|
+
};
|
|
168
|
+
});
|
|
169
|
+
function Ht() {
|
|
170
|
+
const { updateRecipe: V, deleteRecipe: c } = De(), p = ee(), { t: r } = te();
|
|
171
|
+
async function t(n, f) {
|
|
172
|
+
const h = ze(f);
|
|
173
|
+
if (n === Ie.Edit) {
|
|
174
|
+
await V(h);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (n === Ie.Delete) {
|
|
178
|
+
await c(h);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function w(n, f) {
|
|
183
|
+
const h = n.filter(($) => $.type === Ue.enum.SKU), b = n.filter(($) => $.type === Ue.enum.RECIPE);
|
|
184
|
+
return [
|
|
185
|
+
...h.map(($) => ({ ...$, recipeIds: [...f] })),
|
|
186
|
+
...b.filter(($) => p.recipeById[$.id] && !f.has($.id)).flatMap(
|
|
187
|
+
($) => w(p.recipeById[$.id].contains, /* @__PURE__ */ new Set([...f, $.id]))
|
|
188
|
+
)
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
const k = [
|
|
192
|
+
{
|
|
193
|
+
accessorKey: "recipe",
|
|
194
|
+
header: () => r("inventory.recipe.name"),
|
|
195
|
+
size: 400
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
accessorKey: "ingredients",
|
|
199
|
+
header: () => r("inventory.recipe.ingredients"),
|
|
200
|
+
size: "auto",
|
|
201
|
+
// accessor keeps the plain text so filtering still matches; the cell only restyles it
|
|
202
|
+
cell: (n) => le(
|
|
203
|
+
"div",
|
|
204
|
+
{ class: "flex flex-col items-start gap-4" },
|
|
205
|
+
n.row.original.bindings.map(
|
|
206
|
+
(f) => le(
|
|
207
|
+
"div",
|
|
208
|
+
{
|
|
209
|
+
class: "flex flex-wrap items-center gap-8 border-1 border-fm-color-neutral-gray-200 fm-corner-radius-md px-8 py-4"
|
|
210
|
+
},
|
|
211
|
+
[
|
|
212
|
+
f.parentRecipe ? le(ye.FmChip, { compact: !0 }, f.parentRecipe) : null,
|
|
213
|
+
f.labels.join(", ")
|
|
214
|
+
]
|
|
215
|
+
)
|
|
216
|
+
)
|
|
217
|
+
)
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
id: "action",
|
|
221
|
+
header: "",
|
|
222
|
+
cell(n) {
|
|
223
|
+
return $t(
|
|
224
|
+
[qe[Ie.Edit], qe[Ie.Delete]],
|
|
225
|
+
(f) => {
|
|
226
|
+
t(f, n.row.original.original);
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
|
+
},
|
|
230
|
+
enableSorting: !1,
|
|
231
|
+
size: 40,
|
|
232
|
+
meta: {
|
|
233
|
+
cellClass: "",
|
|
234
|
+
headerClass: ""
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
];
|
|
238
|
+
function v(n) {
|
|
239
|
+
const f = ee();
|
|
240
|
+
return w(n.contains, /* @__PURE__ */ new Set([n._id])).map((h) => {
|
|
241
|
+
var i, E, S;
|
|
242
|
+
const b = h.recipeIds.slice(1).length ? ((i = f.recipeById[h.recipeIds.at(-1) ?? ""]) == null ? void 0 : i.name) ?? null : null, $ = f.skuById[h.id];
|
|
243
|
+
return $ ? {
|
|
244
|
+
parentRecipe: b,
|
|
245
|
+
label: `${$.name} (${ie(h.amount)}${((E = h.measurement) == null ? void 0 : E.abbrev) ?? ((S = $ == null ? void 0 : $.unit) == null ? void 0 : S.abbrev)})`
|
|
246
|
+
} : null;
|
|
247
|
+
}).filter((h) => !!h);
|
|
248
|
+
}
|
|
249
|
+
function a(n) {
|
|
250
|
+
const f = [];
|
|
251
|
+
for (const h of n) {
|
|
252
|
+
const b = h.parentRecipe ? f.find(($) => $.parentRecipe === h.parentRecipe) : void 0;
|
|
253
|
+
b ? b.labels.push(h.label) : f.push({ parentRecipe: h.parentRecipe, labels: [h.label] });
|
|
254
|
+
}
|
|
255
|
+
return f;
|
|
256
|
+
}
|
|
257
|
+
function d(n) {
|
|
258
|
+
return n.map((f) => {
|
|
259
|
+
const h = v(f);
|
|
260
|
+
return {
|
|
261
|
+
recipe: f.name,
|
|
262
|
+
ingredients: h.map((b) => b.parentRecipe ? `(${b.parentRecipe}) ${b.label}` : b.label).join(", "),
|
|
263
|
+
bindings: a(h),
|
|
264
|
+
original: f
|
|
265
|
+
};
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
return { columnDefs: k, formatRowData: d };
|
|
269
|
+
}
|
|
270
|
+
function Jt() {
|
|
271
|
+
const V = ee(), c = Ne();
|
|
272
|
+
async function p(t, w, k, v = []) {
|
|
273
|
+
var b, $;
|
|
274
|
+
const a = t.filter((i) => i.type === "SKU"), d = t.filter((i) => i.type !== "SKU"), n = /* @__PURE__ */ new Set();
|
|
275
|
+
if (k)
|
|
276
|
+
for (const i of V.skus)
|
|
277
|
+
!v.some((S) => S === i._id) && i._id !== k && !(($ = (b = i.convert) == null ? void 0 : b.inventoryBindings) != null && $.some((S) => S.id === k)) || n.add(i._id);
|
|
278
|
+
const f = V.skus.map((i) => ({
|
|
279
|
+
label: i.name,
|
|
280
|
+
sublabel: `${i.code}${n.has(i._id) ? " (Cannot bind, will cause recursive binding)" : ""}`,
|
|
281
|
+
value: i,
|
|
282
|
+
disabled: n.has(i._id)
|
|
283
|
+
})), h = f.filter(
|
|
284
|
+
(i) => a.find((E) => E.id === i.value._id) && !n.has(i.value._id)
|
|
285
|
+
).map((i) => i.value);
|
|
286
|
+
c.open({
|
|
287
|
+
title: "Select ingredients",
|
|
288
|
+
contentComponent: We,
|
|
289
|
+
contentComponentProps: {
|
|
290
|
+
items: f,
|
|
291
|
+
modelValue: h,
|
|
292
|
+
virtualScroll: !0
|
|
293
|
+
},
|
|
294
|
+
primaryActions: {
|
|
295
|
+
text: "Confirm",
|
|
296
|
+
close: !0
|
|
297
|
+
},
|
|
298
|
+
secondaryActions: {
|
|
299
|
+
text: "Close",
|
|
300
|
+
close: !0,
|
|
301
|
+
variant: "tertiary"
|
|
302
|
+
}
|
|
303
|
+
}).onPrimary((i) => {
|
|
304
|
+
const E = [
|
|
305
|
+
...d,
|
|
306
|
+
...t.filter((S) => i.find((g) => g._id === S.id)),
|
|
307
|
+
...i.filter((S) => !t.find((g) => g.id === S._id)).map((S) => ({
|
|
308
|
+
type: "SKU",
|
|
309
|
+
id: S._id,
|
|
310
|
+
amount: {
|
|
311
|
+
amount: 1,
|
|
312
|
+
precision: 0
|
|
313
|
+
}
|
|
314
|
+
}))
|
|
315
|
+
];
|
|
316
|
+
w(E);
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
async function r(t, w, k = []) {
|
|
320
|
+
var h;
|
|
321
|
+
const v = t.filter((b) => b.type === "RECIPE"), a = t.filter((b) => b.type !== "RECIPE"), d = /* @__PURE__ */ new Set();
|
|
322
|
+
if (k.length)
|
|
323
|
+
for (const b of V.recipes) {
|
|
324
|
+
const $ = ((h = V.recipeBindingFlattenCache[b._id]) == null ? void 0 : h.inventoryBindings) ?? [], i = $.some(
|
|
325
|
+
(g) => g.bindingPaths.some((o) => k.some((u) => u === o.id))
|
|
326
|
+
), E = $.some(
|
|
327
|
+
(g) => "success" in g && k.includes(g.ingredient._id)
|
|
328
|
+
);
|
|
329
|
+
(k.some((g) => g === b._id) || i || E) && d.add(b._id);
|
|
330
|
+
}
|
|
331
|
+
const n = V.recipes.filter((b) => !k.includes(b._id)).map((b) => ({
|
|
332
|
+
label: b.name,
|
|
333
|
+
sublabel: d.has(b._id) ? "(Cannot bind, will cause recursive binding)" : `${b.contains.length} inventory bindings`,
|
|
334
|
+
value: b,
|
|
335
|
+
disabled: d.has(b._id)
|
|
336
|
+
})), f = n.filter(
|
|
337
|
+
(b) => v.find(($) => $.id === b.value._id) && !d.has(b.value._id)
|
|
338
|
+
).map((b) => b.value);
|
|
339
|
+
c.open({
|
|
340
|
+
title: "Select recipes",
|
|
341
|
+
contentComponent: We,
|
|
342
|
+
contentComponentProps: {
|
|
343
|
+
items: n,
|
|
344
|
+
modelValue: f,
|
|
345
|
+
virtualScroll: !0
|
|
346
|
+
},
|
|
347
|
+
primaryActions: {
|
|
348
|
+
text: "Confirm",
|
|
349
|
+
close: !0
|
|
350
|
+
},
|
|
351
|
+
secondaryActions: {
|
|
352
|
+
text: "Close",
|
|
353
|
+
close: !0,
|
|
354
|
+
variant: "tertiary"
|
|
355
|
+
}
|
|
356
|
+
}).onPrimary((b) => {
|
|
357
|
+
const $ = [
|
|
358
|
+
...t.filter((i) => b.find((E) => E._id === i.id)),
|
|
359
|
+
...b.filter((i) => !t.find((E) => E.id === i._id)).map((i) => ({
|
|
360
|
+
type: "RECIPE",
|
|
361
|
+
id: i._id,
|
|
362
|
+
amount: {
|
|
363
|
+
amount: 1,
|
|
364
|
+
precision: 0
|
|
365
|
+
}
|
|
366
|
+
})),
|
|
367
|
+
...a
|
|
368
|
+
];
|
|
369
|
+
w($);
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
return {
|
|
373
|
+
promptIngredientsBinding: p,
|
|
374
|
+
promptRecipesBinding: r
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
const Qt = { class: "flex flex-col" }, Xt = { class: "flex flex-col gap-4" }, Re = /* @__PURE__ */ ne({
|
|
378
|
+
__name: "InventoryBindingRule",
|
|
379
|
+
props: {
|
|
380
|
+
disabled: { type: Boolean },
|
|
381
|
+
modelValue: {},
|
|
382
|
+
minCount: {},
|
|
383
|
+
maxCount: {}
|
|
384
|
+
},
|
|
385
|
+
emits: ["update:modelValue"],
|
|
386
|
+
setup(V, { emit: c }) {
|
|
387
|
+
const p = V, r = c, { t } = te(), w = St(), k = Je(), v = C(() => {
|
|
388
|
+
var $;
|
|
389
|
+
const h = /* @__PURE__ */ new Map(), b = w.restaurants.value.map((i) => i.customAttributes ?? {});
|
|
390
|
+
for (const i of b)
|
|
391
|
+
for (const [E, S] of Object.entries(i))
|
|
392
|
+
h.has(E) || h.set(E, /* @__PURE__ */ new Set()), S && (($ = h.get(E)) == null || $.add(S));
|
|
393
|
+
return h;
|
|
394
|
+
}), a = C(
|
|
395
|
+
() => w.restaurants.value.filter((h) => {
|
|
396
|
+
var b;
|
|
397
|
+
return (b = h.profile) == null ? void 0 : b.code;
|
|
398
|
+
}).map((h) => ({ value: h.profile.code, label: `${h.profile.name} (${h.profile.code})` }))
|
|
399
|
+
), d = C(() => [
|
|
400
|
+
...[...v.value.entries()].map(([b, $]) => ({
|
|
401
|
+
type: "string",
|
|
402
|
+
key: b,
|
|
403
|
+
entity: "restaurant",
|
|
404
|
+
values: [...$]
|
|
405
|
+
})),
|
|
406
|
+
{
|
|
407
|
+
type: "string",
|
|
408
|
+
key: "state",
|
|
409
|
+
entity: "restaurant",
|
|
410
|
+
values: [
|
|
411
|
+
...new Set(k.locations.map((b) => b.doc.profile.address.state).filter(Boolean))
|
|
412
|
+
]
|
|
413
|
+
},
|
|
414
|
+
...a.value.length > 0 ? [
|
|
415
|
+
{
|
|
416
|
+
type: "string",
|
|
417
|
+
key: "outlet",
|
|
418
|
+
entity: "restaurant",
|
|
419
|
+
options: a.value
|
|
420
|
+
}
|
|
421
|
+
] : []
|
|
422
|
+
]), n = O(null);
|
|
423
|
+
let f = null;
|
|
424
|
+
return de(
|
|
425
|
+
() => p.modelValue,
|
|
426
|
+
(h) => {
|
|
427
|
+
JSON.stringify(h) !== JSON.stringify(f) && (n.value = h ? At.build(h) : null);
|
|
428
|
+
},
|
|
429
|
+
{ immediate: !0 }
|
|
430
|
+
), de(
|
|
431
|
+
n,
|
|
432
|
+
(h) => {
|
|
433
|
+
f = h ? Tt.build(h) : null, r("update:modelValue", f);
|
|
434
|
+
},
|
|
435
|
+
{ deep: !0 }
|
|
436
|
+
), (h, b) => {
|
|
437
|
+
const $ = M("FmLabel"), i = M("FmFormGroup");
|
|
438
|
+
return m(), I("div", Qt, [
|
|
439
|
+
y("div", Xt, [
|
|
440
|
+
_($, {
|
|
441
|
+
label: e(t)("inventory.ingredientGroup.form.rules.title"),
|
|
442
|
+
required: h.minCount != null && h.minCount > 0
|
|
443
|
+
}, null, 8, ["label", "required"]),
|
|
444
|
+
_(e(Ut), {
|
|
445
|
+
modelValue: n.value,
|
|
446
|
+
"onUpdate:modelValue": b[0] || (b[0] = (E) => n.value = E),
|
|
447
|
+
attributes: d.value
|
|
448
|
+
}, null, 8, ["modelValue", "attributes"])
|
|
449
|
+
]),
|
|
450
|
+
_(i, {
|
|
451
|
+
"model-value": n.value,
|
|
452
|
+
rules: [
|
|
453
|
+
(E) => {
|
|
454
|
+
const S = E ? 1 : 0;
|
|
455
|
+
return p.minCount !== void 0 && S < p.minCount ? e(t)("inventory.ingredientGroup.form.rules.validation.minCount", {
|
|
456
|
+
count: p.minCount
|
|
457
|
+
}) : p.maxCount !== void 0 && S > p.maxCount ? e(t)("inventory.ingredientGroup.form.rules.validation.maxCount", {
|
|
458
|
+
count: p.maxCount
|
|
459
|
+
}) : !0;
|
|
460
|
+
}
|
|
461
|
+
]
|
|
462
|
+
}, null, 8, ["model-value", "rules"])
|
|
463
|
+
]);
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
}), Zt = { class: "border-1 mx-3 my-1 rounded-md" }, en = { class: "flex flex-col w-full border-b border-fm-color-neutral-gray-100" }, tn = {
|
|
467
|
+
class: "flex items-center",
|
|
468
|
+
style: { "min-height": "48px" }
|
|
469
|
+
}, nn = { class: "flex-1 fm-typo-en-body-md-400 py-8 px-12" }, on = { class: "line-clamp-1" }, ln = { class: "w-[200px]" }, an = {
|
|
470
|
+
key: 0,
|
|
471
|
+
class: "w-[52px]"
|
|
472
|
+
}, rn = {
|
|
473
|
+
key: 0,
|
|
474
|
+
class: "flex gap-4 text-fm-color-system-error-400 fm-typo-en-body-sm-400 px-8"
|
|
475
|
+
}, sn = { class: "px-12 pb-4" }, dn = /* @__PURE__ */ ne({
|
|
476
|
+
__name: "InventoryRecipeBindingV2Field",
|
|
477
|
+
props: {
|
|
478
|
+
disabled: { type: Boolean },
|
|
479
|
+
readonly: { type: Boolean },
|
|
480
|
+
modelValue: {},
|
|
481
|
+
displayName: {},
|
|
482
|
+
showError: { type: Boolean },
|
|
483
|
+
allowRecipeDecimal: { type: Boolean }
|
|
484
|
+
},
|
|
485
|
+
emits: ["update:modelValue", "delete", "settings"],
|
|
486
|
+
setup(V, { emit: c }) {
|
|
487
|
+
const p = c, { t: r } = te(), t = nt("modelValue"), w = O(ie(t.amount)), k = C(
|
|
488
|
+
() => Se()(w.value) === !0 ? +w.value : w.value
|
|
489
|
+
);
|
|
490
|
+
de(
|
|
491
|
+
() => t.amount,
|
|
492
|
+
(d) => {
|
|
493
|
+
const n = ie(d);
|
|
494
|
+
+w.value != +n && (w.value = n);
|
|
495
|
+
}
|
|
496
|
+
);
|
|
497
|
+
let v = null;
|
|
498
|
+
function a(d) {
|
|
499
|
+
w.value = d, v && clearTimeout(v), v = setTimeout(() => {
|
|
500
|
+
if (Se()(d) !== !0) return;
|
|
501
|
+
const n = +d;
|
|
502
|
+
d.length > 0 && isFinite(n) ? t.amount = Qe.fromNumber(n) : t.amount = { amount: 0, precision: 0 };
|
|
503
|
+
}, 300);
|
|
504
|
+
}
|
|
505
|
+
return (d, n) => {
|
|
506
|
+
const f = M("FmTooltip"), h = M("FmTextField"), b = M("FmFormGroup"), $ = M("FmButton"), i = M("FmIcon");
|
|
507
|
+
return m(), I("div", Zt, [
|
|
508
|
+
y("div", en, [
|
|
509
|
+
y("div", tn, [
|
|
510
|
+
y("div", nn, [
|
|
511
|
+
_(f, {
|
|
512
|
+
zIndex: 51,
|
|
513
|
+
variant: "plain",
|
|
514
|
+
placement: "top",
|
|
515
|
+
content: d.displayName
|
|
516
|
+
}, {
|
|
517
|
+
default: Y(() => [
|
|
518
|
+
y("span", on, U(d.displayName), 1)
|
|
519
|
+
]),
|
|
520
|
+
_: 1
|
|
521
|
+
}, 8, ["content"])
|
|
522
|
+
]),
|
|
523
|
+
y("div", ln, [
|
|
524
|
+
_(b, {
|
|
525
|
+
disabled: d.disabled,
|
|
526
|
+
modelValue: k.value,
|
|
527
|
+
rules: [e(It)(d.allowRecipeDecimal ? 5 : 0), e(et)(-1)]
|
|
528
|
+
}, {
|
|
529
|
+
default: Y(({ invalid: E }) => [
|
|
530
|
+
_(h, {
|
|
531
|
+
class: "w-full",
|
|
532
|
+
disabled: d.disabled,
|
|
533
|
+
modelValue: w.value,
|
|
534
|
+
"onUpdate:modelValue": n[0] || (n[0] = (S) => a(S)),
|
|
535
|
+
invalid: E
|
|
536
|
+
}, null, 8, ["disabled", "modelValue", "invalid"])
|
|
537
|
+
]),
|
|
538
|
+
_: 1
|
|
539
|
+
}, 8, ["disabled", "modelValue", "rules"])
|
|
540
|
+
]),
|
|
541
|
+
d.readonly ? R("", !0) : (m(), I("div", an, [
|
|
542
|
+
_($, {
|
|
543
|
+
disabled: d.disabled,
|
|
544
|
+
type: "button",
|
|
545
|
+
variant: "plain",
|
|
546
|
+
icon: "delete",
|
|
547
|
+
"icon-color": "#000000",
|
|
548
|
+
onClick: n[1] || (n[1] = () => p("delete", e(t).id))
|
|
549
|
+
}, null, 8, ["disabled"])
|
|
550
|
+
]))
|
|
551
|
+
]),
|
|
552
|
+
_(Bt, {
|
|
553
|
+
"recipe-id": e(t).id,
|
|
554
|
+
multiplier: w.value
|
|
555
|
+
}, null, 8, ["recipe-id", "multiplier"]),
|
|
556
|
+
d.showError ? (m(), I("div", rn, [
|
|
557
|
+
_(i, {
|
|
558
|
+
name: "error",
|
|
559
|
+
color: "system-error-300",
|
|
560
|
+
size: "sm"
|
|
561
|
+
}),
|
|
562
|
+
y("div", null, U(e(r)("inventory.inventoryBindings.circularError")), 1)
|
|
563
|
+
])) : R("", !0)
|
|
564
|
+
]),
|
|
565
|
+
y("div", sn, [
|
|
566
|
+
_(Re, {
|
|
567
|
+
modelValue: e(t).rules,
|
|
568
|
+
"onUpdate:modelValue": n[2] || (n[2] = (E) => e(t).rules = E),
|
|
569
|
+
disabled: d.disabled
|
|
570
|
+
}, null, 8, ["modelValue", "disabled"])
|
|
571
|
+
])
|
|
572
|
+
]);
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
function un(V) {
|
|
577
|
+
const c = wt(), { t: p } = Dt(), r = ee(), t = C(() => [
|
|
578
|
+
{
|
|
579
|
+
id: "delete",
|
|
580
|
+
header: "",
|
|
581
|
+
cell(v) {
|
|
582
|
+
const a = v.row.original;
|
|
583
|
+
return le(
|
|
584
|
+
"div",
|
|
585
|
+
{ class: "w-full flex justify-end" },
|
|
586
|
+
le(ye.FmButton, {
|
|
587
|
+
class: "delete-button",
|
|
588
|
+
key: a._id,
|
|
589
|
+
type: "button",
|
|
590
|
+
icon: "delete",
|
|
591
|
+
variant: "tertiary",
|
|
592
|
+
size: "md",
|
|
593
|
+
disabled: V.disabled ?? !1,
|
|
594
|
+
onClick: () => {
|
|
595
|
+
V.bindingAlternatives = V.bindingAlternatives.filter(
|
|
596
|
+
(d) => d._id !== a._id
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
})
|
|
600
|
+
);
|
|
601
|
+
},
|
|
602
|
+
enableSorting: !1,
|
|
603
|
+
size: 40,
|
|
604
|
+
meta: {
|
|
605
|
+
cellClass: "",
|
|
606
|
+
headerClass: ""
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
id: "alternative",
|
|
611
|
+
header: () => p("inventory.inventoryBindings.alternativeTable.ingredient"),
|
|
612
|
+
accessorFn: (v) => {
|
|
613
|
+
var a, d;
|
|
614
|
+
return `${((a = r.skuById[v._id]) == null ? void 0 : a.name) ?? ""} (${((d = r.skuById[v._id]) == null ? void 0 : d.code) ?? ""})`;
|
|
615
|
+
},
|
|
616
|
+
cell: ({ row: v }) => {
|
|
617
|
+
const a = r.skuById[v.original._id];
|
|
618
|
+
return le(
|
|
619
|
+
"div",
|
|
620
|
+
{
|
|
621
|
+
class: "w-full flex flex-col"
|
|
622
|
+
},
|
|
623
|
+
[
|
|
624
|
+
le("div", { class: "fm-typo-en-body-lg-400 line-clamp-1" }, a.name),
|
|
625
|
+
le(
|
|
626
|
+
"div",
|
|
627
|
+
{ class: "fm-typo-en-body-md-400 line-clamp-1 text-fm-color-typo-secondary" },
|
|
628
|
+
a.code
|
|
629
|
+
)
|
|
630
|
+
]
|
|
631
|
+
);
|
|
632
|
+
},
|
|
633
|
+
size: "auto",
|
|
634
|
+
enableSorting: !1
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
id: "unit",
|
|
638
|
+
header: () => p("inventory.inventoryBindings.alternativeTable.unit"),
|
|
639
|
+
accessorFn: (v) => {
|
|
640
|
+
const a = r.skuById[v._id];
|
|
641
|
+
return a.unit.measurements.computeFirst(
|
|
642
|
+
(d) => d.id === v.trackingMeasurement ? d.name : null
|
|
643
|
+
) ?? a.unit.name;
|
|
644
|
+
},
|
|
645
|
+
enableSorting: !1
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
id: "unitOption",
|
|
649
|
+
header: () => p("inventory.inventoryBindings.alternativeTable.unit"),
|
|
650
|
+
accessorKey: "trackingMeasurement",
|
|
651
|
+
cell(v) {
|
|
652
|
+
const a = r.skuById[v.row.original._id];
|
|
653
|
+
if (!a) return null;
|
|
654
|
+
const d = [
|
|
655
|
+
{
|
|
656
|
+
label: a.unit.name,
|
|
657
|
+
sublabel: a.unit.abbrev,
|
|
658
|
+
value: null
|
|
659
|
+
},
|
|
660
|
+
...a.unit.measurements.map((n) => ({
|
|
661
|
+
label: `${n.name} (${n.abbrev})`,
|
|
662
|
+
sublabel: p("inventory.inventoryBindings.alternativeTable.measurementOption"),
|
|
663
|
+
value: n.id
|
|
664
|
+
}))
|
|
665
|
+
].filter((n) => !n.label.toLowerCase().includes("inactive"));
|
|
666
|
+
return le(ye.FmSelect, {
|
|
667
|
+
modelValue: v.row.original.trackingMeasurement ?? null,
|
|
668
|
+
items: d,
|
|
669
|
+
disabled: V.disabled ?? !1,
|
|
670
|
+
"onUpdate:modelValue": (n) => {
|
|
671
|
+
V.bindingAlternatives = V.bindingAlternatives.map((f) => f._id === v.row.original._id ? { ...f, trackingMeasurement: n } : f);
|
|
672
|
+
}
|
|
673
|
+
});
|
|
674
|
+
},
|
|
675
|
+
enableSorting: !1
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
id: "priority",
|
|
679
|
+
header: () => p("inventory.inventoryBindings.alternativeTable.priority"),
|
|
680
|
+
accessorKey: "priority",
|
|
681
|
+
enableSorting: !0,
|
|
682
|
+
cell(v) {
|
|
683
|
+
const a = v.row.original;
|
|
684
|
+
return le(ye.FmTextField, {
|
|
685
|
+
modelValue: a.priority ?? v.row.index + 1,
|
|
686
|
+
rules: [
|
|
687
|
+
Se(),
|
|
688
|
+
Pe(1),
|
|
689
|
+
tt(
|
|
690
|
+
V.bindingAlternatives.filter((d) => d._id !== a._id).map((d) => {
|
|
691
|
+
const n = r.skuById[d._id];
|
|
692
|
+
return {
|
|
693
|
+
label: n == null ? void 0 : n.name,
|
|
694
|
+
value: d.priority
|
|
695
|
+
};
|
|
696
|
+
})
|
|
697
|
+
)
|
|
698
|
+
],
|
|
699
|
+
"onUpdate:modelValue": (d) => {
|
|
700
|
+
const n = Number(d);
|
|
701
|
+
isNaN(n) || (V.bindingAlternatives = V.bindingAlternatives.map((f) => f._id === v.row.original._id ? { ...f, priority: n } : f));
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
id: "default",
|
|
708
|
+
header: () => "",
|
|
709
|
+
accessorKey: "default",
|
|
710
|
+
cell(v) {
|
|
711
|
+
const a = r.skuById[v.row.original._id];
|
|
712
|
+
return a ? le(ye.FmCheckbox, {
|
|
713
|
+
modelValue: v.row.original.default ?? !1,
|
|
714
|
+
value: a._id,
|
|
715
|
+
disabled: V.disabled ?? !1,
|
|
716
|
+
"onUpdate:modelValue": () => {
|
|
717
|
+
V.bindingAlternatives = V.bindingAlternatives.map((d) => d._id === v.row.original._id ? { ...d, default: !0 } : { ...d, default: !1 });
|
|
718
|
+
}
|
|
719
|
+
}) : null;
|
|
720
|
+
},
|
|
721
|
+
enableSorting: !1,
|
|
722
|
+
size: 40,
|
|
723
|
+
meta: {
|
|
724
|
+
cellClass: "",
|
|
725
|
+
headerClass: ""
|
|
726
|
+
}
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
id: "move",
|
|
730
|
+
header: "",
|
|
731
|
+
cell(v) {
|
|
732
|
+
const a = v.row.original;
|
|
733
|
+
return le("div", { class: "w-full flex justify-end" }, [
|
|
734
|
+
le(ye.FmButton, {
|
|
735
|
+
key: a._id,
|
|
736
|
+
type: "button",
|
|
737
|
+
icon: "keyboard_arrow_up",
|
|
738
|
+
variant: "tertiary",
|
|
739
|
+
size: "md",
|
|
740
|
+
disabled: V.disabled ?? !1,
|
|
741
|
+
onClick: () => {
|
|
742
|
+
const d = [...V.bindingAlternatives], n = d.findIndex((f) => f._id === a._id);
|
|
743
|
+
if (n > 0) {
|
|
744
|
+
const f = d[n - 1];
|
|
745
|
+
d[n - 1] = a, d[n] = f;
|
|
746
|
+
}
|
|
747
|
+
V.bindingAlternatives = [...d];
|
|
748
|
+
}
|
|
749
|
+
}),
|
|
750
|
+
le(ye.FmButton, {
|
|
751
|
+
key: a._id,
|
|
752
|
+
type: "button",
|
|
753
|
+
icon: "keyboard_arrow_down",
|
|
754
|
+
variant: "tertiary",
|
|
755
|
+
size: "md",
|
|
756
|
+
disabled: V.disabled ?? !1,
|
|
757
|
+
onClick: () => {
|
|
758
|
+
const d = [...V.bindingAlternatives], n = d.findIndex((f) => f._id === a._id);
|
|
759
|
+
if (n < d.length - 1) {
|
|
760
|
+
const f = d[n + 1];
|
|
761
|
+
d[n + 1] = a, d[n] = f;
|
|
762
|
+
}
|
|
763
|
+
V.bindingAlternatives = [...d];
|
|
764
|
+
}
|
|
765
|
+
})
|
|
766
|
+
]);
|
|
767
|
+
},
|
|
768
|
+
enableSorting: !1,
|
|
769
|
+
size: 40,
|
|
770
|
+
meta: {
|
|
771
|
+
cellClass: "",
|
|
772
|
+
headerClass: ""
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
]);
|
|
776
|
+
return {
|
|
777
|
+
get columnDefs() {
|
|
778
|
+
return t.value;
|
|
779
|
+
},
|
|
780
|
+
promptAddIngredient: async (k) => {
|
|
781
|
+
const v = [];
|
|
782
|
+
for (const n of r.skus)
|
|
783
|
+
k.includes(n._id) || v.push({
|
|
784
|
+
label: n.name,
|
|
785
|
+
sublabel: n.code,
|
|
786
|
+
value: n._id,
|
|
787
|
+
disabled: k.includes(n._id)
|
|
788
|
+
});
|
|
789
|
+
const a = (V.bindingAlternatives ?? []).map((n) => n._id), d = await c.multiSelect(v, a, (n) => {
|
|
790
|
+
var h, b, $, i, E, S;
|
|
791
|
+
const f = (h = V.bindingAlternatives) == null ? void 0 : h.findIndex((g) => g._id === n);
|
|
792
|
+
return {
|
|
793
|
+
_id: n,
|
|
794
|
+
trackingMeasurement: typeof f != "number" || f == -1 ? (b = r.skuById[n]) == null ? void 0 : b.trackingMeasurement : (i = ($ = V.bindingAlternatives) == null ? void 0 : $[f]) == null ? void 0 : i.trackingMeasurement,
|
|
795
|
+
priority: ((S = (E = V.bindingAlternatives) == null ? void 0 : E[f]) == null ? void 0 : S.priority) ?? V.bindingAlternatives.length,
|
|
796
|
+
default: !1
|
|
797
|
+
};
|
|
798
|
+
});
|
|
799
|
+
V.bindingAlternatives = d ?? V.bindingAlternatives;
|
|
800
|
+
},
|
|
801
|
+
columnVisibility: {
|
|
802
|
+
delete: !0,
|
|
803
|
+
unit: !1,
|
|
804
|
+
unitOption: !0,
|
|
805
|
+
default: !1,
|
|
806
|
+
// previous demo: sort priority by moving sku element in the array,
|
|
807
|
+
// new demo: sort priority using priority field.
|
|
808
|
+
// can reenable if this use case is requested to be restored
|
|
809
|
+
move: !1
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
const cn = { class: "flex flex-col gap-16" }, pn = { class: "flex flex-col" }, mn = { class: "flex justify-between items-center px-2" }, Ve = /* @__PURE__ */ ne({
|
|
814
|
+
__name: "InventoryBindingAlternative",
|
|
815
|
+
props: {
|
|
816
|
+
disabled: { type: Boolean },
|
|
817
|
+
modelValue: {},
|
|
818
|
+
filterIngredientIds: {}
|
|
819
|
+
},
|
|
820
|
+
emits: ["update:modelValue"],
|
|
821
|
+
setup(V, { emit: c }) {
|
|
822
|
+
const p = V, r = c, { t } = te(), w = un({
|
|
823
|
+
get disabled() {
|
|
824
|
+
return p.disabled ?? !1;
|
|
825
|
+
},
|
|
826
|
+
get bindingAlternatives() {
|
|
827
|
+
return p.modelValue ?? [];
|
|
828
|
+
},
|
|
829
|
+
set bindingAlternatives(a) {
|
|
830
|
+
r("update:modelValue", a);
|
|
831
|
+
}
|
|
832
|
+
}), k = (a) => a && a.some((d) => p.filterIngredientIds.includes(d._id)) ? "Contains invalid ingredient" : !0, v = (a) => a && a.length > 5 ? t("inventory.binding.alternative.maximumExceeded", { max: 5 }) : !0;
|
|
833
|
+
return (a, d) => {
|
|
834
|
+
var $;
|
|
835
|
+
const n = M("FmLabel"), f = M("FmButton"), h = M("FmFormGroup"), b = M("FmTable");
|
|
836
|
+
return m(), I("div", cn, [
|
|
837
|
+
y("div", pn, [
|
|
838
|
+
y("div", mn, [
|
|
839
|
+
_(n, {
|
|
840
|
+
label: e(t)("inventory.alternatives")
|
|
841
|
+
}, null, 8, ["label"]),
|
|
842
|
+
_(f, {
|
|
843
|
+
disabled: a.disabled,
|
|
844
|
+
"prepend-icon": "link",
|
|
845
|
+
variant: "primary",
|
|
846
|
+
class: "border-1 rounded-lg border-fm-color-primary",
|
|
847
|
+
onClick: d[0] || (d[0] = (i) => e(w).promptAddIngredient(a.filterIngredientIds)),
|
|
848
|
+
size: "md"
|
|
849
|
+
}, null, 8, ["disabled"])
|
|
850
|
+
]),
|
|
851
|
+
_(h, {
|
|
852
|
+
"model-value": a.modelValue,
|
|
853
|
+
rules: [k, v]
|
|
854
|
+
}, null, 8, ["model-value", "rules"])
|
|
855
|
+
]),
|
|
856
|
+
_(b, {
|
|
857
|
+
"row-data": a.modelValue ?? [],
|
|
858
|
+
"column-defs": e(w).columnDefs,
|
|
859
|
+
"page-size": (($ = a.modelValue) == null ? void 0 : $.length) || 0,
|
|
860
|
+
"shrink-at": 9999,
|
|
861
|
+
"column-visibility": e(w).columnVisibility,
|
|
862
|
+
"hide-footer": ""
|
|
863
|
+
}, null, 8, ["row-data", "column-defs", "page-size", "column-visibility"])
|
|
864
|
+
]);
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
}), fn = { class: "border-1 mx-3 my-1 rounded-md" }, vn = { class: "flex flex-col border-b border-fm-color-neutral-gray-100" }, yn = {
|
|
868
|
+
class: "flex items-center w-full",
|
|
869
|
+
style: { "min-height": "48px" }
|
|
870
|
+
}, bn = { class: "flex-1 fm-typo-en-body-md-400 py-8 px-12" }, gn = { class: "line-clamp-1 w-full" }, _n = { class: "w-[150px]" }, kn = {
|
|
871
|
+
key: 0,
|
|
872
|
+
class: "w-[52px]"
|
|
873
|
+
}, hn = { class: "flex flex-col px-12 pb-4" }, xn = /* @__PURE__ */ ne({
|
|
874
|
+
__name: "InventorySkuBindingV2Field",
|
|
875
|
+
props: {
|
|
876
|
+
disabled: { type: Boolean },
|
|
877
|
+
readonly: { type: Boolean },
|
|
878
|
+
modelValue: {},
|
|
879
|
+
displayName: {},
|
|
880
|
+
unit: {},
|
|
881
|
+
showError: { type: Boolean },
|
|
882
|
+
ableToConfigureAlternative: { type: Boolean },
|
|
883
|
+
ableToApplyRules: { type: Boolean }
|
|
884
|
+
},
|
|
885
|
+
emits: ["update:modelValue", "delete", "settings"],
|
|
886
|
+
setup(V, { emit: c }) {
|
|
887
|
+
const p = c, { t: r } = te(), t = nt("modelValue");
|
|
888
|
+
function w(v) {
|
|
889
|
+
v && (t.amount = v.amount, t.measurement = v.measurement);
|
|
890
|
+
}
|
|
891
|
+
function k() {
|
|
892
|
+
return {
|
|
893
|
+
modelValue: {
|
|
894
|
+
amount: t.amount,
|
|
895
|
+
measurement: t.measurement
|
|
896
|
+
},
|
|
897
|
+
amountAsString: zt.toFormatString({
|
|
898
|
+
value: t.amount
|
|
899
|
+
})
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
return (v, a) => {
|
|
903
|
+
const d = M("FmTooltip"), n = M("FmButton"), f = M("FmFormGroup");
|
|
904
|
+
return m(), I("div", fn, [
|
|
905
|
+
y("div", vn, [
|
|
906
|
+
y("div", yn, [
|
|
907
|
+
y("div", bn, [
|
|
908
|
+
_(d, {
|
|
909
|
+
zIndex: 51,
|
|
910
|
+
variant: "plain",
|
|
911
|
+
placement: "top",
|
|
912
|
+
content: v.displayName
|
|
913
|
+
}, {
|
|
914
|
+
default: Y(() => [
|
|
915
|
+
y("span", gn, U(v.displayName), 1)
|
|
916
|
+
]),
|
|
917
|
+
_: 1
|
|
918
|
+
}, 8, ["content"])
|
|
919
|
+
]),
|
|
920
|
+
y("div", _n, [
|
|
921
|
+
_(Ce, {
|
|
922
|
+
"model-value": { amount: e(t).amount, measurement: e(t).measurement },
|
|
923
|
+
"onUpdate:modelValue": w,
|
|
924
|
+
unit: v.unit,
|
|
925
|
+
placement: "bottom",
|
|
926
|
+
"convert-amount-on-change-unit": "",
|
|
927
|
+
disabled: v.readonly
|
|
928
|
+
}, null, 8, ["model-value", "unit", "disabled"])
|
|
929
|
+
]),
|
|
930
|
+
v.readonly ? R("", !0) : (m(), I("div", kn, [
|
|
931
|
+
_(n, {
|
|
932
|
+
disabled: v.disabled,
|
|
933
|
+
type: "button",
|
|
934
|
+
variant: "tertiary",
|
|
935
|
+
icon: "delete",
|
|
936
|
+
onClick: a[0] || (a[0] = () => p("delete", e(t).id))
|
|
937
|
+
}, null, 8, ["disabled"])
|
|
938
|
+
]))
|
|
939
|
+
]),
|
|
940
|
+
y("div", hn, [
|
|
941
|
+
_(f, {
|
|
942
|
+
modelValue: e(t).amount,
|
|
943
|
+
rules: [e(et)(0)]
|
|
944
|
+
}, null, 8, ["modelValue", "rules"]),
|
|
945
|
+
_(f, {
|
|
946
|
+
modelValue: k(),
|
|
947
|
+
rules: [
|
|
948
|
+
e(Mt)(),
|
|
949
|
+
e(Pt)(v.unit),
|
|
950
|
+
() => v.showError ? e(r)("inventory.inventoryBindings.invalidWarning") : !0
|
|
951
|
+
]
|
|
952
|
+
}, null, 8, ["modelValue", "rules"])
|
|
953
|
+
]),
|
|
954
|
+
v.ableToApplyRules ? (m(), W(Re, {
|
|
955
|
+
key: 0,
|
|
956
|
+
modelValue: e(t).rules,
|
|
957
|
+
"onUpdate:modelValue": a[1] || (a[1] = (h) => e(t).rules = h),
|
|
958
|
+
disabled: v.disabled
|
|
959
|
+
}, null, 8, ["modelValue", "disabled"])) : R("", !0),
|
|
960
|
+
v.ableToConfigureAlternative ? (m(), W(Ve, {
|
|
961
|
+
key: 1,
|
|
962
|
+
modelValue: e(t).alternatives,
|
|
963
|
+
"onUpdate:modelValue": a[2] || (a[2] = (h) => e(t).alternatives = h),
|
|
964
|
+
disabled: v.disabled,
|
|
965
|
+
filterIngredientIds: [e(t).id]
|
|
966
|
+
}, null, 8, ["modelValue", "disabled", "filterIngredientIds"])) : R("", !0)
|
|
967
|
+
])
|
|
968
|
+
]);
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
});
|
|
972
|
+
exports.FfCalculator;
|
|
973
|
+
const wn = { class: "flex flex-col gap-24" }, En = {
|
|
974
|
+
key: 0,
|
|
975
|
+
class: "flex flex-col gap-16"
|
|
976
|
+
}, $n = { class: "flex items-center" }, In = { class: "flex-1 fm-typo-en-title-sm-600" }, Vn = { class: "flex flex-col" }, Sn = { class: "flex py-8 px-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 h-[44px] items-center" }, Cn = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Fn = {
|
|
977
|
+
key: 0,
|
|
978
|
+
class: "w-[52px]"
|
|
979
|
+
}, Bn = {
|
|
980
|
+
key: 1,
|
|
981
|
+
class: "w-[52px]"
|
|
982
|
+
}, Rn = { class: "flex flex-col gap-16" }, An = { class: "flex items-center" }, Tn = { class: "flex-1 fm-typo-en-title-sm-600" }, Un = { class: "flex flex-col" }, Mn = { class: "flex py-8 px-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-100 h-[44px] items-center" }, Pn = { class: "flex-1 fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Dn = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary w-[150px] px-16" }, zn = {
|
|
983
|
+
key: 0,
|
|
984
|
+
class: "w-[52px]"
|
|
985
|
+
}, Nn = {
|
|
986
|
+
key: 0,
|
|
987
|
+
class: "flex flex-col border-b border-fm-color-neutral-gray-100"
|
|
988
|
+
}, Ln = {
|
|
989
|
+
class: "flex items-center w-full",
|
|
990
|
+
style: { "min-height": "48px" }
|
|
991
|
+
}, jn = { class: "flex-1 fm-typo-en-body-md-400 py-8 px-12 text-fm-color-typo-secondary line-clamp-1" }, On = {
|
|
992
|
+
key: 0,
|
|
993
|
+
class: "w-[52px]"
|
|
994
|
+
}, Kn = { class: "flex gap-4 text-fm-color-system-error-400 fm-typo-en-body-sm-400 px-12 pb-4" }, Gn = /* @__PURE__ */ ne({
|
|
995
|
+
__name: "InventoryBindingFormV2",
|
|
996
|
+
props: {
|
|
997
|
+
id: {},
|
|
998
|
+
modelValue: { default: () => [] },
|
|
999
|
+
excludeBindingId: {},
|
|
1000
|
+
rules: { default: () => [] },
|
|
1001
|
+
iframeMode: { type: Boolean },
|
|
1002
|
+
disabled: { type: Boolean },
|
|
1003
|
+
readonly: { type: Boolean },
|
|
1004
|
+
recipeBindingConfig: { default: () => ({ enabled: !0, ableToApplyRules: !1 }) },
|
|
1005
|
+
skuBindingConfig: { default: () => ({
|
|
1006
|
+
enabled: !0,
|
|
1007
|
+
ableToApplyRules: !1,
|
|
1008
|
+
ableToConfigureAlternative: !1
|
|
1009
|
+
}) },
|
|
1010
|
+
allowRecipeDecimal: { type: Boolean }
|
|
1011
|
+
},
|
|
1012
|
+
emits: ["update:modelValue", "click:pick-inventory-bindings"],
|
|
1013
|
+
setup(V, { emit: c }) {
|
|
1014
|
+
const { t: p } = te(), r = ee(), t = C(() => r.recipeById), w = C(() => r.skuById), k = V, v = c, a = C(() => bt({
|
|
1015
|
+
parentId: k.id,
|
|
1016
|
+
bindings: k.modelValue,
|
|
1017
|
+
recipes: r.recipes.map((s) => s._id === k.id ? {
|
|
1018
|
+
...s,
|
|
1019
|
+
contains: k.modelValue
|
|
1020
|
+
} : s),
|
|
1021
|
+
skus: r.skus.map((s) => s._id === k.id ? {
|
|
1022
|
+
...s,
|
|
1023
|
+
convert: {
|
|
1024
|
+
inventoryBindings: k.modelValue
|
|
1025
|
+
}
|
|
1026
|
+
} : s),
|
|
1027
|
+
skuGroups: []
|
|
1028
|
+
}).inventoryBindings.filter((s) => "error" in s && s.error).map((s) => s).filter((s) => s.reason === gt.enum.circularDependency)), d = C(
|
|
1029
|
+
() => new Set(a.value.map((u) => {
|
|
1030
|
+
var l;
|
|
1031
|
+
return (l = u.bindingPaths[0]) == null ? void 0 : l.id;
|
|
1032
|
+
}))
|
|
1033
|
+
), n = C(() => k.modelValue.filter((u) => u.type === "RECIPE")), { promptIngredientsBinding: f, promptRecipesBinding: h } = Jt();
|
|
1034
|
+
async function b() {
|
|
1035
|
+
if (k.iframeMode) {
|
|
1036
|
+
v("click:pick-inventory-bindings", "RECIPE");
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
h(
|
|
1040
|
+
k.modelValue,
|
|
1041
|
+
(u) => v("update:modelValue", u),
|
|
1042
|
+
k.id ? [k.id] : []
|
|
1043
|
+
);
|
|
1044
|
+
}
|
|
1045
|
+
const $ = C(() => k.modelValue.filter((u) => u.type === "SKU") ?? []);
|
|
1046
|
+
async function i() {
|
|
1047
|
+
if (k.iframeMode) {
|
|
1048
|
+
v("click:pick-inventory-bindings", "SKU");
|
|
1049
|
+
return;
|
|
1050
|
+
}
|
|
1051
|
+
f(
|
|
1052
|
+
k.modelValue,
|
|
1053
|
+
(u) => v("update:modelValue", u),
|
|
1054
|
+
k.excludeBindingId,
|
|
1055
|
+
k.id ? [k.id] : []
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
function E(u) {
|
|
1059
|
+
const l = k.modelValue.map((s) => s.id === u.id ? u : s);
|
|
1060
|
+
v("update:modelValue", l);
|
|
1061
|
+
}
|
|
1062
|
+
function S(u) {
|
|
1063
|
+
const l = k.modelValue.filter((s) => s.id !== u);
|
|
1064
|
+
v("update:modelValue", l);
|
|
1065
|
+
}
|
|
1066
|
+
function g(u) {
|
|
1067
|
+
var s, A;
|
|
1068
|
+
if (u.type !== Ue.enum.SKU)
|
|
1069
|
+
throw new Error("Non-SKU binding does not have unit");
|
|
1070
|
+
if (!((s = w.value[u.id]) == null ? void 0 : s.unit))
|
|
1071
|
+
throw new Error(`Cannot find ingredient: ${u.id}`);
|
|
1072
|
+
return (A = w.value[u.id]) == null ? void 0 : A.unit;
|
|
1073
|
+
}
|
|
1074
|
+
function o(u) {
|
|
1075
|
+
return !w.value[u.id];
|
|
1076
|
+
}
|
|
1077
|
+
return (u, l) => {
|
|
1078
|
+
var F, N, L;
|
|
1079
|
+
const s = M("FmFormGroup"), A = M("FmButton"), D = M("FmIcon");
|
|
1080
|
+
return m(), I("div", wn, [
|
|
1081
|
+
_(s, {
|
|
1082
|
+
disabled: u.disabled,
|
|
1083
|
+
"model-value": u.modelValue,
|
|
1084
|
+
rules: [
|
|
1085
|
+
...u.rules,
|
|
1086
|
+
() => a.value.length ? "There is a binding error in your configuration" : !0
|
|
1087
|
+
]
|
|
1088
|
+
}, {
|
|
1089
|
+
label: Y(() => l[4] || (l[4] = [
|
|
1090
|
+
y("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Define the inventory bindings for this recipe or ingredient. ", -1)
|
|
1091
|
+
])),
|
|
1092
|
+
_: 1
|
|
1093
|
+
}, 8, ["disabled", "model-value", "rules"]),
|
|
1094
|
+
((F = u.recipeBindingConfig) == null ? void 0 : F.enabled) !== !1 ? (m(), I("div", En, [
|
|
1095
|
+
y("div", $n, [
|
|
1096
|
+
y("div", In, U(e(p)("inventory.inventoryBindings.recipe")), 1),
|
|
1097
|
+
u.readonly ? R("", !0) : (m(), W(A, {
|
|
1098
|
+
key: 0,
|
|
1099
|
+
variant: "secondary",
|
|
1100
|
+
"text-color": "primary",
|
|
1101
|
+
"border-color": "primary",
|
|
1102
|
+
label: e(p)("inventory.inventoryBindings.linkRecipe"),
|
|
1103
|
+
"prepend-icon": "link",
|
|
1104
|
+
onClick: b
|
|
1105
|
+
}, null, 8, ["label"]))
|
|
1106
|
+
]),
|
|
1107
|
+
y("div", Vn, [
|
|
1108
|
+
y("div", Sn, [
|
|
1109
|
+
y("div", Cn, U(e(p)("inventory.inventoryBindings.recipe")), 1),
|
|
1110
|
+
l[5] || (l[5] = y("div", { class: "w-[200px]" }, null, -1)),
|
|
1111
|
+
u.recipeBindingConfig.ableToApplyRules ? (m(), I("div", Fn)) : R("", !0),
|
|
1112
|
+
u.readonly ? R("", !0) : (m(), I("div", Bn))
|
|
1113
|
+
]),
|
|
1114
|
+
(m(!0), I(J, null, me(n.value, (B) => {
|
|
1115
|
+
var P;
|
|
1116
|
+
return m(), W(dn, {
|
|
1117
|
+
key: B.id,
|
|
1118
|
+
"model-value": B,
|
|
1119
|
+
"display-name": (P = t.value[B.id]) == null ? void 0 : P.name,
|
|
1120
|
+
"show-error": d.value.has(B.id),
|
|
1121
|
+
readonly: u.readonly,
|
|
1122
|
+
disabled: u.disabled,
|
|
1123
|
+
"allow-recipe-decimal": u.allowRecipeDecimal,
|
|
1124
|
+
"onUpdate:modelValue": l[0] || (l[0] = (H) => E(H)),
|
|
1125
|
+
onDelete: l[1] || (l[1] = (H) => S(H))
|
|
1126
|
+
}, null, 8, ["model-value", "display-name", "show-error", "readonly", "disabled", "allow-recipe-decimal"]);
|
|
1127
|
+
}), 128))
|
|
1128
|
+
])
|
|
1129
|
+
])) : R("", !0),
|
|
1130
|
+
y("div", Rn, [
|
|
1131
|
+
y("div", An, [
|
|
1132
|
+
y("div", Tn, U(e(p)("inventory.inventoryBindings.ingredient")), 1),
|
|
1133
|
+
u.readonly ? R("", !0) : (m(), W(A, {
|
|
1134
|
+
key: 0,
|
|
1135
|
+
variant: "secondary",
|
|
1136
|
+
"text-color": "primary",
|
|
1137
|
+
"border-color": "primary",
|
|
1138
|
+
label: e(p)("inventory.inventoryBindings.linkIngredient"),
|
|
1139
|
+
"prepend-icon": "link",
|
|
1140
|
+
onClick: i
|
|
1141
|
+
}, null, 8, ["label"]))
|
|
1142
|
+
]),
|
|
1143
|
+
y("div", Un, [
|
|
1144
|
+
y("div", Mn, [
|
|
1145
|
+
y("div", Pn, U(e(p)("inventory.inventoryBindings.ingredient")), 1),
|
|
1146
|
+
y("div", Dn, U(e(p)("inventory.inventoryBindings.amount")), 1),
|
|
1147
|
+
l[6] || (l[6] = y("div", { class: "w-[52px]" }, null, -1)),
|
|
1148
|
+
(N = u.skuBindingConfig) != null && N.ableToApplyRules || (L = u.skuBindingConfig) != null && L.ableToConfigureAlternative ? (m(), I("div", zn)) : R("", !0)
|
|
1149
|
+
]),
|
|
1150
|
+
(m(!0), I(J, null, me($.value, (B) => {
|
|
1151
|
+
var P, H, Q;
|
|
1152
|
+
return m(), I(J, {
|
|
1153
|
+
key: B.id
|
|
1154
|
+
}, [
|
|
1155
|
+
o(B) ? (m(), I("div", Nn, [
|
|
1156
|
+
y("div", Ln, [
|
|
1157
|
+
y("div", jn, U(B.id), 1),
|
|
1158
|
+
u.readonly ? R("", !0) : (m(), I("div", On, [
|
|
1159
|
+
_(A, {
|
|
1160
|
+
disabled: u.disabled,
|
|
1161
|
+
type: "button",
|
|
1162
|
+
variant: "tertiary",
|
|
1163
|
+
icon: "delete",
|
|
1164
|
+
onClick: () => S(B.id)
|
|
1165
|
+
}, null, 8, ["disabled", "onClick"])
|
|
1166
|
+
]))
|
|
1167
|
+
]),
|
|
1168
|
+
y("div", Kn, [
|
|
1169
|
+
_(D, {
|
|
1170
|
+
name: "error",
|
|
1171
|
+
color: "system-error-300",
|
|
1172
|
+
size: "sm"
|
|
1173
|
+
}),
|
|
1174
|
+
y("div", null, U(e(p)("inventory.inventoryBindings.missingIngredient")), 1)
|
|
1175
|
+
])
|
|
1176
|
+
])) : (m(), W(xn, {
|
|
1177
|
+
key: 1,
|
|
1178
|
+
"model-value": B,
|
|
1179
|
+
"display-name": (P = w.value[B.id]) == null ? void 0 : P.name,
|
|
1180
|
+
unit: g(B),
|
|
1181
|
+
"show-error": d.value.has(B.id),
|
|
1182
|
+
"able-to-apply-rules": ((H = u.skuBindingConfig) == null ? void 0 : H.ableToApplyRules) === !0,
|
|
1183
|
+
"able-to-configure-alternative": ((Q = u.skuBindingConfig) == null ? void 0 : Q.ableToConfigureAlternative) === !0,
|
|
1184
|
+
readonly: u.readonly,
|
|
1185
|
+
disabled: u.disabled,
|
|
1186
|
+
"onUpdate:modelValue": l[2] || (l[2] = (re) => E(re)),
|
|
1187
|
+
onDelete: l[3] || (l[3] = (re) => S(re))
|
|
1188
|
+
}, null, 8, ["model-value", "display-name", "unit", "show-error", "able-to-apply-rules", "able-to-configure-alternative", "readonly", "disabled"]))
|
|
1189
|
+
], 64);
|
|
1190
|
+
}), 128))
|
|
1191
|
+
])
|
|
1192
|
+
])
|
|
1193
|
+
]);
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
}), qn = { class: "flex flex-col gap-40" }, Wn = {
|
|
1197
|
+
key: 0,
|
|
1198
|
+
class: "flex flex-col gap-16"
|
|
1199
|
+
}, Yn = {
|
|
1200
|
+
key: 0,
|
|
1201
|
+
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"
|
|
1202
|
+
}, Hn = {
|
|
1203
|
+
key: 0,
|
|
1204
|
+
class: "flex flex-col items-center w-full h-full gap-24"
|
|
1205
|
+
}, Jn = { key: 1 }, Qn = { class: "mt-32" }, Xn = /* @__PURE__ */ ne({
|
|
1206
|
+
__name: "RecipeForm",
|
|
1207
|
+
props: {
|
|
1208
|
+
mode: {},
|
|
1209
|
+
modelValue: {},
|
|
1210
|
+
disabled: { type: Boolean }
|
|
1211
|
+
},
|
|
1212
|
+
emits: ["update:modelValue", "click:submit"],
|
|
1213
|
+
setup(V, { expose: c, emit: p }) {
|
|
1214
|
+
const r = V, t = p, w = je(), { t: k } = te(), v = C({
|
|
1215
|
+
get() {
|
|
1216
|
+
var l;
|
|
1217
|
+
return ((l = r.modelValue) == null ? void 0 : l.name) ?? "";
|
|
1218
|
+
},
|
|
1219
|
+
set(l) {
|
|
1220
|
+
const s = r.modelValue ?? {};
|
|
1221
|
+
s.name = l, t("update:modelValue", s);
|
|
1222
|
+
}
|
|
1223
|
+
}), a = C({
|
|
1224
|
+
get() {
|
|
1225
|
+
var l;
|
|
1226
|
+
return ((l = r.modelValue) == null ? void 0 : l.contains) ?? [];
|
|
1227
|
+
},
|
|
1228
|
+
set(l) {
|
|
1229
|
+
const s = r.modelValue ?? {};
|
|
1230
|
+
s.contains = l, t("update:modelValue", s);
|
|
1231
|
+
}
|
|
1232
|
+
}), d = C({
|
|
1233
|
+
get() {
|
|
1234
|
+
var l;
|
|
1235
|
+
return ((l = r.modelValue) == null ? void 0 : l.customAttributes) ?? {};
|
|
1236
|
+
},
|
|
1237
|
+
set(l) {
|
|
1238
|
+
const s = r.modelValue ? {
|
|
1239
|
+
...r.modelValue
|
|
1240
|
+
} : {};
|
|
1241
|
+
s.customAttributes = l, t("update:modelValue", s);
|
|
1242
|
+
}
|
|
1243
|
+
}), n = C({
|
|
1244
|
+
get() {
|
|
1245
|
+
var l;
|
|
1246
|
+
return ((l = r.modelValue) == null ? void 0 : l.version) ?? null;
|
|
1247
|
+
},
|
|
1248
|
+
set(l) {
|
|
1249
|
+
const s = r.modelValue ? { ...r.modelValue } : {};
|
|
1250
|
+
s.version = l, t("update:modelValue", s);
|
|
1251
|
+
}
|
|
1252
|
+
}), f = C({
|
|
1253
|
+
get() {
|
|
1254
|
+
return n.value === "v2";
|
|
1255
|
+
},
|
|
1256
|
+
set(l) {
|
|
1257
|
+
n.value = l ? "v2" : null;
|
|
1258
|
+
}
|
|
1259
|
+
});
|
|
1260
|
+
function h() {
|
|
1261
|
+
t("click:submit");
|
|
1262
|
+
}
|
|
1263
|
+
const b = O();
|
|
1264
|
+
c({
|
|
1265
|
+
validateInputs: () => {
|
|
1266
|
+
var l, s;
|
|
1267
|
+
(s = (l = b.value) == null ? void 0 : l.validateInputs) == null || s.call(l);
|
|
1268
|
+
},
|
|
1269
|
+
resetInputsValidation: () => {
|
|
1270
|
+
var l, s;
|
|
1271
|
+
(s = (l = b.value) == null ? void 0 : l.resetInputsValidation) == null || s.call(l);
|
|
1272
|
+
},
|
|
1273
|
+
resetInputs: () => {
|
|
1274
|
+
var l, s;
|
|
1275
|
+
(s = (l = b.value) == null ? void 0 : l.resetInputs) == null || s.call(l);
|
|
1276
|
+
}
|
|
1277
|
+
});
|
|
1278
|
+
const $ = ee(), i = O([]), E = O(!1), S = O(!1);
|
|
1279
|
+
de(E, async (l) => {
|
|
1280
|
+
g(l);
|
|
1281
|
+
});
|
|
1282
|
+
async function g(l) {
|
|
1283
|
+
var s, A;
|
|
1284
|
+
l && !S.value && ((s = r.modelValue) != null && s._id) && (S.value = !0, i.value = await $.getAffectedMenu((A = r.modelValue) == null ? void 0 : A._id).delayed(500), S.value = !1);
|
|
1285
|
+
}
|
|
1286
|
+
const o = C(
|
|
1287
|
+
() => $.recipes.map((l) => ({ label: l.name, value: l.name }))
|
|
1288
|
+
), u = C(() => {
|
|
1289
|
+
var l;
|
|
1290
|
+
return ((l = r.modelValue) == null ? void 0 : l.name) ?? "";
|
|
1291
|
+
});
|
|
1292
|
+
return (l, s) => {
|
|
1293
|
+
const A = M("FmTextField"), D = M("FmSwitch"), F = M("FmCard"), N = M("FmSpacer"), L = M("FmCircularProgress"), B = M("FmForm");
|
|
1294
|
+
return m(), W(B, {
|
|
1295
|
+
ref_key: "formRef",
|
|
1296
|
+
ref: b,
|
|
1297
|
+
onValidationSuccess: h
|
|
1298
|
+
}, {
|
|
1299
|
+
default: Y(() => [
|
|
1300
|
+
y("div", qn, [
|
|
1301
|
+
_(A, {
|
|
1302
|
+
disabled: l.disabled,
|
|
1303
|
+
label: e(k)("inventory.recipe.name"),
|
|
1304
|
+
"model-value": v.value,
|
|
1305
|
+
"onUpdate:modelValue": s[0] || (s[0] = (P) => v.value = P),
|
|
1306
|
+
rules: [
|
|
1307
|
+
e(Vt)(),
|
|
1308
|
+
e(tt)(o.value, u.value, (P) => `[${P.value}] already exists`)
|
|
1309
|
+
],
|
|
1310
|
+
"label-mark": "required"
|
|
1311
|
+
}, null, 8, ["disabled", "label", "model-value", "rules"]),
|
|
1312
|
+
e(w).enableRecipeV2 ? (m(), I("div", Wn, [
|
|
1313
|
+
_(D, {
|
|
1314
|
+
modelValue: f.value,
|
|
1315
|
+
"onUpdate:modelValue": s[1] || (s[1] = (P) => f.value = P),
|
|
1316
|
+
value: !0,
|
|
1317
|
+
label: e(k)("inventory.recipe.enableRecipeV2"),
|
|
1318
|
+
"label-placement": "right",
|
|
1319
|
+
disabled: l.disabled,
|
|
1320
|
+
sublabel: e(k)("inventory.recipe.recipeV2Warning")
|
|
1321
|
+
}, null, 8, ["modelValue", "label", "disabled", "sublabel"])
|
|
1322
|
+
])) : R("", !0),
|
|
1323
|
+
_(F, {
|
|
1324
|
+
variant: "outlined",
|
|
1325
|
+
class: "p-16"
|
|
1326
|
+
}, {
|
|
1327
|
+
default: Y(() => {
|
|
1328
|
+
var P, H;
|
|
1329
|
+
return [
|
|
1330
|
+
e(w).enableRecipeV2 ? (m(), W(Gn, {
|
|
1331
|
+
key: 0,
|
|
1332
|
+
id: (P = l.modelValue) == null ? void 0 : P._id,
|
|
1333
|
+
disabled: l.disabled,
|
|
1334
|
+
"model-value": a.value,
|
|
1335
|
+
"onUpdate:modelValue": s[2] || (s[2] = (Q) => a.value = Q),
|
|
1336
|
+
rules: [e(Pe)(1)],
|
|
1337
|
+
"allow-recipe-decimal": "",
|
|
1338
|
+
"recipe-binding-config": { enabled: !f.value, ableToApplyRules: f.value },
|
|
1339
|
+
"sku-binding-config": {
|
|
1340
|
+
ableToConfigureAlternative: f.value
|
|
1341
|
+
}
|
|
1342
|
+
}, null, 8, ["id", "disabled", "model-value", "rules", "recipe-binding-config", "sku-binding-config"])) : (m(), W(Rt, {
|
|
1343
|
+
key: 1,
|
|
1344
|
+
id: (H = l.modelValue) == null ? void 0 : H._id,
|
|
1345
|
+
disabled: l.disabled,
|
|
1346
|
+
"model-value": a.value,
|
|
1347
|
+
"onUpdate:modelValue": s[3] || (s[3] = (Q) => a.value = Q),
|
|
1348
|
+
rules: [e(Pe)(1)],
|
|
1349
|
+
"allow-recipe-decimal": ""
|
|
1350
|
+
}, null, 8, ["id", "disabled", "model-value", "rules"]))
|
|
1351
|
+
];
|
|
1352
|
+
}),
|
|
1353
|
+
_: 1
|
|
1354
|
+
})
|
|
1355
|
+
]),
|
|
1356
|
+
l.mode !== e(ae).CREATE ? (m(), I("div", Yn, [
|
|
1357
|
+
_(D, {
|
|
1358
|
+
label: "Show binded items",
|
|
1359
|
+
modelValue: E.value,
|
|
1360
|
+
"onUpdate:modelValue": s[4] || (s[4] = (P) => E.value = P),
|
|
1361
|
+
"label-placement": "right",
|
|
1362
|
+
disabled: S.value
|
|
1363
|
+
}, null, 8, ["modelValue", "disabled"]),
|
|
1364
|
+
S.value ? (m(), I("div", Hn, [
|
|
1365
|
+
_(N),
|
|
1366
|
+
y("div", null, [
|
|
1367
|
+
_(L, { size: "xl" })
|
|
1368
|
+
]),
|
|
1369
|
+
s[6] || (s[6] = y("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary pl-8" }, "Loading...", -1)),
|
|
1370
|
+
_(N)
|
|
1371
|
+
])) : E.value && i.value.length ? (m(), I("div", Jn, [
|
|
1372
|
+
_(Xe, {
|
|
1373
|
+
name: "Menu",
|
|
1374
|
+
bindings: i.value
|
|
1375
|
+
}, null, 8, ["bindings"])
|
|
1376
|
+
])) : R("", !0)
|
|
1377
|
+
])) : R("", !0),
|
|
1378
|
+
y("div", Qn, [
|
|
1379
|
+
_(Nt, {
|
|
1380
|
+
entity: "inventoryRecipe",
|
|
1381
|
+
modelValue: d.value,
|
|
1382
|
+
"onUpdate:modelValue": s[5] || (s[5] = (P) => d.value = P)
|
|
1383
|
+
}, null, 8, ["modelValue"])
|
|
1384
|
+
])
|
|
1385
|
+
]),
|
|
1386
|
+
_: 1
|
|
1387
|
+
}, 512);
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
}), Zn = { class: "flex gap-4" }, eo = /* @__PURE__ */ ne({
|
|
1391
|
+
__name: "RecipeDialog",
|
|
1392
|
+
props: {
|
|
1393
|
+
show: { type: Boolean },
|
|
1394
|
+
recipe: {},
|
|
1395
|
+
mode: { default: ae.READ }
|
|
1396
|
+
},
|
|
1397
|
+
emits: ["update:show"],
|
|
1398
|
+
setup(V) {
|
|
1399
|
+
const c = V, p = ee(), r = Le(), { t } = te(), w = Me(c, "show"), k = Me(c, "recipe"), v = C(() => {
|
|
1400
|
+
switch (c.mode) {
|
|
1401
|
+
case ae.READ:
|
|
1402
|
+
return "";
|
|
1403
|
+
case ae.UPDATE:
|
|
1404
|
+
return t("inventory.recipe.update.title");
|
|
1405
|
+
case ae.CREATE:
|
|
1406
|
+
return t("inventory.recipe.create.title");
|
|
1407
|
+
}
|
|
1408
|
+
return "";
|
|
1409
|
+
}), a = C(() => {
|
|
1410
|
+
switch (c.mode) {
|
|
1411
|
+
case ae.READ:
|
|
1412
|
+
return "";
|
|
1413
|
+
case ae.UPDATE:
|
|
1414
|
+
return t("common.save");
|
|
1415
|
+
case ae.CREATE:
|
|
1416
|
+
return t("common.add");
|
|
1417
|
+
}
|
|
1418
|
+
return "";
|
|
1419
|
+
}), d = O(), n = O(!1);
|
|
1420
|
+
async function f() {
|
|
1421
|
+
n.value = !0;
|
|
1422
|
+
try {
|
|
1423
|
+
const i = ze(k.value);
|
|
1424
|
+
i.precision ?? (i.precision = 0), i.measurements ?? (i.measurements = []), await p.createRecipe(i), w.value = !1, r.open({
|
|
1425
|
+
title: t("inventory.common.success"),
|
|
1426
|
+
message: t("inventory.recipe.create.success", { name: k.value.name }),
|
|
1427
|
+
type: "success"
|
|
1428
|
+
});
|
|
1429
|
+
} catch (i) {
|
|
1430
|
+
i instanceof Ge || r.open({
|
|
1431
|
+
title: t("inventory.recipe.create.error.title"),
|
|
1432
|
+
message: t("inventory.recipe.create.error.message"),
|
|
1433
|
+
type: "error"
|
|
1434
|
+
});
|
|
1435
|
+
} finally {
|
|
1436
|
+
n.value = !1;
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
async function h() {
|
|
1440
|
+
n.value = !0;
|
|
1441
|
+
try {
|
|
1442
|
+
await p.updateRecipe(k.value), w.value = !1, r.open({
|
|
1443
|
+
title: t("inventory.common.success"),
|
|
1444
|
+
message: t("inventory.recipe.update.success", { name: k.value.name }),
|
|
1445
|
+
type: "success"
|
|
1446
|
+
});
|
|
1447
|
+
} catch (i) {
|
|
1448
|
+
i instanceof Ge || r.open({
|
|
1449
|
+
title: t("inventory.recipe.update.error.title"),
|
|
1450
|
+
message: t("inventory.recipe.update.error.message"),
|
|
1451
|
+
type: "error"
|
|
1452
|
+
});
|
|
1453
|
+
} finally {
|
|
1454
|
+
n.value = !1;
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
function b() {
|
|
1458
|
+
var i, E;
|
|
1459
|
+
(E = (i = d.value) == null ? void 0 : i.validateInputs) == null || E.call(i);
|
|
1460
|
+
}
|
|
1461
|
+
function $() {
|
|
1462
|
+
switch (c.mode) {
|
|
1463
|
+
case ae.READ:
|
|
1464
|
+
return;
|
|
1465
|
+
case ae.UPDATE:
|
|
1466
|
+
return h();
|
|
1467
|
+
case ae.CREATE:
|
|
1468
|
+
return f();
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
return (i, E) => {
|
|
1472
|
+
const S = M("FmButton"), g = M("FmSideSheet");
|
|
1473
|
+
return m(), W(g, {
|
|
1474
|
+
"model-value": e(w),
|
|
1475
|
+
"onUpdate:modelValue": E[3] || (E[3] = (o) => Ae(w) ? w.value = o : null),
|
|
1476
|
+
header: v.value,
|
|
1477
|
+
"close-button": "",
|
|
1478
|
+
"dismiss-away": "",
|
|
1479
|
+
"max-width": 800
|
|
1480
|
+
}, {
|
|
1481
|
+
"side-sheet-footer": Y(() => [
|
|
1482
|
+
y("div", Zn, [
|
|
1483
|
+
_(S, {
|
|
1484
|
+
loading: n.value,
|
|
1485
|
+
label: a.value,
|
|
1486
|
+
onClick: b
|
|
1487
|
+
}, null, 8, ["loading", "label"]),
|
|
1488
|
+
_(S, {
|
|
1489
|
+
disabled: n.value,
|
|
1490
|
+
label: e(t)("common.close"),
|
|
1491
|
+
variant: "tertiary",
|
|
1492
|
+
onClick: E[2] || (E[2] = (o) => w.value = !1)
|
|
1493
|
+
}, null, 8, ["disabled", "label"])
|
|
1494
|
+
])
|
|
1495
|
+
]),
|
|
1496
|
+
default: Y(() => [
|
|
1497
|
+
_(Xn, {
|
|
1498
|
+
class: "w-full",
|
|
1499
|
+
ref_key: "hasValidationExpose",
|
|
1500
|
+
ref: d,
|
|
1501
|
+
modelValue: e(k),
|
|
1502
|
+
"onUpdate:modelValue": E[0] || (E[0] = (o) => Ae(k) ? k.value = o : null),
|
|
1503
|
+
mode: i.mode,
|
|
1504
|
+
disabled: n.value,
|
|
1505
|
+
"onClick:submit": E[1] || (E[1] = (o) => $())
|
|
1506
|
+
}, null, 8, ["modelValue", "mode", "disabled"])
|
|
1507
|
+
]),
|
|
1508
|
+
_: 1
|
|
1509
|
+
}, 8, ["model-value", "header"]);
|
|
1510
|
+
};
|
|
1511
|
+
}
|
|
1512
|
+
});
|
|
1513
|
+
let to = 0;
|
|
1514
|
+
function no(V = null) {
|
|
1515
|
+
return {
|
|
1516
|
+
id: String(++to),
|
|
1517
|
+
type: V,
|
|
1518
|
+
itemId: null,
|
|
1519
|
+
amountModel: be()
|
|
1520
|
+
};
|
|
1521
|
+
}
|
|
1522
|
+
function at(V, c, p, r) {
|
|
1523
|
+
for (const t of V)
|
|
1524
|
+
if (t.type === "RECIPE") {
|
|
1525
|
+
if (t.id === c) return !0;
|
|
1526
|
+
if (!p.has(t.id)) {
|
|
1527
|
+
const w = r[t.id];
|
|
1528
|
+
if (w && at(w.contains, c, /* @__PURE__ */ new Set([...p, t.id]), r))
|
|
1529
|
+
return !0;
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
return !1;
|
|
1533
|
+
}
|
|
1534
|
+
const ge = Ze("recipeBulkEditor", function() {
|
|
1535
|
+
const c = ee(), p = Le(), { t: r } = te(), t = O(!1), w = O(1), k = O(null), v = O(/* @__PURE__ */ new Set()), a = O([]), d = O({}), n = O(!1), f = O(/* @__PURE__ */ new Map()), h = O(""), b = O([]), $ = C(() => {
|
|
1536
|
+
let z = c.recipes;
|
|
1537
|
+
const K = k.value;
|
|
1538
|
+
if (K != null && K.nameSearch) {
|
|
1539
|
+
const G = K.nameSearch.trim().toLowerCase();
|
|
1540
|
+
G && (z = z.filter((q) => q.name.toLowerCase().includes(G)));
|
|
1541
|
+
}
|
|
1542
|
+
if (K != null && K.filters && K.filters.length > 0) {
|
|
1543
|
+
const G = /* @__PURE__ */ new Map();
|
|
1544
|
+
for (const q of z)
|
|
1545
|
+
G.set(
|
|
1546
|
+
q._id,
|
|
1547
|
+
we(q.contains, /* @__PURE__ */ new Set([q._id]), c.recipeById)
|
|
1548
|
+
);
|
|
1549
|
+
for (const q of K.filters)
|
|
1550
|
+
if (q.type === "ingredient") {
|
|
1551
|
+
const { itemId: ue, amount: X, measurementId: se } = q;
|
|
1552
|
+
z = z.filter((fe) => (G.get(fe._id) ?? []).some((oe) => {
|
|
1553
|
+
var ce;
|
|
1554
|
+
if (oe.type !== "SKU" || oe.id !== ue) return !1;
|
|
1555
|
+
if (oe.recipeIds.length === 1) {
|
|
1556
|
+
if (X != null) {
|
|
1557
|
+
const ke = oe.measurement ? Fe.multiplyDecimal(oe.amount, oe.measurement.conversion) : oe.amount;
|
|
1558
|
+
if (!Fe.equal(ke, X)) return !1;
|
|
1559
|
+
}
|
|
1560
|
+
if (se != null && (((ce = oe.measurement) == null ? void 0 : ce.id) ?? null) !== se)
|
|
1561
|
+
return !1;
|
|
1562
|
+
}
|
|
1563
|
+
return !0;
|
|
1564
|
+
}));
|
|
1565
|
+
} else if (q.type === "recipe") {
|
|
1566
|
+
const ue = q.itemId;
|
|
1567
|
+
z = z.filter(
|
|
1568
|
+
(X) => at(X.contains, ue, /* @__PURE__ */ new Set([X._id]), c.recipeById)
|
|
1569
|
+
);
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
return z;
|
|
1573
|
+
}), i = C(
|
|
1574
|
+
() => $.value.filter((z) => !v.value.has(z._id))
|
|
1575
|
+
), E = C(() => i.value.length > 0), S = C(() => {
|
|
1576
|
+
const z = a.value.filter(Ye);
|
|
1577
|
+
if (z.length === 0) {
|
|
1578
|
+
const G = {};
|
|
1579
|
+
for (const q of i.value)
|
|
1580
|
+
G[q._id] = {
|
|
1581
|
+
recipeId: q._id,
|
|
1582
|
+
recipeName: q.name,
|
|
1583
|
+
original: q,
|
|
1584
|
+
projected: null,
|
|
1585
|
+
status: "no-applicable-changes",
|
|
1586
|
+
changes: [],
|
|
1587
|
+
counts: { applied: 0, ignored: 0, blocked: 0, satisfied: 0 }
|
|
1588
|
+
};
|
|
1589
|
+
return G;
|
|
1590
|
+
}
|
|
1591
|
+
const K = {};
|
|
1592
|
+
for (const G of i.value) {
|
|
1593
|
+
const q = JSON.parse(JSON.stringify(G)), { projected: ue, results: X } = Lt(q, z), se = jt(X);
|
|
1594
|
+
let fe = 0, ve = 0, oe = 0, _e = 0;
|
|
1595
|
+
for (const ce of X)
|
|
1596
|
+
ce.outcome === "applied" ? fe++ : ce.outcome === "ignored" ? ve++ : ce.outcome === "blocked" ? oe++ : ce.outcome === "already-satisfied" && _e++;
|
|
1597
|
+
K[G._id] = {
|
|
1598
|
+
recipeId: G._id,
|
|
1599
|
+
recipeName: G.name,
|
|
1600
|
+
original: q,
|
|
1601
|
+
projected: se === "will-update" || se === "partially-ignored" ? ue : null,
|
|
1602
|
+
status: se,
|
|
1603
|
+
changes: X,
|
|
1604
|
+
counts: { applied: fe, ignored: ve, blocked: oe, satisfied: _e }
|
|
1605
|
+
};
|
|
1606
|
+
}
|
|
1607
|
+
return K;
|
|
1608
|
+
}), g = C(() => a.value.some(Ye) ? Object.values(S.value).some(
|
|
1609
|
+
(z) => z.status === "will-update" || z.status === "partially-ignored"
|
|
1610
|
+
) : !1);
|
|
1611
|
+
function o() {
|
|
1612
|
+
l(), t.value = !0;
|
|
1613
|
+
}
|
|
1614
|
+
function u() {
|
|
1615
|
+
t.value = !1;
|
|
1616
|
+
}
|
|
1617
|
+
function l() {
|
|
1618
|
+
w.value = 1, k.value = null, v.value = /* @__PURE__ */ new Set(), a.value = [], d.value = {}, n.value = !1, f.value = /* @__PURE__ */ new Map(), h.value = "", b.value = [];
|
|
1619
|
+
}
|
|
1620
|
+
function s(z) {
|
|
1621
|
+
k.value = z;
|
|
1622
|
+
}
|
|
1623
|
+
function A(z) {
|
|
1624
|
+
const K = new Set(v.value);
|
|
1625
|
+
K.add(z), v.value = K;
|
|
1626
|
+
}
|
|
1627
|
+
function D() {
|
|
1628
|
+
v.value = /* @__PURE__ */ new Set();
|
|
1629
|
+
}
|
|
1630
|
+
function F(z) {
|
|
1631
|
+
a.value = [...a.value, z];
|
|
1632
|
+
}
|
|
1633
|
+
function N(z, K) {
|
|
1634
|
+
const G = [...a.value];
|
|
1635
|
+
G[z] = K, a.value = G;
|
|
1636
|
+
}
|
|
1637
|
+
function L(z) {
|
|
1638
|
+
a.value = a.value.filter((K, G) => G !== z);
|
|
1639
|
+
}
|
|
1640
|
+
function B(z, K) {
|
|
1641
|
+
const G = [...a.value], [q] = G.splice(z, 1);
|
|
1642
|
+
G.splice(K, 0, q), a.value = G;
|
|
1643
|
+
}
|
|
1644
|
+
function P() {
|
|
1645
|
+
d.value = { ...S.value }, w.value = 3;
|
|
1646
|
+
}
|
|
1647
|
+
function H() {
|
|
1648
|
+
d.value = {}, w.value = 2;
|
|
1649
|
+
}
|
|
1650
|
+
function Q() {
|
|
1651
|
+
return Object.values(d.value).filter(
|
|
1652
|
+
(z) => (z.status === "will-update" || z.status === "partially-ignored") && z.projected != null
|
|
1653
|
+
).map((z) => z.projected);
|
|
1654
|
+
}
|
|
1655
|
+
async function re() {
|
|
1656
|
+
if (!n.value) {
|
|
1657
|
+
n.value = !0, f.value = /* @__PURE__ */ new Map();
|
|
1658
|
+
try {
|
|
1659
|
+
const z = Q(), K = await c.importRecipes({
|
|
1660
|
+
create: [],
|
|
1661
|
+
update: z
|
|
1662
|
+
}), G = (K == null ? void 0 : K.errors) ?? [];
|
|
1663
|
+
if (G.length > 0) {
|
|
1664
|
+
const q = /* @__PURE__ */ new Map();
|
|
1665
|
+
for (const { data: ue, error: X } of G) {
|
|
1666
|
+
const se = typeof X == "string" ? X : (X == null ? void 0 : X.message) ?? r("inventory.recipe.bulkEditor.step3.unknownError");
|
|
1667
|
+
q.set(ue._id, se);
|
|
1668
|
+
}
|
|
1669
|
+
f.value = q, p.open({
|
|
1670
|
+
title: r("inventory.recipe.bulkEditor.step3.partialErrorTitle"),
|
|
1671
|
+
message: r("inventory.recipe.bulkEditor.step3.partialErrorMessage", {
|
|
1672
|
+
count: G.length
|
|
1673
|
+
}),
|
|
1674
|
+
type: "warning"
|
|
1675
|
+
});
|
|
1676
|
+
} else
|
|
1677
|
+
p.open({
|
|
1678
|
+
title: r("inventory.recipe.bulkEditor.step3.successTitle"),
|
|
1679
|
+
message: r("inventory.recipe.bulkEditor.step3.successMessage", {
|
|
1680
|
+
count: z.length
|
|
1681
|
+
}),
|
|
1682
|
+
type: "success"
|
|
1683
|
+
}), t.value = !1, l();
|
|
1684
|
+
} catch (z) {
|
|
1685
|
+
p.open({
|
|
1686
|
+
title: r("inventory.recipe.bulkEditor.step3.errorTitle"),
|
|
1687
|
+
message: r("inventory.recipe.bulkEditor.step3.errorMessage"),
|
|
1688
|
+
type: "error"
|
|
1689
|
+
}), console.error("confirmAndApply failed", z);
|
|
1690
|
+
} finally {
|
|
1691
|
+
n.value = !1;
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
return {
|
|
1696
|
+
// state
|
|
1697
|
+
show: t,
|
|
1698
|
+
currentStep: w,
|
|
1699
|
+
query: k,
|
|
1700
|
+
excludedRecipeIds: v,
|
|
1701
|
+
modifications: a,
|
|
1702
|
+
entries: d,
|
|
1703
|
+
isSaving: n,
|
|
1704
|
+
applyErrors: f,
|
|
1705
|
+
nameSearch: h,
|
|
1706
|
+
filterRows: b,
|
|
1707
|
+
// computed
|
|
1708
|
+
matchedRecipes: $,
|
|
1709
|
+
selectedRecipes: i,
|
|
1710
|
+
livePreviewEntries: S,
|
|
1711
|
+
canGoToStep2: E,
|
|
1712
|
+
canGoToStep3: g,
|
|
1713
|
+
// actions
|
|
1714
|
+
openDialog: o,
|
|
1715
|
+
closeDialog: u,
|
|
1716
|
+
reset: l,
|
|
1717
|
+
updateQuery: s,
|
|
1718
|
+
removeRecipe: A,
|
|
1719
|
+
restoreAllRecipes: D,
|
|
1720
|
+
addModification: F,
|
|
1721
|
+
updateModification: N,
|
|
1722
|
+
removeModification: L,
|
|
1723
|
+
reorderModification: B,
|
|
1724
|
+
goToStep3: P,
|
|
1725
|
+
backToStep2: H,
|
|
1726
|
+
buildPayload: Q,
|
|
1727
|
+
confirmAndApply: re
|
|
1728
|
+
};
|
|
1729
|
+
}), oo = { class: "flex flex-col h-full" }, lo = { class: "px-16 pt-16 pb-8 shrink-0 flex items-center justify-between" }, io = { class: "fm-typo-en-heading-sm-700 text-fm-color-typo-primary" }, ao = { class: "px-16 pt-12 pb-16 border-b border-fm-color-border-default bg-fm-color-surface-default flex flex-col gap-12 shrink-0" }, ro = {
|
|
1730
|
+
key: 0,
|
|
1731
|
+
class: "flex flex-wrap items-center gap-8"
|
|
1732
|
+
}, so = {
|
|
1733
|
+
type: "button",
|
|
1734
|
+
class: "inline-flex items-center gap-4 h-[30px] pl-8 pr-6 rounded-l-md border border-r-0 border-fm-color-border-default bg-fm-color-surface-secondary hover:bg-fm-color-surface-hover cursor-pointer select-none transition-colors"
|
|
1735
|
+
}, uo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-primary" }, co = { class: "flex flex-col gap-8 p-12 min-w-[260px]" }, po = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary" }, mo = {
|
|
1736
|
+
key: 0,
|
|
1737
|
+
class: "flex flex-col gap-4"
|
|
1738
|
+
}, fo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, vo = { class: "text-fm-color-typo-placeholder ml-4" }, yo = ["title", "onClick"], bo = { class: "flex-1 overflow-y-auto" }, go = {
|
|
1739
|
+
key: 0,
|
|
1740
|
+
class: "flex flex-col items-center justify-center h-full gap-8 px-24 text-center"
|
|
1741
|
+
}, _o = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ko = {
|
|
1742
|
+
key: 1,
|
|
1743
|
+
class: "divide-y divide-fm-color-border-default"
|
|
1744
|
+
}, ho = { class: "flex-1 min-w-0" }, xo = { class: "fm-typo-en-body-md-600 text-fm-color-typo-primary truncate" }, wo = {
|
|
1745
|
+
key: 0,
|
|
1746
|
+
class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary mt-1 whitespace-normal break-words"
|
|
1747
|
+
}, Eo = { class: "flex items-center gap-4 mt-2" }, $o = /* @__PURE__ */ ne({
|
|
1748
|
+
__name: "RecipeBulkEditorStep1",
|
|
1749
|
+
setup(V) {
|
|
1750
|
+
const { t: c } = te(), p = ee(), r = ge(), t = C({
|
|
1751
|
+
get: () => r.nameSearch,
|
|
1752
|
+
set: (g) => {
|
|
1753
|
+
r.nameSearch = g;
|
|
1754
|
+
}
|
|
1755
|
+
}), w = C(() => r.filterRows), k = O({});
|
|
1756
|
+
function v(g) {
|
|
1757
|
+
return k.value[g] ?? !1;
|
|
1758
|
+
}
|
|
1759
|
+
function a(g, o) {
|
|
1760
|
+
k.value = { ...k.value, [g]: o };
|
|
1761
|
+
}
|
|
1762
|
+
const d = C(
|
|
1763
|
+
() => p.skus.map((g) => ({
|
|
1764
|
+
label: g.name,
|
|
1765
|
+
sublabel: g.code,
|
|
1766
|
+
value: g._id
|
|
1767
|
+
}))
|
|
1768
|
+
), n = C(
|
|
1769
|
+
() => p.recipes.map((g) => ({
|
|
1770
|
+
label: g.name,
|
|
1771
|
+
value: g._id
|
|
1772
|
+
}))
|
|
1773
|
+
);
|
|
1774
|
+
function f(g) {
|
|
1775
|
+
return g.type !== "ingredient" || !g.itemId ? null : p.skuById[g.itemId] ?? null;
|
|
1776
|
+
}
|
|
1777
|
+
function h(g) {
|
|
1778
|
+
var o;
|
|
1779
|
+
if (!g.type) return c("inventory.recipe.bulkEditor.step1.filter");
|
|
1780
|
+
if (g.type === "ingredient") {
|
|
1781
|
+
if (!g.itemId) return c("inventory.recipe.bulkEditor.step1.filterTypeIngredient");
|
|
1782
|
+
const u = p.skuById[g.itemId];
|
|
1783
|
+
if (!u) return c("inventory.recipe.bulkEditor.step1.filterTypeIngredient");
|
|
1784
|
+
const { amount: l, measurement: s } = g.amountModel;
|
|
1785
|
+
if (!(l != null && l.amount > 0)) return u.name;
|
|
1786
|
+
const D = (s == null ? void 0 : s.abbrev) ?? ((o = u.unit) == null ? void 0 : o.abbrev) ?? "", F = ie(l);
|
|
1787
|
+
return `${u.name} (${F}${D})`;
|
|
1788
|
+
}
|
|
1789
|
+
if (g.type === "recipe") {
|
|
1790
|
+
if (!g.itemId) return c("inventory.recipe.bulkEditor.step1.filterTypeRecipe");
|
|
1791
|
+
const u = p.recipeById[g.itemId];
|
|
1792
|
+
return u ? u.name : c("inventory.recipe.bulkEditor.step1.filterTypeRecipe");
|
|
1793
|
+
}
|
|
1794
|
+
return "";
|
|
1795
|
+
}
|
|
1796
|
+
function b(g) {
|
|
1797
|
+
const o = no(g);
|
|
1798
|
+
r.filterRows.push(o), a(o.id, !0);
|
|
1799
|
+
}
|
|
1800
|
+
function $(g) {
|
|
1801
|
+
r.filterRows = r.filterRows.filter((u) => u.id !== g);
|
|
1802
|
+
const o = { ...k.value };
|
|
1803
|
+
delete o[g], k.value = o;
|
|
1804
|
+
}
|
|
1805
|
+
function i(g) {
|
|
1806
|
+
g.amountModel = be(), a(g.id, !0);
|
|
1807
|
+
}
|
|
1808
|
+
de(
|
|
1809
|
+
[t, w],
|
|
1810
|
+
() => {
|
|
1811
|
+
const g = [];
|
|
1812
|
+
for (const l of w.value)
|
|
1813
|
+
if (!(!l.type || !l.itemId))
|
|
1814
|
+
if (l.type === "ingredient") {
|
|
1815
|
+
const s = f(l), { amount: A, measurement: D } = l.amountModel, F = A != null && A.amount > 0;
|
|
1816
|
+
let N, L;
|
|
1817
|
+
s && F && (N = D ? Fe.multiplyDecimal(A, D.conversion) : A, L = (D == null ? void 0 : D.id) ?? null), g.push({
|
|
1818
|
+
id: l.id,
|
|
1819
|
+
type: "ingredient",
|
|
1820
|
+
itemId: l.itemId,
|
|
1821
|
+
amount: N ?? null,
|
|
1822
|
+
measurementId: L
|
|
1823
|
+
});
|
|
1824
|
+
} else l.type === "recipe" && g.push({
|
|
1825
|
+
id: l.id,
|
|
1826
|
+
type: "recipe",
|
|
1827
|
+
itemId: l.itemId
|
|
1828
|
+
});
|
|
1829
|
+
r.updateQuery({
|
|
1830
|
+
nameSearch: t.value,
|
|
1831
|
+
filters: g
|
|
1832
|
+
});
|
|
1833
|
+
const o = t.value.trim().length > 0, u = g.length > 0;
|
|
1834
|
+
!o && !u && r.restoreAllRecipes();
|
|
1835
|
+
},
|
|
1836
|
+
{ deep: !0, immediate: !0 }
|
|
1837
|
+
);
|
|
1838
|
+
function E(g) {
|
|
1839
|
+
var s, A, D;
|
|
1840
|
+
const o = p.skuById[g.id];
|
|
1841
|
+
if (!o) return null;
|
|
1842
|
+
const u = ((s = g.measurement) == null ? void 0 : s.abbrev) ?? ((A = o.unit) == null ? void 0 : A.abbrev) ?? "", l = `${ie(g.amount)}${u}`;
|
|
1843
|
+
return g.recipeIds.slice(1).length ? `(${((D = p.recipeById[g.recipeIds.at(-1) ?? ""]) == null ? void 0 : D.name) ?? ""}) ${o.name} (${l})` : `${o.name} (${l})`;
|
|
1844
|
+
}
|
|
1845
|
+
function S(g) {
|
|
1846
|
+
return we(g.contains, /* @__PURE__ */ new Set([g._id]), p.recipeById).map(E).filter((o) => o !== null).join(", ");
|
|
1847
|
+
}
|
|
1848
|
+
return (g, o) => {
|
|
1849
|
+
const u = M("FmButton"), l = M("FmSearch"), s = M("FmSelect"), A = M("FmPopover"), D = M("FmIcon"), F = M("FmMenuItem"), N = M("FmMenu"), L = M("FmChip");
|
|
1850
|
+
return m(), I("div", oo, [
|
|
1851
|
+
y("div", lo, [
|
|
1852
|
+
y("span", io, U(e(c)("inventory.recipe.bulkEditor.step1.selectedCount", {
|
|
1853
|
+
count: e(r).selectedRecipes.length
|
|
1854
|
+
})), 1),
|
|
1855
|
+
e(r).excludedRecipeIds.size > 0 ? (m(), W(u, {
|
|
1856
|
+
key: 0,
|
|
1857
|
+
label: e(c)("inventory.recipe.bulkEditor.step1.restoreAll"),
|
|
1858
|
+
variant: "tertiary",
|
|
1859
|
+
size: "md",
|
|
1860
|
+
onClick: o[0] || (o[0] = (B) => e(r).restoreAllRecipes())
|
|
1861
|
+
}, null, 8, ["label"])) : R("", !0)
|
|
1862
|
+
]),
|
|
1863
|
+
y("div", ao, [
|
|
1864
|
+
_(l, {
|
|
1865
|
+
modelValue: t.value,
|
|
1866
|
+
"onUpdate:modelValue": o[1] || (o[1] = (B) => t.value = B),
|
|
1867
|
+
placeholder: e(c)("inventory.recipe.bulkEditor.query.nameSearchPlaceholder")
|
|
1868
|
+
}, null, 8, ["modelValue", "placeholder"]),
|
|
1869
|
+
w.value.length > 0 ? (m(), I("div", ro, [
|
|
1870
|
+
(m(!0), I(J, null, me(w.value, (B) => (m(), I("div", {
|
|
1871
|
+
key: B.id,
|
|
1872
|
+
class: "flex items-center"
|
|
1873
|
+
}, [
|
|
1874
|
+
_(A, {
|
|
1875
|
+
"show-popover": v(B.id),
|
|
1876
|
+
"exclude-el-from-click-outside": ["fm-menu"],
|
|
1877
|
+
placement: "bottom-start",
|
|
1878
|
+
onPopoverChanged: (P) => a(B.id, P)
|
|
1879
|
+
}, {
|
|
1880
|
+
"popover-button": Y(() => [
|
|
1881
|
+
y("button", so, [
|
|
1882
|
+
y("span", uo, U(h(B)), 1)
|
|
1883
|
+
])
|
|
1884
|
+
]),
|
|
1885
|
+
default: Y(() => [
|
|
1886
|
+
y("div", co, [
|
|
1887
|
+
y("p", po, U(B.type === "ingredient" ? e(c)("inventory.recipe.bulkEditor.step1.filterTypeIngredient") : e(c)("inventory.recipe.bulkEditor.step1.filterTypeRecipe")), 1),
|
|
1888
|
+
B.type === "ingredient" ? (m(), I(J, { key: 0 }, [
|
|
1889
|
+
_(s, {
|
|
1890
|
+
modelValue: B.itemId,
|
|
1891
|
+
"onUpdate:modelValue": [(P) => B.itemId = P, (P) => i(B)],
|
|
1892
|
+
items: d.value,
|
|
1893
|
+
placeholder: e(c)("inventory.recipe.bulkEditor.step1.selectIngredient"),
|
|
1894
|
+
clearable: ""
|
|
1895
|
+
}, {
|
|
1896
|
+
"menu-wrapper": Y((P) => [
|
|
1897
|
+
_(Be, Ee({ ref_for: !0 }, P, {
|
|
1898
|
+
items: d.value,
|
|
1899
|
+
"model-value": B.itemId
|
|
1900
|
+
}), null, 16, ["items", "model-value"])
|
|
1901
|
+
]),
|
|
1902
|
+
_: 2
|
|
1903
|
+
}, 1032, ["modelValue", "onUpdate:modelValue", "items", "placeholder"]),
|
|
1904
|
+
f(B) ? (m(), I("div", mo, [
|
|
1905
|
+
y("span", fo, [
|
|
1906
|
+
ut(U(e(c)("inventory.recipe.bulkEditor.step1.amountLabel")) + " ", 1),
|
|
1907
|
+
y("span", vo, U(e(c)("inventory.recipe.bulkEditor.step1.amountOptional")), 1)
|
|
1908
|
+
]),
|
|
1909
|
+
_(Ce, {
|
|
1910
|
+
modelValue: B.amountModel,
|
|
1911
|
+
"onUpdate:modelValue": (P) => B.amountModel = P,
|
|
1912
|
+
unit: f(B).unit,
|
|
1913
|
+
placeholder: e(c)("inventory.recipe.bulkEditor.step1.amountPlaceholder"),
|
|
1914
|
+
"convert-amount-on-change-unit": ""
|
|
1915
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "unit", "placeholder"])
|
|
1916
|
+
])) : R("", !0)
|
|
1917
|
+
], 64)) : B.type === "recipe" ? (m(), W(s, {
|
|
1918
|
+
key: 1,
|
|
1919
|
+
modelValue: B.itemId,
|
|
1920
|
+
"onUpdate:modelValue": [(P) => B.itemId = P, (P) => i(B)],
|
|
1921
|
+
items: n.value,
|
|
1922
|
+
placeholder: e(c)("inventory.recipe.bulkEditor.step1.selectRecipe"),
|
|
1923
|
+
clearable: ""
|
|
1924
|
+
}, {
|
|
1925
|
+
"menu-wrapper": Y((P) => [
|
|
1926
|
+
_(Be, Ee({ ref_for: !0 }, P, {
|
|
1927
|
+
items: n.value,
|
|
1928
|
+
"model-value": B.itemId
|
|
1929
|
+
}), null, 16, ["items", "model-value"])
|
|
1930
|
+
]),
|
|
1931
|
+
_: 2
|
|
1932
|
+
}, 1032, ["modelValue", "onUpdate:modelValue", "items", "placeholder"])) : R("", !0)
|
|
1933
|
+
])
|
|
1934
|
+
]),
|
|
1935
|
+
_: 2
|
|
1936
|
+
}, 1032, ["show-popover", "onPopoverChanged"]),
|
|
1937
|
+
y("button", {
|
|
1938
|
+
type: "button",
|
|
1939
|
+
class: "inline-flex items-center justify-center h-[30px] w-[26px] rounded-r-md border border-l-0 border-fm-color-border-default bg-fm-color-surface-secondary hover:bg-fm-color-surface-hover text-fm-color-typo-secondary hover:text-fm-color-typo-primary cursor-pointer transition-colors",
|
|
1940
|
+
title: e(c)("inventory.recipe.bulkEditor.step1.removeFilter"),
|
|
1941
|
+
onClick: (P) => $(B.id)
|
|
1942
|
+
}, [
|
|
1943
|
+
_(D, {
|
|
1944
|
+
name: "close",
|
|
1945
|
+
size: "sm"
|
|
1946
|
+
})
|
|
1947
|
+
], 8, yo)
|
|
1948
|
+
]))), 128))
|
|
1949
|
+
])) : R("", !0),
|
|
1950
|
+
_(N, {
|
|
1951
|
+
"close-on-click": !0,
|
|
1952
|
+
placement: "bottom-start"
|
|
1953
|
+
}, {
|
|
1954
|
+
"menu-button": Y(() => [
|
|
1955
|
+
_(u, {
|
|
1956
|
+
label: e(c)("inventory.recipe.bulkEditor.step1.filter"),
|
|
1957
|
+
variant: "secondary",
|
|
1958
|
+
size: "md",
|
|
1959
|
+
"prepend-icon": "add",
|
|
1960
|
+
class: "self-start"
|
|
1961
|
+
}, null, 8, ["label"])
|
|
1962
|
+
]),
|
|
1963
|
+
default: Y(() => [
|
|
1964
|
+
_(F, {
|
|
1965
|
+
label: e(c)("inventory.recipe.bulkEditor.step1.filterTypeIngredient"),
|
|
1966
|
+
icon: "inventory_2",
|
|
1967
|
+
onClick: o[2] || (o[2] = (B) => b("ingredient"))
|
|
1968
|
+
}, null, 8, ["label"]),
|
|
1969
|
+
_(F, {
|
|
1970
|
+
label: e(c)("inventory.recipe.bulkEditor.step1.filterTypeRecipe"),
|
|
1971
|
+
icon: "restaurant_menu",
|
|
1972
|
+
onClick: o[3] || (o[3] = (B) => b("recipe"))
|
|
1973
|
+
}, null, 8, ["label"])
|
|
1974
|
+
]),
|
|
1975
|
+
_: 1
|
|
1976
|
+
})
|
|
1977
|
+
]),
|
|
1978
|
+
y("div", bo, [
|
|
1979
|
+
e(r).selectedRecipes.length === 0 ? (m(), I("div", go, [
|
|
1980
|
+
_(D, {
|
|
1981
|
+
name: "search_off",
|
|
1982
|
+
size: "lg",
|
|
1983
|
+
class: "text-fm-color-typo-placeholder"
|
|
1984
|
+
}),
|
|
1985
|
+
y("p", _o, U(e(c)("inventory.recipe.bulkEditor.query.noResults")), 1)
|
|
1986
|
+
])) : (m(), I("div", ko, [
|
|
1987
|
+
(m(!0), I(J, null, me(e(r).selectedRecipes, (B) => (m(), I("div", {
|
|
1988
|
+
key: B._id,
|
|
1989
|
+
class: "flex items-center gap-12 px-16 py-12 hover:bg-fm-color-surface-hover transition-colors"
|
|
1990
|
+
}, [
|
|
1991
|
+
y("div", ho, [
|
|
1992
|
+
y("div", xo, U(B.name), 1),
|
|
1993
|
+
B.contains.length > 0 ? (m(), I("div", wo, U(S(B)), 1)) : R("", !0),
|
|
1994
|
+
y("div", Eo, [
|
|
1995
|
+
B.version === "v2" ? (m(), W(L, {
|
|
1996
|
+
key: 0,
|
|
1997
|
+
size: "sm",
|
|
1998
|
+
label: "V2",
|
|
1999
|
+
variant: "info"
|
|
2000
|
+
})) : R("", !0)
|
|
2001
|
+
])
|
|
2002
|
+
]),
|
|
2003
|
+
_(u, {
|
|
2004
|
+
variant: "tertiary",
|
|
2005
|
+
icon: "do_not_disturb_on",
|
|
2006
|
+
title: e(c)("inventory.recipe.bulkEditor.step1.removeRecipeTooltip"),
|
|
2007
|
+
onClick: (P) => e(r).removeRecipe(B._id)
|
|
2008
|
+
}, null, 8, ["title", "onClick"])
|
|
2009
|
+
]))), 128))
|
|
2010
|
+
]))
|
|
2011
|
+
])
|
|
2012
|
+
]);
|
|
2013
|
+
};
|
|
2014
|
+
}
|
|
2015
|
+
}), Io = { class: "flex flex-col gap-0 rounded-lg border border-fm-color-border-default bg-fm-color-surface-default overflow-hidden" }, Vo = { class: "flex items-start gap-12 px-16 py-12" }, So = { class: "flex-1" }, Co = { class: "flex-1" }, Fo = {
|
|
2016
|
+
key: 0,
|
|
2017
|
+
class: "border-t border-fm-color-border-default px-16 py-10 flex items-center gap-10"
|
|
2018
|
+
}, Bo = {
|
|
2019
|
+
key: 1,
|
|
2020
|
+
class: "border-t border-fm-color-border-default px-16 py-10 flex items-start gap-8 bg-fm-color-surface-warning"
|
|
2021
|
+
}, Ro = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-warning" }, Ao = {
|
|
2022
|
+
key: 2,
|
|
2023
|
+
class: "border-t border-fm-color-border-default px-16 py-12 flex flex-col gap-12"
|
|
2024
|
+
}, To = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary -mb-4" }, Uo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Mo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Po = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-warning" }, Do = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary -mt-8" }, zo = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary -mb-4" }, No = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Lo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, jo = /* @__PURE__ */ ne({
|
|
2025
|
+
__name: "ModificationCard",
|
|
2026
|
+
props: {
|
|
2027
|
+
modelValue: {},
|
|
2028
|
+
livePreviewEntries: {}
|
|
2029
|
+
},
|
|
2030
|
+
emits: ["update:modelValue"],
|
|
2031
|
+
setup(V, { emit: c }) {
|
|
2032
|
+
const p = V, r = c, { t } = te(), w = ee(), k = je();
|
|
2033
|
+
function v(x) {
|
|
2034
|
+
const T = x.type === "replace-binding" ? x.from.type : x.type === "remove-binding" || x.type === "update-binding-rule" || x.type === "update-alternatives" ? x.target.type : x.type === "add-binding" ? x.binding.type : null;
|
|
2035
|
+
return T ? T === "RECIPE" ? "recipe" : "ingredient" : null;
|
|
2036
|
+
}
|
|
2037
|
+
function a(x) {
|
|
2038
|
+
return x.type === "update-alternatives" ? !0 : x.type === "add-binding" ? (x.binding.alternatives ?? []).length > 0 : x.type === "replace-binding" ? (x.to.alternatives ?? []).length > 0 : !1;
|
|
2039
|
+
}
|
|
2040
|
+
function d(x) {
|
|
2041
|
+
switch (x.type) {
|
|
2042
|
+
case "add-binding":
|
|
2043
|
+
return "link";
|
|
2044
|
+
case "replace-binding":
|
|
2045
|
+
return x.from.id === x.to.id ? "update" : null;
|
|
2046
|
+
case "remove-binding":
|
|
2047
|
+
return "remove";
|
|
2048
|
+
case "update-binding-rule":
|
|
2049
|
+
return null;
|
|
2050
|
+
case "update-alternatives":
|
|
2051
|
+
return "alts";
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
function n(x) {
|
|
2055
|
+
return x.type === "replace-binding" ? x.from.id || null : (x.type === "remove-binding" || x.type === "update-binding-rule" || x.type === "update-alternatives") && x.target.id || null;
|
|
2056
|
+
}
|
|
2057
|
+
function f(x) {
|
|
2058
|
+
return x.type === "add-binding" && x.binding.id || null;
|
|
2059
|
+
}
|
|
2060
|
+
function h(x) {
|
|
2061
|
+
const T = x.type === "replace-binding" ? x.to : x.type === "add-binding" ? x.binding : null;
|
|
2062
|
+
return T ? { amount: T.amount, measurement: T.measurement ?? null } : be();
|
|
2063
|
+
}
|
|
2064
|
+
function b(x) {
|
|
2065
|
+
return x.type === "replace-binding" ? x.to.rules ?? null : x.type === "add-binding" ? x.binding.rules ?? null : null;
|
|
2066
|
+
}
|
|
2067
|
+
function $(x) {
|
|
2068
|
+
return x.type === "update-alternatives" ? x.alternatives ?? [] : x.type === "add-binding" ? x.binding.alternatives ?? [] : [];
|
|
2069
|
+
}
|
|
2070
|
+
const i = O(v(p.modelValue)), E = O(d(p.modelValue)), S = O(a(p.modelValue)), g = O(n(p.modelValue)), o = O(f(p.modelValue)), u = O(h(p.modelValue)), l = O(b(p.modelValue)), s = O($(p.modelValue)), A = O(
|
|
2071
|
+
(() => {
|
|
2072
|
+
const x = h(p.modelValue);
|
|
2073
|
+
return x.amount ? ie(x.amount) : "";
|
|
2074
|
+
})()
|
|
2075
|
+
);
|
|
2076
|
+
let D = null;
|
|
2077
|
+
function F(x) {
|
|
2078
|
+
return x.trim() === "" ? "Required" : Se()(x);
|
|
2079
|
+
}
|
|
2080
|
+
const N = C(
|
|
2081
|
+
() => i.value === "recipe" && (E.value === "link" || E.value === "update") && F(A.value) !== !0
|
|
2082
|
+
);
|
|
2083
|
+
function L(x) {
|
|
2084
|
+
A.value = x, D && clearTimeout(D), D = setTimeout(() => {
|
|
2085
|
+
if (F(x) !== !0) return;
|
|
2086
|
+
const T = +x;
|
|
2087
|
+
u.value = {
|
|
2088
|
+
amount: Qe.fromNumber(T),
|
|
2089
|
+
measurement: null
|
|
2090
|
+
};
|
|
2091
|
+
}, 300);
|
|
2092
|
+
}
|
|
2093
|
+
de(i, () => {
|
|
2094
|
+
E.value = null, S.value = !1, g.value = null, o.value = null, u.value = be(), l.value = null, s.value = [], A.value = "";
|
|
2095
|
+
}), de(E, () => {
|
|
2096
|
+
g.value = null, o.value = null, u.value = be(), l.value = null, s.value = [], A.value = "";
|
|
2097
|
+
}), de(S, (x) => {
|
|
2098
|
+
x || (s.value = [], E.value === "alts" && (E.value = null));
|
|
2099
|
+
});
|
|
2100
|
+
const B = C(() => [
|
|
2101
|
+
{ label: t("inventory.recipe.bulkEditor.step2.fieldIngredient"), value: "ingredient" },
|
|
2102
|
+
{ label: t("inventory.recipe.bulkEditor.step2.fieldRecipe"), value: "recipe" }
|
|
2103
|
+
]), P = C(() => {
|
|
2104
|
+
const x = [
|
|
2105
|
+
{ label: t("inventory.recipe.bulkEditor.step2.actionLink"), value: "link" },
|
|
2106
|
+
{ label: t("inventory.recipe.bulkEditor.step2.actionUpdate"), value: "update" },
|
|
2107
|
+
{ label: t("inventory.recipe.bulkEditor.step2.actionRemove"), value: "remove" }
|
|
2108
|
+
];
|
|
2109
|
+
return i.value === "ingredient" && S.value && k.enableRecipeV2 && x.push({ label: t("inventory.recipe.bulkEditor.step2.actionAlts"), value: "alts" }), x;
|
|
2110
|
+
}), H = C(() => i.value !== null && E.value !== null), Q = C(
|
|
2111
|
+
() => E.value === "update" || E.value === "remove" || E.value === "alts"
|
|
2112
|
+
), re = C(
|
|
2113
|
+
() => E.value === "link"
|
|
2114
|
+
), z = C(
|
|
2115
|
+
() => E.value === "update" && g.value !== null
|
|
2116
|
+
), K = C(
|
|
2117
|
+
() => i.value === "ingredient" && S.value && k.enableRecipeV2
|
|
2118
|
+
), G = C(
|
|
2119
|
+
() => w.skus.map((x) => ({ label: x.name, sublabel: x.code, value: x._id }))
|
|
2120
|
+
), q = C(
|
|
2121
|
+
() => w.recipes.map((x) => ({ label: x.name, value: x._id }))
|
|
2122
|
+
), ue = C(() => i.value === "recipe" ? q.value : G.value), X = C(() => i.value === "recipe" ? q.value : G.value), se = C(() => i.value !== "ingredient" || !o.value ? null : w.skuById[o.value] ?? null), fe = C(() => i.value !== "ingredient" || !g.value ? null : w.skuById[g.value] ?? null), ve = C(() => {
|
|
2123
|
+
const x = g.value ?? o.value;
|
|
2124
|
+
return x ? [x] : [];
|
|
2125
|
+
}), oe = C(() => K.value ? Object.values(p.livePreviewEntries).filter(
|
|
2126
|
+
(x) => x.original.version !== "v2"
|
|
2127
|
+
).length : 0), _e = C(() => Object.values(p.livePreviewEntries).length);
|
|
2128
|
+
de(
|
|
2129
|
+
() => [E.value, g.value],
|
|
2130
|
+
([x, T], [Z, pe]) => {
|
|
2131
|
+
if (x !== "alts" || T === pe) return;
|
|
2132
|
+
if (!T) {
|
|
2133
|
+
s.value = [];
|
|
2134
|
+
return;
|
|
2135
|
+
}
|
|
2136
|
+
const he = Object.values(p.livePreviewEntries).find(
|
|
2137
|
+
(j) => j.original.version === "v2" && j.original.contains.some((xe) => xe.type === "SKU" && xe.id === T)
|
|
2138
|
+
);
|
|
2139
|
+
if (he) {
|
|
2140
|
+
const j = he.original.contains.find((xe) => xe.type === "SKU" && xe.id === T);
|
|
2141
|
+
s.value = j != null && j.alternatives ? [...j.alternatives] : [];
|
|
2142
|
+
} else
|
|
2143
|
+
s.value = [];
|
|
2144
|
+
}
|
|
2145
|
+
);
|
|
2146
|
+
const ce = C(() => E.value !== "alts" || !g.value ? 0 : Object.values(p.livePreviewEntries).filter(
|
|
2147
|
+
(x) => x.original.version === "v2" && x.original.contains.some((T) => T.type === "SKU" && T.id === g.value)
|
|
2148
|
+
).length);
|
|
2149
|
+
function ke() {
|
|
2150
|
+
return i.value === "recipe" ? "RECIPE" : "SKU";
|
|
2151
|
+
}
|
|
2152
|
+
function Oe() {
|
|
2153
|
+
const x = ke(), T = be().amount, Z = {
|
|
2154
|
+
type: x,
|
|
2155
|
+
id: "",
|
|
2156
|
+
amount: T,
|
|
2157
|
+
measurement: null,
|
|
2158
|
+
rules: null,
|
|
2159
|
+
alternatives: []
|
|
2160
|
+
};
|
|
2161
|
+
switch (E.value) {
|
|
2162
|
+
case "update":
|
|
2163
|
+
return { type: "replace-binding", from: { type: x, id: "" }, to: Z };
|
|
2164
|
+
case "remove":
|
|
2165
|
+
return { type: "remove-binding", target: { type: x, id: "" } };
|
|
2166
|
+
case "alts":
|
|
2167
|
+
return { type: "update-alternatives", target: { type: x, id: "" }, alternatives: [] };
|
|
2168
|
+
case "link":
|
|
2169
|
+
default:
|
|
2170
|
+
return { type: "add-binding", binding: Z };
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
function rt() {
|
|
2174
|
+
return g.value ? { type: ke(), id: g.value } : null;
|
|
2175
|
+
}
|
|
2176
|
+
function Ke(x = !1) {
|
|
2177
|
+
const T = x ? g.value : o.value;
|
|
2178
|
+
if (!T) return null;
|
|
2179
|
+
const { amount: Z, measurement: pe } = u.value, $e = pe ? Fe.multiplyDecimal(Z, pe.conversion) : Z;
|
|
2180
|
+
return {
|
|
2181
|
+
type: ke(),
|
|
2182
|
+
id: T,
|
|
2183
|
+
amount: $e,
|
|
2184
|
+
measurement: pe ?? null,
|
|
2185
|
+
rules: i.value === "recipe" ? l.value ?? null : null,
|
|
2186
|
+
alternatives: K.value ? s.value : []
|
|
2187
|
+
};
|
|
2188
|
+
}
|
|
2189
|
+
function st() {
|
|
2190
|
+
if (!i.value) return;
|
|
2191
|
+
if (!E.value || N.value) {
|
|
2192
|
+
r("update:modelValue", Oe());
|
|
2193
|
+
return;
|
|
2194
|
+
}
|
|
2195
|
+
const x = rt(), T = Ke(!1);
|
|
2196
|
+
let Z = null;
|
|
2197
|
+
switch (E.value) {
|
|
2198
|
+
case "link":
|
|
2199
|
+
T && (Z = { type: "add-binding", binding: T });
|
|
2200
|
+
break;
|
|
2201
|
+
case "update": {
|
|
2202
|
+
const pe = Ke(!0);
|
|
2203
|
+
x && pe && (Z = { type: "replace-binding", from: x, to: pe });
|
|
2204
|
+
break;
|
|
2205
|
+
}
|
|
2206
|
+
case "remove":
|
|
2207
|
+
x && (Z = { type: "remove-binding", target: x });
|
|
2208
|
+
break;
|
|
2209
|
+
case "alts":
|
|
2210
|
+
x && (Z = { type: "update-alternatives", target: x, alternatives: s.value });
|
|
2211
|
+
break;
|
|
2212
|
+
}
|
|
2213
|
+
r("update:modelValue", Z ?? Oe());
|
|
2214
|
+
}
|
|
2215
|
+
return de(
|
|
2216
|
+
[i, E, S, g, o, u, l, s, N],
|
|
2217
|
+
() => st(),
|
|
2218
|
+
{ deep: !0 }
|
|
2219
|
+
), (x, T) => {
|
|
2220
|
+
const Z = M("FmSelect"), pe = M("FmSwitch"), $e = M("FmIcon"), he = M("FmTextField");
|
|
2221
|
+
return m(), I("div", Io, [
|
|
2222
|
+
y("div", Vo, [
|
|
2223
|
+
y("div", So, [
|
|
2224
|
+
_(Z, {
|
|
2225
|
+
modelValue: i.value,
|
|
2226
|
+
"onUpdate:modelValue": T[0] || (T[0] = (j) => i.value = j),
|
|
2227
|
+
items: B.value,
|
|
2228
|
+
label: e(t)("inventory.recipe.bulkEditor.step2.sectionField"),
|
|
2229
|
+
placeholder: e(t)("inventory.recipe.bulkEditor.step2.sectionField")
|
|
2230
|
+
}, null, 8, ["modelValue", "items", "label", "placeholder"])
|
|
2231
|
+
]),
|
|
2232
|
+
y("div", Co, [
|
|
2233
|
+
_(Z, {
|
|
2234
|
+
modelValue: E.value,
|
|
2235
|
+
"onUpdate:modelValue": T[1] || (T[1] = (j) => E.value = j),
|
|
2236
|
+
items: P.value,
|
|
2237
|
+
label: e(t)("inventory.recipe.bulkEditor.step2.sectionAction"),
|
|
2238
|
+
placeholder: e(t)("inventory.recipe.bulkEditor.step2.sectionAction")
|
|
2239
|
+
}, null, 8, ["modelValue", "items", "label", "placeholder"])
|
|
2240
|
+
])
|
|
2241
|
+
]),
|
|
2242
|
+
i.value === "ingredient" && e(k).enableRecipeV2 ? (m(), I("div", Fo, [
|
|
2243
|
+
_(pe, {
|
|
2244
|
+
modelValue: S.value,
|
|
2245
|
+
"onUpdate:modelValue": T[2] || (T[2] = (j) => S.value = j),
|
|
2246
|
+
label: e(t)("inventory.recipe.bulkEditor.step2.includeAlternativesToggle")
|
|
2247
|
+
}, null, 8, ["modelValue", "label"])
|
|
2248
|
+
])) : R("", !0),
|
|
2249
|
+
K.value && oe.value > 0 ? (m(), I("div", Bo, [
|
|
2250
|
+
_($e, {
|
|
2251
|
+
name: "warning",
|
|
2252
|
+
size: "sm",
|
|
2253
|
+
class: "text-fm-color-typo-warning mt-1 shrink-0"
|
|
2254
|
+
}),
|
|
2255
|
+
y("p", Ro, U(e(t)("inventory.recipe.bulkEditor.step2.v1AlternativesWarning", {
|
|
2256
|
+
v1Count: oe.value,
|
|
2257
|
+
total: _e.value
|
|
2258
|
+
})), 1)
|
|
2259
|
+
])) : R("", !0),
|
|
2260
|
+
H.value ? (m(), I("div", Ao, [
|
|
2261
|
+
Q.value ? (m(), I(J, { key: 0 }, [
|
|
2262
|
+
y("p", To, U(e(t)("inventory.recipe.bulkEditor.addModification.targetLabel")), 1),
|
|
2263
|
+
_(Z, {
|
|
2264
|
+
modelValue: g.value,
|
|
2265
|
+
"onUpdate:modelValue": T[3] || (T[3] = (j) => g.value = j),
|
|
2266
|
+
items: ue.value,
|
|
2267
|
+
placeholder: i.value === "recipe" ? e(t)("inventory.recipe.bulkEditor.addModification.recipePlaceholder") : e(t)("inventory.recipe.bulkEditor.addModification.skuPlaceholder"),
|
|
2268
|
+
clearable: ""
|
|
2269
|
+
}, {
|
|
2270
|
+
"menu-wrapper": Y((j) => [
|
|
2271
|
+
_(Be, Ee(j, {
|
|
2272
|
+
items: ue.value,
|
|
2273
|
+
"model-value": g.value
|
|
2274
|
+
}), null, 16, ["items", "model-value"])
|
|
2275
|
+
]),
|
|
2276
|
+
_: 1
|
|
2277
|
+
}, 8, ["modelValue", "items", "placeholder"]),
|
|
2278
|
+
z.value ? (m(), I(J, { key: 0 }, [
|
|
2279
|
+
i.value === "ingredient" && fe.value ? (m(), W(Ce, {
|
|
2280
|
+
key: 0,
|
|
2281
|
+
modelValue: u.value,
|
|
2282
|
+
"onUpdate:modelValue": T[4] || (T[4] = (j) => u.value = j),
|
|
2283
|
+
unit: fe.value.unit,
|
|
2284
|
+
placeholder: e(t)("inventory.recipe.bulkEditor.query.amountPlaceholder"),
|
|
2285
|
+
"convert-amount-on-change-unit": ""
|
|
2286
|
+
}, null, 8, ["modelValue", "unit", "placeholder"])) : i.value === "recipe" ? (m(), W(he, {
|
|
2287
|
+
key: 1,
|
|
2288
|
+
"model-value": A.value,
|
|
2289
|
+
label: e(t)("inventory.recipe.bulkEditor.addModification.amountLabel"),
|
|
2290
|
+
type: "number",
|
|
2291
|
+
rules: [F],
|
|
2292
|
+
"onUpdate:modelValue": T[5] || (T[5] = (j) => L(j))
|
|
2293
|
+
}, null, 8, ["model-value", "label", "rules"])) : R("", !0),
|
|
2294
|
+
i.value === "recipe" ? (m(), I(J, { key: 2 }, [
|
|
2295
|
+
y("p", Uo, U(e(t)("inventory.recipe.bulkEditor.addModification.optionalRuleLabel")), 1),
|
|
2296
|
+
_(Re, {
|
|
2297
|
+
modelValue: l.value,
|
|
2298
|
+
"onUpdate:modelValue": T[6] || (T[6] = (j) => l.value = j)
|
|
2299
|
+
}, null, 8, ["modelValue"])
|
|
2300
|
+
], 64)) : R("", !0),
|
|
2301
|
+
K.value ? (m(), I(J, { key: 3 }, [
|
|
2302
|
+
y("p", Mo, U(e(t)("inventory.recipe.bulkEditor.addModification.optionalAlternativesLabel")), 1),
|
|
2303
|
+
_(Ve, {
|
|
2304
|
+
modelValue: s.value,
|
|
2305
|
+
"onUpdate:modelValue": T[7] || (T[7] = (j) => s.value = j),
|
|
2306
|
+
"filter-ingredient-ids": ve.value
|
|
2307
|
+
}, null, 8, ["modelValue", "filter-ingredient-ids"])
|
|
2308
|
+
], 64)) : R("", !0)
|
|
2309
|
+
], 64)) : R("", !0),
|
|
2310
|
+
E.value === "alts" && g.value ? (m(), I(J, { key: 1 }, [
|
|
2311
|
+
y("p", Po, U(ce.value > 0 ? e(t)("inventory.recipe.bulkEditor.addModification.altsOverwriteWarning", { count: ce.value }) : e(t)("inventory.recipe.bulkEditor.addModification.altsNotFoundWarning")), 1),
|
|
2312
|
+
y("p", Do, U(e(t)("inventory.recipe.bulkEditor.addModification.altsClearNote")), 1),
|
|
2313
|
+
_(Ve, {
|
|
2314
|
+
modelValue: s.value,
|
|
2315
|
+
"onUpdate:modelValue": T[8] || (T[8] = (j) => s.value = j),
|
|
2316
|
+
"filter-ingredient-ids": ve.value
|
|
2317
|
+
}, null, 8, ["modelValue", "filter-ingredient-ids"])
|
|
2318
|
+
], 64)) : R("", !0)
|
|
2319
|
+
], 64)) : R("", !0),
|
|
2320
|
+
re.value ? (m(), I(J, { key: 1 }, [
|
|
2321
|
+
y("p", zo, U(e(t)("inventory.recipe.bulkEditor.addModification.bindingLabel")), 1),
|
|
2322
|
+
_(Z, {
|
|
2323
|
+
modelValue: o.value,
|
|
2324
|
+
"onUpdate:modelValue": T[9] || (T[9] = (j) => o.value = j),
|
|
2325
|
+
items: X.value,
|
|
2326
|
+
placeholder: i.value === "recipe" ? e(t)("inventory.recipe.bulkEditor.addModification.recipePlaceholder") : e(t)("inventory.recipe.bulkEditor.addModification.skuPlaceholder"),
|
|
2327
|
+
clearable: ""
|
|
2328
|
+
}, {
|
|
2329
|
+
"menu-wrapper": Y((j) => [
|
|
2330
|
+
_(Be, Ee(j, {
|
|
2331
|
+
items: X.value,
|
|
2332
|
+
"model-value": o.value
|
|
2333
|
+
}), null, 16, ["items", "model-value"])
|
|
2334
|
+
]),
|
|
2335
|
+
_: 1
|
|
2336
|
+
}, 8, ["modelValue", "items", "placeholder"]),
|
|
2337
|
+
o.value ? (m(), I(J, { key: 0 }, [
|
|
2338
|
+
i.value === "ingredient" && se.value ? (m(), W(Ce, {
|
|
2339
|
+
key: 0,
|
|
2340
|
+
modelValue: u.value,
|
|
2341
|
+
"onUpdate:modelValue": T[10] || (T[10] = (j) => u.value = j),
|
|
2342
|
+
unit: se.value.unit,
|
|
2343
|
+
placeholder: e(t)("inventory.recipe.bulkEditor.query.amountPlaceholder"),
|
|
2344
|
+
"convert-amount-on-change-unit": ""
|
|
2345
|
+
}, null, 8, ["modelValue", "unit", "placeholder"])) : i.value === "recipe" ? (m(), W(he, {
|
|
2346
|
+
key: 1,
|
|
2347
|
+
"model-value": A.value,
|
|
2348
|
+
label: e(t)("inventory.recipe.bulkEditor.addModification.amountLabel"),
|
|
2349
|
+
type: "number",
|
|
2350
|
+
rules: [F],
|
|
2351
|
+
"onUpdate:modelValue": T[11] || (T[11] = (j) => L(j))
|
|
2352
|
+
}, null, 8, ["model-value", "label", "rules"])) : R("", !0),
|
|
2353
|
+
i.value === "recipe" ? (m(), I(J, { key: 2 }, [
|
|
2354
|
+
y("p", No, U(e(t)("inventory.recipe.bulkEditor.addModification.optionalRuleLabel")), 1),
|
|
2355
|
+
_(Re, {
|
|
2356
|
+
modelValue: l.value,
|
|
2357
|
+
"onUpdate:modelValue": T[12] || (T[12] = (j) => l.value = j)
|
|
2358
|
+
}, null, 8, ["modelValue"])
|
|
2359
|
+
], 64)) : R("", !0),
|
|
2360
|
+
K.value ? (m(), I(J, { key: 3 }, [
|
|
2361
|
+
y("p", Lo, U(e(t)("inventory.recipe.bulkEditor.addModification.optionalAlternativesLabel")), 1),
|
|
2362
|
+
_(Ve, {
|
|
2363
|
+
modelValue: s.value,
|
|
2364
|
+
"onUpdate:modelValue": T[13] || (T[13] = (j) => s.value = j),
|
|
2365
|
+
"filter-ingredient-ids": ve.value
|
|
2366
|
+
}, null, 8, ["modelValue", "filter-ingredient-ids"])
|
|
2367
|
+
], 64)) : R("", !0)
|
|
2368
|
+
], 64)) : R("", !0)
|
|
2369
|
+
], 64)) : R("", !0)
|
|
2370
|
+
])) : R("", !0)
|
|
2371
|
+
]);
|
|
2372
|
+
};
|
|
2373
|
+
}
|
|
2374
|
+
}), Oo = { class: "flex flex-col gap-8" }, Ko = { class: "flex flex-wrap items-center gap-12 px-4" }, Go = {
|
|
2375
|
+
key: 0,
|
|
2376
|
+
class: "flex items-center gap-6"
|
|
2377
|
+
}, qo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Wo = {
|
|
2378
|
+
key: 1,
|
|
2379
|
+
class: "flex items-center gap-6"
|
|
2380
|
+
}, Yo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Ho = {
|
|
2381
|
+
key: 2,
|
|
2382
|
+
class: "flex items-center gap-6"
|
|
2383
|
+
}, Jo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Qo = { class: "rounded-lg border border-fm-color-border-default overflow-hidden" }, Xo = {
|
|
2384
|
+
key: 0,
|
|
2385
|
+
class: "px-16 py-12 text-center fm-typo-en-body-sm-400 text-fm-color-typo-placeholder"
|
|
2386
|
+
}, Zo = {
|
|
2387
|
+
key: 1,
|
|
2388
|
+
class: "divide-y divide-fm-color-border-default"
|
|
2389
|
+
}, el = { class: "flex items-center gap-12" }, tl = { class: "flex-1 fm-typo-en-body-sm-600 text-fm-color-typo-primary truncate" }, nl = {
|
|
2390
|
+
key: 0,
|
|
2391
|
+
class: "flex flex-col gap-4 pl-8"
|
|
2392
|
+
}, ol = { class: "flex-1 fm-typo-en-body-xs-400 text-fm-color-typo-secondary font-mono truncate" }, ll = /* @__PURE__ */ ne({
|
|
2393
|
+
__name: "LivePreviewTable",
|
|
2394
|
+
setup(V) {
|
|
2395
|
+
const { t: c } = te(), p = ge(), r = ee(), t = {
|
|
2396
|
+
"will-update": 0,
|
|
2397
|
+
"partially-ignored": 1,
|
|
2398
|
+
"already-satisfied": 2,
|
|
2399
|
+
blocked: 3,
|
|
2400
|
+
"no-applicable-changes": 4
|
|
2401
|
+
}, w = C(
|
|
2402
|
+
() => Object.values(p.livePreviewEntries).sort(
|
|
2403
|
+
(o, u) => t[o.status] - t[u.status]
|
|
2404
|
+
)
|
|
2405
|
+
), k = C(
|
|
2406
|
+
() => w.value.filter((o) => o.status === "will-update").length
|
|
2407
|
+
), v = C(
|
|
2408
|
+
() => w.value.filter((o) => o.status === "partially-ignored").length
|
|
2409
|
+
), a = C(
|
|
2410
|
+
() => w.value.filter((o) => o.status === "already-satisfied").length
|
|
2411
|
+
), d = C(
|
|
2412
|
+
() => w.value.filter((o) => o.status === "blocked").length
|
|
2413
|
+
);
|
|
2414
|
+
function n(o) {
|
|
2415
|
+
switch (o) {
|
|
2416
|
+
case "will-update":
|
|
2417
|
+
return c("inventory.recipe.bulkEditor.status.willUpdate");
|
|
2418
|
+
case "already-satisfied":
|
|
2419
|
+
return c("inventory.recipe.bulkEditor.status.alreadySatisfied");
|
|
2420
|
+
case "partially-ignored":
|
|
2421
|
+
return c("inventory.recipe.bulkEditor.status.partiallyIgnored");
|
|
2422
|
+
case "blocked":
|
|
2423
|
+
return c("inventory.recipe.bulkEditor.status.blocked");
|
|
2424
|
+
case "no-applicable-changes":
|
|
2425
|
+
return c("inventory.recipe.bulkEditor.status.noApplicableChanges");
|
|
2426
|
+
default:
|
|
2427
|
+
return "";
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
function f(o) {
|
|
2431
|
+
switch (o) {
|
|
2432
|
+
case "will-update":
|
|
2433
|
+
return "success";
|
|
2434
|
+
case "already-satisfied":
|
|
2435
|
+
return "info";
|
|
2436
|
+
case "partially-ignored":
|
|
2437
|
+
return "warning";
|
|
2438
|
+
case "blocked":
|
|
2439
|
+
return "critical";
|
|
2440
|
+
case "no-applicable-changes":
|
|
2441
|
+
return "neutral";
|
|
2442
|
+
default:
|
|
2443
|
+
return "neutral";
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
function h(o, u) {
|
|
2447
|
+
var l, s;
|
|
2448
|
+
return o === "SKU" ? ((l = r.skuById[u]) == null ? void 0 : l.name) ?? u : o === "RECIPE" ? ((s = r.recipeById[u]) == null ? void 0 : s.name) ?? u : u;
|
|
2449
|
+
}
|
|
2450
|
+
function b(o) {
|
|
2451
|
+
var l, s;
|
|
2452
|
+
const u = h(o.type, o.id);
|
|
2453
|
+
if (o.type === "SKU") {
|
|
2454
|
+
const A = r.skuById[o.id], D = ((l = o.measurement) == null ? void 0 : l.abbrev) ?? ((s = A == null ? void 0 : A.unit) == null ? void 0 : s.abbrev) ?? "";
|
|
2455
|
+
return `${u} (${ie(o.amount)} ${D})`.trim();
|
|
2456
|
+
}
|
|
2457
|
+
return o.type === "RECIPE" ? `${u} ×${ie(o.amount)}` : u;
|
|
2458
|
+
}
|
|
2459
|
+
function $(o) {
|
|
2460
|
+
return h(o.type, o.id);
|
|
2461
|
+
}
|
|
2462
|
+
function i(o, u) {
|
|
2463
|
+
const l = u.contains.find((s) => s.type === o.type && s.id === o.id);
|
|
2464
|
+
return l ? b(l) : $(o);
|
|
2465
|
+
}
|
|
2466
|
+
function E(o, u) {
|
|
2467
|
+
switch (o.type) {
|
|
2468
|
+
case "add-binding":
|
|
2469
|
+
return `+ ${b(o.binding)}`;
|
|
2470
|
+
case "remove-binding":
|
|
2471
|
+
return `− ${$(o.target)}`;
|
|
2472
|
+
case "replace-binding":
|
|
2473
|
+
return `${i(o.from, u)} → ${b(o.to)}`;
|
|
2474
|
+
case "update-binding-rule":
|
|
2475
|
+
return `Rule: ${$(o.target)}`;
|
|
2476
|
+
case "update-alternatives":
|
|
2477
|
+
return `Alternatives: ${$(o.target)}`;
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
function S(o) {
|
|
2481
|
+
switch (o) {
|
|
2482
|
+
case "applied":
|
|
2483
|
+
return "success";
|
|
2484
|
+
case "already-satisfied":
|
|
2485
|
+
return "info";
|
|
2486
|
+
case "ignored":
|
|
2487
|
+
return "neutral";
|
|
2488
|
+
case "blocked":
|
|
2489
|
+
return "critical";
|
|
2490
|
+
default:
|
|
2491
|
+
return "neutral";
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
function g(o) {
|
|
2495
|
+
switch (o) {
|
|
2496
|
+
case "applied":
|
|
2497
|
+
return c("inventory.recipe.bulkEditor.livePreview.outcomeApplied");
|
|
2498
|
+
case "already-satisfied":
|
|
2499
|
+
return c("inventory.recipe.bulkEditor.livePreview.outcomeAlreadySatisfied");
|
|
2500
|
+
case "ignored":
|
|
2501
|
+
return c("inventory.recipe.bulkEditor.livePreview.outcomeIgnored");
|
|
2502
|
+
case "blocked":
|
|
2503
|
+
return c("inventory.recipe.bulkEditor.livePreview.outcomeBlocked");
|
|
2504
|
+
default:
|
|
2505
|
+
return o;
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
return (o, u) => {
|
|
2509
|
+
const l = M("FmChip");
|
|
2510
|
+
return m(), I("div", Oo, [
|
|
2511
|
+
y("div", Ko, [
|
|
2512
|
+
k.value + v.value > 0 ? (m(), I("div", Go, [
|
|
2513
|
+
_(l, {
|
|
2514
|
+
size: "sm",
|
|
2515
|
+
label: String(k.value + v.value),
|
|
2516
|
+
variant: "success"
|
|
2517
|
+
}, null, 8, ["label"]),
|
|
2518
|
+
y("span", qo, U(e(c)("inventory.recipe.bulkEditor.livePreview.willUpdate")), 1)
|
|
2519
|
+
])) : R("", !0),
|
|
2520
|
+
a.value > 0 ? (m(), I("div", Wo, [
|
|
2521
|
+
_(l, {
|
|
2522
|
+
size: "sm",
|
|
2523
|
+
label: String(a.value),
|
|
2524
|
+
variant: "info"
|
|
2525
|
+
}, null, 8, ["label"]),
|
|
2526
|
+
y("span", Yo, U(e(c)("inventory.recipe.bulkEditor.livePreview.alreadySatisfied")), 1)
|
|
2527
|
+
])) : R("", !0),
|
|
2528
|
+
d.value > 0 ? (m(), I("div", Ho, [
|
|
2529
|
+
_(l, {
|
|
2530
|
+
size: "sm",
|
|
2531
|
+
label: String(d.value),
|
|
2532
|
+
variant: "critical"
|
|
2533
|
+
}, null, 8, ["label"]),
|
|
2534
|
+
y("span", Jo, U(e(c)("inventory.recipe.bulkEditor.livePreview.blocked")), 1)
|
|
2535
|
+
])) : R("", !0)
|
|
2536
|
+
]),
|
|
2537
|
+
y("div", Qo, [
|
|
2538
|
+
w.value.length === 0 ? (m(), I("div", Xo, U(e(c)("inventory.recipe.bulkEditor.livePreview.noRecipes")), 1)) : (m(), I("div", Zo, [
|
|
2539
|
+
(m(!0), I(J, null, me(w.value, (s) => (m(), I("div", {
|
|
2540
|
+
key: s.recipeId,
|
|
2541
|
+
class: "flex flex-col gap-6 px-16 py-10"
|
|
2542
|
+
}, [
|
|
2543
|
+
y("div", el, [
|
|
2544
|
+
y("span", tl, U(s.recipeName), 1),
|
|
2545
|
+
_(l, {
|
|
2546
|
+
size: "sm",
|
|
2547
|
+
label: n(s.status),
|
|
2548
|
+
variant: f(s.status)
|
|
2549
|
+
}, null, 8, ["label", "variant"])
|
|
2550
|
+
]),
|
|
2551
|
+
s.changes.length > 0 ? (m(), I("div", nl, [
|
|
2552
|
+
(m(!0), I(J, null, me(s.changes, (A, D) => (m(), I("div", {
|
|
2553
|
+
key: D,
|
|
2554
|
+
class: "flex items-center gap-8"
|
|
2555
|
+
}, [
|
|
2556
|
+
y("span", ol, U(E(A.change, s.original)), 1),
|
|
2557
|
+
_(l, {
|
|
2558
|
+
size: "sm",
|
|
2559
|
+
label: g(A.outcome),
|
|
2560
|
+
variant: S(A.outcome)
|
|
2561
|
+
}, null, 8, ["label", "variant"])
|
|
2562
|
+
]))), 128))
|
|
2563
|
+
])) : R("", !0)
|
|
2564
|
+
]))), 128))
|
|
2565
|
+
]))
|
|
2566
|
+
])
|
|
2567
|
+
]);
|
|
2568
|
+
};
|
|
2569
|
+
}
|
|
2570
|
+
}), il = { class: "flex flex-col h-full overflow-hidden" }, al = { class: "flex flex-col min-h-0 shrink-0" }, rl = { class: "flex items-center gap-8 px-16 pt-12 border-b border-fm-color-border-default" }, sl = { class: "flex-1 overflow-x-auto min-w-0" }, dl = {
|
|
2571
|
+
class: "px-16 py-14 overflow-y-auto",
|
|
2572
|
+
style: { "max-height": "45vh" }
|
|
2573
|
+
}, ul = {
|
|
2574
|
+
key: 0,
|
|
2575
|
+
class: "flex flex-col items-center justify-center py-40 gap-8 text-center rounded-lg border border-dashed border-fm-color-border-default"
|
|
2576
|
+
}, cl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, pl = { class: "flex-1 overflow-y-auto px-16 py-14 flex flex-col gap-12 min-h-0" }, ml = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary shrink-0" }, fl = /* @__PURE__ */ ne({
|
|
2577
|
+
__name: "RecipeBulkEditorStep2",
|
|
2578
|
+
setup(V) {
|
|
2579
|
+
const { t: c } = te(), p = ge(), r = O(null);
|
|
2580
|
+
de(
|
|
2581
|
+
() => p.modifications.length,
|
|
2582
|
+
(a) => {
|
|
2583
|
+
a === 0 ? r.value = null : (r.value === null || r.value >= a) && (r.value = a - 1);
|
|
2584
|
+
},
|
|
2585
|
+
{ immediate: !0 }
|
|
2586
|
+
);
|
|
2587
|
+
function t(a, d) {
|
|
2588
|
+
const n = a.type === "replace-binding" ? a.from.type : a.type === "remove-binding" || a.type === "update-binding-rule" || a.type === "update-alternatives" ? a.target.type : a.type === "add-binding" ? a.binding.type : null;
|
|
2589
|
+
return n === "RECIPE" ? c("inventory.recipe.bulkEditor.step2.fieldRecipe") : n === "SKU" ? c("inventory.recipe.bulkEditor.step2.fieldIngredient") : c("inventory.recipe.bulkEditor.step2.tabLabel", { n: d + 1 });
|
|
2590
|
+
}
|
|
2591
|
+
const w = C(
|
|
2592
|
+
() => p.modifications.map((a, d) => ({
|
|
2593
|
+
label: t(a, d),
|
|
2594
|
+
value: d
|
|
2595
|
+
}))
|
|
2596
|
+
);
|
|
2597
|
+
function k() {
|
|
2598
|
+
const d = {
|
|
2599
|
+
type: "add-binding",
|
|
2600
|
+
binding: {
|
|
2601
|
+
type: "SKU",
|
|
2602
|
+
id: "",
|
|
2603
|
+
amount: be().amount,
|
|
2604
|
+
measurement: null,
|
|
2605
|
+
rules: null,
|
|
2606
|
+
alternatives: []
|
|
2607
|
+
}
|
|
2608
|
+
};
|
|
2609
|
+
p.addModification(d), r.value = p.modifications.length - 1;
|
|
2610
|
+
}
|
|
2611
|
+
function v(a) {
|
|
2612
|
+
p.removeModification(a);
|
|
2613
|
+
}
|
|
2614
|
+
return (a, d) => {
|
|
2615
|
+
const n = M("FmButton"), f = M("FmTab"), h = M("FmTabs"), b = M("FmIcon");
|
|
2616
|
+
return m(), I("div", il, [
|
|
2617
|
+
y("div", al, [
|
|
2618
|
+
y("div", rl, [
|
|
2619
|
+
y("div", sl, [
|
|
2620
|
+
w.value.length > 0 ? (m(), W(h, {
|
|
2621
|
+
key: 0,
|
|
2622
|
+
"model-value": r.value,
|
|
2623
|
+
items: w.value,
|
|
2624
|
+
"onUpdate:modelValue": d[1] || (d[1] = ($) => r.value = $)
|
|
2625
|
+
}, {
|
|
2626
|
+
default: Y(($) => [
|
|
2627
|
+
_(f, Ee($, {
|
|
2628
|
+
"model-value": r.value,
|
|
2629
|
+
"onUpdate:modelValue": d[0] || (d[0] = (i) => r.value = i)
|
|
2630
|
+
}), {
|
|
2631
|
+
append: Y(() => [
|
|
2632
|
+
_(n, {
|
|
2633
|
+
variant: "tertiary",
|
|
2634
|
+
icon: "close",
|
|
2635
|
+
size: "md",
|
|
2636
|
+
onClick: ct((i) => v($.value), ["stop"])
|
|
2637
|
+
}, null, 8, ["onClick"])
|
|
2638
|
+
]),
|
|
2639
|
+
_: 2
|
|
2640
|
+
}, 1040, ["model-value"])
|
|
2641
|
+
]),
|
|
2642
|
+
_: 1
|
|
2643
|
+
}, 8, ["model-value", "items"])) : R("", !0)
|
|
2644
|
+
]),
|
|
2645
|
+
_(n, {
|
|
2646
|
+
label: e(c)("inventory.recipe.bulkEditor.step2.addModification"),
|
|
2647
|
+
variant: "secondary",
|
|
2648
|
+
size: "md",
|
|
2649
|
+
"prepend-icon": "add",
|
|
2650
|
+
class: "shrink-0",
|
|
2651
|
+
onClick: k
|
|
2652
|
+
}, null, 8, ["label"])
|
|
2653
|
+
]),
|
|
2654
|
+
y("div", dl, [
|
|
2655
|
+
e(p).modifications.length === 0 ? (m(), I("div", ul, [
|
|
2656
|
+
_(b, {
|
|
2657
|
+
name: "edit_note",
|
|
2658
|
+
size: "lg",
|
|
2659
|
+
class: "text-fm-color-typo-placeholder"
|
|
2660
|
+
}),
|
|
2661
|
+
y("p", cl, U(e(c)("inventory.recipe.bulkEditor.step2.emptyState")), 1)
|
|
2662
|
+
])) : r.value !== null && e(p).modifications[r.value] ? (m(), W(jo, {
|
|
2663
|
+
key: r.value,
|
|
2664
|
+
"model-value": e(p).modifications[r.value],
|
|
2665
|
+
"live-preview-entries": e(p).livePreviewEntries,
|
|
2666
|
+
"onUpdate:modelValue": d[2] || (d[2] = ($) => e(p).updateModification(r.value, $))
|
|
2667
|
+
}, null, 8, ["model-value", "live-preview-entries"])) : R("", !0)
|
|
2668
|
+
])
|
|
2669
|
+
]),
|
|
2670
|
+
d[3] || (d[3] = y("div", { class: "border-t border-fm-color-border-default shrink-0" }, null, -1)),
|
|
2671
|
+
y("div", pl, [
|
|
2672
|
+
y("span", ml, U(e(c)("inventory.recipe.bulkEditor.step2.livePreviewTitle")), 1),
|
|
2673
|
+
_(ll)
|
|
2674
|
+
])
|
|
2675
|
+
]);
|
|
2676
|
+
};
|
|
2677
|
+
}
|
|
2678
|
+
});
|
|
2679
|
+
function vl(V) {
|
|
2680
|
+
return !V || Object.keys(V).length === 0 ? "" : Object.entries(V).map(([c, p]) => `${c}: ${p}`).join(", ");
|
|
2681
|
+
}
|
|
2682
|
+
function yl() {
|
|
2683
|
+
const V = ee(), c = ge(), p = V.skuById, r = V.recipeById, w = Object.values(c.entries).filter(
|
|
2684
|
+
(a) => a.status === "will-update" || a.status === "partially-ignored"
|
|
2685
|
+
).flatMap((a, d) => {
|
|
2686
|
+
var h;
|
|
2687
|
+
const n = a.projected ?? a.original, f = vl(n.customAttributes);
|
|
2688
|
+
if ((h = n.contains) != null && h.length) {
|
|
2689
|
+
const b = n.contains.filter((i) => i.type === "RECIPE"), $ = n.contains.filter((i) => i.type === "SKU");
|
|
2690
|
+
return [
|
|
2691
|
+
...d === 0 ? [] : [["", "", "", "", "", "", ""]],
|
|
2692
|
+
...b.map(
|
|
2693
|
+
(i, E) => {
|
|
2694
|
+
var S;
|
|
2695
|
+
return [
|
|
2696
|
+
E === 0 ? n.name : "",
|
|
2697
|
+
"RECIPE",
|
|
2698
|
+
"",
|
|
2699
|
+
((S = r[i.id]) == null ? void 0 : S.name) ?? i.id,
|
|
2700
|
+
ie(i.amount),
|
|
2701
|
+
"UNIT",
|
|
2702
|
+
E === 0 ? f : ""
|
|
2703
|
+
];
|
|
2704
|
+
}
|
|
2705
|
+
),
|
|
2706
|
+
...$.map(
|
|
2707
|
+
(i, E) => {
|
|
2708
|
+
var S, g, o, u;
|
|
2709
|
+
return [
|
|
2710
|
+
!b.length && E === 0 ? n.name : "",
|
|
2711
|
+
"INGREDIENT",
|
|
2712
|
+
((S = p[i.id]) == null ? void 0 : S.code) ?? "",
|
|
2713
|
+
((g = p[i.id]) == null ? void 0 : g.name) ?? i.id,
|
|
2714
|
+
ie(i.amount),
|
|
2715
|
+
i.measurement ? i.measurement.abbrev : ((u = (o = p[i.id]) == null ? void 0 : o.unit) == null ? void 0 : u.abbrev) ?? "",
|
|
2716
|
+
!b.length && E === 0 ? f : ""
|
|
2717
|
+
];
|
|
2718
|
+
}
|
|
2719
|
+
)
|
|
2720
|
+
];
|
|
2721
|
+
}
|
|
2722
|
+
return [
|
|
2723
|
+
...d === 0 ? [] : [["", "", "", "", "", "", ""]],
|
|
2724
|
+
[n.name, "No bindings", "", "", "", "", f]
|
|
2725
|
+
];
|
|
2726
|
+
}), v = ot(w, ["Name", "Type", "Code", "Item", "Amount", "Unit", "Custom Attributes"]);
|
|
2727
|
+
lt(v, `RECIPE_BULK_EDIT_${it(/* @__PURE__ */ new Date(), "-", "-")}.xlsx`);
|
|
2728
|
+
}
|
|
2729
|
+
const bl = { class: "flex flex-col gap-16" }, gl = { class: "rounded-lg border border-fm-color-border-default bg-fm-color-surface-secondary p-16" }, _l = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary mb-8" }, kl = { class: "flex flex-wrap gap-12" }, hl = { class: "flex items-center gap-6" }, xl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, wl = {
|
|
2730
|
+
key: 0,
|
|
2731
|
+
class: "flex items-center gap-6"
|
|
2732
|
+
}, El = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, $l = {
|
|
2733
|
+
key: 1,
|
|
2734
|
+
class: "flex items-center gap-6"
|
|
2735
|
+
}, Il = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Vl = {
|
|
2736
|
+
key: 2,
|
|
2737
|
+
class: "flex items-center gap-6"
|
|
2738
|
+
}, Sl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Cl = {
|
|
2739
|
+
key: 3,
|
|
2740
|
+
class: "flex items-center gap-6"
|
|
2741
|
+
}, Fl = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Bl = { class: "mt-12" }, Rl = ["onClick"], Al = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary flex-1 truncate" }, Tl = {
|
|
2742
|
+
key: 0,
|
|
2743
|
+
class: "px-12 py-8 border-b border-fm-color-border-default"
|
|
2744
|
+
}, Ul = { class: "px-12 py-10 leading-relaxed" }, Ml = {
|
|
2745
|
+
key: 2,
|
|
2746
|
+
class: "fm-typo-en-body-sm-400 text-fm-color-typo-placeholder italic"
|
|
2747
|
+
}, Pl = { class: "flex items-center gap-12 px-12 py-8 border-t border-fm-color-border-default bg-fm-color-surface-secondary text-fm-color-typo-secondary fm-typo-en-body-xs-400" }, Dl = { key: 0 }, zl = { key: 1 }, Nl = {
|
|
2748
|
+
key: 2,
|
|
2749
|
+
class: "text-fm-color-warning"
|
|
2750
|
+
}, Ll = {
|
|
2751
|
+
key: 3,
|
|
2752
|
+
class: "text-fm-color-error"
|
|
2753
|
+
}, jl = {
|
|
2754
|
+
key: 4,
|
|
2755
|
+
class: "text-fm-color-typo-placeholder"
|
|
2756
|
+
}, Ol = /* @__PURE__ */ ne({
|
|
2757
|
+
__name: "RecipeBulkEditorSummaryStep",
|
|
2758
|
+
setup(V) {
|
|
2759
|
+
const { t: c } = te(), p = ee(), r = ge(), t = C(() => Object.values(r.entries)), w = C(
|
|
2760
|
+
() => t.value.filter((o) => o.status === "will-update").length
|
|
2761
|
+
), k = C(
|
|
2762
|
+
() => t.value.filter((o) => o.status === "partially-ignored").length
|
|
2763
|
+
), v = C(
|
|
2764
|
+
() => t.value.filter((o) => o.status === "already-satisfied").length
|
|
2765
|
+
), a = C(
|
|
2766
|
+
() => t.value.filter((o) => o.status === "blocked").length
|
|
2767
|
+
), d = C(
|
|
2768
|
+
() => t.value.filter((o) => o.status === "no-applicable-changes").length
|
|
2769
|
+
), n = O(/* @__PURE__ */ new Set());
|
|
2770
|
+
function f(o) {
|
|
2771
|
+
return n.value.has(o);
|
|
2772
|
+
}
|
|
2773
|
+
function h(o) {
|
|
2774
|
+
const u = new Set(n.value);
|
|
2775
|
+
u.has(o) ? u.delete(o) : u.add(o), n.value = u;
|
|
2776
|
+
}
|
|
2777
|
+
function b(o) {
|
|
2778
|
+
var s, A, D;
|
|
2779
|
+
const u = [], l = we(o.contains, /* @__PURE__ */ new Set([o._id]), p.recipeById);
|
|
2780
|
+
for (let F = 0; F < l.length; F++) {
|
|
2781
|
+
const N = l[F], L = N.recipeIds.slice(1).length > 0, B = L ? ((s = p.recipeById[N.recipeIds.at(-1) ?? ""]) == null ? void 0 : s.name) ?? "" : "", P = p.skuById[N.id];
|
|
2782
|
+
if (!P) continue;
|
|
2783
|
+
const H = ((A = N.measurement) == null ? void 0 : A.abbrev) ?? ((D = P.unit) == null ? void 0 : D.abbrev) ?? "", Q = `${ie(N.amount)}${H}`, re = L ? `(${B}) ${P.name} (${Q})` : `${P.name} (${Q})`;
|
|
2784
|
+
F > 0 && u.push({ text: ", " }), u.push({ text: re });
|
|
2785
|
+
}
|
|
2786
|
+
return u;
|
|
2787
|
+
}
|
|
2788
|
+
function $(o) {
|
|
2789
|
+
var F, N, L;
|
|
2790
|
+
const u = p.skuById[o.id];
|
|
2791
|
+
if (!u) return "";
|
|
2792
|
+
const l = o.recipeIds.slice(1).length > 0, s = l ? ((F = p.recipeById[o.recipeIds.at(-1) ?? ""]) == null ? void 0 : F.name) ?? "" : "", A = ((N = o.measurement) == null ? void 0 : N.abbrev) ?? ((L = u.unit) == null ? void 0 : L.abbrev) ?? "", D = `${ie(o.amount)}${A}`;
|
|
2793
|
+
return l ? `(${s}) ${u.name} (${D})` : `${u.name} (${D})`;
|
|
2794
|
+
}
|
|
2795
|
+
function i(o) {
|
|
2796
|
+
if (!o.projected) return [];
|
|
2797
|
+
const u = we(o.original.contains, /* @__PURE__ */ new Set([o.recipeId]), p.recipeById), l = we(o.projected.contains, /* @__PURE__ */ new Set([o.recipeId]), p.recipeById), s = /* @__PURE__ */ new Map();
|
|
2798
|
+
for (const L of u) s.set(`${L.type}:${L.id}`, L);
|
|
2799
|
+
const A = /* @__PURE__ */ new Map();
|
|
2800
|
+
for (const L of l) A.set(`${L.type}:${L.id}`, L);
|
|
2801
|
+
const D = [];
|
|
2802
|
+
let F = !0;
|
|
2803
|
+
function N(L, B) {
|
|
2804
|
+
B && (F || D.push({ kind: "unchanged", text: ", " }), D.push({ kind: L, text: B }), F = !1);
|
|
2805
|
+
}
|
|
2806
|
+
for (const [L, B] of s) {
|
|
2807
|
+
const P = A.get(L);
|
|
2808
|
+
if (!P)
|
|
2809
|
+
N("removed", $(B));
|
|
2810
|
+
else {
|
|
2811
|
+
const H = $(B), Q = $(P);
|
|
2812
|
+
H === Q ? N("unchanged", H) : (N("removed", H), N("added", Q));
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
for (const [L, B] of A)
|
|
2816
|
+
s.has(L) || N("added", $(B));
|
|
2817
|
+
return D;
|
|
2818
|
+
}
|
|
2819
|
+
const E = C(() => {
|
|
2820
|
+
const o = /* @__PURE__ */ new Map();
|
|
2821
|
+
for (const u of t.value)
|
|
2822
|
+
o.set(u.recipeId, i(u));
|
|
2823
|
+
return o;
|
|
2824
|
+
});
|
|
2825
|
+
function S(o) {
|
|
2826
|
+
switch (o) {
|
|
2827
|
+
case "will-update":
|
|
2828
|
+
return c("inventory.recipe.bulkEditor.status.willUpdate");
|
|
2829
|
+
case "already-satisfied":
|
|
2830
|
+
return c("inventory.recipe.bulkEditor.status.alreadySatisfied");
|
|
2831
|
+
case "partially-ignored":
|
|
2832
|
+
return c("inventory.recipe.bulkEditor.status.partiallyIgnored");
|
|
2833
|
+
case "blocked":
|
|
2834
|
+
return c("inventory.recipe.bulkEditor.status.blocked");
|
|
2835
|
+
case "no-applicable-changes":
|
|
2836
|
+
return c("inventory.recipe.bulkEditor.status.noApplicableChanges");
|
|
2837
|
+
default:
|
|
2838
|
+
return "";
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
function g(o) {
|
|
2842
|
+
switch (o) {
|
|
2843
|
+
case "will-update":
|
|
2844
|
+
return "success";
|
|
2845
|
+
case "already-satisfied":
|
|
2846
|
+
return "info";
|
|
2847
|
+
case "partially-ignored":
|
|
2848
|
+
return "warning";
|
|
2849
|
+
case "blocked":
|
|
2850
|
+
return "critical";
|
|
2851
|
+
case "no-applicable-changes":
|
|
2852
|
+
return "neutral";
|
|
2853
|
+
default:
|
|
2854
|
+
return "neutral";
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
return (o, u) => {
|
|
2858
|
+
const l = M("FmChip"), s = M("FmButton"), A = M("FmBanner"), D = M("FmIcon");
|
|
2859
|
+
return m(), I("div", bl, [
|
|
2860
|
+
y("div", gl, [
|
|
2861
|
+
y("p", _l, U(e(c)("inventory.recipe.bulkEditor.summary.title")), 1),
|
|
2862
|
+
y("div", kl, [
|
|
2863
|
+
y("div", hl, [
|
|
2864
|
+
_(l, {
|
|
2865
|
+
size: "sm",
|
|
2866
|
+
label: String(w.value),
|
|
2867
|
+
variant: "success"
|
|
2868
|
+
}, null, 8, ["label"]),
|
|
2869
|
+
y("span", xl, U(e(c)("inventory.recipe.bulkEditor.summary.countWillUpdate")), 1)
|
|
2870
|
+
]),
|
|
2871
|
+
k.value > 0 ? (m(), I("div", wl, [
|
|
2872
|
+
_(l, {
|
|
2873
|
+
size: "sm",
|
|
2874
|
+
label: String(k.value),
|
|
2875
|
+
variant: "warning"
|
|
2876
|
+
}, null, 8, ["label"]),
|
|
2877
|
+
y("span", El, U(e(c)("inventory.recipe.bulkEditor.summary.countPartiallyIgnored")), 1)
|
|
2878
|
+
])) : R("", !0),
|
|
2879
|
+
v.value > 0 ? (m(), I("div", $l, [
|
|
2880
|
+
_(l, {
|
|
2881
|
+
size: "sm",
|
|
2882
|
+
label: String(v.value),
|
|
2883
|
+
variant: "info"
|
|
2884
|
+
}, null, 8, ["label"]),
|
|
2885
|
+
y("span", Il, U(e(c)("inventory.recipe.bulkEditor.summary.countAlreadySatisfied")), 1)
|
|
2886
|
+
])) : R("", !0),
|
|
2887
|
+
a.value > 0 ? (m(), I("div", Vl, [
|
|
2888
|
+
_(l, {
|
|
2889
|
+
size: "sm",
|
|
2890
|
+
label: String(a.value),
|
|
2891
|
+
variant: "critical"
|
|
2892
|
+
}, null, 8, ["label"]),
|
|
2893
|
+
y("span", Sl, U(e(c)("inventory.recipe.bulkEditor.summary.countBlocked")), 1)
|
|
2894
|
+
])) : R("", !0),
|
|
2895
|
+
d.value > 0 ? (m(), I("div", Cl, [
|
|
2896
|
+
_(l, {
|
|
2897
|
+
size: "sm",
|
|
2898
|
+
label: String(d.value),
|
|
2899
|
+
variant: "neutral"
|
|
2900
|
+
}, null, 8, ["label"]),
|
|
2901
|
+
y("span", Fl, U(e(c)("inventory.recipe.bulkEditor.summary.countNoChanges")), 1)
|
|
2902
|
+
])) : R("", !0)
|
|
2903
|
+
]),
|
|
2904
|
+
y("div", Bl, [
|
|
2905
|
+
_(s, {
|
|
2906
|
+
label: e(c)("common.export"),
|
|
2907
|
+
variant: "secondary",
|
|
2908
|
+
size: "md",
|
|
2909
|
+
onClick: e(yl)
|
|
2910
|
+
}, null, 8, ["label", "onClick"])
|
|
2911
|
+
]),
|
|
2912
|
+
w.value === 0 && k.value === 0 ? (m(), W(A, {
|
|
2913
|
+
key: 0,
|
|
2914
|
+
class: "mt-12",
|
|
2915
|
+
type: "warning",
|
|
2916
|
+
message: e(c)("inventory.recipe.bulkEditor.summary.nothingToSubmit")
|
|
2917
|
+
}, null, 8, ["message"])) : R("", !0)
|
|
2918
|
+
]),
|
|
2919
|
+
(m(!0), I(J, null, me(t.value, (F) => (m(), I("div", {
|
|
2920
|
+
key: F.recipeId,
|
|
2921
|
+
class: "rounded-lg border border-fm-color-border-default overflow-hidden"
|
|
2922
|
+
}, [
|
|
2923
|
+
y("button", {
|
|
2924
|
+
type: "button",
|
|
2925
|
+
class: Te(["w-full flex items-center gap-8 px-12 py-10 bg-fm-color-surface-secondary border-b border-fm-color-border-default text-left cursor-pointer", { "border-b-0": !f(F.recipeId) }]),
|
|
2926
|
+
onClick: (N) => h(F.recipeId)
|
|
2927
|
+
}, [
|
|
2928
|
+
_(D, {
|
|
2929
|
+
name: f(F.recipeId) ? "expand_less" : "expand_more",
|
|
2930
|
+
size: "sm",
|
|
2931
|
+
class: "text-fm-color-typo-secondary flex-shrink-0"
|
|
2932
|
+
}, null, 8, ["name"]),
|
|
2933
|
+
y("span", Al, U(F.recipeName), 1),
|
|
2934
|
+
F.original.version === "v2" ? (m(), W(l, {
|
|
2935
|
+
key: 0,
|
|
2936
|
+
size: "sm",
|
|
2937
|
+
label: "V2",
|
|
2938
|
+
variant: "info"
|
|
2939
|
+
})) : R("", !0),
|
|
2940
|
+
_(l, {
|
|
2941
|
+
size: "sm",
|
|
2942
|
+
label: S(F.status),
|
|
2943
|
+
variant: g(F.status)
|
|
2944
|
+
}, null, 8, ["label", "variant"])
|
|
2945
|
+
], 10, Rl),
|
|
2946
|
+
f(F.recipeId) ? (m(), I(J, { key: 0 }, [
|
|
2947
|
+
e(r).applyErrors.has(F.recipeId) ? (m(), I("div", Tl, [
|
|
2948
|
+
_(A, {
|
|
2949
|
+
type: "error",
|
|
2950
|
+
message: e(r).applyErrors.get(F.recipeId)
|
|
2951
|
+
}, null, 8, ["message"])
|
|
2952
|
+
])) : R("", !0),
|
|
2953
|
+
y("div", Ul, [
|
|
2954
|
+
F.projected ? (E.value.get(F.recipeId) ?? []).length > 0 ? (m(!0), I(J, { key: 1 }, me(E.value.get(F.recipeId), (N, L) => (m(), I("span", {
|
|
2955
|
+
key: L,
|
|
2956
|
+
class: Te(["fm-typo-en-body-sm-400", {
|
|
2957
|
+
"text-fm-color-typo-secondary": N.kind === "unchanged",
|
|
2958
|
+
"line-through text-fm-color-error font-medium": N.kind === "removed",
|
|
2959
|
+
"text-fm-color-success font-medium": N.kind === "added"
|
|
2960
|
+
}])
|
|
2961
|
+
}, U(N.text), 3))), 128)) : (m(), I("span", Ml, U(e(c)("inventory.recipe.bulkEditor.summary.emptyBindings")), 1)) : (m(!0), I(J, { key: 0 }, me(b(F.original), (N, L) => (m(), I("span", {
|
|
2962
|
+
key: L,
|
|
2963
|
+
class: "fm-typo-en-body-sm-400 text-fm-color-typo-placeholder"
|
|
2964
|
+
}, U(N.text), 1))), 128))
|
|
2965
|
+
]),
|
|
2966
|
+
y("div", Pl, [
|
|
2967
|
+
F.counts.applied > 0 ? (m(), I("span", Dl, U(e(c)("inventory.recipe.bulkEditor.summary.footerApplied", { count: F.counts.applied })), 1)) : R("", !0),
|
|
2968
|
+
F.counts.satisfied > 0 ? (m(), I("span", zl, U(e(c)("inventory.recipe.bulkEditor.summary.footerSatisfied", { count: F.counts.satisfied })), 1)) : R("", !0),
|
|
2969
|
+
F.counts.ignored > 0 ? (m(), I("span", Nl, U(e(c)("inventory.recipe.bulkEditor.summary.footerIgnored", { count: F.counts.ignored })), 1)) : R("", !0),
|
|
2970
|
+
F.counts.blocked > 0 ? (m(), I("span", Ll, U(e(c)("inventory.recipe.bulkEditor.summary.footerBlocked", { count: F.counts.blocked })), 1)) : R("", !0),
|
|
2971
|
+
F.counts.applied === 0 && F.counts.satisfied === 0 && F.counts.ignored === 0 && F.counts.blocked === 0 ? (m(), I("span", jl, U(e(c)("inventory.recipe.bulkEditor.summary.noChangesDetail")), 1)) : R("", !0)
|
|
2972
|
+
])
|
|
2973
|
+
], 64)) : R("", !0)
|
|
2974
|
+
]))), 128))
|
|
2975
|
+
]);
|
|
2976
|
+
};
|
|
2977
|
+
}
|
|
2978
|
+
}), Kl = { class: "flex items-center gap-12" }, Gl = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, ql = {
|
|
2979
|
+
key: 0,
|
|
2980
|
+
class: "h-[calc(98vh-120px)] overflow-hidden flex flex-col"
|
|
2981
|
+
}, Wl = {
|
|
2982
|
+
key: 1,
|
|
2983
|
+
class: "h-[calc(98vh-120px)] overflow-hidden flex flex-col"
|
|
2984
|
+
}, Yl = {
|
|
2985
|
+
key: 2,
|
|
2986
|
+
class: "h-[calc(98vh-120px)] overflow-y-auto px-24 py-20"
|
|
2987
|
+
}, Hl = {
|
|
2988
|
+
key: 0,
|
|
2989
|
+
class: "flex items-center gap-8 px-4"
|
|
2990
|
+
}, Jl = {
|
|
2991
|
+
key: 1,
|
|
2992
|
+
class: "flex items-center gap-8 px-4"
|
|
2993
|
+
}, Ql = {
|
|
2994
|
+
key: 2,
|
|
2995
|
+
class: "flex items-center gap-8 px-4"
|
|
2996
|
+
}, Xl = /* @__PURE__ */ ne({
|
|
2997
|
+
__name: "RecipeBulkEditorDialog",
|
|
2998
|
+
props: {
|
|
2999
|
+
show: { type: Boolean }
|
|
3000
|
+
},
|
|
3001
|
+
emits: ["update:show"],
|
|
3002
|
+
setup(V, { emit: c }) {
|
|
3003
|
+
const p = V, { t: r } = te(), t = ge(), w = Me(p, "show"), k = Ne(), v = C(() => t.currentStep === 1), a = C(() => t.currentStep === 2), d = C(() => t.currentStep === 3);
|
|
3004
|
+
function n() {
|
|
3005
|
+
t.currentStep = 2;
|
|
3006
|
+
}
|
|
3007
|
+
function f() {
|
|
3008
|
+
t.currentStep = 1;
|
|
3009
|
+
}
|
|
3010
|
+
function h() {
|
|
3011
|
+
t.goToStep3();
|
|
3012
|
+
}
|
|
3013
|
+
function b() {
|
|
3014
|
+
t.backToStep2();
|
|
3015
|
+
}
|
|
3016
|
+
function $() {
|
|
3017
|
+
k.open({
|
|
3018
|
+
title: r("inventory.recipe.bulkEditor.step3.confirmTitle"),
|
|
3019
|
+
message: r("inventory.recipe.bulkEditor.step3.confirmMessage"),
|
|
3020
|
+
primaryActions: {
|
|
3021
|
+
text: r("inventory.recipe.bulkEditor.step3.confirmButton"),
|
|
3022
|
+
variant: "primary",
|
|
3023
|
+
close: !0
|
|
3024
|
+
},
|
|
3025
|
+
secondaryActions: {
|
|
3026
|
+
text: r("common.cancel"),
|
|
3027
|
+
close: !0
|
|
3028
|
+
}
|
|
3029
|
+
}).onPrimary(async () => {
|
|
3030
|
+
await t.confirmAndApply();
|
|
3031
|
+
});
|
|
3032
|
+
}
|
|
3033
|
+
function i() {
|
|
3034
|
+
w.value = !1, t.reset();
|
|
3035
|
+
}
|
|
3036
|
+
return (E, S) => {
|
|
3037
|
+
const g = M("FmChip"), o = M("FmButton"), u = M("FmDialog");
|
|
3038
|
+
return m(), W(u, {
|
|
3039
|
+
modelValue: e(w),
|
|
3040
|
+
"onUpdate:modelValue": [
|
|
3041
|
+
S[0] || (S[0] = (l) => Ae(w) ? w.value = l : null),
|
|
3042
|
+
S[1] || (S[1] = (l) => {
|
|
3043
|
+
l || e(t).reset();
|
|
3044
|
+
})
|
|
3045
|
+
],
|
|
3046
|
+
overlay: !0,
|
|
3047
|
+
"close-button": "",
|
|
3048
|
+
"max-width": "98vw",
|
|
3049
|
+
"max-height": "98vh"
|
|
3050
|
+
}, {
|
|
3051
|
+
"dialog-header": Y(() => [
|
|
3052
|
+
y("div", Kl, [
|
|
3053
|
+
y("span", Gl, U(e(r)("inventory.recipe.bulkEditor.title")), 1),
|
|
3054
|
+
_(g, {
|
|
3055
|
+
size: "sm",
|
|
3056
|
+
label: e(r)("inventory.recipe.bulkEditor.stepIndicator", { step: e(t).currentStep, total: 3 }),
|
|
3057
|
+
variant: "neutral"
|
|
3058
|
+
}, null, 8, ["label"])
|
|
3059
|
+
])
|
|
3060
|
+
]),
|
|
3061
|
+
"dialog-footer": Y(() => [
|
|
3062
|
+
v.value ? (m(), I("div", Hl, [
|
|
3063
|
+
_(o, {
|
|
3064
|
+
label: e(r)("common.next"),
|
|
3065
|
+
disabled: !e(t).canGoToStep2,
|
|
3066
|
+
onClick: n
|
|
3067
|
+
}, null, 8, ["label", "disabled"]),
|
|
3068
|
+
_(o, {
|
|
3069
|
+
label: e(r)("common.close"),
|
|
3070
|
+
variant: "tertiary",
|
|
3071
|
+
onClick: i
|
|
3072
|
+
}, null, 8, ["label"])
|
|
3073
|
+
])) : a.value ? (m(), I("div", Jl, [
|
|
3074
|
+
_(o, {
|
|
3075
|
+
label: e(r)("inventory.recipe.bulkEditor.step2.reviewButton"),
|
|
3076
|
+
disabled: !e(t).canGoToStep3,
|
|
3077
|
+
onClick: h
|
|
3078
|
+
}, null, 8, ["label", "disabled"]),
|
|
3079
|
+
_(o, {
|
|
3080
|
+
label: e(r)("common.back"),
|
|
3081
|
+
variant: "secondary",
|
|
3082
|
+
onClick: f
|
|
3083
|
+
}, null, 8, ["label"]),
|
|
3084
|
+
_(o, {
|
|
3085
|
+
label: e(r)("common.close"),
|
|
3086
|
+
variant: "tertiary",
|
|
3087
|
+
onClick: i
|
|
3088
|
+
}, null, 8, ["label"])
|
|
3089
|
+
])) : d.value ? (m(), I("div", Ql, [
|
|
3090
|
+
_(o, {
|
|
3091
|
+
label: e(r)("inventory.recipe.bulkEditor.step3.confirmButton"),
|
|
3092
|
+
disabled: e(t).isSaving,
|
|
3093
|
+
loading: e(t).isSaving,
|
|
3094
|
+
onClick: $
|
|
3095
|
+
}, null, 8, ["label", "disabled", "loading"]),
|
|
3096
|
+
_(o, {
|
|
3097
|
+
label: e(r)("common.back"),
|
|
3098
|
+
variant: "secondary",
|
|
3099
|
+
disabled: e(t).isSaving,
|
|
3100
|
+
onClick: b
|
|
3101
|
+
}, null, 8, ["label", "disabled"]),
|
|
3102
|
+
_(o, {
|
|
3103
|
+
label: e(r)("common.close"),
|
|
3104
|
+
variant: "tertiary",
|
|
3105
|
+
disabled: e(t).isSaving,
|
|
3106
|
+
onClick: i
|
|
3107
|
+
}, null, 8, ["label", "disabled"])
|
|
3108
|
+
])) : R("", !0)
|
|
3109
|
+
]),
|
|
3110
|
+
default: Y(() => [
|
|
3111
|
+
v.value ? (m(), I("div", ql, [
|
|
3112
|
+
_($o)
|
|
3113
|
+
])) : a.value ? (m(), I("div", Wl, [
|
|
3114
|
+
_(fl)
|
|
3115
|
+
])) : d.value ? (m(), I("div", Yl, [
|
|
3116
|
+
_(Ol)
|
|
3117
|
+
])) : R("", !0)
|
|
3118
|
+
]),
|
|
3119
|
+
_: 1
|
|
3120
|
+
}, 8, ["modelValue"]);
|
|
3121
|
+
};
|
|
3122
|
+
}
|
|
3123
|
+
});
|
|
3124
|
+
function Zl(V) {
|
|
3125
|
+
return !V || Object.keys(V).length === 0 ? "" : Object.entries(V).map(([c, p]) => `${c}: ${p}`).join(", ");
|
|
3126
|
+
}
|
|
3127
|
+
function ei() {
|
|
3128
|
+
const V = ee(), c = V.recipes, p = V.recipeById, r = V.skuById, t = c.flatMap((v, a) => {
|
|
3129
|
+
var n;
|
|
3130
|
+
const d = Zl(v.customAttributes);
|
|
3131
|
+
if ((n = v.contains) != null && n.length) {
|
|
3132
|
+
const f = v.contains.filter((b) => b.type === "RECIPE"), h = v.contains.filter((b) => b.type === "SKU");
|
|
3133
|
+
return [
|
|
3134
|
+
...a === 0 ? [] : [["", "", "", "", "", "", ""]],
|
|
3135
|
+
...f.map(
|
|
3136
|
+
(b, $) => {
|
|
3137
|
+
var i;
|
|
3138
|
+
return [
|
|
3139
|
+
$ === 0 ? v.name : "",
|
|
3140
|
+
"RECIPE",
|
|
3141
|
+
"",
|
|
3142
|
+
(i = p[b.id]) == null ? void 0 : i.name,
|
|
3143
|
+
ie(b.amount),
|
|
3144
|
+
"UNIT",
|
|
3145
|
+
$ === 0 ? d : ""
|
|
3146
|
+
];
|
|
3147
|
+
}
|
|
3148
|
+
),
|
|
3149
|
+
...h.map(
|
|
3150
|
+
(b, $) => {
|
|
3151
|
+
var i, E, S, g;
|
|
3152
|
+
return [
|
|
3153
|
+
!f.length && $ === 0 ? v.name : "",
|
|
3154
|
+
"INGREDIENT",
|
|
3155
|
+
(i = r[b.id]) == null ? void 0 : i.code,
|
|
3156
|
+
(E = r[b.id]) == null ? void 0 : E.name,
|
|
3157
|
+
ie(b.amount),
|
|
3158
|
+
b.measurement ? b.measurement.abbrev : (g = (S = r[b.id]) == null ? void 0 : S.unit) == null ? void 0 : g.abbrev,
|
|
3159
|
+
!f.length && $ === 0 ? d : ""
|
|
3160
|
+
];
|
|
3161
|
+
}
|
|
3162
|
+
)
|
|
3163
|
+
];
|
|
3164
|
+
}
|
|
3165
|
+
return [
|
|
3166
|
+
...a === 0 ? [] : [["", "", "", "", "", "", ""]],
|
|
3167
|
+
[v.name, "No bindings", "", "", "", "", d]
|
|
3168
|
+
];
|
|
3169
|
+
}), k = ot(t, ["Name", "Type", "Code", "Item", "Amount", "Unit", "Custom Attributes"]);
|
|
3170
|
+
lt(k, `RECIPE_${it(/* @__PURE__ */ new Date(), "-", "-")}.xlsx`);
|
|
3171
|
+
}
|
|
3172
|
+
const ti = { class: "flex flex-col py-8" }, ni = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, oi = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Ri = /* @__PURE__ */ ne({
|
|
3173
|
+
__name: "RecipeView",
|
|
3174
|
+
setup(V) {
|
|
3175
|
+
const c = ee(), p = C(() => c.recipes), r = Je(), { createRecipe: t, updateRecipe: w } = De(), { recipeDialogProps: k, recipeViewLoading: v } = Et(De()), { columnDefs: a, formatRowData: d } = Ht(), n = C(() => d(p.value)), f = ge(), h = je();
|
|
3176
|
+
O(!1);
|
|
3177
|
+
function b(l) {
|
|
3178
|
+
if (l === "add")
|
|
3179
|
+
return t();
|
|
3180
|
+
if (l === "export")
|
|
3181
|
+
return ei();
|
|
3182
|
+
l === "bulk-edit" && f.openDialog();
|
|
3183
|
+
}
|
|
3184
|
+
const $ = O(""), i = C(() => v.value), { breakpoints: E } = _t(), S = C(() => E.value.xs || E.value.sm), g = C(() => S.value ? 10 : 20), o = Ct(), { t: u } = te();
|
|
3185
|
+
return (l, s) => {
|
|
3186
|
+
const A = M("FmTable");
|
|
3187
|
+
return m(), W(Ft, {
|
|
3188
|
+
title: e(u)("inventory.recipe.title"),
|
|
3189
|
+
actions: [
|
|
3190
|
+
{
|
|
3191
|
+
label: e(u)("inventory.recipe.create.title"),
|
|
3192
|
+
value: "add",
|
|
3193
|
+
isPrimary: !0,
|
|
3194
|
+
prependIcon: "add"
|
|
3195
|
+
},
|
|
3196
|
+
...e(h).enableBulkEditRecipes ? [{ label: e(u)("inventory.recipe.bulkEditor.title"), value: "bulk-edit", isPrimary: !1 }] : [],
|
|
3197
|
+
{ label: e(u)("common.export"), value: "export", isPrimary: !1 }
|
|
3198
|
+
],
|
|
3199
|
+
"onClick:action": b
|
|
3200
|
+
}, {
|
|
3201
|
+
default: Y(() => [
|
|
3202
|
+
y("div", {
|
|
3203
|
+
class: Te([
|
|
3204
|
+
"relative flex flex-col gap-8 max-h-full",
|
|
3205
|
+
{
|
|
3206
|
+
"p-0": S.value,
|
|
3207
|
+
"px-24 ": !S.value
|
|
3208
|
+
}
|
|
3209
|
+
])
|
|
3210
|
+
}, [
|
|
3211
|
+
_(Kt, {
|
|
3212
|
+
searchable: "",
|
|
3213
|
+
search: $.value,
|
|
3214
|
+
"onUpdate:search": s[0] || (s[0] = (D) => $.value = D)
|
|
3215
|
+
}, null, 8, ["search"]),
|
|
3216
|
+
(m(), W(A, {
|
|
3217
|
+
style: pt(e(o).tableHeight),
|
|
3218
|
+
"column-defs": e(a),
|
|
3219
|
+
"row-data": n.value,
|
|
3220
|
+
"search-value": $.value,
|
|
3221
|
+
loading: !e(r)._currentLocation || i.value,
|
|
3222
|
+
onRowClick: s[1] || (s[1] = (D) => e(w)(D.original.original)),
|
|
3223
|
+
key: p.value.length,
|
|
3224
|
+
"page-size": g.value
|
|
3225
|
+
}, {
|
|
3226
|
+
"list-row": Y((D) => [
|
|
3227
|
+
_(Ot, {
|
|
3228
|
+
row: D,
|
|
3229
|
+
onRowClick: (F) => e(w)(F.original)
|
|
3230
|
+
}, {
|
|
3231
|
+
default: Y((F) => {
|
|
3232
|
+
var N, L, B, P, H, Q, re, z, K, G;
|
|
3233
|
+
return [
|
|
3234
|
+
y("div", ti, [
|
|
3235
|
+
y("div", ni, [
|
|
3236
|
+
_(e(He), {
|
|
3237
|
+
render: (B = (L = (N = F.recipe) == null ? void 0 : N.column) == null ? void 0 : L.columnDef) == null ? void 0 : B.cell,
|
|
3238
|
+
props: (H = (P = F.recipe) == null ? void 0 : P.getContext) == null ? void 0 : H.call(P)
|
|
3239
|
+
}, null, 8, ["render", "props"])
|
|
3240
|
+
]),
|
|
3241
|
+
y("div", oi, [
|
|
3242
|
+
_(e(He), {
|
|
3243
|
+
render: (z = (re = (Q = F.ingredients) == null ? void 0 : Q.column) == null ? void 0 : re.columnDef) == null ? void 0 : z.cell,
|
|
3244
|
+
props: (G = (K = F.ingredients) == null ? void 0 : K.getContext) == null ? void 0 : G.call(K)
|
|
3245
|
+
}, null, 8, ["render", "props"])
|
|
3246
|
+
])
|
|
3247
|
+
])
|
|
3248
|
+
];
|
|
3249
|
+
}),
|
|
3250
|
+
_: 2
|
|
3251
|
+
}, 1032, ["row", "onRowClick"])
|
|
3252
|
+
]),
|
|
3253
|
+
_: 1
|
|
3254
|
+
}, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"]))
|
|
3255
|
+
], 2),
|
|
3256
|
+
(m(), W(mt, { to: "body" }, [
|
|
3257
|
+
_(eo, ft(vt(e(k))), null, 16),
|
|
3258
|
+
e(h).enableBulkEditRecipes ? (m(), W(Xl, {
|
|
3259
|
+
key: 0,
|
|
3260
|
+
show: e(f).show,
|
|
3261
|
+
"onUpdate:show": s[2] || (s[2] = (D) => e(f).show = D)
|
|
3262
|
+
}, null, 8, ["show"])) : R("", !0)
|
|
3263
|
+
]))
|
|
3264
|
+
]),
|
|
3265
|
+
_: 1
|
|
3266
|
+
}, 8, ["title", "actions"]);
|
|
3267
|
+
};
|
|
3268
|
+
}
|
|
3269
|
+
});
|
|
3270
|
+
export {
|
|
3271
|
+
Ri as default
|
|
3272
|
+
};
|