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

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