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