@feedmepos/mf-inventory-portal 1.9.0-dev.1 → 1.9.0-dev.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/dist/{App-OAKZ4Qdf.js → App-DDALXIcF.js} +500 -499
  2. package/dist/{ApprovalView-DN0rWMUh.js → ApprovalView-BJVCW2q7.js} +9 -9
  3. package/dist/{BindingsDialog-BWpIeq6j.js → BindingsDialog-DDMJjWjv.js} +2 -2
  4. package/dist/{BindingsPicker-DRROpR8i.js → BindingsPicker-twbdYEAL.js} +2 -2
  5. package/dist/{BindingsTable-BFEoUCIT.js → BindingsTable-Cpx3vSvk.js} +4 -4
  6. package/dist/{BulkReceiveRequestPage-wnXszulg.js → BulkReceiveRequestPage-DD33ulSC.js} +21 -21
  7. package/dist/{ChangeLocationComponent.vue_vue_type_script_setup_true_lang-BtEblqcM.js → ChangeLocationComponent.vue_vue_type_script_setup_true_lang-CtHsMnkV.js} +1 -1
  8. package/dist/{ClosingDraftView-BRNRWXnj.js → ClosingDraftView-BUc5bGIU.js} +19 -19
  9. package/dist/{ClosingHistoryView-DWPINMVP.js → ClosingHistoryView-DPz6D5S2.js} +7 -7
  10. package/dist/ClosingTemplateView-DabFVZCc.js +2392 -0
  11. package/dist/{CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-cxhbnvht.js → CustomPrintTemplatePreview.vue_vue_type_script_setup_true_lang-izGh8Myj.js} +1 -1
  12. package/dist/{DefaultView-CTQ0-HzQ.js → DefaultView-DURO6g6_.js} +2 -2
  13. package/dist/{DeliveryOrderPrintPreview-gReWM4vq.js → DeliveryOrderPrintPreview-BJBheF-Y.js} +2 -2
  14. package/dist/{EmailDialog.vue_vue_type_script_setup_true_lang-IYcE8OSG.js → EmailDialog.vue_vue_type_script_setup_true_lang-BDZaoowM.js} +8430 -8430
  15. package/dist/{FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-CGkF-JhJ.js → FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-lABO5UTH.js} +1 -1
  16. package/dist/{FeatureCapabilityGate-Ce4_ozRL.js → FeatureCapabilityGate-4YBofjM5.js} +2 -2
  17. package/dist/{FeaturePageGate.vue_vue_type_script_setup_true_lang-DViz4hgB.js → FeaturePageGate.vue_vue_type_script_setup_true_lang-VwGbsXYy.js} +1 -1
  18. package/dist/{FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-B6f-p8K7.js → FmDateRangePickerChip.vue_vue_type_script_setup_true_lang-CrYonFQ4.js} +1 -1
  19. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-C-6cGWEV.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-D0cZr3AO.js} +2 -2
  20. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BALpSufj.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-CvIVLMp-.js} +28 -24
  21. package/dist/{FmMultiselectDialog-CJLfLql2.js → FmMultiselectDialog-Cwd47xa5.js} +2 -2
  22. package/dist/{FmMultiselectDialog-B4Diosc4.js → FmMultiselectDialog-lXXaY5lK.js} +2 -2
  23. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-DuNzft4K.js → FmUnitInput.vue_vue_type_script_setup_true_lang-CqqOESle.js} +5 -5
  24. package/dist/{ImportView-DnYVbQ6I.js → ImportView-hEJUxq3v.js} +7 -7
  25. package/dist/{IngredientsView-COUJUWAb.js → IngredientsView-DEhTu1Jk.js} +15 -15
  26. package/dist/{IntegrationExplorerView-CgE2WN-x.js → IntegrationExplorerView-KpAJ2V3E.js} +6 -6
  27. package/dist/{IntegrationPlatformView-BtTv4P3n.js → IntegrationPlatformView-qrPYWqT5.js} +4472 -4425
  28. package/dist/{IntegrationView-D_YkXYOW.js → IntegrationView-BcZjB2Df.js} +15 -15
  29. package/dist/{InventoryBindingForm-B4HvjUs9.js → InventoryBindingForm-BVW5nyBI.js} +1 -1
  30. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CjVc2mCE.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-ClC9JScP.js} +4 -4
  31. package/dist/{InventoryBindingSummary-CCFW8rw_.js → InventoryBindingSummary-karaxDWz.js} +1 -1
  32. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-PJMjcN03.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DC-dWx9K.js} +2 -2
  33. package/dist/{ProductionRunDetailPage-ChNKrpyj.js → ProductionRunDetailPage-CRoWs8GL.js} +4 -4
  34. package/dist/{ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-536rtKru.js → ProductionRunLifecycleDialogs.vue_vue_type_script_setup_true_lang-lzagKc6P.js} +8 -8
  35. package/dist/{ProductionRunPage-FIUKUyDB.js → ProductionRunPage-DeEzvebS.js} +4 -4
  36. package/dist/PublishView-BG0YVyQ_.js +282 -0
  37. package/dist/{PurchaseOrderPrintPreview-C8-zlH52.js → PurchaseOrderPrintPreview-DZs6nzcB.js} +2 -2
  38. package/dist/{ReceiveRequestView-DIuftfMU.js → ReceiveRequestView-B5jmw3_m.js} +16 -16
  39. package/dist/{RecipeView-BKYAdx6j.js → RecipeView-D-u82Imb.js} +16 -16
  40. package/dist/{SettingsView-CZR-ELPO.js → SettingsView-CavH72Zf.js} +7 -7
  41. package/dist/{StockView-C-9o5zUV.js → StockView-Mbbag4gi.js} +21 -21
  42. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-Db4DrwQJ.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-I8S3lE8n.js} +1 -1
  43. package/dist/{SupplierView-CHX-eb1W.js → SupplierView-BKjQQMUB.js} +13 -13
  44. package/dist/{SurchargeView-D1y5BUvB.js → SurchargeView-tG9jxSHT.js} +7 -7
  45. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-DU2wYI2T.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-f3MH8VXz.js} +2 -2
  46. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-DKTWIz-E.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CVPc0HNQ.js} +1 -1
  47. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-BzJkA7ub.js +5002 -0
  48. package/dist/{TransferTemplateView-Bq7Euggq.js → TransferTemplateView-DUvgcoFR.js} +19 -19
  49. package/dist/{UnitCostHistoryView-CLpnjeEP.js → UnitCostHistoryView-DXFlnpzI.js} +4 -4
  50. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-CiWUAHMw.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-T4rShFa9.js} +4 -4
  51. package/dist/{UnitView-RxPdbO_C.js → UnitView-ChPy6-nH.js} +7 -7
  52. package/dist/{WarehouseView-Ba_77-lL.js → WarehouseView-B4rRtSI3.js} +8 -8
  53. package/dist/{WastageTemplateView-DRB3J1CD.js → WastageTemplateView-BWvFXjS6.js} +15 -15
  54. package/dist/api/inventory.d.ts +22 -91
  55. package/dist/api/purchase-order-template.d.ts +1 -1
  56. package/dist/{app-B2FciWDu.js → app-DMflhu6b.js} +7841 -7235
  57. package/dist/app.js +1 -1
  58. package/dist/{bulk-edit-simulation.helper-gZPNWgS7.js → bulk-edit-simulation.helper-DezcOq8o.js} +2 -2
  59. package/dist/{closing-template-L7d2nmhr.js → closing-template-BGERrbIQ.js} +1 -1
  60. package/dist/components/FmInventoryTableToolbar.vue.d.ts +7 -0
  61. package/dist/{date2--N7dpGRR.js → date2-DIxf2HSS.js} +1 -1
  62. package/dist/{dayjs.min-CFhuhXoi.js → dayjs.min-W80OrMgJ.js} +1 -1
  63. package/dist/{decimal-gywux_Ld.js → decimal-BTK7NAET.js} +2 -2
  64. package/dist/{defineDeepModel-B2EkoePs.js → defineDeepModel-DJ9LqqzR.js} +1 -1
  65. package/dist/{duplicate-template-t-iu60N3.js → duplicate-template-BC7pMF-s.js} +1 -1
  66. package/dist/feature-flags/plan-tier.d.ts +0 -2
  67. package/dist/{feature-CvQ6eKvB.js → feature-h3MFKUcz.js} +3 -3
  68. package/dist/{format-time-from-id-BVk3iOfV.js → format-time-from-id-DSAFHO8d.js} +1 -1
  69. package/dist/{format-unit-display-CLmFpKSI.js → format-unit-display-wiLcRFDI.js} +99 -101
  70. package/dist/{id-to-date-DKmIZp6I.js → id-to-date-Di8Eschw.js} +1 -1
  71. package/dist/{import-export.helper-qShUWqck.js → import-export.helper-avwvLBKD.js} +5 -5
  72. package/dist/{index-CJ1pZPwZ.js → index-C-uWBaU4.js} +3 -3
  73. package/dist/{index-CrUvC9l4.js → index-CXhgWYdX.js} +1 -1
  74. package/dist/{index-CoGFfqOs.js → index-CcmysfjG.js} +1 -1
  75. package/dist/{lz-string-mHxrGSbY.js → lz-string-MCnthIwP.js} +1 -1
  76. package/dist/{netsuite-BDcapEOO.js → netsuite-CsMFS8uH.js} +2522 -2505
  77. package/dist/{netsuite-explorer-FeiogpVF.js → netsuite-explorer-CLsdKVZp.js} +1 -1
  78. package/dist/{predefined-templates-CVAkYLi5.js → predefined-templates-B4URhizE.js} +1 -1
  79. package/dist/publish-versions-BGoX_gD4.js +87 -0
  80. package/dist/purchase-order-template-Cn2JQYD0.js +41 -0
  81. package/dist/{recalculationUtils-BuhlMBRB.js → recalculationUtils-sCuVobBd.js} +1 -1
  82. package/dist/{row-action.enum-b--87Y19.js → row-action.enum-BM2HgD4R.js} +1 -1
  83. package/dist/{rules-CFEKk1zY.js → rules-BaYKzbRv.js} +3 -3
  84. package/dist/{stock-Bet2VY1l.js → stock-B4uI5_D4.js} +2 -2
  85. package/dist/{stock-B4FZa2Ci.js → stock-BZMbxbyg.js} +1 -1
  86. package/dist/stores/inventory.in-flight.spec.d.ts +1 -0
  87. package/dist/stores/location.d.ts +0 -289
  88. package/dist/stores/publish-versions.d.ts +19 -0
  89. package/dist/stores/publish-versions.spec.d.ts +1 -0
  90. package/dist/{supplier-DX_LR2LR.js → supplier-B0dtsWm4.js} +2 -2
  91. package/dist/{surcharge-gnQZF_xQ.js → surcharge-Djbv5SzM.js} +1 -1
  92. package/dist/tsconfig.app.tsbuildinfo +1 -1
  93. package/dist/{uom-rules-B4qbIOqA.js → uom-rules-jR6owpw7.js} +1 -1
  94. package/dist/{use-ingredient-select-dialog-BE5IHSwH.js → use-ingredient-select-dialog-VfIKtgzP.js} +2 -2
  95. package/dist/{use-inventory-binding-dialog-B0xEQiLV.js → use-inventory-binding-dialog-BdgHGwC_.js} +2 -2
  96. package/dist/{use-template-enabled-locations-BvAG1cJF.js → use-template-enabled-locations-B1xMD71z.js} +2 -2
  97. package/dist/{use-transfer-locations-pyDvqZxC.js → use-transfer-locations-NrMDt6DD.js} +2 -2
  98. package/dist/{useHrmPermission-kFc2vRek.js → useHrmPermission-DT0o2-yP.js} +1 -1
  99. package/dist/{useNavigationMenu-C9-LqWKt.js → useNavigationMenu-CMjxTTiM.js} +86 -66
  100. package/dist/{useSseClient-CoafBOe-.js → useSseClient-D4n-A1ST.js} +1 -1
  101. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.d.ts +5 -0
  102. package/dist/views/closing-template/components/closing-template-form/composables/use-closing-template-items.spec.d.ts +1 -0
  103. package/dist/views/publish/PublishView.spec.d.ts +1 -0
  104. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-total-cost.d.ts +24 -0
  105. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-total-cost.spec.d.ts +1 -0
  106. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +3 -3
  107. package/dist/{vue-BMDdrHy_.js → vue-BOcyAWzp.js} +37 -30
  108. package/dist/{vue-i18n-Bkodg08l.js → vue-i18n-69kj_U4j.js} +261 -261
  109. package/dist/{xlsx.util-DOCqFSat.js → xlsx.util-CJm8uh4D.js} +2 -2
  110. package/package.json +4 -6
  111. package/dist/ClosingTemplateView-gqjNm3Wi.js +0 -2358
  112. package/dist/PublishView-JDX28AHk.js +0 -213
  113. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-eSgt3P6r.js +0 -4961
  114. package/dist/purchase-order-template-CrRp6r28.js +0 -41
@@ -1,2358 +0,0 @@
1
- import { defineComponent as te, resolveComponent as G, createElementBlock as T, openBlock as _, createElementVNode as r, createCommentVNode as H, normalizeClass as Z, createTextVNode as K, toDisplayString as D, unref as f, createVNode as A, withCtx as j, Fragment as Y, renderList as X, ref as V, computed as U, watch as Ce, createSlots as Qe, createBlock as W, h as Fe, createStaticVNode as Je, normalizeStyle as De, withDirectives as qe, isRef as Ue, vModelText as Xe, withModifiers as he, Teleport as Ze, normalizeProps as et, guardReactiveProps as tt, mergeProps as ot } from "vue";
2
- import { u as nt, _ as st } from "./SingleColumnLayout.vue_vue_type_script_setup_true_lang-DpwneGOV.js";
3
- import { useCoreStore as Se, useI18n as ne } from "@feedmepos/mf-common";
4
- import { useDialogChild as at, useSnackbar as de, useDialog as Ie, FmButtonVariant as _e, components as rt, useProxiedModel as lt, useBreakpoints as it } from "@feedmepos/ui-library";
5
- import { defineStore as Ve, storeToRefs as ze } from "pinia";
6
- import { F as oe } from "./form-mode.enum-BKiNVH6A.js";
7
- import { a as ue } from "./closing-template-L7d2nmhr.js";
8
- import { a as Ae, m as ct, u as Re, c as Ge } from "./app-B2FciWDu.js";
9
- import { t as $e, a as Pe, d as Me, s as Oe, r as mt } from "./xlsx.util-DOCqFSat.js";
10
- import { F as dt } from "./FmDroppableField-J0tG_U3w.js";
11
- import { f as He, b as we } from "./date2--N7dpGRR.js";
12
- import { u as ut } from "./netsuite-BDcapEOO.js";
13
- import { D as xe, R as J } from "./row-action.enum-b--87Y19.js";
14
- import { c as pt } from "./component-BmLAdDiY.js";
15
- import { f as ft } from "./format-time-from-id-BVk3iOfV.js";
16
- import { _ as yt } from "./TemplatePublishDialog.vue_vue_type_script_setup_true_lang-DKTWIz-E.js";
17
- import { u as vt } from "./duplicate-template-t-iu60N3.js";
18
- import { _ as gt } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-BALpSufj.js";
19
- import { _ as bt } from "./CursorPaginatedTable.vue_vue_type_script_setup_true_lang-BCUhtL_B.js";
20
- import { R as ht, A as _t } from "./rules-CFEKk1zY.js";
21
- import { u as je } from "./use-ingredient-select-dialog-BE5IHSwH.js";
22
- import { d as xt } from "./defineDeepModel-B2EkoePs.js";
23
- import { _ as kt } from "./FeatureCapabilityBadge.vue_vue_type_script_setup_true_lang-CGkF-JhJ.js";
24
- import { u as wt } from "./use-template-enabled-locations-BvAG1cJF.js";
25
- import { _ as $t } from "./SystemTrailDialog.vue_vue_type_script_setup_true_lang-DU2wYI2T.js";
26
- import { _ as Tt } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-gJQQKKAC.js";
27
- import { F as ke } from "./index-eGvSlWMU.js";
28
- import { _ as Ct } from "./_plugin-vue_export-helper-CHgC5LLL.js";
29
- var Ee = /* @__PURE__ */ ((m) => (m.Ingredients = "Ingredients", m))(Ee || {});
30
- function Ye(m) {
31
- const t = m.sku, e = new Set(m.disabledMeasurements);
32
- return [
33
- {
34
- code: t.code,
35
- name: t.name,
36
- unit: t.unit.abbrev,
37
- enabled: !e.has(t.unit._id)
38
- },
39
- ...t.unit.measurements.map((u) => ({
40
- unit: u.abbrev,
41
- enabled: !e.has(u.id)
42
- }))
43
- ];
44
- }
45
- function Ke() {
46
- return [
47
- {
48
- id: "code",
49
- name: "Code"
50
- },
51
- {
52
- id: "name",
53
- name: "Name"
54
- },
55
- {
56
- id: "unit",
57
- name: "Unit"
58
- },
59
- {
60
- id: "enabled",
61
- name: "Enabled"
62
- }
63
- ];
64
- }
65
- function It(m) {
66
- var h;
67
- const e = Se().currentBusiness.value, a = (h = m.map((l) => {
68
- var y;
69
- const o = l.items.flatMap(Ye), g = Ke(), i = [
70
- ["Template ID", l._id],
71
- ["Template name", l.name],
72
- ["Business name", e == null ? void 0 : e.name],
73
- ["Business ID", e == null ? void 0 : e._id],
74
- ["Menu version", e == null ? void 0 : e.menuVersion],
75
- [
76
- "Locations",
77
- ...(y = l.locations) != null && y.length ? l.locations.map((x) => `${x.name} (${x.dbName})`) : ["All"]
78
- ],
79
- ["Reference", l.ref ?? ""],
80
- [],
81
- g.map((x) => x.name),
82
- ...o.map((x) => g.map((d) => x[d.id]))
83
- ], F = g.map((x) => `system:${x.id}`), I = $e(i, F);
84
- return { name: l.name, sheet: I };
85
- }).reduce(
86
- (l, o) => {
87
- var i;
88
- const g = o.name.slice(0, 12);
89
- return (i = l.sheetOccurence)[g] ?? (i[g] = 0), l.sheetOccurence[g] += 1, l.sheets[`${g} (${l.sheetOccurence[g]})`] = o.sheet, l;
90
- },
91
- {
92
- sheets: {},
93
- sheetOccurence: {}
94
- }
95
- )) == null ? void 0 : h.sheets, u = `${e == null ? void 0 : e.name} closing templates (${He(/* @__PURE__ */ new Date())}).xlsx`, b = Pe(a);
96
- return Me(b, u), u;
97
- }
98
- function Ft(m) {
99
- Se().currentBusiness.value;
100
- const e = 3, k = (i) => {
101
- const F = [], I = i.sku, y = new Set(i.disabledMeasurements || []);
102
- y.has(I.unit._id) || F.push(I.unit.abbrev);
103
- for (const x of I.unit.measurements) {
104
- if (F.length >= e) break;
105
- y.has(x.id) || F.push(x.abbrev);
106
- }
107
- return F;
108
- }, a = ["#", "Code", "Name", "UOM"], u = [
109
- ["Template:", m.name],
110
- ["Reference:", m.ref ?? ""],
111
- [],
112
- a,
113
- ...m.items.map((i, F) => {
114
- const I = k(i);
115
- return [
116
- F + 1,
117
- // Index starting from 1
118
- i.sku.code,
119
- i.sku.name,
120
- // Add UOM columns (up to MAX_UOM_COLUMNS)
121
- ...Array(e).fill("").map(
122
- (y, x) => I[x] ? `_____ ${I[x]}` : ""
123
- )
124
- ];
125
- })
126
- ], b = $e(u, a);
127
- if (b["!ref"]) {
128
- const i = {
129
- top: { style: "thin", color: { rgb: "000000" } },
130
- bottom: { style: "thin", color: { rgb: "000000" } },
131
- left: { style: "thin", color: { rgb: "000000" } },
132
- right: { style: "thin", color: { rgb: "000000" } }
133
- }, F = 4, I = F + m.items.length, y = a.map((x, d) => String.fromCharCode(65 + d));
134
- for (let x = F; x <= I; x++)
135
- y.forEach((d) => {
136
- const $ = `${d}${x}`;
137
- b[$] || (b[$] = { t: "s", v: "" }), b[$].s = {
138
- border: i
139
- };
140
- });
141
- }
142
- b["!cols"] = [
143
- { wch: 5 },
144
- // Index column - narrow
145
- { wch: 15 },
146
- // Code column
147
- { wch: 30 },
148
- // Name column - adjusted for more columns
149
- ...Array.from({ length: e }, () => ({ wch: 15 }))
150
- // UOM columns
151
- ], b["!margins"] = {
152
- left: 0.7,
153
- right: 0.7,
154
- top: 0.75,
155
- bottom: 0.75,
156
- header: 0.3,
157
- footer: 0.3
158
- };
159
- const l = m.name.slice(0, 31), o = Pe({ [l]: b }), g = `${m.name} - Closing Template (${He(/* @__PURE__ */ new Date())}).xlsx`;
160
- return Me(o, g), g;
161
- }
162
- function Dt() {
163
- const m = Se(), t = Ae(), e = ut(), k = Ye({
164
- sku: {
165
- unit: {
166
- _id: "",
167
- name: "Unit",
168
- abbrev: "Unit",
169
- precision: 0,
170
- measurements: []
171
- },
172
- code: "ING001",
173
- _id: "",
174
- name: "Sugar"
175
- }
176
- })[0], a = m.currentBusiness.value, u = Ke(), b = [
177
- ["Template ID (leave empty to create new)", ""],
178
- ["Template Name", "New template"],
179
- ["Business name", a == null ? void 0 : a.name],
180
- ["Business ID", a == null ? void 0 : a._id],
181
- ["Menu version", a == null ? void 0 : a.menuVersion],
182
- [
183
- "Location codes (leave empty to enable all)",
184
- "Example outlet (restaurant_xxx)",
185
- "Example outlet 2 (restaurant_xxx)"
186
- ],
187
- ["Reference:"],
188
- [],
189
- u.map((y) => y.name),
190
- u.map((y) => k[y.id])
191
- ], h = u.map((y) => `system:${y.id}`), l = $e(b, h), o = e.isEnabled ? e.state.setting.childItems ?? [] : [], g = o.reduce(
192
- (y, x) => {
193
- var S, P;
194
- const d = (S = e.netSuiteItemIdToSkuId.get(x.parentNetSuiteId)) == null ? void 0 : S[0], $ = (P = e.netSuiteMeasurementIdToMeasurementId.get(
195
- x.unitOfMeasureId
196
- )) == null ? void 0 : P[0];
197
- if (!x.externalId)
198
- return y;
199
- if (!d)
200
- return console.error(`Item ${x.externalId} cannot be mapped to parent FdoInventorySku.`, x), y;
201
- const n = t.skuById[d], w = n.unit.measurements.find((s) => s.id === $);
202
- return w ? (y[x.externalId] = {
203
- sku: n,
204
- measurement: w
205
- }, y) : (console.error(
206
- `Item ${x.externalId} found parent FdoInventorySku of ${n.code} ${n.name} but the measurement of netsuite id ${x.unitOfMeasureId} cannot be found.`,
207
- x
208
- ), y);
209
- },
210
- {}
211
- ), i = $e(
212
- [
213
- ...t.skus.flatMap((y) => [
214
- [y.code, y.name, y.unit.abbrev, !0],
215
- ...y.unit.measurements.map((d) => [
216
- "",
217
- "",
218
- d.abbrev,
219
- !d.abbrev.toLocaleLowerCase("en-us").includes("inactive")
220
- ])
221
- ]),
222
- ...Object.entries(g).map(([y, { sku: x, measurement: d }]) => [
223
- x.code,
224
- x.name,
225
- d.abbrev,
226
- !d.abbrev.toLocaleLowerCase("en-us").includes("inactive"),
227
- y
228
- ])
229
- ],
230
- [
231
- "Code",
232
- "Name",
233
- "Units",
234
- "Enabled (true/false)",
235
- ...o.length ? ["Netsuite Parent"] : []
236
- ]
237
- ), F = Pe({
238
- Template: l,
239
- Ingredients: i
240
- }), I = `${a == null ? void 0 : a.name} transfer templates import.xlsx`;
241
- return Me(F, I), I;
242
- }
243
- function St(m) {
244
- if (!m.length || `${m[0]}`.toLocaleLowerCase() === "all")
245
- return [];
246
- const t = /(.*) \(((warehouse_|restaurant_).{24,})\)/, k = Re().locationByDbName;
247
- return m.map((a) => {
248
- const u = new Array(), b = a.trim(), h = t.exec(b);
249
- if (!h)
250
- return u.push(`Enabled location value of ${b} cannot be read.`), {
251
- errors: u
252
- };
253
- const l = h[1], o = h[2], g = k[o];
254
- return g ? (l !== g.name && u.push(
255
- `Location id ${o} has non-matching name. Found ${l} but expected ${g.name}`
256
- ), {
257
- errors: u,
258
- location: g
259
- }) : (u.push(`Location (${l}) of id ${o} is not found.`), {
260
- errors: u
261
- });
262
- });
263
- }
264
- function At(m) {
265
- const [
266
- t,
267
- e,
268
- k,
269
- a,
270
- u,
271
- b,
272
- h,
273
- l
274
- ] = Oe(m);
275
- return {
276
- id: `${e[1] ?? ""}`.trim(),
277
- name: `${k[1] ?? ""}`.trim(),
278
- locations: h.slice(1).map((o) => `${o}`.trim()).filter((o) => o),
279
- reference: `${l[1] ?? ""}`.trim()
280
- };
281
- }
282
- function Rt(m) {
283
- const [
284
- t,
285
- e,
286
- k,
287
- a,
288
- u,
289
- b,
290
- h,
291
- l,
292
- o,
293
- g,
294
- ...i
295
- ] = Oe(m);
296
- if (!t || !t.length || t.some((d) => d.length && !d.startsWith("system:")))
297
- throw new Error("Missing meta header. Excel file does not come from the template.");
298
- const F = t.map((d) => d.split(":")[1]), y = ["code", "name", "unit", "enabled"].filter((d) => !F.includes(d));
299
- if (y.length)
300
- throw new Error(
301
- `Missing meta headers (${y.join()}). Excel file does not come from the template.`
302
- );
303
- return i.map((d, $) => {
304
- const n = {};
305
- for (const w in F) {
306
- const S = F[w];
307
- Object.assign(n, { [S]: d[w] });
308
- }
309
- return {
310
- index: $,
311
- data: n
312
- };
313
- });
314
- }
315
- function Pt(m) {
316
- return m.reduce(
317
- (t, e) => {
318
- var u;
319
- const k = e.data, a = e.index;
320
- return k.unit && (k.code ? t.result.push({ parent: e, children: [] }) : t.result.length ? (u = t.result.at(-1)) == null || u.children.push(e) : t.errors.push(`Cannot find parent for row ${a + 9}`)), t;
321
- },
322
- { result: new Array(), errors: new Array() }
323
- );
324
- }
325
- function Mt(m) {
326
- const t = m.parent.data, e = new Array(), a = Ae().skuByCode[t.code ?? ""];
327
- if (!a)
328
- return e.push(`Cannot find ingredient of code ${t.code} ${t.name}`), { errors: e };
329
- const u = {
330
- sku: a
331
- }, b = /* @__PURE__ */ new Set([a.unit._id, ...a.unit.measurements.map((l) => l.id)]), h = a.unit.measurements.find((l) => l.abbrev === t.unit);
332
- t.unit !== a.unit.abbrev && !h ? e.push(
333
- `Cannot find measurement unit of ${t.unit} for (${t.code}) ${t.name}.`
334
- ) : (t.enabled === !0 || `${t.enabled}`.toLocaleLowerCase() === "true") && b.delete(a.unit._id);
335
- for (const l of m.children) {
336
- const o = l.data, g = o.unit === a.unit.abbrev ? a.unit : void 0, i = a.unit.measurements.find((F) => F.abbrev === o.unit);
337
- if (!i && !g) {
338
- e.push(
339
- `Cannot find measurement unit of ${o.unit} for (${t.code}) ${t.name}.`
340
- );
341
- continue;
342
- }
343
- (o.enabled === !0 || `${o.enabled}`.toLocaleLowerCase() === "true") && b.delete((i == null ? void 0 : i.id) ?? (g == null ? void 0 : g._id) ?? "");
344
- }
345
- return b.has(a.unit._id) && u.sku.unit.measurements.every((l) => b.has(l.id)) && e.push(`Ingredient ${a.code} - ${a.name} must have at least one unit enabled.`), u.disabledMeasurements = [...b], { errors: e, templateItem: u };
346
- }
347
- async function Et(m) {
348
- const t = m.SheetNames.filter(
349
- (u) => !Object.values(Ee).map(String).includes(u)
350
- ), k = await ue().readTemplates(), a = ct(k, "_id");
351
- try {
352
- return t.reduce(
353
- (u, b) => {
354
- const h = new Array(), l = m.Sheets[b], o = At(l), g = St(o.locations), i = g.filter((n) => n.location).map((n) => n.location);
355
- h.push(...g.flatMap((n) => n.errors));
356
- const F = Rt(l).filter(
357
- (n) => n.data.code || n.data.unit
358
- ), I = Pt(F);
359
- h.push(...I.errors);
360
- const y = I.result.map(
361
- (n) => Mt(n)
362
- );
363
- h.push(...y.flatMap((n) => n.errors));
364
- const x = y.filter((n) => n.templateItem).map((n) => n.templateItem);
365
- if (o.id) {
366
- const n = a[o.id];
367
- if (!n) {
368
- const S = {
369
- _id: o.id,
370
- _rev: "",
371
- name: o.name || `(unnamed from sheet ${b || "<unnamed sheet>"})`,
372
- items: []
373
- };
374
- return h.push(`Template ID ${o.id} is not found.`), u.importUpdateResult.push({
375
- type: "update",
376
- original: S,
377
- template: S,
378
- excelSheetName: b,
379
- errors: h
380
- }), u;
381
- }
382
- const w = {
383
- type: "update",
384
- original: n,
385
- template: {
386
- ...n,
387
- name: o.name,
388
- locations: i.length ? i : null,
389
- ref: o.reference,
390
- items: x
391
- },
392
- excelSheetName: b,
393
- errors: h
394
- };
395
- return u.importUpdateResult.push(w), u;
396
- }
397
- const $ = {
398
- type: "create",
399
- template: {
400
- name: o.name,
401
- locations: i.length ? i : null,
402
- ref: o.reference,
403
- items: x
404
- },
405
- excelSheetName: b,
406
- errors: h
407
- };
408
- return u.importCreateResult.push($), u;
409
- },
410
- {
411
- invalidExcel: !1,
412
- importCreateResult: new Array(),
413
- importUpdateResult: new Array()
414
- }
415
- );
416
- } catch (u) {
417
- return {
418
- invalidExcel: !0,
419
- invalidExcelMessage: (u == null ? void 0 : u.message) ?? "Invalid excel",
420
- importCreateResult: [],
421
- importUpdateResult: []
422
- };
423
- }
424
- }
425
- const Nt = { class: "flex items-center gap-12 pl-8" }, Bt = { class: "flex flex-col" }, Lt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, Ut = {
426
- key: 0,
427
- class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
428
- }, Vt = { key: 0 }, Le = /* @__PURE__ */ te({
429
- __name: "ClosingTemplateImportItem",
430
- props: {
431
- type: {},
432
- name: {},
433
- locations: {},
434
- items: {},
435
- errors: {}
436
- },
437
- setup(m) {
438
- const { t } = ne();
439
- return (e, k) => {
440
- var b, h, l;
441
- const a = G("FmIcon"), u = G("FmTooltip");
442
- return _(), T("div", Nt, [
443
- k[0] || (k[0] = r("div", null, "•", -1)),
444
- r("div", Bt, [
445
- r("div", Lt, [
446
- r("div", {
447
- class: Z({
448
- "text-fm-color-system-error-300": e.errors.length
449
- })
450
- }, [
451
- K(D(e.name) + " ", 1),
452
- e.type === "create" ? (_(), T("span", Ut, "(" + D(f(t)("inventory.closing.template.import.new")) + ")", 1)) : H("", !0)
453
- ], 2),
454
- e.errors.length ? (_(), T("div", Vt, [
455
- A(u, { "z-index": 50 }, {
456
- content: j(() => [
457
- r("ol", null, [
458
- (_(!0), T(Y, null, X(e.errors, (o, g) => (_(), T("li", { key: g }, D(o), 1))), 128))
459
- ])
460
- ]),
461
- default: j(() => [
462
- A(a, {
463
- name: "error",
464
- size: "sm",
465
- color: "system-error-300"
466
- })
467
- ]),
468
- _: 1
469
- })
470
- ])) : H("", !0)
471
- ]),
472
- r("div", {
473
- class: Z([
474
- "fm-typo-en-body-sm-400",
475
- {
476
- "text-fm-color-system-error-200": e.errors.length,
477
- "text-fm-color-typo-secondary": !e.errors.length
478
- }
479
- ])
480
- }, D((b = e.locations) != null && b.length ? f(t)("inventory.closing.template.import.nLocations", { count: (h = e.locations) == null ? void 0 : h.length }) : f(t)("inventory.closing.template.import.allLocations")) + ", " + D(f(t)("inventory.closing.template.import.nItems", { count: (l = e.items) == null ? void 0 : l.length })), 3)
481
- ])
482
- ]);
483
- };
484
- }
485
- }), zt = { class: "flex flex-col gap-24" }, Gt = { class: "fm-typo-en-body-md-400" }, Ot = {
486
- key: 0,
487
- class: "flex items-center gap-8"
488
- }, Ht = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, jt = { class: "flex flex-col gap-8" }, Yt = { class: "line-clamp-2 text-ellipsis break-all" }, Kt = {
489
- key: 2,
490
- class: "shrink-0"
491
- }, Wt = {
492
- key: 0,
493
- class: "flex flex-col"
494
- }, Qt = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Jt = {
495
- key: 0,
496
- class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
497
- }, qt = { class: "fm-typo-en-body-lg-600" }, Xt = /* @__PURE__ */ te({
498
- __name: "ClosingTemplateImport",
499
- setup(m) {
500
- const t = V(null), e = at(), k = de(), a = V(!1), u = V(!1), b = V(new Array()), h = V([]), l = V([]), o = U(
501
- () => !!b.value.length || h.value.some((I) => I.errors.length) || l.value.some((I) => I.errors.length)
502
- ), g = U(
503
- () => !!h.value.length || !!l.value.length
504
- ), { t: i } = ne();
505
- async function F(I) {
506
- b.value = [], h.value = [], l.value = [];
507
- try {
508
- a.value = !0;
509
- const [y] = await Promise.all([
510
- mt(I),
511
- // fake buffer
512
- new Promise((n) => setTimeout(n, 1e3))
513
- ]);
514
- if (!y.SheetNames.filter(
515
- (n) => !Object.values(Ee).map(String).includes(n)
516
- ).find((n) => n)) {
517
- b.value.push(i("inventory.ingredient.import.fileError.noSheet"));
518
- return;
519
- }
520
- const $ = await Et(y);
521
- if ($.invalidExcel) {
522
- b.value.push(
523
- $.invalidExcelMessage ?? i("inventory.ingredient.import.fileError.invalidExcel")
524
- );
525
- return;
526
- }
527
- if (h.value = $.importCreateResult, l.value = $.importUpdateResult, !h.value.length && !l.value.length) {
528
- b.value.push(i("inventory.ingredient.import.fileError.noData"));
529
- return;
530
- }
531
- e.emitData($);
532
- } catch (y) {
533
- k.open({
534
- title: i("inventory.ingredient.import.fileError.unableToRead"),
535
- message: y == null ? void 0 : y.message,
536
- type: "error"
537
- }), console.error("Error in reading file", y);
538
- } finally {
539
- b.value.length && k.open({
540
- title: i("inventory.ingredient.import.fileError.invalidExcel"),
541
- type: "error"
542
- }), a.value = !1;
543
- }
544
- }
545
- return Ce(t, (I) => {
546
- I && F(I);
547
- }), (I, y) => {
548
- const x = G("FmCircularProgress"), d = G("FmIcon"), $ = G("FmButton");
549
- return _(), T("div", zt, [
550
- r("div", Gt, D(f(i)("inventory.closing.template.import.message")), 1),
551
- u.value ? (_(), T("div", Ot, [
552
- r("div", null, [
553
- A(x, {
554
- size: "md",
555
- color: "neutral-gray-200"
556
- })
557
- ]),
558
- r("div", Ht, D(f(i)("inventory.formField.loading")), 1)
559
- ])) : (_(), T(Y, { key: 1 }, [
560
- A(dt, {
561
- class: Z({
562
- "w-full": !0,
563
- "h-[200px]": !t.value
564
- }),
565
- accept: ".xlsx",
566
- onFileUpload: y[0] || (y[0] = (n) => t.value = n),
567
- label: f(i)("inventory.ingredient.import.uploadTemplate"),
568
- "button-label": f(i)("inventory.ingredient.import.selectFile")
569
- }, Qe({ _: 2 }, [
570
- t.value ? {
571
- name: "default",
572
- fn: j(({ openFileDialog: n }) => [
573
- r("div", jt, [
574
- r("div", {
575
- class: Z([
576
- "fm-corner-radius-md p-16 flex items-center gap-16",
577
- {
578
- "border border-fm-color-neutral-gray-100": a.value,
579
- "border border-fm-color-neutral-gray-200": !a.value && !o.value,
580
- "border border-fm-color-system-error-200": o.value
581
- }
582
- ])
583
- }, [
584
- a.value ? (_(), W(x, {
585
- key: 0,
586
- size: "md",
587
- color: "neutral-gray-200"
588
- })) : (_(), W(d, {
589
- key: 1,
590
- name: o.value ? "error" : "attach_file",
591
- outline: "",
592
- color: o.value ? "system-error-300" : void 0
593
- }, null, 8, ["name", "color"])),
594
- r("div", {
595
- class: Z([
596
- "fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
597
- {
598
- "text-fm-color-typo-disabled": a.value,
599
- "text-fm-color-typo-primary": !a.value
600
- }
601
- ])
602
- }, [
603
- r("div", Yt, D(t.value.name), 1)
604
- ], 2),
605
- a.value ? H("", !0) : (_(), T("div", Kt, [
606
- A($, {
607
- label: f(i)("inventory.ingredient.import.replaceFile"),
608
- variant: o.value ? "destructive" : "secondary",
609
- "prepend-icon": o.value ? void 0 : "autorenew",
610
- onClick: n
611
- }, null, 8, ["label", "variant", "prepend-icon", "onClick"])
612
- ]))
613
- ], 2),
614
- b.value.length ? (_(), T("div", Wt, [
615
- (_(!0), T(Y, null, X(b.value, (w, S) => (_(), T("div", {
616
- key: S,
617
- class: "flex gap-8 items-center"
618
- }, [
619
- A(d, {
620
- name: "error",
621
- size: "sm",
622
- color: "system-error-300"
623
- }),
624
- r("div", Qt, D(w), 1)
625
- ]))), 128))
626
- ])) : H("", !0)
627
- ])
628
- ]),
629
- key: "0"
630
- } : void 0
631
- ]), 1032, ["class", "label", "button-label"]),
632
- g.value ? (_(), T("div", Jt, [
633
- r("div", qt, D(f(i)("inventory.ingredient.import.summary")), 1),
634
- (_(!0), T(Y, null, X(h.value, (n, w) => (_(), W(Le, {
635
- key: w,
636
- name: n.template.name,
637
- locations: n.template.locations,
638
- items: n.template.items,
639
- errors: n.errors,
640
- type: "create"
641
- }, null, 8, ["name", "locations", "items", "errors"]))), 128)),
642
- (_(!0), T(Y, null, X(l.value, (n) => (_(), W(Le, {
643
- key: n.template._id,
644
- name: n.template.name,
645
- locations: n.template.locations,
646
- items: n.template.items,
647
- errors: n.errors,
648
- type: "update"
649
- }, null, 8, ["name", "locations", "items", "errors"]))), 128))
650
- ])) : H("", !0)
651
- ], 64))
652
- ]);
653
- };
654
- }
655
- }), Ne = Ve(
656
- "closingTemplateTable",
657
- function() {
658
- var P;
659
- const { t } = ne(), e = Ie(), k = de();
660
- function a(s) {
661
- console.error("Row action failed:", s), k.open({
662
- title: t("inventory.common.somethingWentWrong"),
663
- message: (s == null ? void 0 : s.message) || t("inventory.common.tryAgain"),
664
- type: "error"
665
- });
666
- }
667
- const u = V({}), b = Te(), h = V({}), l = V(new Array()), o = V(!1), g = Re(), i = ue();
668
- function F(s) {
669
- const c = {
670
- title: s.name,
671
- doc: s,
672
- controller: {
673
- publishAll: async (M) => {
674
- const R = M || s.locations, B = await i.publishSingleDoc(
675
- s._id,
676
- R == null ? void 0 : R.map((z) => z.dbName)
677
- );
678
- return u.value = B.publishedRevByLocation || {}, u.value;
679
- },
680
- publishAtLocation: async (M) => {
681
- const R = await i.publishSingleDoc(s._id, [M.dbName]);
682
- return u.value = R.publishedRevByLocation || {}, u.value;
683
- },
684
- unpublishAll: async (M) => {
685
- const R = M || s.locations, B = await i.unpublishSingleDoc(
686
- s._id,
687
- R == null ? void 0 : R.map((z) => z.dbName)
688
- );
689
- return u.value = B.publishedRevByLocation || {}, u.value;
690
- },
691
- unpublishAtLocation: async (M) => {
692
- const R = await i.unpublishSingleDoc(s._id, [
693
- M.dbName
694
- ]);
695
- return u.value = R.publishedRevByLocation || {}, u.value;
696
- }
697
- },
698
- initialPublishedRev: u.value,
699
- locations: g.locations,
700
- enabledLocations: s.locations
701
- };
702
- e.open({
703
- title: "Publish template",
704
- contentComponent: yt,
705
- contentComponentProps: c,
706
- closeButton: !0,
707
- minWidth: 700,
708
- maxHeight: "80vh",
709
- contentScrollable: !1,
710
- primaryActions: {
711
- text: t("common.close"),
712
- close: !0,
713
- variant: "tertiary"
714
- }
715
- });
716
- }
717
- const I = V(0);
718
- let y = (P = g._currentLocation) == null ? void 0 : P.dbName;
719
- async function x(s) {
720
- if (!g._currentLocation) return { docs: [], nextStartkey: null, hasMore: !1 };
721
- if (y = g._currentLocation.dbName, s.startkey) return i.listTemplatesPage(s);
722
- const [c, M, R] = await Promise.all([
723
- i.listTemplatesPage(s),
724
- i.getRecentPublishingJob(),
725
- i.getRecentPublishInfo()
726
- ]);
727
- return h.value = M, u.value = R.publishedRevByLocation || {}, c;
728
- }
729
- function d() {
730
- l.value = [], I.value++;
731
- }
732
- async function $() {
733
- var c;
734
- ((c = g._currentLocation) == null ? void 0 : c.dbName) !== y && d();
735
- }
736
- async function n(s) {
737
- if (!l.value.find((c) => c._id) && g._currentLocation) {
738
- o.value = !0;
739
- try {
740
- const [c] = await Promise.all([
741
- i.getTemplate(s),
742
- new Promise((R) => setTimeout(R, 1e3))
743
- ]), { toClosingTemplateListItem: M } = await import("./index-CrUvC9l4.js");
744
- l.value = [
745
- M(c)
746
- ];
747
- } catch (c) {
748
- console.log("Something went wrong when fetching templates:", c);
749
- } finally {
750
- o.value = !1;
751
- }
752
- }
753
- }
754
- function w(s, c) {
755
- switch (c = Ge(c), s) {
756
- case J.Details:
757
- return b.viewTemplate(c._id).catch(a);
758
- case J.Edit:
759
- return b.updateTemplate(c._id).catch(a);
760
- case J.Delete:
761
- return b.deleteTemplate(c, o, d);
762
- case J.Publish:
763
- return F(c);
764
- case J.Duplicate:
765
- return b.duplicateTemplate(c, o, d);
766
- }
767
- }
768
- return {
769
- columnDefs: [
770
- {
771
- id: "_id",
772
- accessorKey: "_id",
773
- header: () => t("inventory.closing.table.createdAt"),
774
- cell(s) {
775
- return ft(`${s.getValue()}`);
776
- },
777
- enableSorting: !0
778
- },
779
- {
780
- id: "name",
781
- accessorKey: "name",
782
- header: () => t("inventory.closing.table.name"),
783
- enableSorting: !0,
784
- size: 200
785
- },
786
- {
787
- id: "noOfItems",
788
- accessorKey: "itemCount",
789
- header: () => t("inventory.closing.table.noOfItems"),
790
- enableSorting: !1,
791
- meta: {
792
- width: "10rem",
793
- textAlign: "right"
794
- }
795
- },
796
- {
797
- id: "enabledLocations",
798
- accessorKey: "locations.length",
799
- header: () => t("inventory.closing.table.enabledOutlets"),
800
- cell(s) {
801
- var M;
802
- const c = (M = s.row.original.locations) == null ? void 0 : M.length;
803
- return c ? `${c}` : "All";
804
- },
805
- enableSorting: !1,
806
- meta: {
807
- width: "10rem",
808
- textAlign: "right"
809
- }
810
- },
811
- {
812
- id: "ref",
813
- accessorKey: "ref",
814
- header: () => t("inventory.closing.table.reference"),
815
- enableSorting: !1,
816
- size: "auto"
817
- },
818
- {
819
- id: "status",
820
- header: () => t("inventory.adjustment.template.table.status"),
821
- enableSorting: !1,
822
- cell(s) {
823
- const c = s.row.original, R = (s.row.original.locations || g.locations).filter((O) => !!g.locationByDbName[O.dbName]), B = R.filter((O) => !!(u.value[O.dbName] || []).find(
824
- (ee) => ee._id === c._id && (ee.updatedAt ? ee.updatedAt === c.updatedAt : ee._rev === c._rev)
825
- )).length, z = R.length > 0 && B === R.length;
826
- return Fe(
827
- "div",
828
- {
829
- class: "flex items-center gap-8"
830
- },
831
- Fe(
832
- "div",
833
- {
834
- class: [
835
- "fm-status-badge",
836
- z ? "fm-status-badge-success-secondary" : "fm-status-badge-info-secondary"
837
- ]
838
- },
839
- z ? "Published" : "Unpublished"
840
- )
841
- );
842
- }
843
- },
844
- {
845
- id: "action",
846
- cell(s) {
847
- const c = s.row.original, M = [
848
- xe[J.Edit],
849
- xe[J.Duplicate],
850
- xe[J.Delete],
851
- xe[J.Publish]
852
- ];
853
- return pt(M, (R) => w(R, c));
854
- },
855
- enableSorting: !1,
856
- size: 40,
857
- meta: {
858
- cellClass: "",
859
- headerClass: ""
860
- }
861
- }
862
- ],
863
- recentPublish: h,
864
- templates: l,
865
- loading: o,
866
- tableKey: I,
867
- fetchTemplatesPage: x,
868
- refresh: d,
869
- onLocationChanged: $,
870
- loadTemplate: n
871
- };
872
- }
873
- ), Te = Ve("closingTemplateActions", () => {
874
- const { t: m } = ne(), t = Ie(), e = de(), k = ue(), a = vt(), u = Ne(), { loading: b } = ze(u), h = V({});
875
- function l() {
876
- h.value = {
877
- mode: oe.CREATE,
878
- show: !0,
879
- "onUpdate:show"(n) {
880
- h.value.show = n;
881
- }
882
- };
883
- }
884
- async function o(n, w) {
885
- const S = typeof n == "string" ? await k.getTemplate(n, w) : n;
886
- return h.value = {
887
- mode: oe.UPDATE,
888
- modelValue: S,
889
- show: !0,
890
- "onUpdate:show"(P) {
891
- h.value.show = P;
892
- }
893
- }, S;
894
- }
895
- function g(n, w, S) {
896
- t.open({
897
- title: `Confirm deleting template ${n.name}?`,
898
- message: "Deleted template can no longer be retrieved",
899
- primaryActions: {
900
- text: "Delete",
901
- variant: _e.Destructive,
902
- close: !0
903
- },
904
- secondaryActions: {
905
- text: "Cancel",
906
- variant: _e.Plain,
907
- close: !0
908
- }
909
- }).onPrimary(async () => {
910
- e.open({
911
- title: `Deleting ${n.name}`,
912
- type: "info"
913
- });
914
- try {
915
- w.value = !0;
916
- const [P] = await Promise.allSettled([
917
- k.deleteTemplate(n),
918
- new Promise((s) => setTimeout(s, 1e3))
919
- ]);
920
- if (P.status === "rejected") throw P.reason;
921
- e.open({
922
- title: `Deleted "${n.name}"`,
923
- type: "success"
924
- });
925
- } catch (P) {
926
- e.open({
927
- title: `Unable to delete "${n.name}"`,
928
- message: P.message,
929
- type: "error"
930
- });
931
- } finally {
932
- w.value = !1, S();
933
- }
934
- });
935
- }
936
- function i(n, w, S) {
937
- let P;
938
- t.open({
939
- title: `Confirm duplicating template "${n.name}"?`,
940
- message: "Duplicated template can be edited after creation",
941
- primaryActions: {
942
- text: "Duplicate",
943
- variant: _e.Destructive,
944
- close: !0
945
- },
946
- secondaryActions: {
947
- text: "Cancel",
948
- variant: _e.Plain,
949
- close: !0
950
- },
951
- contentComponent: te({
952
- props: ["modelValue"],
953
- emits: ["update:modelValue"],
954
- setup(s) {
955
- return () => Fe(rt.FmTextField, {
956
- modelValue: s.modelValue,
957
- "onUpdate:modelValue": (c) => P = c,
958
- label: "New Template Name",
959
- size: "md",
960
- variant: "primary"
961
- });
962
- }
963
- })
964
- }).onPrimary(async () => {
965
- e.open({
966
- title: `Duplicating "${n.name}"`,
967
- type: "info"
968
- });
969
- try {
970
- w.value = !0;
971
- const [s] = await Promise.allSettled([
972
- a.duplicateClosingTemplate(n._id, P),
973
- new Promise((c) => setTimeout(c, 1e3))
974
- ]);
975
- if (s.status === "rejected") throw s.reason;
976
- e.open({
977
- title: `Duplicated "${n.name}"`,
978
- type: "success"
979
- });
980
- } catch (s) {
981
- e.open({
982
- title: `Unable to duplicate "${n.name}"`,
983
- message: `See error from server: ${s}`,
984
- type: "error"
985
- }), console.error("error on duplicating closing template", s);
986
- } finally {
987
- w.value = !1, S();
988
- }
989
- });
990
- }
991
- const F = V({});
992
- async function I(n) {
993
- const w = await k.getTemplate(n);
994
- F.value = {
995
- template: w,
996
- show: !0,
997
- "onUpdate:show"(S) {
998
- F.value.show = S;
999
- },
1000
- "onAction:edit"() {
1001
- F.value.show = !1, o(Ge(w));
1002
- }
1003
- };
1004
- }
1005
- async function y() {
1006
- const n = await k.readTemplates();
1007
- if (!n.length) {
1008
- e.open({
1009
- title: "No data to export",
1010
- type: "error"
1011
- });
1012
- return;
1013
- }
1014
- const w = It(n);
1015
- e.open({
1016
- title: m("inventory.ingredient.export.success"),
1017
- message: m("inventory.ingredient.export.filename", [w]),
1018
- type: "success"
1019
- });
1020
- }
1021
- function x(n) {
1022
- if (!n.items.length) {
1023
- e.open({
1024
- title: "No items in template to export",
1025
- type: "error"
1026
- });
1027
- return;
1028
- }
1029
- const w = Ft(n);
1030
- e.open({
1031
- title: m("inventory.ingredient.export.success"),
1032
- message: m("inventory.ingredient.export.filename", [w]),
1033
- type: "success"
1034
- });
1035
- }
1036
- function d() {
1037
- u.loading || t.open({
1038
- title: m("inventory.ingredient.import.title"),
1039
- contentComponent: Xt,
1040
- overlay: !0,
1041
- closeButton: !0,
1042
- primaryActions: {
1043
- text: m("common.import"),
1044
- close: !1
1045
- },
1046
- secondaryActions: {
1047
- text: m("common.close"),
1048
- close: !0
1049
- },
1050
- tertiaryActions: {
1051
- text: m("inventory.ingredient.import.actions.downloadTemplate"),
1052
- close: !1,
1053
- variant: "plain"
1054
- }
1055
- }).onPrimary((n) => {
1056
- if (!n) {
1057
- e.open({
1058
- title: m("inventory.ingredient.import.error.noData"),
1059
- type: "error"
1060
- });
1061
- return;
1062
- }
1063
- if (!n.importCreateResult.length && !n.importUpdateResult.length) {
1064
- e.open({
1065
- title: m("inventory.ingredient.import.error.invalidContent"),
1066
- message: m("inventory.ingredient.import.error.noImportData"),
1067
- type: "error"
1068
- });
1069
- return;
1070
- }
1071
- if (n.importCreateResult.some((w) => w.errors.length) || n.importUpdateResult.some((w) => w.errors.length)) {
1072
- e.open({
1073
- title: m("inventory.ingredient.import.error.invalidContent"),
1074
- message: m("inventory.ingredient.import.error.hasErrors"),
1075
- type: "error"
1076
- });
1077
- return;
1078
- }
1079
- t.close(), $(n);
1080
- }).onTertiary(Dt);
1081
- }
1082
- async function $(n) {
1083
- b.value = !0;
1084
- try {
1085
- const w = [
1086
- ...n.importCreateResult.map(
1087
- (c) => c.template
1088
- ),
1089
- ...n.importUpdateResult.map(
1090
- (c) => c.template
1091
- )
1092
- ], S = 100;
1093
- let P = 0;
1094
- const s = () => {
1095
- P += S, e.open({
1096
- title: m("inventory.ingredient.import.progress", [
1097
- Math.min(P, w.length),
1098
- w.length
1099
- ])
1100
- });
1101
- };
1102
- for (const c of w.chunk(100))
1103
- s(), await k.importTemplates(c);
1104
- e.open({
1105
- title: m("inventory.ingredient.import.success"),
1106
- type: "success"
1107
- });
1108
- } catch (w) {
1109
- e.open({
1110
- title: m("inventory.ingredient.import.error.failed"),
1111
- message: m("inventory.ingredient.import.error.systemMessage", [w == null ? void 0 : w.message]),
1112
- type: "error"
1113
- }), console.error("Error in importing skus", n, w);
1114
- } finally {
1115
- b.value = !1, u.refresh();
1116
- }
1117
- }
1118
- return {
1119
- createTemplate: l,
1120
- viewTemplate: I,
1121
- updateTemplate: o,
1122
- deleteTemplate: g,
1123
- duplicateTemplate: i,
1124
- exportTemplates: y,
1125
- exportSingleTemplate: x,
1126
- importTemplates: d,
1127
- templateDialogProps: h,
1128
- templateDetailsProps: F
1129
- };
1130
- });
1131
- function Zt(m) {
1132
- return m ? Number(m.amount) / Math.pow(10, Number(m.precision) || 0) : 0;
1133
- }
1134
- function Be(m) {
1135
- const t = new Set(m.disabledMeasurements ?? []), e = [
1136
- {
1137
- id: m.sku.unit._id,
1138
- label: m.sku.unit.abbrev,
1139
- isBase: !0,
1140
- factor: 0,
1141
- enabled: !t.has(m.sku.unit._id)
1142
- }
1143
- ];
1144
- for (const k of m.sku.unit.measurements)
1145
- e.push({
1146
- id: k.id,
1147
- label: k.abbrev,
1148
- isBase: !1,
1149
- factor: Zt(k.conversion),
1150
- enabled: !t.has(k.id)
1151
- });
1152
- return e;
1153
- }
1154
- function eo(m) {
1155
- return Be(m).filter((t) => t.enabled).length;
1156
- }
1157
- function to(m) {
1158
- return Be(m).filter((t) => t.enabled).map((t) => !t.isBase && t.factor ? `${t.label} ×${t.factor}` : t.label);
1159
- }
1160
- function oo(m, t) {
1161
- const e = new Set(m.disabledMeasurements ?? []);
1162
- if (t.enabled) {
1163
- if (eo(m) <= 1) return null;
1164
- e.add(t.id);
1165
- } else
1166
- e.delete(t.id);
1167
- return { ...m, disabledMeasurements: [...e] };
1168
- }
1169
- const no = { class: "flex items-center gap-12 py-12" }, so = {
1170
- class: "flex items-center justify-center shrink-0 rounded-md border border-fm-color-neutral-gray-300 fm-typo-en-body-sm-600 text-fm-color-typo-secondary",
1171
- style: { width: "28px", height: "28px" }
1172
- }, ao = {
1173
- class: "flex flex-col gap-2 shrink-0",
1174
- style: { width: "280px" }
1175
- }, ro = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary bg-fm-color-neutral-gray-100 border border-fm-color-neutral-gray-200 rounded px-8 py-1 self-start" }, lo = {
1176
- class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary",
1177
- style: { "word-break": "break-word", "line-height": "1.2" }
1178
- }, io = {
1179
- class: "flex-1 flex flex-wrap items-center",
1180
- style: { gap: "6px" }
1181
- }, co = {
1182
- key: 0,
1183
- class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary bg-fm-color-neutral-gray-200 rounded",
1184
- style: { padding: "0 6px" }
1185
- }, mo = {
1186
- key: 1,
1187
- class: "fm-typo-en-body-sm-400 text-fm-color-primary",
1188
- style: { opacity: "0.7" }
1189
- }, uo = {
1190
- class: "shrink-0 flex items-center justify-end gap-4",
1191
- style: { width: "200px" }
1192
- }, po = /* @__PURE__ */ te({
1193
- __name: "ClosingTemplateItem",
1194
- props: {
1195
- item: {},
1196
- index: {},
1197
- disabled: { type: Boolean }
1198
- },
1199
- emits: ["update", "delete"],
1200
- setup(m, { emit: t }) {
1201
- const e = m, k = t, a = U(() => Be(e.item)), u = U(() => a.value.filter((o) => o.enabled)), b = U(() => u.value.length);
1202
- function h(o) {
1203
- if (e.disabled) return;
1204
- const g = oo(e.item, o);
1205
- g && k("update", g);
1206
- }
1207
- function l(o) {
1208
- return o.isBase ? "Base unit" : o.factor ? `1 ${o.label} = ${o.factor} ${e.item.sku.unit.abbrev}` : "";
1209
- }
1210
- return (o, g) => {
1211
- const i = G("FmButton"), F = G("FmMenuItem"), I = G("FmMenu");
1212
- return _(), T("div", no, [
1213
- r("span", so, D(o.index + 1), 1),
1214
- r("div", ao, [
1215
- r("span", ro, D(o.item.sku.code), 1),
1216
- r("div", lo, D(o.item.sku.name), 1)
1217
- ]),
1218
- r("div", io, [
1219
- (_(!0), T(Y, null, X(u.value, (y) => (_(), T("span", {
1220
- key: y.id,
1221
- class: Z([
1222
- "flex items-center rounded-full border",
1223
- y.isBase ? "border-fm-color-neutral-gray-300 bg-fm-color-neutral-gray-100" : "border-fm-color-primary bg-fm-color-system-warning-100"
1224
- ]),
1225
- style: { gap: "6px", padding: "4px 12px" }
1226
- }, [
1227
- r("span", {
1228
- class: Z(["fm-typo-en-body-sm-600 whitespace-nowrap", y.isBase ? "text-fm-color-typo-primary" : "text-fm-color-primary"])
1229
- }, D(y.label), 3),
1230
- y.isBase ? (_(), T("span", co, " BASE ")) : y.factor ? (_(), T("span", mo, " ×" + D(y.factor), 1)) : H("", !0)
1231
- ], 2))), 128))
1232
- ]),
1233
- r("div", uo, [
1234
- A(I, { "close-on-click": !1 }, {
1235
- "menu-button": j(() => [
1236
- A(i, {
1237
- variant: "secondary",
1238
- "prepend-icon": "tune",
1239
- size: "md",
1240
- disabled: o.disabled,
1241
- label: `Units ${b.value}/${a.value.length}`
1242
- }, null, 8, ["disabled", "label"])
1243
- ]),
1244
- default: j(() => [
1245
- (_(!0), T(Y, null, X(a.value, (y) => (_(), W(F, {
1246
- key: y.id,
1247
- "model-value": y.enabled,
1248
- "has-checkbox": "",
1249
- label: y.label,
1250
- sublabel: l(y),
1251
- disabled: o.disabled || y.enabled && b.value === 1,
1252
- onClick: (x) => h(y)
1253
- }, null, 8, ["model-value", "label", "sublabel", "disabled", "onClick"]))), 128))
1254
- ]),
1255
- _: 1
1256
- }),
1257
- A(i, {
1258
- disabled: o.disabled,
1259
- icon: "delete",
1260
- variant: "tertiary",
1261
- size: "md",
1262
- onClick: g[0] || (g[0] = (y) => k("delete"))
1263
- }, null, 8, ["disabled"])
1264
- ])
1265
- ]);
1266
- };
1267
- }
1268
- });
1269
- function fo(m) {
1270
- const t = V("");
1271
- Ce(m, () => {
1272
- t.value = "";
1273
- });
1274
- const e = U(() => t.value.trim().length > 0);
1275
- function k(a) {
1276
- const u = t.value.trim().toLowerCase();
1277
- return u ? a.filter(
1278
- (b) => b.sku.name.toLowerCase().includes(u) || b.sku.code.toLowerCase().includes(u)
1279
- ) : a;
1280
- }
1281
- return { searchQuery: t, hasQuery: e, filterItems: k };
1282
- }
1283
- const yo = { class: "flex flex-col gap-12" }, vo = { class: "flex items-start justify-between gap-8" }, go = { class: "flex flex-col" }, bo = { class: "flex items-center gap-8" }, ho = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _o = { class: "flex gap-8 shrink-0" }, xo = { class: "flex flex-wrap items-center gap-8" }, ko = ["onClick"], wo = { class: "fm-typo-en-body-md-600 whitespace-nowrap" }, $o = ["disabled"], To = { class: "rounded-lg border border-fm-color-neutral-gray-200 overflow-hidden" }, Co = { class: "flex items-center gap-12 px-16 py-12 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-50" }, Io = {
1284
- key: 0,
1285
- class: "flex-1 flex items-baseline gap-8 min-w-0"
1286
- }, Fo = {
1287
- key: 1,
1288
- class: "flex-1 min-w-0"
1289
- }, Do = {
1290
- class: "fm-typo-en-body-sm-600 text-fm-color-typo-secondary bg-fm-color-neutral-gray-100 rounded-full shrink-0",
1291
- style: { padding: "4px 10px" }
1292
- }, So = {
1293
- key: 0,
1294
- class: "flex items-center gap-8 px-16 py-8 border-b border-fm-color-neutral-gray-200 bg-white"
1295
- }, Ao = {
1296
- key: 1,
1297
- class: "flex items-center gap-4 px-16 py-8 border-b border-fm-color-neutral-gray-200 bg-fm-color-neutral-gray-50 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1298
- }, Ro = {
1299
- key: 2,
1300
- class: "flex flex-col"
1301
- }, Po = ["draggable", "onDragstart", "onDrop"], Mo = {
1302
- key: 0,
1303
- class: "m-16 rounded-lg border border-dashed border-fm-color-neutral-gray-300 text-center fm-typo-en-body-sm-400 text-fm-color-typo-secondary",
1304
- style: { padding: "24px" }
1305
- }, Eo = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-primary" }, No = {
1306
- key: 1,
1307
- class: "m-16 rounded-lg border border-dashed border-fm-color-neutral-gray-300 text-center fm-typo-en-body-sm-400 text-fm-color-typo-secondary",
1308
- style: { padding: "24px" }
1309
- }, Bo = {
1310
- key: 3,
1311
- class: "flex flex-col"
1312
- }, Lo = {
1313
- key: 0,
1314
- class: "m-16 rounded-lg border border-dashed border-fm-color-neutral-gray-300 text-center fm-typo-en-body-sm-400 text-fm-color-typo-secondary",
1315
- style: { padding: "24px" }
1316
- }, Uo = { class: "fm-typo-en-body-sm-600 text-fm-color-typo-primary" }, Vo = {
1317
- key: 1,
1318
- class: "m-16 rounded-lg border border-dashed border-fm-color-neutral-gray-300 text-center fm-typo-en-body-sm-400 text-fm-color-typo-secondary",
1319
- style: { padding: "24px" }
1320
- }, zo = ["draggable", "onDragstart", "onDrop"], Go = {
1321
- class: "flex items-center justify-center shrink-0 rounded-md border border-fm-color-neutral-gray-300 fm-typo-en-body-sm-600 text-fm-color-typo-secondary",
1322
- style: { width: "28px", height: "28px" }
1323
- }, Oo = { class: "flex-1 min-w-0" }, Ho = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, jo = {
1324
- class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary",
1325
- style: { "line-height": "1.2" }
1326
- }, Yo = {
1327
- class: "flex flex-wrap gap-4 justify-end",
1328
- style: { "max-width": "320px" }
1329
- }, Ko = /* @__PURE__ */ te({
1330
- __name: "ClosingTemplateGroupsEditor",
1331
- props: {
1332
- items: {},
1333
- groups: {},
1334
- updateItem: { type: Function },
1335
- deleteItem: { type: Function },
1336
- updateGroups: { type: Function },
1337
- disabled: { type: Boolean }
1338
- },
1339
- emits: ["reorderDefault", "addItems"],
1340
- setup(m, { emit: t }) {
1341
- const { promptSelectIngredients: e } = je(), k = Ie(), a = m, u = t, b = ["#EAB308", "#22C55E", "#3B82F6", "#A855F7", "#F97316", "#EC4899", "#14B8A6"], h = V("default"), { searchQuery: l, hasQuery: o, filterItems: g } = fo(h), i = U(() => a.groups ?? []);
1342
- function F(p) {
1343
- a.updateGroups(p);
1344
- }
1345
- function I() {
1346
- return `tmplGroup_${Date.now()}_${Math.floor(Math.random() * 1e4)}`;
1347
- }
1348
- const y = V(null), x = V(null);
1349
- function d(p, v, C) {
1350
- var E;
1351
- x.value = p, y.value = v, (E = C.dataTransfer) == null || E.setData("text/plain", String(v)), C.dataTransfer && (C.dataTransfer.effectAllowed = "move");
1352
- }
1353
- function $(p, v, C) {
1354
- const E = [...p], [L] = E.splice(v, 1);
1355
- return E.splice(C, 0, L), E;
1356
- }
1357
- function n(p, v) {
1358
- const C = y.value, E = x.value;
1359
- if (y.value = null, x.value = null, !(C === null || E !== p || C === v))
1360
- if (p === "default")
1361
- u(
1362
- "reorderDefault",
1363
- $(
1364
- a.items.map((L) => L.sku._id),
1365
- C,
1366
- v
1367
- )
1368
- );
1369
- else {
1370
- const L = O(p);
1371
- L && ae(
1372
- p,
1373
- $(
1374
- L.items.map((N) => N.skuId),
1375
- C,
1376
- v
1377
- )
1378
- );
1379
- }
1380
- }
1381
- const w = U(
1382
- () => Object.fromEntries(a.items.map((p) => [p.sku._id, p]))
1383
- );
1384
- Ce(
1385
- () => a.items.map((p) => p.sku._id),
1386
- (p) => {
1387
- const v = new Set(p);
1388
- let C = !1;
1389
- const E = i.value.map((L) => {
1390
- const N = L.items.filter((Q) => v.has(Q.skuId));
1391
- return N.length !== L.items.length ? (C = !0, { ...L, items: N }) : L;
1392
- });
1393
- C && F(E);
1394
- }
1395
- );
1396
- const S = U(() => {
1397
- const p = /* @__PURE__ */ new Map();
1398
- for (const C of i.value)
1399
- for (const E of C.items) p.set(E.skuId, (p.get(E.skuId) ?? 0) + 1);
1400
- let v = 0;
1401
- return p.forEach((C) => {
1402
- C > 1 && v++;
1403
- }), v;
1404
- }), P = U(() => {
1405
- const p = i.value.length;
1406
- return `${a.items.length} items in Default · ${S.value} shared across named groups · ${p + 1} total groups (${p} named + Default)`;
1407
- }), s = U(() => [
1408
- { id: "default", isDefault: !0, name: "Default", color: null, itemCount: a.items.length },
1409
- ...i.value.map((p, v) => ({
1410
- id: p.id,
1411
- isDefault: !1,
1412
- name: p.name,
1413
- color: b[v % b.length],
1414
- itemCount: p.items.length
1415
- }))
1416
- ]), c = U(
1417
- () => s.value.find((p) => p.id === h.value) ?? s.value[0]
1418
- ), M = U(() => c.value.isDefault), R = U(
1419
- () => M.value ? [] : re(h.value)
1420
- );
1421
- function B(p) {
1422
- return h.value === p;
1423
- }
1424
- function z() {
1425
- const p = I();
1426
- F([...i.value, { id: p, name: `Group ${i.value.length + 1}`, items: [] }]), h.value = p;
1427
- }
1428
- function O(p) {
1429
- return i.value.find((v) => v.id === p) ?? null;
1430
- }
1431
- function ce(p) {
1432
- F(i.value.filter((v) => v.id !== p)), h.value === p && (h.value = "default");
1433
- }
1434
- function ee(p, v) {
1435
- k.open({
1436
- title: `Delete group "${v || "Untitled"}"?`,
1437
- closeButton: !1,
1438
- message: "This removes the group and its item selection. The items stay in Default and other groups.",
1439
- primaryActions: { text: "Delete", close: !0, variant: "destructive" },
1440
- secondaryActions: { text: "Cancel", close: !0 }
1441
- }).onPrimary(() => ce(p));
1442
- }
1443
- function se(p, v) {
1444
- F(i.value.map((C) => C.id === p ? { ...C, name: v } : C));
1445
- }
1446
- function ae(p, v) {
1447
- F(
1448
- i.value.map(
1449
- (C) => C.id === p ? { ...C, items: v.map((E, L) => ({ skuId: E, position: L })) } : C
1450
- )
1451
- );
1452
- }
1453
- async function pe(p) {
1454
- if (a.disabled) return;
1455
- const v = O(p);
1456
- if (!v) return;
1457
- const C = await e(
1458
- v.items.map((E) => E.skuId),
1459
- (E) => E,
1460
- a.items.map((E) => E.sku)
1461
- );
1462
- C && ae(p, C);
1463
- }
1464
- function fe() {
1465
- M.value ? u("addItems") : pe(h.value);
1466
- }
1467
- function ye(p, v) {
1468
- const C = O(p);
1469
- if (!C) return;
1470
- const E = C.items.some((L) => L.skuId === v) ? C.items.filter((L) => L.skuId !== v).map((L) => L.skuId) : [...C.items.map((L) => L.skuId), v];
1471
- ae(p, E);
1472
- }
1473
- function re(p) {
1474
- const v = O(p);
1475
- return v ? v.items.map((C) => w.value[C.skuId]).filter(Boolean) : [];
1476
- }
1477
- const le = U(() => g(a.items)), ie = U(
1478
- () => g(R.value)
1479
- ), ve = U(
1480
- () => o.value ? M.value ? le.value.length : ie.value.length : c.value.itemCount
1481
- );
1482
- function ge(p) {
1483
- const v = B(p.id);
1484
- if (p.isDefault)
1485
- return v ? { background: "#1F2937", color: "#FFFFFF", border: "1px solid #1F2937" } : { background: "#FFFFFF", color: "#374151", border: "1px solid #E5E7EB" };
1486
- const C = p.color || "#999999";
1487
- return v ? { background: C, color: me(C), border: `1px solid ${C}` } : { background: `${C}1A`, color: "#374151", border: `1px solid ${C}` };
1488
- }
1489
- function me(p) {
1490
- const v = p.replace("#", ""), C = parseInt(v.slice(0, 2), 16), E = parseInt(v.slice(2, 4), 16), L = parseInt(v.slice(4, 6), 16);
1491
- return (0.299 * C + 0.587 * E + 0.114 * L) / 255 > 0.6 ? "#1F2937" : "#FFFFFF";
1492
- }
1493
- function be(p) {
1494
- return B(p.id) ? (p.isDefault ? "#FFFFFF" : me(p.color || "#999999")) === "#FFFFFF" ? { background: "rgba(255,255,255,0.25)", color: "#FFFFFF" } : { background: "rgba(0,0,0,0.12)", color: "#1F2937" } : { background: "rgba(0,0,0,0.06)", color: "inherit" };
1495
- }
1496
- return (p, v) => {
1497
- const C = G("FmButton"), E = G("FmIcon"), L = G("FmTextField");
1498
- return _(), T("div", yo, [
1499
- r("div", vo, [
1500
- r("div", go, [
1501
- r("div", bo, [
1502
- v[6] || (v[6] = r("div", { class: "fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, "Groups & items", -1)),
1503
- A(kt, {
1504
- tier: "standard",
1505
- category: "beta"
1506
- })
1507
- ]),
1508
- r("div", ho, D(P.value), 1)
1509
- ]),
1510
- r("div", _o, [
1511
- A(C, {
1512
- disabled: p.disabled,
1513
- label: "New Group",
1514
- "prepend-icon": "add",
1515
- variant: "primary",
1516
- size: "md",
1517
- class: "rounded-lg",
1518
- onClick: z
1519
- }, null, 8, ["disabled"])
1520
- ])
1521
- ]),
1522
- v[15] || (v[15] = Je('<div class="flex items-start gap-8 p-12 fm-corner-radius-md border-1 border-yellow-500 bg-yellow-50 text-yellow-700"><div class="flex flex-col gap-2"><div class="fm-typo-en-body-md-600 text-fm-color-typo-primary">📦 Closing Groups</div><div class="fm-typo-en-body-sm-400"> Split a closing template into named groups (e.g. by section, fridge, or station) so several staff can stock take in parallel and you manage them in one place. Group stock take is currently only available in the Inventory mobile app — it&#39;s not yet available in POS. You can keep using the <span class="fm-typo-en-body-sm-600 text-fm-color-typo-primary">Default (master list)</span> group as usual. </div></div></div>', 1)),
1523
- r("div", xo, [
1524
- (_(!0), T(Y, null, X(s.value, (N) => (_(), T("button", {
1525
- key: N.id,
1526
- type: "button",
1527
- class: "flex items-center rounded-full",
1528
- style: De([{ gap: "8px", padding: "6px 14px" }, ge(N)]),
1529
- onClick: (Q) => h.value = N.id
1530
- }, [
1531
- r("span", wo, D(N.name), 1),
1532
- r("span", {
1533
- class: "fm-typo-en-body-sm-600 rounded-full",
1534
- style: De([{ padding: "0 8px" }, be(N)])
1535
- }, D(N.itemCount), 5)
1536
- ], 12, ko))), 128)),
1537
- r("button", {
1538
- type: "button",
1539
- disabled: p.disabled,
1540
- class: "flex items-center rounded-full border border-dashed border-fm-color-neutral-gray-400 text-fm-color-typo-secondary",
1541
- style: { gap: "6px", padding: "6px 14px" },
1542
- onClick: z
1543
- }, [
1544
- A(E, {
1545
- name: "add",
1546
- size: "sm"
1547
- }),
1548
- v[7] || (v[7] = r("span", { class: "fm-typo-en-body-md-400 whitespace-nowrap" }, "New group", -1))
1549
- ], 8, $o)
1550
- ]),
1551
- r("div", To, [
1552
- r("div", Co, [
1553
- M.value ? (_(), T("div", Io, v[8] || (v[8] = [
1554
- r("span", { class: "fm-typo-en-body-lg-600 italic text-fm-color-typo-primary" }, "Default", -1),
1555
- r("span", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary truncate" }, " master list · sets the item pool & units ", -1)
1556
- ]))) : (_(), T("div", Fo, [
1557
- A(L, {
1558
- "model-value": c.value.name,
1559
- disabled: p.disabled,
1560
- placeholder: "Group name",
1561
- "onUpdate:modelValue": v[0] || (v[0] = (N) => se(h.value, N))
1562
- }, null, 8, ["model-value", "disabled"])
1563
- ])),
1564
- r("span", Do, [
1565
- f(o) ? (_(), T(Y, { key: 0 }, [
1566
- K(D(ve.value) + " of " + D(c.value.itemCount), 1)
1567
- ], 64)) : (_(), T(Y, { key: 1 }, [
1568
- K(D(c.value.itemCount), 1)
1569
- ], 64)),
1570
- v[9] || (v[9] = K(" items "))
1571
- ]),
1572
- M.value ? H("", !0) : (_(), W(C, {
1573
- key: 2,
1574
- disabled: p.disabled,
1575
- label: "Delete group",
1576
- "prepend-icon": "delete",
1577
- variant: "secondary",
1578
- size: "md",
1579
- class: "rounded-lg shrink-0",
1580
- onClick: v[1] || (v[1] = (N) => ee(h.value, c.value.name))
1581
- }, null, 8, ["disabled"])),
1582
- A(C, {
1583
- disabled: p.disabled,
1584
- label: "Add items",
1585
- "prepend-icon": "add",
1586
- variant: "primary",
1587
- size: "md",
1588
- class: "rounded-lg shrink-0",
1589
- onClick: fe
1590
- }, null, 8, ["disabled"])
1591
- ]),
1592
- c.value.itemCount > 0 || f(o) ? (_(), T("div", So, [
1593
- A(E, {
1594
- name: "search",
1595
- size: "sm",
1596
- color: "neutral-gray-400",
1597
- class: "shrink-0"
1598
- }),
1599
- qe(r("input", {
1600
- "onUpdate:modelValue": v[2] || (v[2] = (N) => Ue(l) ? l.value = N : null),
1601
- type: "search",
1602
- "aria-label": "Search items by name or code",
1603
- placeholder: "Search items by name or code...",
1604
- class: "flex-1 bg-transparent outline-none fm-typo-en-body-md-400 text-fm-color-typo-primary placeholder:text-fm-color-typo-disabled"
1605
- }, null, 512), [
1606
- [Xe, f(l)]
1607
- ]),
1608
- f(o) ? (_(), T("button", {
1609
- key: 0,
1610
- type: "button",
1611
- "aria-label": "Clear search",
1612
- title: "Clear search",
1613
- class: "flex items-center text-fm-color-typo-secondary hover:text-fm-color-typo-primary",
1614
- onClick: v[3] || (v[3] = (N) => l.value = "")
1615
- }, [
1616
- A(E, {
1617
- name: "close",
1618
- size: "sm"
1619
- })
1620
- ])) : H("", !0)
1621
- ])) : H("", !0),
1622
- !f(o) && c.value.itemCount > 1 ? (_(), T("div", Ao, [
1623
- A(E, {
1624
- name: "drag_indicator",
1625
- size: "sm",
1626
- color: "neutral-gray-400",
1627
- class: "shrink-0"
1628
- }),
1629
- v[10] || (v[10] = K(" Drag a row to reorder items. "))
1630
- ])) : H("", !0),
1631
- M.value ? (_(), T("div", Ro, [
1632
- (_(!0), T(Y, null, X(le.value, (N, Q) => (_(), T("div", {
1633
- key: N.sku._id,
1634
- draggable: !f(o),
1635
- onDragstart: (q) => !f(o) && d("default", Q, q),
1636
- onDragover: v[4] || (v[4] = he(() => {
1637
- }, ["prevent"])),
1638
- onDrop: he((q) => !f(o) && n("default", Q), ["prevent"]),
1639
- class: Z(["flex items-center gap-4 px-16 border-b border-fm-color-neutral-gray-200 hover:bg-fm-color-neutral-gray-100", f(o) ? "cursor-default" : "cursor-grab"])
1640
- }, [
1641
- f(o) ? H("", !0) : (_(), W(E, {
1642
- key: 0,
1643
- name: "drag_indicator",
1644
- size: "sm",
1645
- color: "neutral-gray-400",
1646
- class: "shrink-0"
1647
- })),
1648
- A(po, {
1649
- class: "flex-1 min-w-0",
1650
- item: N,
1651
- index: Q,
1652
- disabled: p.disabled,
1653
- onUpdate: p.updateItem,
1654
- onDelete: (q) => p.deleteItem(N)
1655
- }, null, 8, ["item", "index", "disabled", "onUpdate", "onDelete"])
1656
- ], 42, Po))), 128)),
1657
- f(o) && p.items.length > 0 && !le.value.length ? (_(), T("div", Mo, [
1658
- v[11] || (v[11] = K(" No items match ")),
1659
- r("span", Eo, D(f(l)), 1)
1660
- ])) : p.items.length ? H("", !0) : (_(), T("div", No, v[12] || (v[12] = [
1661
- K(" No items yet — click "),
1662
- r("span", { class: "fm-typo-en-body-sm-600 text-fm-color-typo-primary" }, "+ Add items", -1),
1663
- K(" to add from your catalog. ")
1664
- ])))
1665
- ])) : (_(), T("div", Bo, [
1666
- f(o) && R.value.length > 0 && !ie.value.length ? (_(), T("div", Lo, [
1667
- v[13] || (v[13] = K(" No items match ")),
1668
- r("span", Uo, D(f(l)), 1)
1669
- ])) : R.value.length ? H("", !0) : (_(), T("div", Vo, v[14] || (v[14] = [
1670
- K(" No items yet — click "),
1671
- r("span", { class: "fm-typo-en-body-sm-600 text-fm-color-typo-primary" }, "+ Add items", -1),
1672
- K(" on this group to assign items. ")
1673
- ]))),
1674
- (_(!0), T(Y, null, X(ie.value, (N, Q) => (_(), T("div", {
1675
- key: N.sku._id,
1676
- draggable: !f(o),
1677
- onDragstart: (q) => !f(o) && d(h.value, Q, q),
1678
- onDragover: v[5] || (v[5] = he(() => {
1679
- }, ["prevent"])),
1680
- onDrop: he((q) => !f(o) && n(h.value, Q), ["prevent"]),
1681
- class: Z(["flex items-center gap-12 px-16 py-12 border-b border-fm-color-neutral-gray-200 hover:bg-fm-color-neutral-gray-100", f(o) ? "cursor-default" : "cursor-grab"])
1682
- }, [
1683
- f(o) ? H("", !0) : (_(), W(E, {
1684
- key: 0,
1685
- name: "drag_indicator",
1686
- size: "sm",
1687
- color: "neutral-gray-400",
1688
- class: "shrink-0"
1689
- })),
1690
- r("span", Go, D(R.value.findIndex((q) => q.sku._id === N.sku._id) + 1), 1),
1691
- r("div", Oo, [
1692
- r("div", Ho, D(N.sku.code), 1),
1693
- r("div", jo, D(N.sku.name), 1)
1694
- ]),
1695
- r("div", Yo, [
1696
- (_(!0), T(Y, null, X(f(to)(N), (q, We) => (_(), T("span", {
1697
- key: We,
1698
- class: "px-8 py-2 rounded-full border border-fm-color-neutral-gray-200 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1699
- }, D(q), 1))), 128))
1700
- ]),
1701
- A(C, {
1702
- disabled: p.disabled,
1703
- icon: "delete",
1704
- variant: "tertiary",
1705
- size: "md",
1706
- onClick: (q) => ye(h.value, N.sku._id)
1707
- }, null, 8, ["disabled", "onClick"])
1708
- ], 42, zo))), 128))
1709
- ]))
1710
- ])
1711
- ]);
1712
- };
1713
- }
1714
- }), Wo = { class: "flex flex-col gap-16" }, Qo = { class: "flex flex-col gap-24" }, Jo = { class: "flex flex-col gap-16" }, qo = { class: "flex items-center" }, Xo = { class: "flex-1 fm-typo-en-title-sm-600" }, Zo = { class: "flex flex-col gap-16" }, en = { class: "flex items-center" }, tn = { class: "flex-1 gap-8 fm-typo-en-title-sm-600" }, on = /* @__PURE__ */ te({
1715
- __name: "ClosingTemplateForm",
1716
- props: {
1717
- modelValue: {},
1718
- disabled: { type: Boolean }
1719
- },
1720
- setup(m, { expose: t }) {
1721
- const e = xt(), { t: k } = ne(), a = Ae(), {
1722
- promptSelectLocations: u,
1723
- columnDefs: b,
1724
- rowData: h
1725
- } = wt({
1726
- getLocations() {
1727
- return e.locations;
1728
- },
1729
- setLocations(d) {
1730
- e.locations = d;
1731
- }
1732
- }), l = V(), o = U(() => e.items.map((d, $) => ({ item: d, originalIndex: $ })).sort((d, $) => {
1733
- const n = d.item.position ?? d.originalIndex, w = $.item.position ?? $.originalIndex;
1734
- return n - w;
1735
- }).map(({ item: d }) => d));
1736
- function g(d) {
1737
- const $ = new Map(e.items.map((w) => [w.sku._id, w])), n = [];
1738
- d.forEach((w, S) => {
1739
- const P = $.get(w);
1740
- P && n.push({ ...P, position: S });
1741
- }), e.items = n;
1742
- }
1743
- t({
1744
- validateInputs: () => {
1745
- var d, $;
1746
- ($ = (d = l.value) == null ? void 0 : d.validateInputs) == null || $.call(d);
1747
- },
1748
- resetInputsValidation: () => {
1749
- var d, $;
1750
- ($ = (d = l.value) == null ? void 0 : d.resetInputsValidation) == null || $.call(d);
1751
- },
1752
- resetInputs: () => {
1753
- var d, $;
1754
- ($ = (d = l.value) == null ? void 0 : d.resetInputs) == null || $.call(d);
1755
- }
1756
- });
1757
- function i(d) {
1758
- e.items = e.items.map(($) => $.sku._id === d.sku._id ? d : $);
1759
- }
1760
- function F(d) {
1761
- e.items = e.items.filter(($) => $.sku._id !== d.sku._id);
1762
- }
1763
- function I(d) {
1764
- e.groups = d;
1765
- }
1766
- const { promptSelectIngredients: y } = je();
1767
- async function x() {
1768
- const $ = a.skus.map((S) => ({
1769
- label: S.name,
1770
- sublabel: S.code,
1771
- value: S
1772
- })).filter((S) => {
1773
- var P;
1774
- return (P = e.items) == null ? void 0 : P.find((s) => s.sku._id === S.value._id);
1775
- }).map((S) => S.value), n = e.items ?? [], w = await y(
1776
- $.map((S) => S._id),
1777
- (S) => {
1778
- const P = a.skuById[S], s = n.find((M) => M.sku._id === P._id);
1779
- return s || {
1780
- sku: P
1781
- };
1782
- }
1783
- );
1784
- w && (w.sort((S, P) => S.sku.code.localeCompare(P.sku.code)), e.items = w);
1785
- }
1786
- return (d, $) => {
1787
- const n = G("FmTextField"), w = G("FmButton"), S = G("FmTable"), P = G("FmFormGroup"), s = G("FmForm");
1788
- return _(), W(s, {
1789
- ref_key: "formRef",
1790
- ref: l,
1791
- class: "flex flex-col gap-32",
1792
- disabled: d.disabled
1793
- }, {
1794
- default: j(() => [
1795
- r("div", Wo, [
1796
- r("div", Qo, [
1797
- A(n, {
1798
- label: f(k)("inventory.closing.form.name"),
1799
- "label-mark": "required",
1800
- modelValue: f(e).name,
1801
- "onUpdate:modelValue": $[0] || ($[0] = (c) => f(e).name = c),
1802
- rules: [f(ht)()]
1803
- }, null, 8, ["label", "modelValue", "rules"]),
1804
- A(n, {
1805
- label: f(k)("inventory.closing.form.reference"),
1806
- "label-mark": "optional",
1807
- modelValue: f(e).ref,
1808
- "onUpdate:modelValue": $[1] || ($[1] = (c) => f(e).ref = c)
1809
- }, null, 8, ["label", "modelValue"])
1810
- ])
1811
- ]),
1812
- r("div", Jo, [
1813
- r("div", qo, [
1814
- r("div", Xo, D(f(k)("inventory.closing.form.locations")), 1),
1815
- A(w, {
1816
- disabled: d.disabled,
1817
- label: f(k)("inventory.closing.form.selectLocation"),
1818
- "prepend-icon": "add",
1819
- variant: "plain",
1820
- class: "border-2 rounded-lg border-fm-color-primary",
1821
- onClick: f(u)
1822
- }, null, 8, ["disabled", "label", "onClick"])
1823
- ]),
1824
- A(S, {
1825
- "column-defs": f(b),
1826
- "row-data": f(h),
1827
- "shrink-at": 9999,
1828
- onRowClick: f(u),
1829
- "hide-footer": ""
1830
- }, null, 8, ["column-defs", "row-data", "onRowClick"])
1831
- ]),
1832
- r("div", Zo, [
1833
- r("div", en, [
1834
- r("div", tn, D(f(k)("inventory.closing.form.items.title")), 1)
1835
- ]),
1836
- A(Ko, {
1837
- items: o.value,
1838
- groups: f(e).groups,
1839
- "update-item": i,
1840
- "delete-item": F,
1841
- "update-groups": I,
1842
- disabled: d.disabled,
1843
- onReorderDefault: g,
1844
- onAddItems: x
1845
- }, null, 8, ["items", "groups", "disabled"]),
1846
- A(P, {
1847
- "model-value": f(e).items.length,
1848
- rules: [f(_t)(1)]
1849
- }, null, 8, ["model-value", "rules"])
1850
- ])
1851
- ]),
1852
- _: 1
1853
- }, 8, ["disabled"]);
1854
- };
1855
- }
1856
- }), nn = { class: "flex items-center" }, sn = { class: "fm-typo-en-title-md-600" }, an = { class: "flex justify-between" }, rn = { class: "fm-typo-en-body-lg-600" }, ln = { class: "flex flex-col gap-8" }, cn = { class: "flex flex-col gap-4" }, mn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, dn = { class: "flex items-center gap-8" }, un = { class: "fm-typo-en-body-lg-600" }, pn = { class: "flex gap-4" }, fn = /* @__PURE__ */ te({
1857
- __name: "ClosingTemplateDialog",
1858
- props: {
1859
- mode: {},
1860
- modelValue: {},
1861
- show: { type: Boolean }
1862
- },
1863
- emits: ["update:show", "submitted"],
1864
- setup(m, { expose: t, emit: e }) {
1865
- var P;
1866
- const k = m, a = e, u = ue(), b = Te(), h = de(), { t: l } = ne(), o = lt(k, "show");
1867
- function g() {
1868
- return {
1869
- _id: "",
1870
- name: "",
1871
- items: []
1872
- };
1873
- }
1874
- const i = V(k.modelValue ?? g()), F = V(((P = k.modelValue) == null ? void 0 : P._id) ?? `${Math.random()}`);
1875
- Ce(
1876
- () => k.show,
1877
- (s) => {
1878
- var c;
1879
- s && (i.value = k.modelValue ?? g(), F.value = ((c = k.modelValue) == null ? void 0 : c._id) ?? `${Math.random()}`);
1880
- }
1881
- );
1882
- const I = V(!1), y = U(() => {
1883
- switch (k.mode) {
1884
- case oe.READ:
1885
- return "";
1886
- case oe.CREATE:
1887
- return l("inventory.closing.template.create.title");
1888
- case oe.UPDATE:
1889
- return l("inventory.closing.template.update.title");
1890
- }
1891
- return "";
1892
- }), x = V();
1893
- t({
1894
- validateInputs: () => {
1895
- var s, c;
1896
- (c = (s = x.value) == null ? void 0 : s.validateInputs) == null || c.call(s);
1897
- },
1898
- resetInputsValidation: () => {
1899
- var s, c;
1900
- (c = (s = x.value) == null ? void 0 : s.resetInputsValidation) == null || c.call(s);
1901
- },
1902
- resetInputs: () => {
1903
- var s, c;
1904
- (c = (s = x.value) == null ? void 0 : s.resetInputs) == null || c.call(s);
1905
- }
1906
- });
1907
- async function d() {
1908
- const s = i.value;
1909
- if (s) {
1910
- I.value = !0;
1911
- try {
1912
- await u.createTemplate(s), await new Promise((c) => setTimeout(c, 1e3)), h.open({
1913
- title: l("inventory.closing.template.create.success"),
1914
- message: l("inventory.closing.template.create.successMessage"),
1915
- type: "success"
1916
- }), a("update:show", !1), a("submitted");
1917
- } catch (c) {
1918
- h.open({
1919
- title: l("inventory.closing.template.create.error"),
1920
- message: l("inventory.closing.template.create.errorMessage"),
1921
- type: "error"
1922
- }), console.error("Error in creating closing template", c);
1923
- } finally {
1924
- I.value = !1;
1925
- }
1926
- }
1927
- }
1928
- async function $() {
1929
- const s = i.value;
1930
- if (s) {
1931
- I.value = !0, delete s.updatedAt;
1932
- try {
1933
- await u.updateTemplate({
1934
- ...s,
1935
- _rev: s._rev ?? ""
1936
- }), await new Promise((c) => setTimeout(c, 1e3)), h.open({
1937
- title: l("inventory.closing.template.update.success"),
1938
- message: l("inventory.closing.template.update.successMessage"),
1939
- type: "success"
1940
- }), a("update:show", !1), a("submitted");
1941
- } catch (c) {
1942
- h.open({
1943
- title: l("inventory.closing.template.update.error"),
1944
- message: l("inventory.closing.template.update.errorMessage"),
1945
- type: "error"
1946
- }), console.error("Error in updating closing template", c);
1947
- } finally {
1948
- I.value = !1;
1949
- }
1950
- }
1951
- }
1952
- function n() {
1953
- switch (k.mode) {
1954
- case oe.CREATE:
1955
- return d();
1956
- case oe.UPDATE:
1957
- return $();
1958
- }
1959
- }
1960
- function w() {
1961
- var s, c;
1962
- (c = (s = x.value) == null ? void 0 : s.validateInputs) == null || c.call(s);
1963
- }
1964
- function S() {
1965
- i.value && b.exportSingleTemplate(i.value);
1966
- }
1967
- return (s, c) => {
1968
- const M = G("FmMenuDivider"), R = G("FmCard"), B = G("FmButton"), z = G("FmSideSheet");
1969
- return _(), W(z, {
1970
- modelValue: f(o),
1971
- "onUpdate:modelValue": c[2] || (c[2] = (O) => Ue(o) ? o.value = O : null),
1972
- "dismiss-away": "",
1973
- "close-button": "",
1974
- "max-width": 9999
1975
- }, {
1976
- "side-sheet-header": j(() => [
1977
- r("div", nn, [
1978
- r("div", sn, D(y.value), 1)
1979
- ])
1980
- ]),
1981
- default: j(() => [
1982
- i.value.updatedAt ? (_(), W(R, {
1983
- key: 0,
1984
- variant: "outlined",
1985
- class: "flex flex-col gap-8 px-12 py-16 mb-16"
1986
- }, {
1987
- default: j(() => {
1988
- var O;
1989
- return [
1990
- r("div", an, [
1991
- r("div", rn, D(f(l)("inventory.transfer.template.details.templateSummary")), 1)
1992
- ]),
1993
- A(M),
1994
- r("div", ln, [
1995
- r("div", cn, [
1996
- r("div", mn, D(f(l)("inventory.transfer.receiveRequest.details.updatedAt")), 1),
1997
- r("div", dn, [
1998
- r("div", un, [
1999
- K(D(f(we)(i.value.updatedAt)) + " ", 1),
2000
- (O = i.value.updatedBy) != null && O.name ? (_(), T(Y, { key: 0 }, [
2001
- K(" (" + D(i.value.updatedBy.name) + ") ", 1)
2002
- ], 64)) : H("", !0)
2003
- ]),
2004
- A($t, {
2005
- "closing-id": i.value._id
2006
- }, null, 8, ["closing-id"])
2007
- ])
2008
- ])
2009
- ])
2010
- ];
2011
- }),
2012
- _: 1
2013
- })) : H("", !0),
2014
- (_(), W(on, {
2015
- class: "w-full",
2016
- ref_key: "formRef",
2017
- ref: x,
2018
- onValidationSuccess: n,
2019
- "model-value": i.value,
2020
- "onUpdate:modelValue": c[0] || (c[0] = (O) => i.value = O),
2021
- disabled: I.value,
2022
- key: F.value
2023
- }, null, 8, ["model-value", "disabled"]))
2024
- ]),
2025
- "side-sheet-footer": j(() => [
2026
- r("div", pn, [
2027
- A(B, {
2028
- loading: I.value,
2029
- label: f(l)("common.save"),
2030
- onClick: w
2031
- }, null, 8, ["loading", "label"]),
2032
- s.mode === f(oe).UPDATE ? (_(), W(B, {
2033
- key: 0,
2034
- disabled: I.value,
2035
- variant: "secondary",
2036
- label: f(l)("inventory.common.export"),
2037
- "prepend-icon": "download",
2038
- onClick: S
2039
- }, null, 8, ["disabled", "label"])) : H("", !0),
2040
- A(B, {
2041
- disabled: I.value,
2042
- variant: "tertiary",
2043
- label: f(l)("common.close"),
2044
- onClick: c[1] || (c[1] = (O) => a("update:show", !1))
2045
- }, null, 8, ["disabled", "label"])
2046
- ])
2047
- ]),
2048
- _: 1
2049
- }, 8, ["modelValue"]);
2050
- };
2051
- }
2052
- }), yn = {};
2053
- function vn(m, t) {
2054
- return _(), T("div");
2055
- }
2056
- const gn = /* @__PURE__ */ Ct(yn, [["render", vn]]), bn = { class: "flex flex-col gap-40" }, hn = { key: 0 }, _n = {
2057
- key: 1,
2058
- class: "flex gap-8 items-center"
2059
- }, xn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary" }, kn = {
2060
- key: 2,
2061
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary"
2062
- }, wn = {
2063
- key: 3,
2064
- class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary flex flex-col gap-12"
2065
- }, $n = { class: "fm-typo-en-body-md-600" }, Tn = { class: "fm-typo-en-body-md-600" }, Cn = { key: 4 }, In = { class: "fm-typo-en-body-md-600" }, Fn = { class: "fm-typo-en-body-md-600" }, Dn = { class: "flex sm:flex-col xs:flex-col justify-end gap-8 w-full mb-16" }, Sn = /* @__PURE__ */ te({
2066
- __name: "ClosingTemplatePublish",
2067
- emits: ["close"],
2068
- setup(m, { emit: t }) {
2069
- const e = V(!1), k = de(), a = ue(), u = Ne(), { t: b } = ne(), h = t;
2070
- async function l() {
2071
- e.value = !0;
2072
- try {
2073
- await a.startNewPublish().delayed(1e3), k.open({
2074
- title: "Success",
2075
- message: "You may refresh after a while to review publish status",
2076
- type: "success"
2077
- }), i();
2078
- } catch (F) {
2079
- k.open({
2080
- title: "Something went wrong",
2081
- message: "Please try again",
2082
- type: "error"
2083
- }), console.error("error on creating publish task", F);
2084
- } finally {
2085
- e.value = !1;
2086
- }
2087
- }
2088
- const o = U(() => u.recentPublish.recentJob), g = U(
2089
- () => u.templates.length && (!o.value || o.value.outlets.length === o.value.completed.length)
2090
- );
2091
- function i() {
2092
- h("close");
2093
- }
2094
- return (F, I) => {
2095
- const y = G("FmCircularProgress"), x = G("i18n-t"), d = G("FmButton");
2096
- return _(), T("div", bn, [
2097
- f(u).templates.length ? e.value ? (_(), T("div", _n, [
2098
- r("div", null, [
2099
- A(y, {
2100
- size: "md",
2101
- color: "neutral-gray-300"
2102
- })
2103
- ]),
2104
- r("div", xn, [
2105
- r("span", null, D(f(b)("inventory.closing.template.publish.publishing")), 1)
2106
- ])
2107
- ])) : o.value ? o.value.outlets.length === o.value.completed.length ? (_(), T("div", wn, [
2108
- A(x, {
2109
- keypath: "inventory.closing.template.publish.recentlyPublishedAt",
2110
- tag: "p"
2111
- }, {
2112
- started: j(() => [
2113
- r("span", $n, D(f(we)(new Date(o.value.createdAt))), 1)
2114
- ]),
2115
- finished: j(() => [
2116
- r("span", Tn, D(f(we)(new Date(o.value.updatedAt))), 1)
2117
- ]),
2118
- _: 1
2119
- }),
2120
- r("p", null, D(f(b)("inventory.closing.template.publish.message")), 1)
2121
- ])) : (_(), T("div", Cn, [
2122
- A(x, {
2123
- keypath: "inventory.closing.template.publish.stillPublishing",
2124
- tag: "p"
2125
- }, {
2126
- started: j(() => [
2127
- r("span", In, D(f(we)(new Date(o.value.createdAt))), 1)
2128
- ]),
2129
- progress: j(() => [
2130
- r("span", Fn, " (" + D(o.value.completed.length) + "/" + D(o.value.outlets.length) + " completed) ", 1)
2131
- ]),
2132
- _: 1
2133
- }),
2134
- K(" Your recent publishing task is still pending (" + D(o.value.completed.length) + " / " + D(o.value.outlets.length) + "). Please wait until all publishing task has completed. ", 1)
2135
- ])) : (_(), T("div", kn, [
2136
- r("p", null, D(f(b)("inventory.closing.template.publish.noRecentActivity")), 1),
2137
- r("p", null, D(f(b)("inventory.closing.template.publish.message")), 1)
2138
- ])) : (_(), T("div", hn, [
2139
- r("p", null, D(f(b)("inventory.closing.template.publish.nothingToPublish")), 1)
2140
- ])),
2141
- r("div", Dn, [
2142
- A(d, {
2143
- disabled: !g.value,
2144
- loading: e.value,
2145
- label: "Publish to all outlets",
2146
- onClick: l
2147
- }, null, 8, ["disabled", "loading"]),
2148
- A(d, {
2149
- variant: "tertiary",
2150
- label: "Close",
2151
- onClick: i
2152
- })
2153
- ])
2154
- ]);
2155
- };
2156
- }
2157
- }), An = { class: "flex-1 flex flex-col gap-8" }, Rn = { class: "flex flex-col" }, Pn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Mn = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, En = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, Nn = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, ds = /* @__PURE__ */ te({
2158
- __name: "ClosingTemplateView",
2159
- setup(m) {
2160
- const { t } = ne(), { createTemplate: e, updateTemplate: k, exportTemplates: a, importTemplates: u } = Te(), { templateDialogProps: b, templateDetailsProps: h } = ze(Te()), l = Re(), o = Ie(), g = Ne(), i = nt(), { breakpoints: F } = it();
2161
- l.watchLocation(g.onLocationChanged);
2162
- const I = U(() => g.loading), y = V(""), x = V();
2163
- function d(M) {
2164
- var R;
2165
- (R = x.value) == null || R.openRowDetail(M);
2166
- }
2167
- async function $(M) {
2168
- const { toClosingTemplateListItem: R } = await import("./index-CrUvC9l4.js");
2169
- return { ...R(M), _rev: M._rev };
2170
- }
2171
- const n = U(() => F.value.xs || F.value.sm), w = U(() => n.value ? 10 : 20);
2172
- function S(M) {
2173
- switch (M) {
2174
- case J.Add:
2175
- return e();
2176
- case "publish":
2177
- return P();
2178
- case "import":
2179
- return u();
2180
- case "export":
2181
- return a();
2182
- case "refresh":
2183
- return g.refresh();
2184
- }
2185
- }
2186
- function P() {
2187
- o.open({
2188
- title: "Publish closing templates",
2189
- contentComponent: Sn,
2190
- contentComponentProps: {
2191
- onClose() {
2192
- o.close();
2193
- }
2194
- }
2195
- });
2196
- }
2197
- function s(M) {
2198
- return M;
2199
- }
2200
- const c = U(() => n.value ? [
2201
- {
2202
- label: t("inventory.closing.template.create.title"),
2203
- value: J.Add,
2204
- isPrimary: !0,
2205
- prependIcon: "add"
2206
- },
2207
- {
2208
- label: t("inventory.common.refresh"),
2209
- value: "refresh",
2210
- isPrimary: !1
2211
- },
2212
- {
2213
- label: t("inventory.common.publish"),
2214
- value: "publish",
2215
- isPrimary: !1
2216
- },
2217
- {
2218
- label: t("inventory.common.import"),
2219
- value: "import",
2220
- isPrimary: !1
2221
- },
2222
- {
2223
- label: t("inventory.common.export"),
2224
- value: "export",
2225
- isPrimary: !1
2226
- }
2227
- ] : [
2228
- {
2229
- label: t("inventory.closing.template.create.title"),
2230
- value: J.Add,
2231
- isPrimary: !0,
2232
- prependIcon: "add"
2233
- },
2234
- {
2235
- label: t("inventory.common.publish"),
2236
- value: "publish",
2237
- isPrimary: !1
2238
- },
2239
- {
2240
- label: t("inventory.common.import"),
2241
- value: "import",
2242
- isPrimary: !1
2243
- },
2244
- {
2245
- label: t("inventory.common.refresh"),
2246
- value: "refresh",
2247
- isPrimary: !1
2248
- },
2249
- {
2250
- label: t("inventory.common.export"),
2251
- value: "export",
2252
- isPrimary: !1
2253
- }
2254
- ]);
2255
- return (M, R) => (_(), T(Y, null, [
2256
- A(st, {
2257
- title: f(t)("inventory.closing.template.title"),
2258
- actions: c.value,
2259
- "onClick:action": S
2260
- }, {
2261
- default: j(() => [
2262
- r("div", {
2263
- class: Z([
2264
- "flex flex-col gap-8 max-h-full",
2265
- {
2266
- "p-0": n.value,
2267
- "px-24 ": !n.value
2268
- }
2269
- ])
2270
- }, [
2271
- A(gt, {
2272
- searchable: "",
2273
- search: y.value,
2274
- "onUpdate:search": R[0] || (R[0] = (B) => y.value = B)
2275
- }, null, 8, ["search"]),
2276
- A(bt, {
2277
- style: De(f(i).tableHeight),
2278
- "column-defs": f(g).columnDefs,
2279
- rows: f(g).templates,
2280
- "onUpdate:rows": R[1] || (R[1] = (B) => f(g).templates = B),
2281
- "fetch-page": f(g).fetchTemplatesPage,
2282
- "refresh-key": f(g).tableKey,
2283
- ref_key: "tableRef",
2284
- ref: x,
2285
- "search-value": y.value,
2286
- loading: I.value,
2287
- "fetch-detail": (B, z) => f(k)(B._id, z),
2288
- "detail-to-row": $,
2289
- "page-size": w.value
2290
- }, {
2291
- "list-row": j((B) => [
2292
- A(Tt, {
2293
- row: B,
2294
- onRowClick: (z) => d(z)
2295
- }, {
2296
- default: j((z) => {
2297
- var O, ce, ee, se, ae, pe, fe, ye, re, le, ie, ve, ge, me, be, p, v, C, E, L, N, Q;
2298
- return [
2299
- r("div", An, [
2300
- r("div", Rn, [
2301
- r("div", Pn, [
2302
- A(f(ke), {
2303
- render: (ee = (ce = (O = z._id) == null ? void 0 : O.column) == null ? void 0 : ce.columnDef) == null ? void 0 : ee.cell,
2304
- props: (ae = (se = z._id) == null ? void 0 : se.getContext) == null ? void 0 : ae.call(se)
2305
- }, null, 8, ["render", "props"])
2306
- ]),
2307
- r("div", Mn, [
2308
- A(f(ke), {
2309
- render: (ye = (fe = (pe = z.name) == null ? void 0 : pe.column) == null ? void 0 : fe.columnDef) == null ? void 0 : ye.cell,
2310
- props: (le = (re = z.name) == null ? void 0 : re.getContext) == null ? void 0 : le.call(re)
2311
- }, null, 8, ["render", "props"])
2312
- ]),
2313
- r("div", null, D((ie = B.original.locations) != null && ie.length ? f(t)("inventory.closing.table.enabledForN", {
2314
- count: ((ve = B.original.locations) == null ? void 0 : ve.length) ?? 0
2315
- }) : f(t)("inventory.closing.table.enabledForAll")), 1),
2316
- r("div", En, D([
2317
- ...B.original.previewItemNames,
2318
- ...B.original.itemCount - B.original.previewItemNames.length > 0 ? [
2319
- `and ${B.original.itemCount - B.original.previewItemNames.length} more items`
2320
- ] : []
2321
- ].join(", ")), 1),
2322
- r("div", Nn, [
2323
- A(f(ke), {
2324
- render: (be = (me = (ge = z.ref) == null ? void 0 : ge.column) == null ? void 0 : me.columnDef) == null ? void 0 : be.cell,
2325
- props: (v = (p = z.ref) == null ? void 0 : p.getContext) == null ? void 0 : v.call(p)
2326
- }, null, 8, ["render", "props"])
2327
- ])
2328
- ]),
2329
- r("div", null, [
2330
- A(f(ke), {
2331
- render: (L = (E = (C = z.status) == null ? void 0 : C.column) == null ? void 0 : E.columnDef) == null ? void 0 : L.cell,
2332
- props: (Q = (N = z.status) == null ? void 0 : N.getContext) == null ? void 0 : Q.call(N)
2333
- }, null, 8, ["render", "props"])
2334
- ])
2335
- ])
2336
- ];
2337
- }),
2338
- _: 2
2339
- }, 1032, ["row", "onRowClick"])
2340
- ]),
2341
- _: 1
2342
- }, 8, ["style", "column-defs", "rows", "fetch-page", "refresh-key", "search-value", "loading", "fetch-detail", "page-size"])
2343
- ], 2)
2344
- ]),
2345
- _: 1
2346
- }, 8, ["title", "actions"]),
2347
- (_(), W(Ze, { to: "body" }, [
2348
- A(gn, et(tt(f(h))), null, 16),
2349
- A(fn, ot(f(b), {
2350
- onSubmitted: R[2] || (R[2] = (B) => f(g).refresh())
2351
- }), null, 16)
2352
- ]))
2353
- ], 64));
2354
- }
2355
- });
2356
- export {
2357
- ds as default
2358
- };