@feedmepos/mf-inventory-portal 0.0.18-dev.3 → 0.0.19-dev.10

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 (114) hide show
  1. package/dist/ApprovalView-BgTTFiOw.js +121 -0
  2. package/dist/{BindingsDialog-CVeD1mOn.js → BindingsDialog-BROnpXEI.js} +9 -10
  3. package/dist/{BindingsPicker-K04aOoGr.js → BindingsPicker-aQHfS_vY.js} +7 -8
  4. package/dist/{BindingsTable-65aYkpX7.js → BindingsTable-DvtIQMFk.js} +4 -6
  5. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DR9YAhaJ.js +272 -0
  6. package/dist/IngredientsView-BgAQCCD-.js +1751 -0
  7. package/dist/IntegrationView-DEBb_X5K.js +1172 -0
  8. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-kidodonU.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-VF3PDSzP.js} +1 -1
  9. package/dist/PremiumBadge.vue_vue_type_script_setup_true_lang-BIRzNfFN.js +88 -0
  10. package/dist/PreviewBadge.vue_vue_type_script_setup_true_lang-CRZiQHjx.js +29 -0
  11. package/dist/{PurchaseOrderPrintPreview-B4uzudnC.js → PurchaseOrderPrintPreview-D2zNGZhx.js} +4 -4
  12. package/dist/ReceiveRequestView-Dc5JlUMC.js +208 -0
  13. package/dist/RecipeView-C1DBn8pW.js +573 -0
  14. package/dist/StockForecast.vue_vue_type_style_index_0_lang-KLXSWvo5.js +59 -0
  15. package/dist/StockView-6wi6BEOE.js +1877 -0
  16. package/dist/SupplierView-CS7YdL5Q.js +801 -0
  17. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CBbbXOhl.js +745 -0
  18. package/dist/TransferDialog.vue_vue_type_script_setup_true_lang-CWEypKBc.js +1662 -0
  19. package/dist/TransferTemplateView-C1hmdeKM.js +933 -0
  20. package/dist/UnitView-BUdKTKch.js +638 -0
  21. package/dist/WarehouseView-BbreEn79.js +1050 -0
  22. package/dist/api/bill.d.ts +2 -2
  23. package/dist/api/purchase-order-template.d.ts +7 -0
  24. package/dist/app-B3oV5Muh.js +67059 -0
  25. package/dist/app.d.ts +1111 -0
  26. package/dist/app.js +7 -3
  27. package/dist/components/FmDroppableField.vue.d.ts +1 -1
  28. package/dist/components/FmMultiselectDialogProps.d.ts +7 -0
  29. package/dist/components/FmUnitInputProps.d.ts +2 -0
  30. package/dist/components/FmUnitInputRules.d.ts +1 -0
  31. package/dist/components/row-action.enum.d.ts +2 -0
  32. package/dist/composable/defineDeepModel.d.ts +2 -0
  33. package/dist/{decimal-ziY3648r.js → decimal-DzjRPmPY.js} +1 -1
  34. package/dist/helper/country.d.ts +2 -0
  35. package/dist/id-to-date-CG1QobkF.js +30 -0
  36. package/dist/layout-qEWDq5Vs.js +147 -0
  37. package/dist/purchase-order-transaction-type-D-GMrgDp.js +294 -0
  38. package/dist/router/name.d.ts +2 -1
  39. package/dist/row-action.enum-7jVyol1k.js +36 -0
  40. package/dist/stores/supplier.d.ts +90 -7
  41. package/dist/style.css +1 -1
  42. package/dist/supplier-BE_AQA4h.js +54 -0
  43. package/dist/tsconfig.app.tsbuildinfo +1 -1
  44. package/dist/views/dev/components/FmMultiselectDialogGrouped.vue.d.ts +2 -0
  45. package/dist/views/ingredients/components/inventory-binding/InventoryBindingForm.vue.d.ts +2 -0
  46. package/dist/views/ingredients/components/inventory-binding/InventoryBindingSummary.vue.d.ts +26 -0
  47. package/dist/views/ingredients/composables/use-ingredient-form.d.ts +14 -2
  48. package/dist/views/ingredients/composables/use-ingredient-table.d.ts +1 -2
  49. package/dist/views/ingredients/helper/calculate-default-cost.d.ts +9 -0
  50. package/dist/views/receive-request/components/transfer-dialog/TransferDialogProps.d.ts +1 -0
  51. package/dist/views/receive-request/components/transfer-form/SparkIcon.vue.d.ts +1 -1
  52. package/dist/views/receive-request/components/transfer-form/TransferForm.vue.d.ts +4 -0
  53. package/dist/views/receive-request/components/transfer-form/TransferForm2.vue.d.ts +22 -0
  54. package/dist/views/receive-request/components/transfer-form/TransferFormProps.d.ts +2 -1
  55. package/dist/views/receive-request/components/transfer-form/components/ForecastStock.vue.d.ts +187 -0
  56. package/dist/views/receive-request/components/transfer-form/components/TransferItem.vue.d.ts +23 -0
  57. package/dist/views/receive-request/components/transfer-form/components/TransferItemTable.vue.d.ts +21 -0
  58. package/dist/views/receive-request/components/transfer-form/composables/use-backdate-po.d.ts +9 -0
  59. package/dist/views/receive-request/components/transfer-form/composables/use-compare-price.d.ts +6 -0
  60. package/dist/views/receive-request/components/transfer-form/composables/use-transfer-items.d.ts +112 -0
  61. package/dist/views/receive-request/composables/use-receive-request-form.d.ts +3 -1
  62. package/dist/views/receive-request/composables/use-receive-request-table.d.ts +18 -12
  63. package/dist/views/receive-request/helper/get-transfer-type.d.ts +2 -0
  64. package/dist/views/recipe/composables/use-recipe-form.d.ts +14 -2
  65. package/dist/views/recipe/composables/use-recipe-table.d.ts +1 -2
  66. package/dist/views/stock/components/StockRecordCard.vue.d.ts +1 -1
  67. package/dist/views/stock/components/dialog/AdjustedItemForm.vue.d.ts +2 -2
  68. package/dist/views/stock/composables/use-stock-action.d.ts +26 -0
  69. package/dist/views/stock/composables/use-stock-table.d.ts +1 -8
  70. package/dist/views/stock/helper/compute-summary-total.d.ts +2 -2
  71. package/dist/views/transfer-template/TransferTemplateView.vue.d.ts +2 -0
  72. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialog.vue.d.ts +22 -0
  73. package/dist/views/transfer-template/components/transfer-template-dialog/TransferTemplateDialogProps.d.ts +10 -0
  74. package/dist/views/transfer-template/components/transfer-template-form/TransferTemplateForm.vue.d.ts +16 -0
  75. package/dist/views/transfer-template/components/transfer-template-form/TransferTemplateFormProps.d.ts +7 -0
  76. package/dist/views/transfer-template/components/transfer-template-form/components/TransferTemplateItem.vue.d.ts +18 -0
  77. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-locations.d.ts +116 -0
  78. package/dist/views/transfer-template/components/transfer-template-form/composables/use-transfer-template-items.d.ts +112 -0
  79. package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +470 -0
  80. package/dist/views/transfer-template/composables/use-transfer-template-table.d.ts +290 -0
  81. package/dist/views/unit/composables/use-unit-form.d.ts +14 -2
  82. package/dist/views/unit/composables/use-unit-table.d.ts +1 -2
  83. package/dist/{xlsx-BG4CsaGF.js → xlsx-BGXLmGtO.js} +1 -1
  84. package/dist/xlsx.util-DxU-P-ww.js +109 -0
  85. package/package.json +6 -5
  86. package/dist/ApprovalView-G-u9nPxH.js +0 -118
  87. package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DgHp7KgJ.js +0 -268
  88. package/dist/FmMultiselectDialog.vue_vue_type_script_setup_true_lang-C5WBLEy3.js +0 -143
  89. package/dist/FmUnitInput.vue_vue_type_script_setup_true_lang-QKFZeZKM.js +0 -236
  90. package/dist/IngredientsView-6Q2UWsu-.js +0 -1776
  91. package/dist/IntegrationView-ZMPPIopU.js +0 -1166
  92. package/dist/InventoryBindingForm.vue_vue_type_script_setup_true_lang-C8YTZoBw.js +0 -276
  93. package/dist/PreviewBadge.vue_vue_type_script_setup_true_lang-BvadeWUz.js +0 -35
  94. package/dist/ReceiveRequestView-DuHtLwZN.js +0 -1394
  95. package/dist/RecipeView-CRj0pC9N.js +0 -573
  96. package/dist/StockForecast.vue_vue_type_style_index_0_lang-B5EK101t.js +0 -58
  97. package/dist/StockView-CQbeZ5pU.js +0 -1862
  98. package/dist/SupplierView-CrfQATQf.js +0 -796
  99. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CLUo-Tve.js +0 -1028
  100. package/dist/UnitView-D1acjiRV.js +0 -635
  101. package/dist/WarehouseView-DID1G1qK.js +0 -1043
  102. package/dist/app-D1teOEQX.js +0 -66113
  103. package/dist/date2-6Vt_hnAG.js +0 -95
  104. package/dist/dayjs.min-Co7-8-Mb.js +0 -282
  105. package/dist/fuzzy-gvHXFsh0.js +0 -41
  106. package/dist/index-Do1KDD1S.js +0 -21515
  107. package/dist/layout-BxDEsp4a.js +0 -151
  108. package/dist/number-Dvvpk3SV.js +0 -97
  109. package/dist/row-action.enum-BwQbURNh.js +0 -28
  110. package/dist/rules-CQu9yXsg.js +0 -85
  111. package/dist/stock-estimate-Wysv30cx.js +0 -122
  112. package/dist/supplier-BFdAYn3E.js +0 -65
  113. package/dist/use-inventory-binding-dialog-CuyOzZ5r.js +0 -93
  114. package/dist/xlsx.util-BkVYceD0.js +0 -107
@@ -1,635 +0,0 @@
1
- import { defineComponent as H, computed as x, openBlock as c, createElementBlock as w, Fragment as j, renderList as q, createElementVNode as l, toDisplayString as g, createCommentVNode as G, ref as R, resolveComponent as A, createBlock as M, withCtx as D, createVNode as m, unref as d, isRef as Q, normalizeStyle as le, Teleport as se, normalizeProps as ae, guardReactiveProps as ne } from "vue";
2
- import { u as K, S as re, c as ee, b as W, f as ie } from "./app-D1teOEQX.js";
3
- import { useDialog as de, useSnackbar as te, useProxiedModel as X, useBreakpoints as ue } from "@feedmepos/ui-library";
4
- import { i as ce, _ as me } from "./is-linked-ingredient-error-C6AghEwR.js";
5
- import { F as U, D as Z, R as L } from "./row-action.enum-BwQbURNh.js";
6
- import { c as pe, _ as fe, F as ve, u as ye } from "./layout-BxDEsp4a.js";
7
- import { _ as be, a as _e } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DgHp7KgJ.js";
8
- import { R as z, A as ge, a as xe } from "./rules-CQu9yXsg.js";
9
- import { a as O, c as he } from "./number-Dvvpk3SV.js";
10
- import { F as Ve } from "./decimal-ziY3648r.js";
11
- import { _ as Ue } from "./NumberPrecisionInput.vue_vue_type_script_setup_true_lang-kidodonU.js";
12
- const we = { class: "flex flex-col gap-8" }, Ce = /* @__PURE__ */ l("div", { class: "fm-typo-en-body-md-400" }, "Sorry, this unit is used in the following modules:", -1), Se = {
13
- key: 0,
14
- class: "flex flex-col"
15
- }, $e = /* @__PURE__ */ l("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" }, [
16
- /* @__PURE__ */ l("div", { class: "flex-1 py-8 px-16" }, "Ingredient"),
17
- /* @__PURE__ */ l("div", {
18
- class: "flex-0 py-8 px-16",
19
- style: { "flex-basis": "240px" }
20
- }, "Used in")
21
- ], -1), ke = { class: "flex-1 py-8 px-16" }, Fe = {
22
- class: "flex-0 py-8 px-16",
23
- style: { "flex-basis": "240px" }
24
- }, Ae = {
25
- key: 1,
26
- class: "flex flex-col"
27
- }, Ee = /* @__PURE__ */ l("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" }, [
28
- /* @__PURE__ */ l("div", { class: "flex-1 py-8 px-16" }, "Recipe"),
29
- /* @__PURE__ */ l("div", {
30
- class: "flex-0 py-8 px-16",
31
- style: { "flex-basis": "240px" }
32
- }, "Used in")
33
- ], -1), Ie = { class: "flex-1 py-8 px-16" }, De = {
34
- class: "flex-0 py-8 px-16",
35
- style: { "flex-basis": "240px" }
36
- }, Re = {
37
- key: 2,
38
- class: "flex flex-col"
39
- }, Pe = /* @__PURE__ */ l("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" }, [
40
- /* @__PURE__ */ l("div", { class: "flex-1 py-8 px-16" }, "Menu"),
41
- /* @__PURE__ */ l("div", {
42
- class: "flex-0 py-8 px-16",
43
- style: { "flex-basis": "240px" }
44
- }, "Used in")
45
- ], -1), Me = { class: "flex-1 py-8 px-16" }, Te = {
46
- class: "flex-0 py-8 px-16",
47
- style: { "flex-basis": "240px" }
48
- }, Be = /* @__PURE__ */ H({
49
- __name: "UnitUsedBy",
50
- props: {
51
- unit: {}
52
- },
53
- setup(h) {
54
- const u = h, b = K(), a = x(() => b.validateUnitUsage(u.unit)), s = x(() => a.value.filter((f) => f.from === "INGREDIENT")), r = x(() => a.value.filter((f) => f.from === "RECIPE")), p = x(() => a.value.filter((f) => f.from === "MENU"));
55
- return (f, V) => (c(), w("div", we, [
56
- Ce,
57
- s.value.length ? (c(), w("div", Se, [
58
- $e,
59
- (c(!0), w(j, null, q(s.value, (t) => {
60
- var n;
61
- return c(), w("div", {
62
- key: t.code,
63
- class: "flex flex-row fm-typo-en-body-md-400 h-48 items-center border-b border-b-fm-color-neutral-gray-100"
64
- }, [
65
- l("div", ke, g(t.code) + " " + g(t.name), 1),
66
- l("div", Fe, g((n = t.bindedIngredient) != null && n.length ? "Convert binding" : "Item unit"), 1)
67
- ]);
68
- }), 128))
69
- ])) : G("", !0),
70
- r.value.length ? (c(), w("div", Ae, [
71
- Ee,
72
- (c(!0), w(j, null, q(r.value, (t) => {
73
- var n, v, y;
74
- return c(), w("div", {
75
- key: t.code,
76
- class: "flex flex-row fm-typo-en-body-md-400 h-48 items-center border-b border-b-fm-color-neutral-gray-100"
77
- }, [
78
- l("div", Ie, g(t.code) + " " + g(t.name), 1),
79
- l("div", De, g((n = t.bindedIngredient) == null ? void 0 : n.slice(0, 3).map((e) => e.code).join(", ")) + " " + g(t.bindedIngredient && ((v = t.bindedIngredient) == null ? void 0 : v.length) > 3 ? `and ${((y = t.bindedIngredient) == null ? void 0 : y.length) - 3} more` : ""), 1)
80
- ]);
81
- }), 128))
82
- ])) : G("", !0),
83
- p.value.length ? (c(), w("div", Re, [
84
- Pe,
85
- (c(!0), w(j, null, q(p.value, (t) => {
86
- var n, v, y;
87
- return c(), w("div", {
88
- key: t.code,
89
- class: "flex flex-row fm-typo-en-body-md-400 h-48 items-center border-b border-b-fm-color-neutral-gray-100"
90
- }, [
91
- l("div", Me, g(t.code) + " " + g(t.name), 1),
92
- l("div", Te, g((n = t.bindedIngredient) == null ? void 0 : n.slice(0, 3).map((e) => e.code).join(", ")) + " " + g(t.bindedIngredient && ((v = t.bindedIngredient) == null ? void 0 : v.length) > 3 ? `and ${((y = t.bindedIngredient) == null ? void 0 : y.length) - 3} more` : ""), 1)
93
- ]);
94
- }), 128))
95
- ])) : G("", !0)
96
- ]));
97
- }
98
- });
99
- function Ne() {
100
- const h = de(), u = te(), b = K(), a = R(!1), s = R();
101
- function r() {
102
- const t = {
103
- unit: {},
104
- mode: U.CREATE,
105
- show: !0,
106
- "onUpdate:show"(n) {
107
- s.value.show = n;
108
- }
109
- };
110
- s.value = t;
111
- }
112
- async function p(t) {
113
- const n = {
114
- unit: t,
115
- mode: U.UPDATE,
116
- show: !0,
117
- "onUpdate:show"(v) {
118
- s.value.show = v;
119
- }
120
- };
121
- s.value = n;
122
- }
123
- async function f(t) {
124
- a.value = !0;
125
- try {
126
- await b.deleteUnit(t), u.open({
127
- title: "Success",
128
- message: `Deleted ${t.name}`,
129
- type: "success"
130
- });
131
- } catch (n) {
132
- n instanceof re && ce(n) ? h.open({
133
- title: "Cannot delete unit",
134
- contentComponent: me,
135
- contentComponentProps: {
136
- subject: (t == null ? void 0 : t.name) ?? "",
137
- items: n.errorResponse.message
138
- },
139
- secondaryActions: {
140
- text: "Close",
141
- close: !0
142
- }
143
- }) : console.log("unable to delete unit", n), u.open({
144
- title: `Cannot delete ${t.name}`,
145
- message: "Please try again.",
146
- type: "error"
147
- }), console.error("failed to delete unit", n);
148
- } finally {
149
- a.value = !1;
150
- }
151
- }
152
- function V(t) {
153
- if (b.validateUnitUsage(t).length) {
154
- h.open({
155
- title: `Cannot delete ${(t == null ? void 0 : t.name) ?? "unit"}`,
156
- overlay: !0,
157
- dismissAway: !0,
158
- closeButton: !0,
159
- contentComponent: Be,
160
- contentComponentProps: {
161
- unit: t
162
- },
163
- primaryActions: {
164
- text: "Confirm",
165
- close: !0
166
- }
167
- });
168
- return;
169
- }
170
- h.open({
171
- title: `Delete ${(t == null ? void 0 : t.name) ?? "unit"}?`,
172
- closeButton: !1,
173
- message: "You may not be able to delete this unit if it is linked in any of the inventory modules.",
174
- primaryActions: {
175
- text: "Delete",
176
- close: !0,
177
- variant: "destructive"
178
- },
179
- secondaryActions: {
180
- text: "Cancel",
181
- close: !0
182
- }
183
- }).onPrimary(() => f(t));
184
- }
185
- return {
186
- createUnit: r,
187
- updateUnit: p,
188
- deleteUnit: V,
189
- unitDialogProps: s,
190
- unitViewLoading: a
191
- };
192
- }
193
- function Le({
194
- updateUnit: h,
195
- deleteUnit: u
196
- }) {
197
- async function b(s, r) {
198
- const p = ee(r);
199
- if (s === L.Edit) {
200
- await h(p);
201
- return;
202
- }
203
- if (s === L.Delete) {
204
- await u(p);
205
- return;
206
- }
207
- }
208
- return { columnDefs: [
209
- {
210
- accessorKey: "name",
211
- header: "Name",
212
- enableSorting: !0,
213
- size: 300
214
- },
215
- {
216
- accessorKey: "abbrev",
217
- header: "Symbol",
218
- enableSorting: !1,
219
- size: "auto"
220
- },
221
- {
222
- id: "action",
223
- header: "",
224
- cell(s) {
225
- return pe(
226
- [Z[L.Edit], Z[L.Delete]],
227
- (r) => {
228
- b(r, s.row.original);
229
- }
230
- );
231
- },
232
- enableSorting: !1,
233
- size: 40,
234
- meta: {
235
- cellClass: "",
236
- headerClass: ""
237
- }
238
- }
239
- ] };
240
- }
241
- const ze = { class: "flex flex-col gap-24" }, je = { class: "flex gap-24" }, qe = { class: "flex-1" }, He = { class: "flex-1" }, Ke = { class: "flex" }, Ge = { class: "flex items-center" }, Oe = { class: "fm-typo-en-body-lg-600 flex-grow" }, Ye = { class: "flex flex-col gap-24" }, Je = { class: "flex gap-24" }, Qe = { class: "flex-1" }, We = { class: "flex-1" }, Xe = /* @__PURE__ */ H({
242
- __name: "UnitForm",
243
- props: {
244
- mode: {},
245
- modelValue: {},
246
- disabled: { type: Boolean }
247
- },
248
- emits: ["update:modelValue", "click:submit"],
249
- setup(h, { expose: u, emit: b }) {
250
- const a = h, s = b;
251
- function r() {
252
- s("click:submit");
253
- }
254
- const p = x({
255
- get() {
256
- var e;
257
- return ((e = a.modelValue) == null ? void 0 : e.name) ?? "";
258
- },
259
- set(e) {
260
- const o = a.modelValue ?? {};
261
- o.name = e, s("update:modelValue", o);
262
- }
263
- }), f = x({
264
- get() {
265
- var e;
266
- return ((e = a.modelValue) == null ? void 0 : e.abbrev) ?? "";
267
- },
268
- set(e) {
269
- const o = a.modelValue ?? {};
270
- o.abbrev = e, s("update:modelValue", o);
271
- }
272
- }), V = x({
273
- get() {
274
- var e;
275
- return ((e = a.modelValue) == null ? void 0 : e.precision) ?? 0;
276
- },
277
- set(e) {
278
- const o = a.modelValue ?? {};
279
- o.precision = e, s("update:modelValue", o);
280
- }
281
- }), t = x({
282
- get() {
283
- var e;
284
- return ((e = a.modelValue) == null ? void 0 : e.measurements) ?? [];
285
- },
286
- set(e) {
287
- const o = a.modelValue ?? {};
288
- o.measurements = e, s("update:modelValue", o);
289
- }
290
- });
291
- function n() {
292
- const e = a.modelValue ?? {}, o = e.measurements ?? [];
293
- e.measurements = [
294
- ...o,
295
- {
296
- id: `measurement_${(/* @__PURE__ */ new Date()).toISOString()}_${Math.random().toString(16).slice(2, 8)}`,
297
- name: "",
298
- abbrev: "",
299
- conversion: {
300
- amount: 1,
301
- precision: 0
302
- }
303
- }
304
- ], s("update:modelValue", e);
305
- }
306
- function v(e) {
307
- const o = a.modelValue ?? {}, i = o.measurements ?? [];
308
- i.splice(e, 1), o.measurements = i, s("update:modelValue", o);
309
- }
310
- const y = R();
311
- return u({
312
- validateInputs: () => {
313
- var e, o;
314
- (o = (e = y.value) == null ? void 0 : e.validateInputs) == null || o.call(e);
315
- },
316
- resetInputsValidation: () => {
317
- var e, o;
318
- (o = (e = y.value) == null ? void 0 : e.resetInputsValidation) == null || o.call(e);
319
- },
320
- resetInputs: () => {
321
- var e, o;
322
- (o = (e = y.value) == null ? void 0 : e.resetInputs) == null || o.call(e);
323
- }
324
- }), (e, o) => {
325
- const i = A("FmTextField"), E = A("FmStepperField"), S = A("FmButton"), $ = A("FmCard"), F = A("FmForm");
326
- return c(), M(F, {
327
- ref_key: "formRef",
328
- ref: y,
329
- class: "flex flex-col gap-40",
330
- onValidationSuccess: r
331
- }, {
332
- default: D(() => {
333
- var P;
334
- return [
335
- l("div", ze, [
336
- l("div", je, [
337
- l("div", qe, [
338
- m(i, {
339
- disabled: e.disabled,
340
- label: "Name",
341
- modelValue: p.value,
342
- "onUpdate:modelValue": o[0] || (o[0] = (C) => p.value = C),
343
- rules: [d(z)()],
344
- "label-mark": "required"
345
- }, null, 8, ["disabled", "modelValue", "rules"])
346
- ]),
347
- l("div", He, [
348
- m(i, {
349
- disabled: e.disabled,
350
- label: "Symbol",
351
- modelValue: f.value,
352
- "onUpdate:modelValue": o[1] || (o[1] = (C) => f.value = C),
353
- rules: [d(z)()],
354
- "label-mark": "required"
355
- }, null, 8, ["disabled", "modelValue", "rules"])
356
- ])
357
- ]),
358
- l("div", null, [
359
- m(E, {
360
- disabled: e.disabled,
361
- class: "col-span-3",
362
- label: "Precision",
363
- modelValue: V.value,
364
- "onUpdate:modelValue": o[2] || (o[2] = (C) => V.value = C),
365
- rules: [d(ge)(0)]
366
- }, null, 8, ["disabled", "modelValue", "rules"])
367
- ])
368
- ]),
369
- l("div", Ke, [
370
- m(S, {
371
- disabled: e.disabled,
372
- type: "button",
373
- "prepend-icon": "add",
374
- label: "Add measurement",
375
- variant: "plain",
376
- onClick: n
377
- }, null, 8, ["disabled"])
378
- ]),
379
- (c(!0), w(j, null, q((P = e.modelValue) == null ? void 0 : P.measurements, (C, _) => (c(), M($, {
380
- class: "flex flex-col gap-16 p-16",
381
- variant: "outlined",
382
- key: C.id
383
- }, {
384
- default: D(() => [
385
- l("div", Ge, [
386
- l("div", Oe, "Measurement " + g(_ + 1), 1),
387
- m(S, {
388
- disabled: e.disabled,
389
- variant: "tertiary",
390
- "prepend-icon": "delete",
391
- onClick: (k) => v(_)
392
- }, null, 8, ["disabled", "onClick"])
393
- ]),
394
- l("div", Ye, [
395
- l("div", Je, [
396
- l("div", Qe, [
397
- m(i, {
398
- disabled: e.disabled,
399
- class: "col-span-2",
400
- label: "Name",
401
- modelValue: e.modelValue.measurements[_].name,
402
- "onUpdate:modelValue": (k) => e.modelValue.measurements[_].name = k,
403
- rules: [d(z)()],
404
- "label-mark": "required"
405
- }, null, 8, ["disabled", "modelValue", "onUpdate:modelValue", "rules"])
406
- ]),
407
- l("div", We, [
408
- m(i, {
409
- disabled: e.disabled,
410
- label: "Symbol",
411
- modelValue: e.modelValue.measurements[_].abbrev,
412
- "onUpdate:modelValue": (k) => e.modelValue.measurements[_].abbrev = k,
413
- rules: [d(z)()],
414
- "label-mark": "required"
415
- }, null, 8, ["disabled", "modelValue", "onUpdate:modelValue", "rules"])
416
- ])
417
- ]),
418
- m(Ue, {
419
- disabled: e.disabled,
420
- class: "col-span-3",
421
- label: "Conversion",
422
- "model-value": +d(O)(e.modelValue.measurements[_].conversion),
423
- "onUpdate:modelValue": (k) => t.value = t.value.map(
424
- (I, T) => T === _ ? {
425
- ...I,
426
- conversion: d(Ve).toPrecision(
427
- d(he)(k),
428
- V.value
429
- )
430
- } : I
431
- ),
432
- rules: [d(xe)(0)],
433
- step: +d(O)({ amount: 1, precision: V.value }),
434
- "helper-text": `1 ${e.modelValue.measurements[_].name || "measurement unit"} equal to ${+d(O)(e.modelValue.measurements[_].conversion)} ${p.value || "base unit"}`
435
- }, null, 8, ["disabled", "model-value", "onUpdate:modelValue", "rules", "step", "helper-text"])
436
- ])
437
- ]),
438
- _: 2
439
- }, 1024))), 128))
440
- ];
441
- }),
442
- _: 1
443
- }, 512);
444
- };
445
- }
446
- }), Ze = { class: "flex gap-4" }, et = /* @__PURE__ */ H({
447
- __name: "UnitDialog",
448
- props: {
449
- show: { type: Boolean },
450
- unit: {},
451
- mode: { default: U.READ }
452
- },
453
- emits: ["update:show"],
454
- setup(h) {
455
- const u = h, b = K(), a = te(), s = X(u, "show"), r = X(u, "unit"), p = x(() => {
456
- switch (u.mode) {
457
- case U.READ:
458
- return "View unit";
459
- case U.UPDATE:
460
- return "Edit unit";
461
- case U.CREATE:
462
- return "Add unit";
463
- }
464
- return "";
465
- }), f = x(() => {
466
- switch (u.mode) {
467
- case U.READ:
468
- return "";
469
- case U.UPDATE:
470
- return "Save";
471
- case U.CREATE:
472
- return "Add";
473
- }
474
- return "";
475
- }), V = R(), t = R(!1);
476
- async function n() {
477
- t.value = !0;
478
- try {
479
- const o = ee(r.value);
480
- o.precision ?? (o.precision = 0), o.measurements ?? (o.measurements = []), await b.createUnit(o), s.value = !1, a.open({
481
- title: "Success",
482
- message: "Created " + r.value.name,
483
- type: "success"
484
- });
485
- } catch (o) {
486
- o instanceof W || a.open({
487
- title: "Failed to create unit",
488
- message: "Please try again",
489
- type: "error"
490
- });
491
- } finally {
492
- t.value = !1;
493
- }
494
- }
495
- async function v() {
496
- t.value = !0;
497
- try {
498
- await b.updateUnit(r.value), s.value = !1, a.open({
499
- title: "Success",
500
- message: "Updated " + r.value.name,
501
- type: "success"
502
- });
503
- } catch (o) {
504
- o instanceof W || a.open({
505
- title: "Failed to update unit",
506
- message: "Please try again",
507
- type: "error"
508
- });
509
- } finally {
510
- t.value = !1;
511
- }
512
- }
513
- function y() {
514
- var o, i;
515
- (i = (o = V.value) == null ? void 0 : o.validateInputs) == null || i.call(o);
516
- }
517
- function e() {
518
- switch (u.mode) {
519
- case U.READ:
520
- return;
521
- case U.UPDATE:
522
- return v();
523
- case U.CREATE:
524
- return n();
525
- }
526
- }
527
- return (o, i) => {
528
- const E = A("FmButton"), S = A("FmSideSheet");
529
- return c(), M(S, {
530
- "model-value": d(s),
531
- "onUpdate:modelValue": i[3] || (i[3] = ($) => Q(s) ? s.value = $ : null),
532
- header: p.value,
533
- "close-button": "",
534
- "dismiss-away": "",
535
- "max-width": 500
536
- }, {
537
- "side-sheet-footer": D(() => [
538
- l("div", Ze, [
539
- m(E, {
540
- loading: t.value,
541
- label: f.value,
542
- onClick: y
543
- }, null, 8, ["loading", "label"]),
544
- m(E, {
545
- disabled: t.value,
546
- label: "Close",
547
- variant: "tertiary",
548
- onClick: i[2] || (i[2] = ($) => s.value = !1)
549
- }, null, 8, ["disabled"])
550
- ])
551
- ]),
552
- default: D(() => [
553
- m(Xe, {
554
- class: "w-full",
555
- ref_key: "hasValidationExpose",
556
- ref: V,
557
- modelValue: d(r),
558
- "onUpdate:modelValue": i[0] || (i[0] = ($) => Q(r) ? r.value = $ : null),
559
- mode: o.mode,
560
- disabled: t.value,
561
- "onClick:submit": i[1] || (i[1] = ($) => e())
562
- }, null, 8, ["modelValue", "mode", "disabled"])
563
- ]),
564
- _: 1
565
- }, 8, ["model-value", "header"]);
566
- };
567
- }
568
- }), tt = { class: "px-24 xs:p-0 sm:p-0 flex flex-col gap-8 max-h-full" }, ot = { class: "flex flex-col py-8" }, lt = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, st = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, yt = /* @__PURE__ */ H({
569
- __name: "UnitView",
570
- setup(h) {
571
- const u = K(), b = ie(), a = x(() => u.units), { createUnit: s, updateUnit: r, deleteUnit: p, unitDialogProps: f, unitViewLoading: V } = Ne(), { columnDefs: t } = Le({ updateUnit: r, deleteUnit: p });
572
- function n(E) {
573
- E === "add" && s();
574
- }
575
- const v = R(""), y = x(() => V.value), { breakpoints: e } = ue(), o = x(() => e.value.xs || e.value.sm ? 10 : 20), i = ye();
576
- return (E, S) => {
577
- const $ = A("FmTable");
578
- return c(), M(be, {
579
- title: "Unit",
580
- actions: [{ label: "Add unit", value: "add", isPrimary: !0, prependIcon: "add" }],
581
- "onClick:action": n
582
- }, {
583
- default: D(() => [
584
- l("div", tt, [
585
- m(_e, {
586
- searchable: "",
587
- search: v.value,
588
- "onUpdate:search": S[0] || (S[0] = (F) => v.value = F)
589
- }, null, 8, ["search"]),
590
- m($, {
591
- style: le(d(i).tableHeight),
592
- "column-defs": d(t),
593
- "row-data": a.value,
594
- "search-value": v.value,
595
- loading: !d(b)._currentLocation || y.value,
596
- onRowClick: S[1] || (S[1] = (F) => d(r)(F.original)),
597
- "page-size": o.value
598
- }, {
599
- "list-row": D((F) => [
600
- m(fe, {
601
- row: F,
602
- onRowClick: d(r)
603
- }, {
604
- default: D((P) => {
605
- var C, _, k, I, T, B, Y, N, J;
606
- return [
607
- l("div", ot, [
608
- l("div", lt, [
609
- m(d(ve), {
610
- render: (k = (_ = (C = P.name) == null ? void 0 : C.column) == null ? void 0 : _.columnDef) == null ? void 0 : k.cell,
611
- props: (T = (I = P.name) == null ? void 0 : I.getContext) == null ? void 0 : T.call(I)
612
- }, null, 8, ["render", "props"])
613
- ]),
614
- l("div", st, g((J = (N = (Y = (B = F.original.measurements) == null ? void 0 : B.map) == null ? void 0 : Y.call(B, (oe) => oe.name)) == null ? void 0 : N.join) == null ? void 0 : J.call(N, ", ")), 1)
615
- ])
616
- ];
617
- }),
618
- _: 2
619
- }, 1032, ["row", "onRowClick"])
620
- ]),
621
- _: 1
622
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
623
- ]),
624
- (c(), M(se, { to: "body" }, [
625
- m(et, ae(ne(d(f))), null, 16)
626
- ]))
627
- ]),
628
- _: 1
629
- });
630
- };
631
- }
632
- });
633
- export {
634
- yt as default
635
- };