@feedmepos/mf-inventory-portal 0.0.22-dev.2 → 0.0.22-dev.21

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 (81) hide show
  1. package/dist/App.vue.d.ts +2 -0
  2. package/dist/{ApprovalView-D7WEr35k.js → ApprovalView-CCYykhrK.js} +14 -14
  3. package/dist/{BindingsDialog-C-3uO6pD.js → BindingsDialog-33VV_AST.js} +1 -1
  4. package/dist/{BindingsPicker-B3tGisCE.js → BindingsPicker-BKu4vN8J.js} +8 -8
  5. package/dist/{BindingsTable-CPtiH3vj.js → BindingsTable-Dd0h5gDf.js} +1 -1
  6. package/dist/ClosingTemplateView-BhevjTLl.js +1067 -0
  7. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-ohHZLOuR.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-3gp56NNJ.js} +14 -16
  8. package/dist/{IngredientsView-D-EKGLq9.js → IngredientsView-DckIH9eR.js} +5 -6
  9. package/dist/{IntegrationView-BVAO_vch.js → IntegrationView-BqQ4jRIp.js} +2 -2
  10. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-CJYmB7Ct.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-Vi0q_bDz.js} +1 -1
  11. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BxkM-SOw.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BIL8LWRz.js} +1 -1
  12. package/dist/{PurchaseOrderPrintPreview-CP-mK62z.js → PurchaseOrderPrintPreview-Ct7daTTa.js} +1 -1
  13. package/dist/{ReceiveRequestView-x8WTvuDk.js → ReceiveRequestView-B4wHTogG.js} +25 -26
  14. package/dist/RecipeView-DuE4cXLz.js +590 -0
  15. package/dist/Standalone.vue.d.ts +2 -0
  16. package/dist/{StockView-SyWxT4Ee.js → StockView-Bn9v2Ix8.js} +602 -585
  17. package/dist/{SupplierView-a0HAZJau.js → SupplierView-C8rqHSOV.js} +37 -37
  18. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CStnY5Zh.js +851 -0
  19. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-DRKiv_t8.js +1511 -0
  20. package/dist/TransferTemplateView-RM6Y-WL4.js +1209 -0
  21. package/dist/{UnitView-B3c7W5lw.js → UnitView-BXISVrop.js} +4 -4
  22. package/dist/{WarehouseView-DDV-yslF.js → WarehouseView-B055eB90.js} +18 -18
  23. package/dist/api/closing-template.d.ts +14 -0
  24. package/dist/api/inventory.d.ts +5 -7
  25. package/dist/api/netsuite.d.ts +46 -0
  26. package/dist/api/purchase-order-template.d.ts +0 -4
  27. package/dist/{app-DURkcZal.js → app-9algzyce.js} +16045 -15403
  28. package/dist/app.d.ts +6 -0
  29. package/dist/app.js +2 -2
  30. package/dist/components/FmMinMaxInputRules.d.ts +2 -0
  31. package/dist/components/FmUnitInputRules.d.ts +2 -0
  32. package/dist/{decimal-BGJlFDm8.js → decimal-CMuMGm4y.js} +1 -1
  33. package/dist/{defineDeepModel-pATZSiCT.js → defineDeepModel-CjPowyho.js} +1 -1
  34. package/dist/extensions/promises.d.ts +14 -0
  35. package/dist/{format-time-from-id-BCAuJEq2.js → format-time-from-id-DNKcbBFm.js} +1 -1
  36. package/dist/helper/date2.d.ts +1 -0
  37. package/dist/helper/rules.d.ts +7 -0
  38. package/dist/helper/rules.spec.d.ts +1 -0
  39. package/dist/{id-to-date-CVHmTOJk.js → id-to-date-C6W4aVdr.js} +1 -1
  40. package/dist/purchase-order-transaction-type-CscRvNAR.js +680 -0
  41. package/dist/stores/api.d.ts +1 -0
  42. package/dist/stores/feature.d.ts +0 -1
  43. package/dist/stores/helper/core-store-proxy.d.ts +3 -0
  44. package/dist/stores/helper/generate-backend-urls.d.ts +1 -0
  45. package/dist/stores/inventory.d.ts +7 -0
  46. package/dist/stores/location.d.ts +24 -42
  47. package/dist/stores/netsuite.d.ts +56 -0
  48. package/dist/stores/route.d.ts +0 -5
  49. package/dist/stores/warehouse.d.ts +4 -7
  50. package/dist/style.css +1 -1
  51. package/dist/{supplier-DmBbGAwf.js → supplier-BiCX3dpL.js} +1 -1
  52. package/dist/tsconfig.app.tsbuildinfo +1 -1
  53. package/dist/use-template-enabled-locations-2-Dtg2qOTm.js +85 -0
  54. package/dist/views/closing-template/components/closing-template-publish/ClosingTemplatePublish.vue.d.ts +6 -0
  55. package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +276 -84
  56. package/dist/views/closing-template/composables/use-closing-template-table.d.ts +341 -85
  57. package/dist/views/receive-request/components/transfer-details/TransferDetailsProps.d.ts +1 -0
  58. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +916 -0
  59. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +1 -0
  60. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +788 -152
  61. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +800 -164
  62. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations-2.d.ts +13 -0
  63. package/dist/views/transfer-template/components/transfer-template-form/composables/use-template-enabled-locations.d.ts +4 -7
  64. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +2 -2
  65. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +1285 -109
  66. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +399 -993
  67. package/dist/views/transfer-template/helpers/remove-deleted-skus.helper.d.ts +345 -0
  68. package/dist/views/warehouse/components/WarehouseForm.vue.d.ts +8 -14
  69. package/dist/{xlsx-1DLm6bBD.js → xlsx-fKJqx2Qc.js} +1 -1
  70. package/dist/{xlsx.util-DLtch7r5.js → xlsx.util-LOnzE3KS.js} +2 -2
  71. package/package.json +5 -5
  72. package/dist/ClosingTemplateView-Df0lgpjS.js +0 -928
  73. package/dist/RecipeView-BysIWI1W.js +0 -581
  74. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-ckp8gcT_.js +0 -740
  75. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-BSvpuWY9.js +0 -1409
  76. package/dist/TransferTemplateView-BGi6zd6d.js +0 -1350
  77. package/dist/array-ClJzD_Lt.js +0 -30
  78. package/dist/layout/InventoryLayout.vue.d.ts +0 -2
  79. package/dist/layout/layout-routes.d.ts +0 -6
  80. package/dist/purchase-order-transaction-type-DvSpCSXr.js +0 -712
  81. package/dist/use-template-enabled-locations-BiuOdu1M.js +0 -57
@@ -1,928 +0,0 @@
1
- import { ref as F, computed as E, h as U, defineComponent as G, openBlock as $, createElementBlock as B, createElementVNode as y, toDisplayString as N, createVNode as w, unref as a, Fragment as Q, renderList as ue, resolveComponent as V, createBlock as P, withCtx as S, isRef as pe, createCommentVNode as ce, watch as he, onMounted as we, normalizeClass as xe, normalizeStyle as ke, Teleport as Te, normalizeProps as Ce, guardReactiveProps as $e, mergeProps as De } from "vue";
2
- import { u as Se, _ as Ve, a as Fe } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-ohHZLOuR.js";
3
- import { useCoreStore as Me, useI18n as H } from "@feedmepos/mf-common";
4
- import { useDialog as fe, useSnackbar as W, FmButtonVariant as de, components as O, useProxiedModel as Ie, useBreakpoints as Ae } from "@feedmepos/ui-library";
5
- import { defineStore as ge, storeToRefs as Pe } from "pinia";
6
- import { F as L, D as me, R } from "./row-action.enum-PMKMRrZR.js";
7
- import { n as Ee, c as ve, j as Ue, u as be, R as Le, A as Re, y as Be, i as Ne } from "./app-DURkcZal.js";
8
- import { c as ze, F as j, _ as ye } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
9
- import { f as je } from "./format-time-from-id-BCAuJEq2.js";
10
- import "vue-router";
11
- import { d as Ke } from "./defineDeepModel-pATZSiCT.js";
12
- import { u as qe } from "./use-template-enabled-locations-BiuOdu1M.js";
13
- const X = Ee((u, v) => {
14
- function h() {
15
- var e;
16
- return `business_${((e = Me().currentBusiness.value) == null ? void 0 : e._id) ?? ""}`;
17
- }
18
- return {
19
- async getTemplate(t) {
20
- const o = h(), e = `${u.inventoryBackendUrl}/${o}/closing-template/${t}`;
21
- return v.get(e);
22
- },
23
- async readTemplates() {
24
- const t = h(), o = `${u.inventoryBackendUrl}/${t}/closing-template`;
25
- return v.get(o);
26
- },
27
- async createTemplate(t) {
28
- const o = h(), e = `${u.inventoryBackendUrl}/${o}/closing-template`;
29
- return v.post(e, t);
30
- },
31
- async updateTemplate(t) {
32
- const o = h(), e = `${u.inventoryBackendUrl}/${o}/closing-template`;
33
- return v.put(e, t);
34
- },
35
- async deleteTemplate(t) {
36
- const o = h(), e = `${u.inventoryBackendUrl}/${o}/closing-template`;
37
- return v.delete(e, { _id: t._id, _rev: t._rev });
38
- }
39
- };
40
- }), J = ge("closingTemplateActions", () => {
41
- const u = fe(), v = W(), h = X(), t = F({});
42
- function o() {
43
- t.value = {
44
- mode: L.CREATE,
45
- show: !0,
46
- "onUpdate:show"(r) {
47
- t.value.show = r;
48
- }
49
- };
50
- }
51
- function e(r) {
52
- t.value = {
53
- mode: L.UPDATE,
54
- modelValue: r,
55
- show: !0,
56
- "onUpdate:show"(p) {
57
- t.value.show = p;
58
- }
59
- };
60
- }
61
- function b(r, p, _) {
62
- u.open({
63
- title: `Confirm deleting template ${r.name}?`,
64
- message: "Deleted template can no longer be retrieved",
65
- primaryActions: {
66
- text: "Delete",
67
- variant: de.Destructive,
68
- close: !0
69
- },
70
- secondaryActions: {
71
- text: "Cancel",
72
- variant: de.Plain,
73
- close: !0
74
- }
75
- }).onPrimary(async () => {
76
- v.open({
77
- title: `Deleting ${r.name}`,
78
- type: "info"
79
- });
80
- try {
81
- p.value = !0;
82
- const [g] = await Promise.allSettled([
83
- h.deleteTemplate(r),
84
- new Promise((m) => setTimeout(m, 1e3))
85
- ]);
86
- if (g.status === "rejected") throw g.reason;
87
- v.open({
88
- title: `Deleted ${r.name}`,
89
- type: "success"
90
- });
91
- } catch (g) {
92
- v.open({
93
- title: `Unable to delete ${r.name}`,
94
- message: `See error from server: ${g}`,
95
- type: "error"
96
- }), console.error("error on deleting closing template", g);
97
- } finally {
98
- p.value = !1, _();
99
- }
100
- });
101
- }
102
- const n = F({});
103
- function d(r) {
104
- n.value = {
105
- template: r,
106
- show: !0,
107
- "onUpdate:show"(p) {
108
- n.value.show = p;
109
- },
110
- "onAction:edit"() {
111
- n.value.show = !1, e(ve(r));
112
- }
113
- };
114
- }
115
- return {
116
- createTemplate: o,
117
- viewTemplate: d,
118
- updateTemplate: e,
119
- deleteTemplate: b,
120
- templateDialogProps: t,
121
- templateDetailsProps: n
122
- };
123
- }), Ge = ge(
124
- "closingTable",
125
- function() {
126
- const { t: v } = H(), { viewTemplate: h, updateTemplate: t, deleteTemplate: o } = J(), e = F(new Array()), b = F(!1), n = Ue(), d = X();
127
- async function r() {
128
- if (e.value = [], !!n._currentLocation) {
129
- b.value = !0;
130
- try {
131
- const [m, c] = await Promise.all([
132
- d.readTemplates(),
133
- new Promise((s) => setTimeout(s, 1e3))
134
- ]);
135
- e.value = m;
136
- } catch (m) {
137
- console.log("Something went wrong when fetching templates:", m);
138
- } finally {
139
- b.value = !1;
140
- }
141
- }
142
- }
143
- async function p(m) {
144
- if (!e.value.find((c) => c._id) && n._currentLocation) {
145
- b.value = !0;
146
- try {
147
- const [c] = await Promise.all([
148
- d.getTemplate(m),
149
- new Promise((s) => setTimeout(s, 1e3))
150
- ]);
151
- e.value = [c];
152
- } catch (c) {
153
- console.log("Something went wrong when fetching templates:", c);
154
- } finally {
155
- b.value = !1;
156
- }
157
- }
158
- }
159
- function _(m, c) {
160
- switch (c = ve(c), m) {
161
- case R.Details:
162
- return h(c);
163
- case R.Edit:
164
- return t(c);
165
- case R.Delete:
166
- return o(c, b, r);
167
- }
168
- }
169
- return {
170
- columnDefs: [
171
- {
172
- id: "_id",
173
- accessorKey: "_id",
174
- header: () => v("inventory.closing.table.createdAt"),
175
- cell(m) {
176
- return je(`${m.getValue()}`);
177
- },
178
- enableSorting: !0
179
- },
180
- {
181
- id: "name",
182
- accessorKey: "name",
183
- header: () => v("inventory.closing.table.name"),
184
- enableSorting: !0,
185
- size: 200
186
- },
187
- // {
188
- // id: 'supplier',
189
- // accessorKey: 'supplier.name',
190
- // header: () => t('inventory.closing.table.closingFrom'),
191
- // enableSorting: true,
192
- // size: 200
193
- // },
194
- // {
195
- // id: 'type',
196
- // header: () => t('inventory.closing.receiveRequest.details.type.title'),
197
- // enableSorting: true,
198
- // sortingFn(rowA, rowB) {
199
- // const typeA = getTransferType(rowA.original.closing)
200
- // const typeB = getTransferType(rowB.original.closing)
201
- // return typeA.localeCompare(typeB)
202
- // },
203
- // size: 200,
204
- // cell(props) {
205
- // const type = getTransferType(props.row.original.closing)
206
- // const label = t(
207
- // `inventory.closing.receiveRequest.details.type.${type.toLocaleLowerCase()}`
208
- // )
209
- // return h(components.FmChip, {
210
- // label: label,
211
- // class: 'fm-chip-closing-info',
212
- // compact: true
213
- // })
214
- // }
215
- // },
216
- {
217
- id: "noOfItems",
218
- accessorKey: "items.length",
219
- header: () => v("inventory.closing.table.noOfItems"),
220
- enableSorting: !1,
221
- meta: {
222
- width: "10rem",
223
- textAlign: "right"
224
- }
225
- },
226
- {
227
- id: "enabledLocations",
228
- accessorKey: "locations.length",
229
- header: () => "Enabled outlets",
230
- cell(m) {
231
- var s;
232
- const c = (s = m.row.original.locations) == null ? void 0 : s.length;
233
- return c ? `${c}` : "All";
234
- },
235
- enableSorting: !1,
236
- meta: {
237
- width: "10rem",
238
- textAlign: "right"
239
- }
240
- },
241
- {
242
- id: "ref",
243
- accessorKey: "ref",
244
- header: () => v("inventory.closing.table.reference"),
245
- enableSorting: !1,
246
- size: "auto"
247
- },
248
- {
249
- id: "action",
250
- cell(m) {
251
- const c = m.row.original, s = [
252
- me[R.Edit],
253
- me[R.Delete]
254
- ];
255
- return ze(s, (f) => _(f, c));
256
- },
257
- enableSorting: !1,
258
- size: 40,
259
- meta: {
260
- cellClass: "",
261
- headerClass: ""
262
- }
263
- }
264
- ],
265
- templates: e,
266
- loading: b,
267
- fetchTemplates: r,
268
- loadTemplate: p
269
- };
270
- }
271
- );
272
- var z = /* @__PURE__ */ ((u) => (u.Name = "Name", u.Unit = "Unit", u.Delete = "Delete", u))(z || {});
273
- function He(u) {
274
- return {
275
- columnDefs: E(() => {
276
- const h = u.items.map((o) => o.sku.unit.measurements.length).reduce((o, e) => o + e, -1);
277
- return [
278
- {
279
- id: "Name",
280
- header: () => "Name",
281
- enableSorting: !1,
282
- size: 400,
283
- cell(o) {
284
- const e = o.row.original;
285
- return U(
286
- "div",
287
- {
288
- class: "flex flex-col"
289
- },
290
- [
291
- U(
292
- "span",
293
- { class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary line-clamp-1" },
294
- e.sku.name
295
- ),
296
- U(
297
- "span",
298
- { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary line-clamp-1" },
299
- e.sku.code
300
- )
301
- ]
302
- );
303
- }
304
- },
305
- {
306
- id: "Unit",
307
- header: () => "Enable unit",
308
- enableSorting: !1,
309
- size: "auto",
310
- cell(o) {
311
- var b, n;
312
- const e = o.row.original;
313
- return U(O.FmCheckbox, {
314
- label: e.sku.unit.abbrev,
315
- value: e.sku.unit._id,
316
- modelValue: !((b = e.disabledMeasurements) != null && b.includes(e.sku.unit._id)),
317
- disabled: u.disabled || !((n = e.disabledMeasurements) != null && n.includes(e.sku.unit._id)) && e.sku.unit.measurements.every((d) => {
318
- var r;
319
- return (r = e.disabledMeasurements) == null ? void 0 : r.includes(d.id);
320
- }),
321
- "onUpdate:modelValue"(d) {
322
- var r;
323
- if (d)
324
- u.updateItem({
325
- ...e,
326
- disabledMeasurements: (r = e.disabledMeasurements) == null ? void 0 : r.filter(
327
- (p) => p !== e.sku.unit._id
328
- )
329
- });
330
- else {
331
- const p = e.disabledMeasurements ?? [];
332
- u.updateItem({
333
- ...e,
334
- disabledMeasurements: [...p, e.sku.unit._id]
335
- });
336
- }
337
- }
338
- });
339
- }
340
- },
341
- ...Array.from({ length: Math.max(h, 0) }).map(
342
- (o, e) => ({
343
- id: `measurement${e}`,
344
- header: () => "",
345
- enableSorting: !1,
346
- size: "auto",
347
- cell(b) {
348
- var r, p, _;
349
- const n = b.row.original, d = n.sku.unit.measurements[e];
350
- return d ? U(O.FmCheckbox, {
351
- label: d.abbrev,
352
- value: d.id,
353
- modelValue: !((r = n.disabledMeasurements) != null && r.includes(d.id)),
354
- disabled: u.disabled || !((p = n.disabledMeasurements) != null && p.includes(d.id)) && ((_ = n.disabledMeasurements) == null ? void 0 : _.includes(n.sku.unit._id)) && n.sku.unit.measurements.filter((g) => g.id != d.id).every((g) => {
355
- var m;
356
- return (m = n.disabledMeasurements) == null ? void 0 : m.includes(g.id);
357
- }),
358
- "onUpdate:modelValue"(g) {
359
- var m;
360
- if (g)
361
- u.updateItem({
362
- ...n,
363
- disabledMeasurements: (m = n.disabledMeasurements) == null ? void 0 : m.filter(
364
- (c) => c !== d.id
365
- )
366
- });
367
- else {
368
- const c = n.disabledMeasurements ?? [];
369
- u.updateItem({
370
- ...n,
371
- disabledMeasurements: [...c, d.id]
372
- });
373
- }
374
- }
375
- }) : null;
376
- }
377
- })
378
- ),
379
- {
380
- id: "Delete",
381
- header: "",
382
- cell(o) {
383
- const e = o.row.original;
384
- return U(
385
- "div",
386
- { class: "w-full flex justify-end" },
387
- U(O.FmButton, {
388
- class: "delete-button",
389
- key: e.sku._id,
390
- type: "button",
391
- icon: "delete",
392
- variant: "tertiary",
393
- size: "md",
394
- disabled: u.disabled,
395
- onClick: () => {
396
- u.deleteItem(e);
397
- }
398
- })
399
- );
400
- },
401
- enableSorting: !1,
402
- size: 40,
403
- meta: {
404
- cellClass: "",
405
- headerClass: ""
406
- }
407
- }
408
- ];
409
- })
410
- };
411
- }
412
- const Oe = { class: "flex flex-col gap-16 py-12" }, Je = { class: "flex" }, Qe = { class: "flex-1 flex flex-col" }, We = { class: "fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, Xe = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Ye = { class: "flex flex-col gap-4" }, Ze = /* @__PURE__ */ G({
413
- __name: "ClosingTemplateItem",
414
- props: {
415
- cellByColId: {},
416
- row: {}
417
- },
418
- setup(u) {
419
- const v = u, h = E(() => v.row), t = E(
420
- () => h.value.getVisibleCells().filter((o) => o.column.id !== z.Name && o.column.id !== z.Delete)
421
- );
422
- return (o, e) => {
423
- var b, n, d, r, p;
424
- return $(), B("div", Oe, [
425
- y("div", Je, [
426
- y("div", Qe, [
427
- y("div", We, N(h.value.original.sku.name), 1),
428
- y("div", Xe, N(h.value.original.sku.code), 1)
429
- ]),
430
- y("div", null, [
431
- w(a(j), {
432
- render: (d = (n = (b = o.cellByColId[a(z).Delete]) == null ? void 0 : b.column) == null ? void 0 : n.columnDef) == null ? void 0 : d.cell,
433
- props: (p = (r = o.cellByColId[a(z).Delete]) == null ? void 0 : r.getContext) == null ? void 0 : p.call(r)
434
- }, null, 8, ["render", "props"])
435
- ])
436
- ]),
437
- y("div", Ye, [
438
- e[0] || (e[0] = y("div", { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, "Enabled units", -1)),
439
- ($(!0), B(Q, null, ue(t.value, (_) => {
440
- var g, m, c;
441
- return $(), B("div", {
442
- key: _.id
443
- }, [
444
- w(a(j), {
445
- render: (m = (g = _.column) == null ? void 0 : g.columnDef) == null ? void 0 : m.cell,
446
- props: (c = _.getContext) == null ? void 0 : c.call(_)
447
- }, null, 8, ["render", "props"])
448
- ]);
449
- }), 128))
450
- ])
451
- ]);
452
- };
453
- }
454
- }), et = { class: "flex flex-col gap-16" }, tt = { class: "flex flex-col gap-24" }, ot = { class: "p-16 border border-fm-color-neutral-gray-300 fm-corner-radius-md flex flex-col gap-16" }, nt = { key: 1 }, lt = { class: "flex flex-col gap-16" }, st = { class: "flex items-center" }, at = { class: "flex-1 gap-8 fm-typo-en-title-sm-800" }, it = /* @__PURE__ */ G({
455
- __name: "ClosingTemplateForm",
456
- props: {
457
- modelValue: {},
458
- disabled: { type: Boolean }
459
- },
460
- setup(u, { expose: v }) {
461
- const h = u, t = Ke(), { t: o } = H(), e = be(), b = fe(), { enabledLocations: n, enabledLocationsSwitch: d, promptSelectLocations: r, removeLocation: p } = qe({
462
- getLocations() {
463
- return t.locations;
464
- },
465
- setLocations(s) {
466
- t.locations = s;
467
- }
468
- }), _ = F();
469
- v({
470
- validateInputs: () => {
471
- var s, f;
472
- (f = (s = _.value) == null ? void 0 : s.validateInputs) == null || f.call(s);
473
- },
474
- resetInputsValidation: () => {
475
- var s, f;
476
- (f = (s = _.value) == null ? void 0 : s.resetInputsValidation) == null || f.call(s);
477
- },
478
- resetInputs: () => {
479
- var s, f;
480
- (f = (s = _.value) == null ? void 0 : s.resetInputs) == null || f.call(s);
481
- }
482
- });
483
- const g = He({
484
- updateItem: (s) => {
485
- t.items = t.items.map((f) => f.sku._id !== s.sku._id ? f : s);
486
- },
487
- deleteItem: (s) => {
488
- t.items = t.items.filter((f) => f.sku._id !== s.sku._id);
489
- },
490
- get items() {
491
- return t.items;
492
- },
493
- get disabled() {
494
- return h.disabled;
495
- }
496
- }), m = E(() => g.columnDefs.value);
497
- function c() {
498
- const s = e.skus.map((T) => ({
499
- label: T.name,
500
- sublabel: T.code,
501
- value: T
502
- })), f = s.filter((T) => {
503
- var C;
504
- return (C = t.items) == null ? void 0 : C.find((k) => k.sku._id === T.value._id);
505
- }).map((T) => T.value);
506
- b.open({
507
- title: o("inventory.closing.form.items.selectItem"),
508
- closeButton: !0,
509
- contentComponent: Be,
510
- contentComponentProps: {
511
- modelValue: f,
512
- items: s,
513
- virtualScroll: !0
514
- },
515
- primaryActions: {
516
- text: o("common.confirm"),
517
- close: !0
518
- },
519
- secondaryActions: {
520
- text: o("common.close"),
521
- close: !0,
522
- variant: "tertiary"
523
- }
524
- }).onPrimary((T) => {
525
- const C = t.items ?? [], k = T.map((i) => {
526
- const l = C.find((A) => A.sku._id === i._id);
527
- return l || {
528
- sku: i
529
- };
530
- });
531
- k.sort((i, l) => i.sku.code.localeCompare(l.sku.code)), t.items = k;
532
- });
533
- }
534
- return (s, f) => {
535
- const T = V("FmTextField"), C = V("FmSwitch"), k = V("FmButton"), i = V("FmListItem"), l = V("FmList"), D = V("FmFormGroup"), A = V("FmTable"), M = V("FmForm");
536
- return $(), P(M, {
537
- ref_key: "formRef",
538
- ref: _,
539
- class: "flex flex-col gap-32",
540
- disabled: s.disabled
541
- }, {
542
- default: S(() => [
543
- y("div", et, [
544
- y("div", tt, [
545
- w(T, {
546
- label: a(o)("inventory.closing.form.name"),
547
- "label-mark": "required",
548
- modelValue: a(t).name,
549
- "onUpdate:modelValue": f[0] || (f[0] = (x) => a(t).name = x),
550
- rules: [a(Le)()]
551
- }, null, 8, ["label", "modelValue", "rules"]),
552
- w(T, {
553
- label: a(o)("inventory.closing.form.reference"),
554
- "label-mark": "optional",
555
- modelValue: a(t).ref,
556
- "onUpdate:modelValue": f[1] || (f[1] = (x) => a(t).ref = x)
557
- }, null, 8, ["label", "modelValue"])
558
- ])
559
- ]),
560
- y("div", ot, [
561
- w(C, {
562
- modelValue: a(d),
563
- "onUpdate:modelValue": f[2] || (f[2] = (x) => pe(d) ? d.value = x : null),
564
- label: "Locations rule",
565
- sublabel: "Enable template for specific locations only",
566
- "label-placement": "right"
567
- }, null, 8, ["modelValue"]),
568
- a(d) ? ($(), P(D, {
569
- key: 0,
570
- modelValue: a(n),
571
- rules: [a(Re)(1)],
572
- class: "flex-1 flex gap-8 h-48 xs:flex-col xs:pt-16 sm:flex-col sm:pt-16"
573
- }, {
574
- default: S(() => [
575
- w(l, null, {
576
- default: S(() => [
577
- ($(!0), B(Q, null, ue(a(n), (x) => ($(), P(i, {
578
- key: x.doc._id,
579
- label: x.name,
580
- sublabel: x.type,
581
- disabled: s.disabled
582
- }, {
583
- append: S(() => [
584
- w(k, {
585
- "prepend-icon": "delete",
586
- variant: "tertiary",
587
- disabled: s.disabled,
588
- onClick: (I) => a(p)(x.doc._id)
589
- }, null, 8, ["disabled", "onClick"])
590
- ]),
591
- _: 2
592
- }, 1032, ["label", "sublabel", "disabled"]))), 128))
593
- ]),
594
- _: 1
595
- })
596
- ]),
597
- _: 1
598
- }, 8, ["modelValue", "rules"])) : ce("", !0),
599
- a(d) ? ($(), B("div", nt, [
600
- w(k, {
601
- disabled: s.disabled,
602
- label: a(o)("inventory.closing.form.items.addItem"),
603
- "prepend-icon": "add",
604
- variant: "plain",
605
- class: "border-2 rounded-lg border-fm-color-primary",
606
- onClick: a(r)
607
- }, null, 8, ["disabled", "label", "onClick"])
608
- ])) : ce("", !0)
609
- ]),
610
- y("div", lt, [
611
- y("div", st, [
612
- y("div", at, N(a(o)("inventory.closing.form.items.title")), 1),
613
- w(k, {
614
- disabled: s.disabled,
615
- label: a(o)("inventory.closing.form.items.addItem"),
616
- "prepend-icon": "add",
617
- variant: "plain",
618
- class: "border-2 rounded-lg border-fm-color-primary",
619
- onClick: f[3] || (f[3] = (x) => c()),
620
- size: "md"
621
- }, null, 8, ["disabled", "label"])
622
- ]),
623
- ($(), P(A, {
624
- "column-defs": m.value,
625
- "row-data": a(t).items,
626
- key: a(t).items.map((x) => x.sku._id).join("."),
627
- "hide-footer": ""
628
- }, {
629
- "list-row": S((x) => [
630
- ($(), P(ye, {
631
- row: x,
632
- key: a(t).items.map((I) => I.sku._id).join(".")
633
- }, {
634
- default: S((I) => [
635
- w(Ze, {
636
- row: x,
637
- "cell-by-col-id": I
638
- }, null, 8, ["row", "cell-by-col-id"])
639
- ]),
640
- _: 2
641
- }, 1032, ["row"]))
642
- ]),
643
- _: 1
644
- }, 8, ["column-defs", "row-data"]))
645
- ])
646
- ]),
647
- _: 1
648
- }, 8, ["disabled"]);
649
- };
650
- }
651
- }), rt = { class: "flex items-center" }, ct = { class: "fm-typo-en-title-md-800" }, dt = { class: "flex gap-4" }, mt = /* @__PURE__ */ G({
652
- __name: "ClosingTemplateDialog",
653
- props: {
654
- mode: {},
655
- modelValue: {},
656
- show: { type: Boolean }
657
- },
658
- emits: ["update:show", "submitted"],
659
- setup(u, { expose: v, emit: h }) {
660
- var k;
661
- const t = u, o = h, e = X(), b = W(), { t: n } = H(), d = Ie(t, "show");
662
- function r() {
663
- return {
664
- _id: "",
665
- name: "",
666
- items: []
667
- };
668
- }
669
- const p = F(t.modelValue ?? r()), _ = F(((k = t.modelValue) == null ? void 0 : k._id) ?? `${Math.random()}`);
670
- he(
671
- () => t.show,
672
- (i) => {
673
- var l;
674
- i && (p.value = t.modelValue ?? r(), _.value = ((l = t.modelValue) == null ? void 0 : l._id) ?? `${Math.random()}`);
675
- }
676
- );
677
- const g = F(!1), m = E(() => {
678
- switch (t.mode) {
679
- case L.READ:
680
- return "";
681
- case L.CREATE:
682
- return n("inventory.closing.template.create.title");
683
- case L.UPDATE:
684
- return n("inventory.closing.template.update.title");
685
- }
686
- return "";
687
- }), c = F();
688
- v({
689
- validateInputs: () => {
690
- var i, l;
691
- (l = (i = c.value) == null ? void 0 : i.validateInputs) == null || l.call(i);
692
- },
693
- resetInputsValidation: () => {
694
- var i, l;
695
- (l = (i = c.value) == null ? void 0 : i.resetInputsValidation) == null || l.call(i);
696
- },
697
- resetInputs: () => {
698
- var i, l;
699
- (l = (i = c.value) == null ? void 0 : i.resetInputs) == null || l.call(i);
700
- }
701
- });
702
- async function s() {
703
- const i = p.value;
704
- if (i) {
705
- g.value = !0;
706
- try {
707
- await e.createTemplate(i), await new Promise((l) => setTimeout(l, 1e3)), b.open({
708
- title: n("inventory.closing.template.create.success"),
709
- message: n("inventory.closing.template.create.successMessage"),
710
- type: "success"
711
- }), o("update:show", !1), o("submitted");
712
- } catch (l) {
713
- b.open({
714
- title: n("inventory.closing.template.create.error"),
715
- message: n("inventory.closing.template.create.errorMessage"),
716
- type: "error"
717
- }), console.error("Error in creating closing template", l);
718
- } finally {
719
- g.value = !1;
720
- }
721
- }
722
- }
723
- async function f() {
724
- const i = p.value;
725
- if (i) {
726
- g.value = !0;
727
- try {
728
- await e.updateTemplate(i), await new Promise((l) => setTimeout(l, 1e3)), b.open({
729
- title: n("inventory.closing.template.update.success"),
730
- message: n("inventory.closing.template.update.successMessage"),
731
- type: "success"
732
- }), o("update:show", !1), o("submitted");
733
- } catch (l) {
734
- b.open({
735
- title: n("inventory.closing.template.update.error"),
736
- message: n("inventory.closing.template.update.errorMessage"),
737
- type: "error"
738
- }), console.error("Error in updating closing template", l);
739
- } finally {
740
- g.value = !1;
741
- }
742
- }
743
- }
744
- function T() {
745
- switch (t.mode) {
746
- case L.CREATE:
747
- return s();
748
- case L.UPDATE:
749
- return f();
750
- }
751
- }
752
- function C() {
753
- var i, l;
754
- (l = (i = c.value) == null ? void 0 : i.validateInputs) == null || l.call(i);
755
- }
756
- return (i, l) => {
757
- const D = V("FmButton"), A = V("FmSideSheet");
758
- return $(), P(A, {
759
- modelValue: a(d),
760
- "onUpdate:modelValue": l[2] || (l[2] = (M) => pe(d) ? d.value = M : null),
761
- "dismiss-away": "",
762
- "close-button": "",
763
- "max-width": 800
764
- }, {
765
- "side-sheet-header": S(() => [
766
- y("div", rt, [
767
- y("div", ct, N(m.value), 1)
768
- ])
769
- ]),
770
- default: S(() => [
771
- ($(), P(it, {
772
- class: "w-full",
773
- ref_key: "formRef",
774
- ref: c,
775
- onValidationSuccess: T,
776
- "model-value": p.value,
777
- "onUpdate:modelValue": l[0] || (l[0] = (M) => p.value = M),
778
- disabled: g.value,
779
- key: _.value
780
- }, null, 8, ["model-value", "disabled"]))
781
- ]),
782
- "side-sheet-footer": S(() => [
783
- y("div", dt, [
784
- w(D, {
785
- loading: g.value,
786
- label: a(n)("common.save"),
787
- onClick: C
788
- }, null, 8, ["loading", "label"]),
789
- w(D, {
790
- disabled: g.value,
791
- variant: "tertiary",
792
- label: a(n)("common.close"),
793
- onClick: l[1] || (l[1] = (M) => o("update:show", !1))
794
- }, null, 8, ["disabled", "label"])
795
- ])
796
- ]),
797
- _: 1
798
- }, 8, ["modelValue"]);
799
- };
800
- }
801
- }), ut = {};
802
- function pt(u, v) {
803
- return $(), B("div");
804
- }
805
- const ft = /* @__PURE__ */ Ne(ut, [["render", pt]]), gt = { class: "flex-1 flex flex-col gap-8" }, vt = { class: "flex flex-col" }, bt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, yt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, _t = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, ht = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, At = /* @__PURE__ */ G({
806
- __name: "ClosingTemplateView",
807
- setup(u) {
808
- const { t: v } = H(), { createTemplate: h, updateTemplate: t } = J(), { templateDialogProps: o, templateDetailsProps: e } = Pe(J()), b = be(), n = Ge(), d = Se(), { breakpoints: r } = Ae(), p = F(!1), _ = W();
809
- we(() => {
810
- n.fetchTemplates(), p.value = !1, b.readInventory().catch((C) => {
811
- _.open({
812
- title: "Something went wrong",
813
- message: "Unable to read inventory. Please try again.",
814
- type: "error"
815
- }), console.error("error at reading inventory", C);
816
- }).finally(() => {
817
- p.value = !1;
818
- });
819
- });
820
- const g = E(() => n.loading || p.value), m = F(""), c = E(() => r.value.xs || r.value.sm), s = E(() => c.value ? 10 : 20);
821
- function f(C) {
822
- switch (C) {
823
- case R.Add:
824
- return h();
825
- }
826
- }
827
- function T(C) {
828
- return C;
829
- }
830
- return (C, k) => {
831
- const i = V("FmTable");
832
- return $(), B(Q, null, [
833
- w(Ve, {
834
- title: a(v)("inventory.closing.template.title"),
835
- actions: [
836
- {
837
- label: a(v)("inventory.closing.template.create.title"),
838
- value: a(R).Add,
839
- isPrimary: !0,
840
- prependIcon: "add"
841
- }
842
- ],
843
- "onClick:action": f
844
- }, {
845
- default: S(() => [
846
- y("div", {
847
- class: xe([
848
- "flex flex-col gap-8 max-h-full",
849
- {
850
- "p-0": c.value,
851
- "px-24 ": !c.value
852
- }
853
- ])
854
- }, [
855
- w(Fe, {
856
- searchable: "",
857
- search: m.value,
858
- "onUpdate:search": k[0] || (k[0] = (l) => m.value = l),
859
- actions: [{ icon: "refresh", onClick: a(n).fetchTemplates }]
860
- }, null, 8, ["search", "actions"]),
861
- w(i, {
862
- style: ke(a(d).tableHeight),
863
- "column-defs": a(n).columnDefs,
864
- "row-data": a(n).templates,
865
- "search-value": m.value,
866
- loading: g.value,
867
- onRowClick: k[1] || (k[1] = (l) => a(t)(l.original)),
868
- "page-size": s.value
869
- }, {
870
- "list-row": S((l) => [
871
- w(ye, {
872
- row: l,
873
- onRowClick: (D) => a(t)(D)
874
- }, {
875
- default: S((D) => {
876
- var A, M, x, I, Y, Z, ee, te, K, oe, ne, le, se, ae, ie, q, re;
877
- return [
878
- y("div", gt, [
879
- y("div", vt, [
880
- y("div", bt, [
881
- w(a(j), {
882
- render: (x = (M = (A = D._id) == null ? void 0 : A.column) == null ? void 0 : M.columnDef) == null ? void 0 : x.cell,
883
- props: (Y = (I = D._id) == null ? void 0 : I.getContext) == null ? void 0 : Y.call(I)
884
- }, null, 8, ["render", "props"])
885
- ]),
886
- y("div", yt, [
887
- w(a(j), {
888
- render: (te = (ee = (Z = D.name) == null ? void 0 : Z.column) == null ? void 0 : ee.columnDef) == null ? void 0 : te.cell,
889
- props: (oe = (K = D.name) == null ? void 0 : K.getContext) == null ? void 0 : oe.call(K)
890
- }, null, 8, ["render", "props"])
891
- ]),
892
- y("div", null, N((ne = l.original.locations) != null && ne.length ? `Enabled for ${(le = l.original.locations) == null ? void 0 : le.length} outlets` : "Enabled for all outlets"), 1),
893
- y("div", _t, N([
894
- ...l.original.items.slice(0, 3).map((_e) => _e.sku.name),
895
- ...l.original.items.length >= 3 ? [`and ${l.original.items.length - 3} more items`] : []
896
- ].join(", ")), 1),
897
- y("div", ht, [
898
- w(a(j), {
899
- render: (ie = (ae = (se = D.ref) == null ? void 0 : se.column) == null ? void 0 : ae.columnDef) == null ? void 0 : ie.cell,
900
- props: (re = (q = D.ref) == null ? void 0 : q.getContext) == null ? void 0 : re.call(q)
901
- }, null, 8, ["render", "props"])
902
- ])
903
- ])
904
- ])
905
- ];
906
- }),
907
- _: 2
908
- }, 1032, ["row", "onRowClick"])
909
- ]),
910
- _: 1
911
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
912
- ], 2)
913
- ]),
914
- _: 1
915
- }, 8, ["title", "actions"]),
916
- ($(), P(Te, { to: "body" }, [
917
- w(ft, Ce($e(a(e))), null, 16),
918
- w(mt, De(a(o), {
919
- onSubmitted: k[2] || (k[2] = (l) => a(n).fetchTemplates())
920
- }), null, 16)
921
- ]))
922
- ], 64);
923
- };
924
- }
925
- });
926
- export {
927
- At as default
928
- };