@feedmepos/mf-inventory-portal 1.2.12-dev.3 → 1.2.13

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 (74) hide show
  1. package/dist/{App-D5hXQpVn.js → App-ZoXow3DD.js} +40 -44
  2. package/dist/{ApprovalView-B__WDklZ.js → ApprovalView-BWX6xBQs.js} +30 -30
  3. package/dist/{BindingsDialog-DXdwRSnn.js → BindingsDialog-CuwkcDKX.js} +2 -2
  4. package/dist/{BindingsPicker-CqAD3aHc.js → BindingsPicker-BibFsY0g.js} +1 -1
  5. package/dist/{BindingsTable-DVNjpusl.js → BindingsTable-AdjKwSPH.js} +1 -1
  6. package/dist/{ClosingDraftView-DL678GBB.js → ClosingDraftView-DWFHP9nE.js} +129 -129
  7. package/dist/{ClosingTemplateView-DThiXLtp.js → ClosingTemplateView-DOCF5f_u.js} +28 -28
  8. package/dist/{DeliveryOrderPrintPreview-B2MB9S6a.js → DeliveryOrderPrintPreview-DNDtL_Vo.js} +1 -1
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BNxs6Bcr.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-BWhINOE8.js} +3 -3
  10. package/dist/{FmMultiselectDialog-B45ZLjVp.js → FmMultiselectDialog-Dfo04ak5.js} +1 -1
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-D8ks6AEM.js → FmUnitInput.vue_vue_type_script_setup_true_lang-DGVs4zLl.js} +45 -45
  12. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-C5zIvG2h.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BESx2u4Y.js} +1 -1
  13. package/dist/{IngredientGroupView-D95dFXIZ.js → IngredientGroupView-M9sXlnE0.js} +32 -31
  14. package/dist/IngredientsView-DUwhH3j1.js +2475 -0
  15. package/dist/{IntegrationView-9m3N_9lW.js → IntegrationView-BlUNz1yc.js} +57 -57
  16. package/dist/{InventoryBindingForm-kLoQskao.js → InventoryBindingForm-CvQ5zh6v.js} +1 -1
  17. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-BytErBcK.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-BEAEmPsU.js} +31 -31
  18. package/dist/{InventoryBindingSummary-Dg0FH7ad.js → InventoryBindingSummary-CsJ-6G2P.js} +1 -1
  19. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BKrUNLuG.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DjN_ktl1.js} +1 -1
  20. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-BL1f817e.js → PremiumBadge.vue_vue_type_script_setup_true_lang-BN_e7k7U.js} +1 -1
  21. package/dist/{PublishView-BcOHSAj3.js → PublishView-DZgCyLK2.js} +15 -15
  22. package/dist/{PurchaseOrderPrintPreview-UfF8RVkv.js → PurchaseOrderPrintPreview-CB2xvQ33.js} +1 -1
  23. package/dist/{ReceiveRequestView-D_y_xNUb.js → ReceiveRequestView-DgDHOS-Y.js} +63 -62
  24. package/dist/RecipeView-DQDfwCJd.js +621 -0
  25. package/dist/{StockView-ciU6aAV7.js → StockView-eJOngk08.js} +166 -165
  26. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-XwDTGpR-.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-BMFfegsk.js} +1 -1
  27. package/dist/{SupplierView-DFwtALPg.js → SupplierView-BS8rBAKC.js} +492 -490
  28. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-w98ibfql.js +3060 -0
  29. package/dist/{TransferTemplateView-BXr_GqTi.js → TransferTemplateView-By5Ci4Yg.js} +48 -48
  30. package/dist/UnitView-DmuWMFlA.js +667 -0
  31. package/dist/{WarehouseView-BYd0bPhi.js → WarehouseView-4ZLSJXYc.js} +32 -32
  32. package/dist/api/inventory.d.ts +0 -306
  33. package/dist/api/purchase-order.d.ts +0 -1
  34. package/dist/{app-Bb0-8bRg.js → app-D2lun71R.js} +11108 -11723
  35. package/dist/app.d.ts +0 -421
  36. package/dist/app.js +1 -1
  37. package/dist/array-Ca8T3f_G.js +44 -0
  38. package/dist/{closing-template-DPVNEyI7.js → closing-template-Cm1TtVzm.js} +1 -1
  39. package/dist/{decimal-BdBZYISm.js → decimal-eeicE4jp.js} +1 -1
  40. package/dist/{format-unit-display-DlmCwWo_.js → format-unit-display-vHKazw0l.js} +25 -25
  41. package/dist/helper/number.d.ts +0 -1
  42. package/dist/{index-CqBKFj1B.js → index-C5s-1g7c.js} +1 -1
  43. package/dist/{index-CKFmV1Pk.js → index-DvX9cMJV.js} +1 -1
  44. package/dist/{purchase-order-template-CLtEYr5E.js → purchase-order-template-uTs7bR89.js} +1 -1
  45. package/dist/router/name.d.ts +0 -1
  46. package/dist/{stock-nHQhfe2W.js → stock-CL2LNdXp.js} +1 -1
  47. package/dist/stores/feature.d.ts +0 -2
  48. package/dist/stores/inventory.d.ts +199 -26
  49. package/dist/{supplier-DuOjLpOa.js → supplier-CuzoW2k4.js} +1 -1
  50. package/dist/tsconfig.app.tsbuildinfo +1 -1
  51. package/dist/{use-ingredient-select-dialog-B-11Eqlm.js → use-ingredient-select-dialog-Cpg4lHHC.js} +1 -1
  52. package/dist/{use-inventory-binding-dialog-DhLSdRtp.js → use-inventory-binding-dialog-h4M4ICQK.js} +1 -1
  53. package/dist/views/ingredients/helper/import-export.helper.d.ts +1 -3
  54. package/dist/views/recipe/RecipeView.vue.d.ts +0 -1
  55. package/dist/views/unit/UnitView.vue.d.ts +0 -1
  56. package/package.json +2 -2
  57. package/dist/ImportView-EXm_g_jD.js +0 -1303
  58. package/dist/IngredientsView-MF1USuZI.js +0 -2240
  59. package/dist/RecipeView-DOaU9GIF.js +0 -636
  60. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CdA5_lEz.js +0 -3221
  61. package/dist/UnitView-CAXHvh3n.js +0 -674
  62. package/dist/import-export.helper-B04wszRI.js +0 -243
  63. package/dist/views/import/ImportView.vue.d.ts +0 -3
  64. package/dist/views/import/components/ImportDialog.vue.d.ts +0 -2
  65. package/dist/views/import/helper/import-export.helper.d.ts +0 -4
  66. package/dist/views/receive-request/components/delivery-order-form/SystemTrailDialog.vue.d.ts +0 -17
  67. package/dist/views/recipe/components/import-recipes/ImportRecipeItem.vue.d.ts +0 -16
  68. package/dist/views/recipe/components/import-recipes/ImportRecipes.vue.d.ts +0 -2
  69. package/dist/views/recipe/helper/import-recipe.d.ts +0 -48
  70. package/dist/views/unit/components/import-units/ImportUnitItem.vue.d.ts +0 -12
  71. package/dist/views/unit/components/import-units/ImportUnitItemProps.d.ts +0 -6
  72. package/dist/views/unit/components/import-units/ImportUnits.vue.d.ts +0 -9
  73. package/dist/views/unit/components/import-units/ImportUnitsProps.d.ts +0 -5
  74. package/dist/views/unit/helper/import-export.helper.d.ts +0 -40
@@ -0,0 +1,667 @@
1
+ import { defineComponent as K, computed as b, openBlock as v, createElementBlock as w, createElementVNode as s, Fragment as q, renderList as H, toDisplayString as V, createCommentVNode as Y, ref as R, watch as ee, resolveComponent as I, createBlock as T, withCtx as A, createVNode as f, unref as l, isRef as te, normalizeClass as ie, normalizeStyle as ue, Teleport as de, normalizeProps as me, guardReactiveProps as ce } from "vue";
2
+ import { a as O, e as U, S as pe, i as ve, D as ne, j as L, f as se, a0 as fe, p as j, A as ye, l as J, a1 as be, a2 as ge, w as oe, u as xe, b as _e, O as he, P as Ve, Q as Ue, T as we, V as Ce } from "./app-D2lun71R.js";
3
+ import { useDialog as Se, useSnackbar as ae, useProxiedModel as le, useBreakpoints as ke } from "@feedmepos/ui-library";
4
+ import { i as Fe, _ as $e } from "./is-linked-ingredient-error-fJ2TJb3z.js";
5
+ import { defineStore as Ee, storeToRefs as Ie } from "pinia";
6
+ import { useI18n as G } from "@feedmepos/mf-common";
7
+ import { F as De } from "./decimal-eeicE4jp.js";
8
+ import { _ as Ae } from "./NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DjN_ktl1.js";
9
+ const Re = { class: "flex flex-col gap-8" }, Me = {
10
+ key: 0,
11
+ class: "flex flex-col"
12
+ }, Pe = { class: "flex-1 py-8 px-16" }, Te = {
13
+ class: "flex-0 py-8 px-16",
14
+ style: { "flex-basis": "240px" }
15
+ }, Be = {
16
+ key: 1,
17
+ class: "flex flex-col"
18
+ }, Ne = { class: "flex-1 py-8 px-16" }, ze = {
19
+ class: "flex-0 py-8 px-16",
20
+ style: { "flex-basis": "240px" }
21
+ }, Le = {
22
+ key: 2,
23
+ class: "flex flex-col"
24
+ }, je = { class: "flex-1 py-8 px-16" }, qe = {
25
+ class: "flex-0 py-8 px-16",
26
+ style: { "flex-basis": "240px" }
27
+ }, He = /* @__PURE__ */ K({
28
+ __name: "UnitUsedBy",
29
+ props: {
30
+ unit: {}
31
+ },
32
+ setup(F) {
33
+ const c = F, y = O(), m = b(() => y.validateUnitUsage(c.unit)), a = b(() => m.value.filter((n) => n.from === "INGREDIENT")), r = b(() => m.value.filter((n) => n.from === "RECIPE")), d = b(() => m.value.filter((n) => n.from === "MENU"));
34
+ return (n, p) => (v(), w("div", Re, [
35
+ p[3] || (p[3] = s("div", { class: "fm-typo-en-body-md-400" }, "Sorry, this unit is used in the following modules:", -1)),
36
+ a.value.length ? (v(), w("div", Me, [
37
+ p[0] || (p[0] = s("div", { class: "flex flex-row fm-typo-en-body-md-600 bg-fm-color-neutral-gray-100 text-fm-color-typo-secondary h-48 items-center" }, [
38
+ s("div", { class: "flex-1 py-8 px-16" }, "Ingredient"),
39
+ s("div", {
40
+ class: "flex-0 py-8 px-16",
41
+ style: { "flex-basis": "240px" }
42
+ }, "Used in")
43
+ ], -1)),
44
+ (v(!0), w(q, null, H(a.value, (i) => {
45
+ var t;
46
+ return v(), w("div", {
47
+ key: i.code,
48
+ class: "flex flex-row fm-typo-en-body-md-400 h-48 items-center border-b border-b-fm-color-neutral-gray-100"
49
+ }, [
50
+ s("div", Pe, V(i.code) + " " + V(i.name), 1),
51
+ s("div", Te, V((t = i.bindedIngredient) != null && t.length ? "Convert binding" : "Item unit"), 1)
52
+ ]);
53
+ }), 128))
54
+ ])) : Y("", !0),
55
+ r.value.length ? (v(), w("div", Be, [
56
+ p[1] || (p[1] = s("div", { class: "flex flex-row fm-typo-en-body-md-600 bg-fm-color-neutral-gray-100 text-fm-color-typo-secondary h-48 items-center" }, [
57
+ s("div", { class: "flex-1 py-8 px-16" }, "Recipe"),
58
+ s("div", {
59
+ class: "flex-0 py-8 px-16",
60
+ style: { "flex-basis": "240px" }
61
+ }, "Used in")
62
+ ], -1)),
63
+ (v(!0), w(q, null, H(r.value, (i) => {
64
+ var t, u, g;
65
+ return v(), w("div", {
66
+ key: i.code,
67
+ class: "flex flex-row fm-typo-en-body-md-400 h-48 items-center border-b border-b-fm-color-neutral-gray-100"
68
+ }, [
69
+ s("div", Ne, V(i.code) + " " + V(i.name), 1),
70
+ s("div", ze, V((t = i.bindedIngredient) == null ? void 0 : t.slice(0, 3).map((C) => C.code).join(", ")) + " " + V(i.bindedIngredient && ((u = i.bindedIngredient) == null ? void 0 : u.length) > 3 ? `and ${((g = i.bindedIngredient) == null ? void 0 : g.length) - 3} more` : ""), 1)
71
+ ]);
72
+ }), 128))
73
+ ])) : Y("", !0),
74
+ d.value.length ? (v(), w("div", Le, [
75
+ p[2] || (p[2] = s("div", { class: "flex flex-row fm-typo-en-body-md-600 bg-fm-color-neutral-gray-100 text-fm-color-typo-secondary h-48 items-center" }, [
76
+ s("div", { class: "flex-1 py-8 px-16" }, "Menu"),
77
+ s("div", {
78
+ class: "flex-0 py-8 px-16",
79
+ style: { "flex-basis": "240px" }
80
+ }, "Used in")
81
+ ], -1)),
82
+ (v(!0), w(q, null, H(d.value, (i) => {
83
+ var t, u, g;
84
+ return v(), w("div", {
85
+ key: i.code,
86
+ class: "flex flex-row fm-typo-en-body-md-400 h-48 items-center border-b border-b-fm-color-neutral-gray-100"
87
+ }, [
88
+ s("div", je, V(i.code) + " " + V(i.name), 1),
89
+ s("div", qe, V((t = i.bindedIngredient) == null ? void 0 : t.slice(0, 3).map((C) => C.code).join(", ")) + " " + V(i.bindedIngredient && ((u = i.bindedIngredient) == null ? void 0 : u.length) > 3 ? `and ${((g = i.bindedIngredient) == null ? void 0 : g.length) - 3} more` : ""), 1)
90
+ ]);
91
+ }), 128))
92
+ ])) : Y("", !0)
93
+ ]));
94
+ }
95
+ }), W = Ee("unitForm", function() {
96
+ const c = Se(), y = ae(), m = O(), a = R(!1), r = R();
97
+ function d() {
98
+ const t = {
99
+ unit: {},
100
+ mode: U.CREATE,
101
+ show: !0,
102
+ "onUpdate:show"(u) {
103
+ r.value.show = u;
104
+ }
105
+ };
106
+ r.value = t;
107
+ }
108
+ async function n(t) {
109
+ const u = {
110
+ unit: t,
111
+ mode: U.UPDATE,
112
+ show: !0,
113
+ "onUpdate:show"(g) {
114
+ r.value.show = g;
115
+ }
116
+ };
117
+ r.value = u;
118
+ }
119
+ async function p(t) {
120
+ a.value = !0;
121
+ try {
122
+ await m.deleteUnit(t), y.open({
123
+ title: "Success",
124
+ message: `Deleted ${t.name}`,
125
+ type: "success"
126
+ });
127
+ } catch (u) {
128
+ u instanceof pe && Fe(u) ? c.open({
129
+ title: "Cannot delete unit",
130
+ contentComponent: $e,
131
+ contentComponentProps: {
132
+ subject: (t == null ? void 0 : t.name) ?? "",
133
+ items: u.errorResponse.message
134
+ },
135
+ secondaryActions: {
136
+ text: "Close",
137
+ close: !0
138
+ }
139
+ }) : console.log("unable to delete unit", u), y.open({
140
+ title: `Cannot delete ${t.name}`,
141
+ message: "Please try again.",
142
+ type: "error"
143
+ }), console.error("failed to delete unit", u);
144
+ } finally {
145
+ a.value = !1;
146
+ }
147
+ }
148
+ function i(t) {
149
+ if (m.validateUnitUsage(t).length) {
150
+ c.open({
151
+ title: `Cannot delete ${(t == null ? void 0 : t.name) ?? "unit"}`,
152
+ overlay: !0,
153
+ dismissAway: !0,
154
+ closeButton: !0,
155
+ contentComponent: He,
156
+ contentComponentProps: {
157
+ unit: t
158
+ },
159
+ primaryActions: {
160
+ text: "Confirm",
161
+ close: !0
162
+ }
163
+ });
164
+ return;
165
+ }
166
+ c.open({
167
+ title: `Delete ${(t == null ? void 0 : t.name) ?? "unit"}?`,
168
+ closeButton: !1,
169
+ message: "You may not be able to delete this unit if it is linked in any of the inventory modules.",
170
+ primaryActions: {
171
+ text: "Delete",
172
+ close: !0,
173
+ variant: "destructive"
174
+ },
175
+ secondaryActions: {
176
+ text: "Cancel",
177
+ close: !0
178
+ }
179
+ }).onPrimary(() => p(t));
180
+ }
181
+ return {
182
+ createUnit: d,
183
+ updateUnit: n,
184
+ deleteUnit: i,
185
+ unitDialogProps: r,
186
+ unitViewLoading: a
187
+ };
188
+ });
189
+ function Ke() {
190
+ const { updateUnit: F, deleteUnit: c } = W(), { t: y } = G();
191
+ async function m(r, d) {
192
+ const n = se(d);
193
+ if (r === L.Edit) {
194
+ await F(n);
195
+ return;
196
+ }
197
+ if (r === L.Delete) {
198
+ await c(n);
199
+ return;
200
+ }
201
+ }
202
+ return { columnDefs: [
203
+ {
204
+ accessorKey: "name",
205
+ header: y("inventory.unit.table.name"),
206
+ enableSorting: !0,
207
+ size: 300
208
+ },
209
+ {
210
+ accessorKey: "abbrev",
211
+ header: y("inventory.unit.table.symbol"),
212
+ enableSorting: !1,
213
+ size: "auto"
214
+ },
215
+ {
216
+ id: "action",
217
+ header: "",
218
+ cell(r) {
219
+ return ve(
220
+ [ne[L.Edit], ne[L.Delete]],
221
+ (d) => {
222
+ m(d, r.row.original);
223
+ }
224
+ );
225
+ },
226
+ enableSorting: !1,
227
+ size: 40,
228
+ meta: {
229
+ cellClass: "",
230
+ headerClass: ""
231
+ }
232
+ }
233
+ ] };
234
+ }
235
+ const Oe = { class: "flex flex-col gap-24" }, Ge = { class: "flex gap-24" }, Qe = { class: "flex-1" }, Ye = { class: "flex-1" }, Je = { class: "flex" }, We = { class: "flex items-center" }, Xe = { class: "fm-typo-en-body-lg-600 flex-grow" }, Ze = { class: "flex flex-col gap-24" }, et = { class: "flex gap-24" }, tt = { class: "flex-1" }, nt = { class: "flex-1" }, ot = /* @__PURE__ */ K({
236
+ __name: "UnitForm",
237
+ props: {
238
+ mode: {},
239
+ modelValue: {},
240
+ disabled: { type: Boolean }
241
+ },
242
+ emits: ["update:modelValue", "click:submit"],
243
+ setup(F, { expose: c, emit: y }) {
244
+ const m = F, a = y, { t: r } = G();
245
+ function d() {
246
+ a("click:submit");
247
+ }
248
+ const n = R(m.modelValue);
249
+ ee(
250
+ () => m.modelValue,
251
+ (e) => {
252
+ n.value = e;
253
+ }
254
+ );
255
+ const p = b({
256
+ get() {
257
+ var e;
258
+ return ((e = n.value) == null ? void 0 : e.name) ?? "";
259
+ },
260
+ set(e) {
261
+ n.value.name = e, a("update:modelValue", n.value);
262
+ }
263
+ }), i = b({
264
+ get() {
265
+ var e;
266
+ return ((e = n.value) == null ? void 0 : e.abbrev) ?? "";
267
+ },
268
+ set(e) {
269
+ n.value.abbrev = e, a("update:modelValue", n.value);
270
+ }
271
+ }), t = b({
272
+ get() {
273
+ var e;
274
+ return ((e = n.value) == null ? void 0 : e.precision) ?? 0;
275
+ },
276
+ set(e) {
277
+ n.value.precision = e, a("update:modelValue", n.value);
278
+ }
279
+ }), u = b({
280
+ get() {
281
+ var e;
282
+ return ((e = n.value) == null ? void 0 : e.measurements) ?? [];
283
+ },
284
+ set(e) {
285
+ n.value.measurements = e, a("update:modelValue", n.value);
286
+ }
287
+ });
288
+ ee(
289
+ () => t.value,
290
+ (e) => {
291
+ if (typeof e == "number" && !isNaN(e)) {
292
+ const o = u.value.map((x) => ({
293
+ ...x,
294
+ conversion: fe.convertPrecision({
295
+ value: x.conversion,
296
+ precision: e
297
+ })
298
+ }));
299
+ n.value.measurements = o, a("update:modelValue", n.value);
300
+ }
301
+ },
302
+ { immediate: !0 }
303
+ );
304
+ function g() {
305
+ const e = n.value.measurements ?? [];
306
+ n.value.measurements = [
307
+ ...e,
308
+ {
309
+ id: `measurement_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
310
+ name: "",
311
+ abbrev: "",
312
+ conversion: {
313
+ amount: 1,
314
+ precision: 0
315
+ }
316
+ }
317
+ ], a("update:modelValue", n.value);
318
+ }
319
+ function C(e) {
320
+ const o = n.value.measurements ?? [];
321
+ o.splice(e, 1), n.value.measurements = o, a("update:modelValue", n.value);
322
+ }
323
+ const S = R();
324
+ return c({
325
+ validateInputs: () => {
326
+ var e, o;
327
+ (o = (e = S.value) == null ? void 0 : e.validateInputs) == null || o.call(e);
328
+ },
329
+ resetInputsValidation: () => {
330
+ var e, o;
331
+ (o = (e = S.value) == null ? void 0 : e.resetInputsValidation) == null || o.call(e);
332
+ },
333
+ resetInputs: () => {
334
+ var e, o;
335
+ (o = (e = S.value) == null ? void 0 : e.resetInputs) == null || o.call(e);
336
+ }
337
+ }), (e, o) => {
338
+ const x = I("FmTextField"), M = I("FmStepperField"), _ = I("FmButton"), Q = I("FmCard"), E = I("FmForm");
339
+ return v(), T(E, {
340
+ ref_key: "formRef",
341
+ ref: S,
342
+ class: "flex flex-col gap-40",
343
+ onValidationSuccess: d
344
+ }, {
345
+ default: A(() => {
346
+ var P;
347
+ return [
348
+ s("div", Oe, [
349
+ s("div", Ge, [
350
+ s("div", Qe, [
351
+ f(x, {
352
+ disabled: e.disabled,
353
+ label: l(r)("inventory.unit.name"),
354
+ modelValue: p.value,
355
+ "onUpdate:modelValue": o[0] || (o[0] = (k) => p.value = k),
356
+ rules: [l(j)()],
357
+ "label-mark": "required"
358
+ }, null, 8, ["disabled", "label", "modelValue", "rules"])
359
+ ]),
360
+ s("div", Ye, [
361
+ f(x, {
362
+ disabled: e.disabled,
363
+ label: l(r)("inventory.unit.symbol"),
364
+ modelValue: i.value,
365
+ "onUpdate:modelValue": o[1] || (o[1] = (k) => i.value = k),
366
+ rules: [l(j)()],
367
+ "label-mark": "required"
368
+ }, null, 8, ["disabled", "label", "modelValue", "rules"])
369
+ ])
370
+ ]),
371
+ s("div", null, [
372
+ f(M, {
373
+ disabled: e.disabled,
374
+ class: "col-span-3",
375
+ label: l(r)("inventory.unit.precision"),
376
+ modelValue: t.value,
377
+ "onUpdate:modelValue": o[2] || (o[2] = (k) => t.value = k),
378
+ rules: [l(ye)(0)]
379
+ }, null, 8, ["disabled", "label", "modelValue", "rules"])
380
+ ])
381
+ ]),
382
+ s("div", Je, [
383
+ f(_, {
384
+ disabled: e.disabled,
385
+ type: "button",
386
+ "prepend-icon": "add",
387
+ label: l(r)("inventory.unit.measurement.addMeasurement"),
388
+ variant: "plain",
389
+ onClick: g
390
+ }, null, 8, ["disabled", "label"])
391
+ ]),
392
+ (v(!0), w(q, null, H((P = e.modelValue) == null ? void 0 : P.measurements, (k, h) => (v(), T(Q, {
393
+ class: "flex flex-col gap-16 p-16",
394
+ variant: "outlined",
395
+ key: k.id
396
+ }, {
397
+ default: A(() => [
398
+ s("div", We, [
399
+ s("div", Xe, V(l(r)("inventory.unit.measurement.measurementDefault", [h + 1])), 1),
400
+ f(_, {
401
+ disabled: e.disabled,
402
+ variant: "tertiary",
403
+ "prepend-icon": "delete",
404
+ onClick: ($) => C(h)
405
+ }, null, 8, ["disabled", "onClick"])
406
+ ]),
407
+ s("div", Ze, [
408
+ s("div", et, [
409
+ s("div", tt, [
410
+ f(x, {
411
+ disabled: e.disabled,
412
+ class: "col-span-2",
413
+ label: l(r)("inventory.unit.measurement.name"),
414
+ modelValue: e.modelValue.measurements[h].name,
415
+ "onUpdate:modelValue": ($) => e.modelValue.measurements[h].name = $,
416
+ rules: [l(j)()],
417
+ "label-mark": "required"
418
+ }, null, 8, ["disabled", "label", "modelValue", "onUpdate:modelValue", "rules"])
419
+ ]),
420
+ s("div", nt, [
421
+ f(x, {
422
+ disabled: e.disabled,
423
+ label: l(r)("inventory.unit.measurement.symbol"),
424
+ modelValue: e.modelValue.measurements[h].abbrev,
425
+ "onUpdate:modelValue": ($) => e.modelValue.measurements[h].abbrev = $,
426
+ rules: [l(j)()],
427
+ "label-mark": "required"
428
+ }, null, 8, ["disabled", "label", "modelValue", "onUpdate:modelValue", "rules"])
429
+ ])
430
+ ]),
431
+ f(Ae, {
432
+ disabled: e.disabled,
433
+ class: "col-span-3",
434
+ label: l(r)("inventory.unit.measurement.conversion"),
435
+ "model-value": +l(J)(e.modelValue.measurements[h].conversion),
436
+ "onUpdate:modelValue": ($) => u.value = u.value.map(
437
+ (D, B) => B === h ? {
438
+ ...D,
439
+ conversion: l(De).toPrecision(
440
+ l(be)($),
441
+ t.value
442
+ )
443
+ } : D
444
+ ),
445
+ rules: [l(ge)(0)],
446
+ step: +l(J)({ amount: 1, precision: t.value }),
447
+ "helper-text": l(r)("inventory.unit.measurement.conversionHelper", {
448
+ measurementSymbol: e.modelValue.measurements[h].name || " measurement unit",
449
+ conversion: +l(J)(e.modelValue.measurements[h].conversion),
450
+ unitSymbol: i.value || "base unit"
451
+ })
452
+ }, null, 8, ["disabled", "label", "model-value", "onUpdate:modelValue", "rules", "step", "helper-text"])
453
+ ])
454
+ ]),
455
+ _: 2
456
+ }, 1024))), 128))
457
+ ];
458
+ }),
459
+ _: 1
460
+ }, 512);
461
+ };
462
+ }
463
+ }), lt = { class: "flex gap-4" }, st = /* @__PURE__ */ K({
464
+ __name: "UnitDialog",
465
+ props: {
466
+ show: { type: Boolean },
467
+ unit: {},
468
+ mode: { default: U.READ }
469
+ },
470
+ emits: ["update:show"],
471
+ setup(F) {
472
+ const c = F, y = O(), m = ae(), { t: a } = G(), r = le(c, "show"), d = le(c, "unit"), n = b(() => {
473
+ switch (c.mode) {
474
+ case U.READ:
475
+ return "";
476
+ case U.UPDATE:
477
+ return a("inventory.unit.update.title");
478
+ case U.CREATE:
479
+ return a("inventory.unit.create.title");
480
+ }
481
+ return "";
482
+ }), p = b(() => {
483
+ switch (c.mode) {
484
+ case U.READ:
485
+ return "";
486
+ case U.UPDATE:
487
+ return a("common.save");
488
+ case U.CREATE:
489
+ return a("common.add");
490
+ }
491
+ return "";
492
+ }), i = R(), t = R(!1);
493
+ async function u() {
494
+ t.value = !0;
495
+ try {
496
+ const e = se(d.value);
497
+ e.precision ?? (e.precision = 0), e.measurements ?? (e.measurements = []), await y.createUnit(e), r.value = !1, m.open({
498
+ title: a("inventory.common.success"),
499
+ message: a("inventory.unit.create.success", { name: d.value.name }),
500
+ type: "success"
501
+ });
502
+ } catch (e) {
503
+ e instanceof oe || m.open({
504
+ title: a("inventory.unit.create.error.title"),
505
+ message: a("inventory.unit.create.error.message"),
506
+ type: "error"
507
+ });
508
+ } finally {
509
+ t.value = !1;
510
+ }
511
+ }
512
+ async function g() {
513
+ t.value = !0;
514
+ try {
515
+ await y.updateUnit(d.value), r.value = !1, m.open({
516
+ title: a("inventory.common.success"),
517
+ message: a("inventory.unit.update.success", { name: d.value.name }),
518
+ type: "success"
519
+ });
520
+ } catch (e) {
521
+ e instanceof oe || m.open({
522
+ title: a("inventory.unit.update.error.title"),
523
+ message: a("inventory.unit.update.error.message"),
524
+ type: "error"
525
+ });
526
+ } finally {
527
+ t.value = !1;
528
+ }
529
+ }
530
+ function C() {
531
+ var e, o;
532
+ (o = (e = i.value) == null ? void 0 : e.validateInputs) == null || o.call(e);
533
+ }
534
+ function S() {
535
+ switch (c.mode) {
536
+ case U.READ:
537
+ return;
538
+ case U.UPDATE:
539
+ return g();
540
+ case U.CREATE:
541
+ return u();
542
+ }
543
+ }
544
+ return (e, o) => {
545
+ const x = I("FmButton"), M = I("FmSideSheet");
546
+ return v(), T(M, {
547
+ "model-value": l(r),
548
+ "onUpdate:modelValue": o[3] || (o[3] = (_) => te(r) ? r.value = _ : null),
549
+ header: n.value,
550
+ "close-button": "",
551
+ "dismiss-away": "",
552
+ "max-width": 500
553
+ }, {
554
+ "side-sheet-footer": A(() => [
555
+ s("div", lt, [
556
+ f(x, {
557
+ loading: t.value,
558
+ label: p.value,
559
+ onClick: C
560
+ }, null, 8, ["loading", "label"]),
561
+ f(x, {
562
+ disabled: t.value,
563
+ label: l(a)("common.close"),
564
+ variant: "tertiary",
565
+ onClick: o[2] || (o[2] = (_) => r.value = !1)
566
+ }, null, 8, ["disabled", "label"])
567
+ ])
568
+ ]),
569
+ default: A(() => [
570
+ f(ot, {
571
+ class: "w-full",
572
+ ref_key: "hasValidationExpose",
573
+ ref: i,
574
+ modelValue: l(d),
575
+ "onUpdate:modelValue": o[0] || (o[0] = (_) => te(d) ? d.value = _ : null),
576
+ mode: e.mode,
577
+ disabled: t.value,
578
+ "onClick:submit": o[1] || (o[1] = (_) => S())
579
+ }, null, 8, ["modelValue", "mode", "disabled"])
580
+ ]),
581
+ _: 1
582
+ }, 8, ["model-value", "header"]);
583
+ };
584
+ }
585
+ }), at = { class: "flex flex-col py-8" }, rt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, it = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, bt = /* @__PURE__ */ K({
586
+ __name: "UnitView",
587
+ setup(F) {
588
+ const c = O(), y = xe(), m = _e(), a = b(() => c.units), { createUnit: r, updateUnit: d } = W(), { unitDialogProps: n, unitViewLoading: p } = Ie(W()), { columnDefs: i } = Ke();
589
+ function t(M) {
590
+ M === "add" && r();
591
+ }
592
+ const u = R(""), g = b(() => p.value), { breakpoints: C } = ke(), S = b(() => C.value.xs || C.value.sm), e = b(() => S.value ? 10 : 20), o = he(), { t: x } = G();
593
+ return (M, _) => {
594
+ const Q = I("FmTable");
595
+ return v(), T(Ve, {
596
+ title: l(x)("inventory.unit.title"),
597
+ actions: l(m).isEnabled ? [] : [
598
+ {
599
+ label: l(x)("inventory.unit.create.title"),
600
+ value: "add",
601
+ isPrimary: !0,
602
+ prependIcon: "add"
603
+ }
604
+ ],
605
+ "onClick:action": t
606
+ }, {
607
+ default: A(() => [
608
+ s("div", {
609
+ class: ie([
610
+ "flex flex-col gap-8 max-h-full",
611
+ {
612
+ "p-0": S.value,
613
+ "px-24 ": !S.value
614
+ }
615
+ ])
616
+ }, [
617
+ f(Ue, {
618
+ searchable: "",
619
+ search: u.value,
620
+ "onUpdate:search": _[0] || (_[0] = (E) => u.value = E)
621
+ }, null, 8, ["search"]),
622
+ f(Q, {
623
+ style: ue(l(o).tableHeight),
624
+ "column-defs": l(i),
625
+ "row-data": a.value,
626
+ "search-value": u.value,
627
+ loading: !l(y)._currentLocation || g.value,
628
+ onRowClick: _[1] || (_[1] = (E) => l(d)(E.original)),
629
+ "page-size": e.value
630
+ }, {
631
+ "list-row": A((E) => [
632
+ f(we, {
633
+ row: E,
634
+ onRowClick: l(d)
635
+ }, {
636
+ default: A((P) => {
637
+ var k, h, $, D, B, N, X, z, Z;
638
+ return [
639
+ s("div", at, [
640
+ s("div", rt, [
641
+ f(l(Ce), {
642
+ render: ($ = (h = (k = P.name) == null ? void 0 : k.column) == null ? void 0 : h.columnDef) == null ? void 0 : $.cell,
643
+ props: (B = (D = P.name) == null ? void 0 : D.getContext) == null ? void 0 : B.call(D)
644
+ }, null, 8, ["render", "props"])
645
+ ]),
646
+ s("div", it, V((Z = (z = (X = (N = E.original.measurements) == null ? void 0 : N.map) == null ? void 0 : X.call(N, (re) => re.name)) == null ? void 0 : z.join) == null ? void 0 : Z.call(z, ", ")), 1)
647
+ ])
648
+ ];
649
+ }),
650
+ _: 2
651
+ }, 1032, ["row", "onRowClick"])
652
+ ]),
653
+ _: 1
654
+ }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
655
+ ], 2),
656
+ (v(), T(de, { to: "body" }, [
657
+ f(st, me(ce(l(n))), null, 16)
658
+ ]))
659
+ ]),
660
+ _: 1
661
+ }, 8, ["title", "actions"]);
662
+ };
663
+ }
664
+ });
665
+ export {
666
+ bt as default
667
+ };