@feedmepos/mf-inventory-portal 1.9.1 → 1.9.3-dev.0

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