@feedmepos/mf-inventory-portal 1.7.0-dev.6 → 1.7.0-dev.7

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