@feedmepos/mf-inventory-portal 1.0.12-dev.1 → 1.0.12-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 (55) hide show
  1. package/dist/{App-Cicsptfk.js → App-Byn7tHre.js} +37 -37
  2. package/dist/{ApprovalView-oRqJ-z0x.js → ApprovalView-C_B6Ud1v.js} +2 -2
  3. package/dist/{BindingsDialog-BOIsLkdn.js → BindingsDialog-DpM-rpFr.js} +2 -2
  4. package/dist/{BindingsPicker-Co4UtTLT.js → BindingsPicker-CCKlnHQ8.js} +1 -1
  5. package/dist/{BindingsTable-DLsppTGt.js → BindingsTable-m3Z7ozrU.js} +1 -1
  6. package/dist/{ClosingDraftView-CQ0s4iL_.js → ClosingDraftView-Dm8eo0Vz.js} +2 -2
  7. package/dist/{ClosingTemplateView-B0q2VTDz.js → ClosingTemplateView-C0kKeAKu.js} +2 -2
  8. package/dist/{DeliveryOrderPrintPreview-BVR-8Wuk.js → DeliveryOrderPrintPreview-BiFBV9NI.js} +1 -1
  9. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DozsNol6.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-bBhR9dWX.js} +3 -3
  10. package/dist/{FmMultiselectDialog-cp5Eu4lS.js → FmMultiselectDialog-Cg-plZjp.js} +1 -1
  11. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-BLqmn5u9.js → FmUnitInput.vue_vue_type_script_setup_true_lang-B0DdbgR8.js} +1 -1
  12. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-Di-N8CUr.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-DNkyBsYX.js} +1 -1
  13. package/dist/IngredientGroupView-oRzzQrxP.js +8779 -0
  14. package/dist/{IngredientsView-Bqs24FKe.js → IngredientsView-UYr-9ckX.js} +5 -5
  15. package/dist/{IntegrationView-B5UglyZs.js → IntegrationView-Nb0j9Myn.js} +5 -5
  16. package/dist/{InventoryBindingForm-CNHEIU--.js → InventoryBindingForm-CfV17fI5.js} +1 -1
  17. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-CXs6G1yw.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-LZRjwQEB.js} +4 -4
  18. package/dist/{InventoryBindingSummary-Y_t0JvQf.js → InventoryBindingSummary-B2rDd4KS.js} +1 -1
  19. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-BtpbycMa.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-O3oG04C3.js} +1 -1
  20. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-Bv_4XhnW.js → PremiumBadge.vue_vue_type_script_setup_true_lang-C9P0w1Yo.js} +1 -1
  21. package/dist/{PublishView-CwZCF0a5.js → PublishView-lKWxaVGi.js} +2 -2
  22. package/dist/{PurchaseOrderPrintPreview-CSYvISrP.js → PurchaseOrderPrintPreview-C3pE7pKw.js} +1 -1
  23. package/dist/{ReceiveRequestView-CTuh_NZ_.js → ReceiveRequestView-Cntcdt7e.js} +11 -11
  24. package/dist/RecipeView-bzu1U9Gq.js +620 -0
  25. package/dist/{StockView-Cg1jE2Zw.js → StockView-R5AjS5ZP.js} +8 -8
  26. package/dist/{SupplierView-EknM6vks.js → SupplierView-BP_67SXq.js} +4 -4
  27. package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-Dkk3gKIY.js → TransferDetails.vue_vue_type_script_setup_true_lang-BvgmrVSD.js} +6 -6
  28. package/dist/{TransferTemplateView-Ciwc17PA.js → TransferTemplateView-BJLK64th.js} +7 -7
  29. package/dist/{UnitView-B2mpu5IV.js → UnitView--wdY45MB.js} +3 -3
  30. package/dist/{WarehouseView-DpZzsLzE.js → WarehouseView-iSOrBTnq.js} +1 -1
  31. package/dist/api/inventory.d.ts +0 -66
  32. package/dist/{app-C_s8CpzV.js → app-kveWTQjE.js} +3154 -3245
  33. package/dist/app.js +1 -1
  34. package/dist/{array-hChJVZLE.js → array-Ca8T3f_G.js} +7 -6
  35. package/dist/components/inventory-binding/InventoryBinding.vue.d.ts +0 -22
  36. package/dist/components/shell/inventory/binding-ui.vue.d.ts +0 -22
  37. package/dist/{decimal-D6jyMGK9.js → decimal-DY8OyZOE.js} +1 -1
  38. package/dist/{feature-BGozj4cq.js → feature-C0TlUzuT.js} +2 -2
  39. package/dist/{format-unit-display-WWMXXaOF.js → format-unit-display-Q_edRr_A.js} +2 -2
  40. package/dist/{index-ChkhtUlV.js → index-B-ZEfBgj.js} +2 -2
  41. package/dist/{index-D1dhDInI.js → index-BMpOpRCf.js} +1 -1
  42. package/dist/{stock-5qJE0ApW.js → stock-C40mVN4W.js} +1 -1
  43. package/dist/stores/inventory.d.ts +0 -88
  44. package/dist/{supplier-CxTBVGVa.js → supplier-DvZ8SCGg.js} +2 -2
  45. package/dist/tsconfig.app.tsbuildinfo +1 -1
  46. package/dist/{use-ingredient-select-dialog-Cxn_cX8W.js → use-ingredient-select-dialog-CeK0rLZb.js} +1 -1
  47. package/dist/{use-inventory-binding-dialog--nqAQCSl.js → use-inventory-binding-dialog-BV-rxXkP.js} +1 -1
  48. package/dist/views/recipe/components/recipe-form/RecipeForm.vue.d.ts +0 -44
  49. package/dist/{vue-i18n-DDOrxu8s.js → vue-i18n-CYoGKQoJ.js} +201 -201
  50. package/package.json +3 -3
  51. package/dist/IngredientGroupView-DbkNqoE2.js +0 -898
  52. package/dist/RecipeView-OMZcKOQh.js +0 -767
  53. package/dist/app-YTo31ukE.js +0 -7888
  54. package/dist/views/recipe/components/recipe-override-form-field/RecipeOverrideFormField.vue.d.ts +0 -61
  55. package/dist/views/recipe/composables/use-recipe-overrides-form-field.d.ts +0 -10
@@ -1,898 +0,0 @@
1
- import { ref as V, computed as w, h as F, defineComponent as j, resolveComponent as h, openBlock as S, createElementBlock as B, createVNode as g, unref as s, createElementVNode as u, createBlock as T, withCtx as C, toDisplayString as A, Fragment as pe, renderList as fe, createTextVNode as ve, createCommentVNode as oe, watch as ge, isRef as ye, normalizeClass as _e, normalizeStyle as be, createSlots as ke, Teleport as xe, normalizeProps as he, guardReactiveProps as we } from "vue";
2
- import { a as P, d as I, e as z, f as Re, D as se, h as q, G as re, l as ue, p as ae, u as Ie, z as Ge, _ as Se, B as Fe, C as Ve, E as le } from "./app-C_s8CpzV.js";
3
- import { useDialog as Ce, useSnackbar as Y, components as K, useProxiedModel as De, useBreakpoints as $e } from "@feedmepos/ui-library";
4
- import { useI18n as U, useCoreStore as Ae } from "@feedmepos/mf-common";
5
- import { defineStore as de, storeToRefs as ie } from "pinia";
6
- import "./array-hChJVZLE.js";
7
- import { x as Ee, N as Te, b as Me } from "./app-YTo31ukE.js";
8
- import { u as Be } from "./FmMultiselectDialog-cp5Eu4lS.js";
9
- import { r as ce } from "./random-CSbEbElR.js";
10
- import { u as ze, R as Pe } from "./usePromise-CbVUCxhj.js";
11
- const H = de(
12
- "ingredientGroupactions",
13
- function() {
14
- const v = Ce(), p = Y(), k = P(), { t: i } = U(), m = V();
15
- function e() {
16
- const c = {
17
- modelValue: {},
18
- mode: I.CREATE,
19
- show: !0,
20
- "onUpdate:show"(f) {
21
- m.value.show = f;
22
- }
23
- };
24
- m.value = c;
25
- }
26
- async function a(c) {
27
- const f = {
28
- modelValue: z(c),
29
- mode: I.UPDATE,
30
- show: !0,
31
- "onUpdate:show"(d) {
32
- m.value.show = d;
33
- }
34
- };
35
- m.value = f;
36
- }
37
- async function n(c, f, d) {
38
- f.value = !0;
39
- try {
40
- await k.deleteSkuGroup(c), p.open({
41
- title: "Success",
42
- message: `Deleted ${c.name}`,
43
- type: "success"
44
- });
45
- } catch (y) {
46
- p.open({
47
- title: `Cannot delete ${c.name}`,
48
- message: "Please try again.",
49
- type: "error"
50
- }), console.error("failed to delete ingredient", y);
51
- } finally {
52
- f.value = !1, d();
53
- }
54
- }
55
- function o(c, f, d) {
56
- v.open({
57
- title: i("inventory.ingredient.delete.title", [(c == null ? void 0 : c.name) ?? ""]),
58
- closeButton: !1,
59
- message: i("inventory.ingredient.delete.message"),
60
- primaryActions: {
61
- text: i("common.delete"),
62
- close: !0,
63
- variant: "destructive"
64
- },
65
- secondaryActions: {
66
- text: i("common.cancel"),
67
- close: !0
68
- }
69
- }).onPrimary(() => n(c, f, d));
70
- }
71
- function t() {
72
- }
73
- function _() {
74
- }
75
- return {
76
- createIngredientGroup: e,
77
- updateIngredientGroup: a,
78
- deleteIngredientGroup: o,
79
- importIngredientGroups: t,
80
- exportIngredientGroups: _,
81
- ingredientGroupDialogProps: m
82
- };
83
- }
84
- ), Ue = de(
85
- "ingredientGroupTable",
86
- function() {
87
- const v = V(!1), p = Y(), k = P(), i = H();
88
- async function m() {
89
- v.value = !0;
90
- try {
91
- await k.readInventory();
92
- } catch (n) {
93
- console.error("error on reading inventory", n), p.open({
94
- title: "Error",
95
- message: "Something went wrong, please try again.",
96
- type: "error"
97
- });
98
- } finally {
99
- v.value = !1;
100
- }
101
- }
102
- function e(n, o) {
103
- switch (o = z(o), n) {
104
- case q.Edit:
105
- return i.updateIngredientGroup(o);
106
- case q.Delete:
107
- return i.deleteIngredientGroup(
108
- o,
109
- v,
110
- () => m()
111
- );
112
- }
113
- }
114
- const a = w(() => [
115
- {
116
- accessorKey: "name",
117
- header: () => "Name"
118
- },
119
- {
120
- accessorKey: "skuRefs.length",
121
- header: () => "No. of items"
122
- },
123
- {
124
- accessorKey: "ref",
125
- header: () => "Reference"
126
- },
127
- {
128
- id: "action",
129
- header: "",
130
- cell(n) {
131
- return Re(
132
- [se[q.Edit], se[q.Delete]],
133
- (o) => {
134
- e(o, n.row.original);
135
- }
136
- );
137
- },
138
- enableSorting: !1,
139
- size: 40,
140
- meta: {
141
- cellClass: "",
142
- headerClass: ""
143
- }
144
- }
145
- ]);
146
- return {
147
- fetchIngredientGroups: m,
148
- loading: v,
149
- columnDefs: a
150
- };
151
- }
152
- );
153
- function Le(l) {
154
- return {
155
- addItem: () => {
156
- const i = l.create();
157
- l.items = [...l.items, i];
158
- },
159
- updateItem: (i) => {
160
- i && (l.items = l.items.map(
161
- (m) => l.id(m) === l.id(i) ? i : m
162
- ));
163
- },
164
- removeItem: (i) => {
165
- l.items = l.items.filter((m) => l.id(m) !== l.id(i));
166
- }
167
- };
168
- }
169
- function me(l) {
170
- const v = Be(), p = P(), k = w(() => [
171
- {
172
- id: "delete",
173
- header: "",
174
- cell(e) {
175
- const a = e.row.original;
176
- return F(
177
- "div",
178
- { class: "w-full flex justify-end" },
179
- F(K.FmButton, {
180
- class: "delete-button",
181
- key: a._id,
182
- type: "button",
183
- icon: "delete",
184
- variant: "tertiary",
185
- size: "md",
186
- disabled: l.disabled ?? !1,
187
- onClick: () => {
188
- l.skuRefs = l.skuRefs.filter((n) => n._id !== a._id);
189
- }
190
- })
191
- );
192
- },
193
- enableSorting: !1,
194
- size: 40,
195
- meta: {
196
- cellClass: "",
197
- headerClass: ""
198
- }
199
- },
200
- {
201
- id: "skuRef",
202
- header: () => "Ingredient",
203
- accessorFn: (e) => {
204
- var a, n;
205
- return `${((a = p.skuById[e._id]) == null ? void 0 : a.name) ?? ""} (${((n = p.skuById[e._id]) == null ? void 0 : n.code) ?? ""})`;
206
- },
207
- cell: ({ row: e }) => {
208
- const a = p.skuById[e.original._id];
209
- return F(
210
- "div",
211
- {
212
- class: "w-full flex flex-col"
213
- },
214
- [
215
- F("div", { class: "fm-typo-en-body-lg-400" }, a.name),
216
- F("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, a.code)
217
- ]
218
- );
219
- },
220
- size: "auto",
221
- enableSorting: !1
222
- },
223
- {
224
- id: "unit",
225
- header: () => "Unit",
226
- accessorFn: (e) => {
227
- const a = p.skuById[e._id];
228
- return a.unit.measurements.computeFirst(
229
- (n) => n.id === e.trackingMeasurement ? n.name : null
230
- ) ?? a.unit.name;
231
- },
232
- enableSorting: !1
233
- },
234
- {
235
- id: "unitOption",
236
- header: () => "Unit",
237
- accessorKey: "trackingMeasurement",
238
- cell(e) {
239
- const a = p.skuById[e.row.original._id];
240
- if (!a) return null;
241
- const n = [
242
- {
243
- label: a.unit.name,
244
- sublabel: a.unit.abbrev,
245
- value: null
246
- },
247
- ...a.unit.measurements.map((o) => ({
248
- label: o.name,
249
- sublabel: o.abbrev,
250
- value: o.id
251
- }))
252
- ];
253
- return F(K.FmSelect, {
254
- modelValue: e.row.original.trackingMeasurement ?? null,
255
- items: n,
256
- disabled: l.disabled ?? !1,
257
- "onUpdate:modelValue": (o) => {
258
- l.skuRefs = l.skuRefs.map((t) => t._id === e.row.original._id ? { ...t, trackingMeasurement: o } : t);
259
- }
260
- });
261
- },
262
- enableSorting: !1
263
- },
264
- {
265
- id: "move",
266
- header: "",
267
- cell(e) {
268
- const a = e.row.original;
269
- return F("div", { class: "w-full flex justify-end" }, [
270
- F(K.FmButton, {
271
- key: a._id,
272
- type: "button",
273
- icon: "keyboard_arrow_up",
274
- variant: "tertiary",
275
- size: "md",
276
- disabled: l.disabled ?? !1,
277
- onClick: () => {
278
- const n = [...l.skuRefs], o = n.findIndex((t) => t._id === a._id);
279
- if (o > 0) {
280
- const t = n[o - 1];
281
- n[o - 1] = a, n[o] = t;
282
- }
283
- l.skuRefs = [...n];
284
- }
285
- }),
286
- F(K.FmButton, {
287
- key: a._id,
288
- type: "button",
289
- icon: "keyboard_arrow_down",
290
- variant: "tertiary",
291
- size: "md",
292
- disabled: l.disabled ?? !1,
293
- onClick: () => {
294
- const n = [...l.skuRefs], o = n.findIndex((t) => t._id === a._id);
295
- if (o < n.length - 1) {
296
- const t = n[o + 1];
297
- n[o + 1] = a, n[o] = t;
298
- }
299
- l.skuRefs = [...n];
300
- }
301
- })
302
- ]);
303
- },
304
- enableSorting: !1,
305
- size: 40,
306
- meta: {
307
- cellClass: "",
308
- headerClass: ""
309
- }
310
- }
311
- ]);
312
- return {
313
- get columnDefs() {
314
- return k.value;
315
- },
316
- promptAddIngredient: async () => {
317
- if (!l.isDefaultList && !l.allowOverride)
318
- return v.alert("Not allowed", "You cannot add ingredients to this list.");
319
- const m = p.skus.map((n) => ({
320
- label: n.name,
321
- sublabel: n.code,
322
- value: n._id
323
- })), e = (l.skuRefs ?? []).map((n) => n._id), a = await v.multiSelect(m, e, (n) => {
324
- var o, t, _;
325
- return {
326
- _id: n,
327
- trackingMeasurement: ((t = (o = l.skuRefs) == null ? void 0 : o.find((c) => c._id === n)) == null ? void 0 : t.trackingMeasurement) ?? ((_ = p.skuById[n]) == null ? void 0 : _.trackingMeasurement)
328
- };
329
- });
330
- l.skuRefs = a ?? l.skuRefs;
331
- },
332
- columnVisibility: {
333
- delete: l.isDefaultList || !!l.allowOverride,
334
- unit: !l.isDefaultList && !l.allowOverride,
335
- unitOption: l.isDefaultList || !!l.allowOverride
336
- }
337
- };
338
- }
339
- const Ne = { class: "flex flex-col gap-16" }, Oe = { class: "flex flex-col" }, qe = { class: "flex flex-col gap-4" }, Ke = { class: "flex flex-col gap-16" }, je = { class: "flex flex-col" }, He = { class: "flex flex-col gap-4" }, Ye = /* @__PURE__ */ j({
340
- __name: "IngredientGroupRuleField",
341
- props: {
342
- disabled: { type: Boolean },
343
- modelValue: {}
344
- },
345
- setup(l) {
346
- const v = l, { t: p } = U(), k = Ae(), i = w(() => {
347
- const o = /* @__PURE__ */ new Map();
348
- return o.set("restaurantId", new Set(k.restaurants.value.map((t) => t._id))), o;
349
- }), m = w(() => [
350
- ...[...i.value.entries()].map(([t, _]) => ({
351
- type: "string",
352
- key: t,
353
- entity: "restaurant",
354
- values: [..._]
355
- }))
356
- ]), e = re("modelValue", {
357
- get default() {
358
- return {
359
- _id: `skuGroupRule_${(/* @__PURE__ */ new Date()).toISOString()}_${ce(4)}`,
360
- name: "",
361
- rule: null,
362
- skuRefs: []
363
- };
364
- },
365
- watchProps: !0
366
- }), a = w({
367
- get() {
368
- return e.rule ? Ee.build(e.rule) : null;
369
- },
370
- set(o) {
371
- e.rule = Te.build(o);
372
- }
373
- }), n = me({
374
- get disabled() {
375
- return v.disabled ?? !1;
376
- },
377
- get skuRefs() {
378
- return e.skuRefs ?? [];
379
- },
380
- set skuRefs(o) {
381
- e.skuRefs = o;
382
- },
383
- isDefaultList: !1,
384
- allowOverride: !1
385
- });
386
- return (o, t) => {
387
- const _ = h("FmTextField"), c = h("FmLabel"), f = h("FmFormGroup"), d = h("FmTable");
388
- return S(), B("div", Ne, [
389
- g(_, {
390
- modelValue: s(e).name,
391
- "onUpdate:modelValue": t[0] || (t[0] = (y) => s(e).name = y),
392
- label: s(p)("inventory.ingredientGroup.form.rules.name"),
393
- "label-mark": "required",
394
- rules: [s(ue)()]
395
- }, null, 8, ["modelValue", "label", "rules"]),
396
- u("div", Oe, [
397
- u("div", qe, [
398
- g(c, {
399
- label: s(p)("inventory.ingredientGroup.form.rules.title"),
400
- required: ""
401
- }, null, 8, ["label"]),
402
- g(s(Me), {
403
- modelValue: a.value,
404
- "onUpdate:modelValue": t[1] || (t[1] = (y) => a.value = y),
405
- attributes: m.value
406
- }, null, 8, ["modelValue", "attributes"])
407
- ]),
408
- g(f, {
409
- "model-value": a.value,
410
- rules: [
411
- (y) => {
412
- var G;
413
- return !!((G = y == null ? void 0 : y.rules) != null && G.length) || "At least one rule is required";
414
- }
415
- ]
416
- }, null, 8, ["model-value", "rules"])
417
- ]),
418
- u("div", Ke, [
419
- u("div", je, [
420
- u("div", He, [
421
- u("div", null, [
422
- g(c, {
423
- label: s(p)("inventory.ingredientGroup.form.rules.ingredients"),
424
- required: ""
425
- }, null, 8, ["label"])
426
- ])
427
- ]),
428
- g(f, {
429
- "model-value": s(e).skuRefs,
430
- rules: [
431
- (y) => !!(y != null && y.length) || "At least one ingredient is required"
432
- ]
433
- }, null, 8, ["model-value", "rules"])
434
- ]),
435
- g(d, {
436
- "row-data": s(e).skuRefs,
437
- "column-defs": s(n).columnDefs,
438
- "page-size": s(e).skuRefs.length,
439
- "shrink-at": 9999,
440
- "column-visibility": s(n).columnVisibility,
441
- "hide-footer": ""
442
- }, null, 8, ["row-data", "column-defs", "page-size", "column-visibility"])
443
- ])
444
- ]);
445
- };
446
- }
447
- }), Je = { class: "flex flex-col gap-16" }, Qe = { class: "flex flex-col gap-16" }, We = { class: "flex flex-col" }, Xe = { class: "flex items-center" }, Ze = { class: "flex-1" }, et = { class: "flex flex-col gap-8" }, tt = { class: "flex-1 fm-typo-en-title-sm-600" }, nt = { class: "flex-1 fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ot = { class: "flex flex-col gap-16" }, st = { class: "flex flex-col gap-8" }, at = { class: "flex-1 fm-typo-en-title-sm-600" }, lt = { class: "flex-1 fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, it = { class: "flex flex-col gap-12" }, rt = { class: "flex items-center" }, ut = { class: "flex-1 fm-typo-en-body-lg-600 line-clamp-1" }, dt = { key: 0 }, ct = {
448
- key: 1,
449
- class: "fm-typo-en-body-lg-400"
450
- }, mt = /* @__PURE__ */ j({
451
- __name: "IngredientGroupForm",
452
- props: {
453
- mode: {},
454
- disabled: { type: Boolean },
455
- modelValue: {},
456
- menu: {}
457
- },
458
- emits: ["validation-success"],
459
- setup(l, { expose: v, emit: p }) {
460
- const k = l, i = re("modelValue", {
461
- watchProps: !0
462
- }), m = p, { t: e } = U(), a = Le({
463
- get items() {
464
- return i.rules ?? [];
465
- },
466
- set items(t) {
467
- i.rules = t;
468
- },
469
- create: function() {
470
- var t;
471
- return {
472
- _id: `skuGroupRule_${(/* @__PURE__ */ new Date()).toISOString()}_${ce(4)}`,
473
- name: "",
474
- rule: null,
475
- skuRefs: ((t = k.modelValue) == null ? void 0 : t.defaultSkuRefs) ?? []
476
- };
477
- },
478
- id: function(t) {
479
- return t._id;
480
- }
481
- }), n = me({
482
- get disabled() {
483
- return k.disabled;
484
- },
485
- get skuRefs() {
486
- return i.defaultSkuRefs ?? [];
487
- },
488
- set skuRefs(t) {
489
- i.defaultSkuRefs = t;
490
- const _ = t.map((d) => d._id), c = i.rules;
491
- if (!c) return;
492
- const f = t.groupBy(
493
- (d) => d._id,
494
- (d) => d.trackingMeasurement
495
- );
496
- for (const d of c) {
497
- const y = d.skuRefs.filter((x) => _.includes(x._id)), G = t.filter(
498
- (x) => !y.some((R) => R._id === x._id)
499
- );
500
- d.skuRefs = [...y, ...G].map((x) => {
501
- var R;
502
- return {
503
- ...x,
504
- trackingMeasurement: ((R = f.get(x._id)) == null ? void 0 : R[0]) ?? null
505
- };
506
- });
507
- }
508
- i.rules = [...c];
509
- },
510
- isDefaultList: !0
511
- }), o = V();
512
- return v({
513
- validateInputs: () => {
514
- var t;
515
- return (t = o.value) == null ? void 0 : t.validateInputs();
516
- },
517
- resetInputsValidation: () => {
518
- var t;
519
- return (t = o.value) == null ? void 0 : t.resetInputsValidation();
520
- },
521
- resetInputs: () => {
522
- var t;
523
- return (t = o.value) == null ? void 0 : t.resetInputs();
524
- }
525
- }), (t, _) => {
526
- const c = h("FmTextField"), f = h("FmButton"), d = h("FmFormGroup"), y = h("FmTable"), G = h("FmCard"), x = h("FmForm");
527
- return S(), T(x, {
528
- onValidationSuccess: _[2] || (_[2] = (R) => m("validation-success")),
529
- ref_key: "formRef",
530
- ref: o,
531
- class: "flex flex-col gap-64"
532
- }, {
533
- default: C(() => {
534
- var R;
535
- return [
536
- u("div", Je, [
537
- g(c, {
538
- label: s(e)("inventory.ingredientGroup.form.name"),
539
- "label-mark": "required",
540
- rules: [s(ue)()],
541
- modelValue: s(i).name,
542
- "onUpdate:modelValue": _[0] || (_[0] = (r) => s(i).name = r)
543
- }, null, 8, ["label", "rules", "modelValue"]),
544
- g(c, {
545
- label: s(e)("inventory.ingredientGroup.form.ref"),
546
- "label-mark": "optional",
547
- modelValue: s(i).ref,
548
- "onUpdate:modelValue": _[1] || (_[1] = (r) => s(i).ref = r)
549
- }, null, 8, ["label", "modelValue"])
550
- ]),
551
- u("div", Qe, [
552
- u("div", We, [
553
- u("div", Xe, [
554
- u("div", Ze, [
555
- u("div", et, [
556
- u("div", tt, A(s(e)("inventory.ingredientGroup.form.defaultRule.title")), 1)
557
- ])
558
- ]),
559
- u("div", null, [
560
- g(f, {
561
- disabled: t.disabled,
562
- label: "Add ingredient",
563
- "prepend-icon": "link",
564
- variant: "plain",
565
- class: "border-1 rounded-lg border-fm-color-primary",
566
- onClick: s(n).promptAddIngredient,
567
- size: "md"
568
- }, null, 8, ["disabled", "onClick"])
569
- ])
570
- ]),
571
- g(d, {
572
- "model-value": s(i).defaultSkuRefs,
573
- rules: [
574
- (r) => !!(r != null && r.length) || "At least one ingredient is required"
575
- ]
576
- }, null, 8, ["model-value", "rules"])
577
- ]),
578
- u("div", null, [
579
- g(y, {
580
- "row-data": s(i).defaultSkuRefs ?? [],
581
- "column-defs": s(n).columnDefs,
582
- "column-visibility": s(n).columnVisibility,
583
- "page-size": (R = s(i).defaultSkuRefs) == null ? void 0 : R.length,
584
- "shrink-at": 9999,
585
- "hide-footer": ""
586
- }, null, 8, ["row-data", "column-defs", "column-visibility", "page-size"])
587
- ]),
588
- u("div", null, [
589
- u("div", nt, A(s(e)("inventory.ingredientGroup.form.defaultRule.description")), 1)
590
- ])
591
- ]),
592
- u("div", ot, [
593
- u("div", st, [
594
- u("div", at, A(s(e)("inventory.ingredientGroup.form.rules.title")), 1),
595
- u("div", lt, A(s(e)("inventory.ingredientGroup.form.rules.description")), 1)
596
- ]),
597
- (S(!0), B(pe, null, fe(s(i).rules, (r, b) => (S(), T(G, {
598
- key: r.id,
599
- variant: "outlined",
600
- class: "p-16"
601
- }, {
602
- default: C(() => [
603
- u("div", it, [
604
- u("div", rt, [
605
- u("div", ut, [
606
- ve(A(s(e)("inventory.ingredientGroup.form.rules.rule_N", [b + 1])), 1),
607
- r.name ? (S(), B("span", dt, ": ")) : oe("", !0),
608
- r.name ? (S(), B("span", ct, A(r.name), 1)) : oe("", !0)
609
- ]),
610
- g(f, {
611
- variant: "tertiary",
612
- icon: "delete",
613
- onClick: (D) => s(a).removeItem(r)
614
- }, null, 8, ["onClick"])
615
- ]),
616
- u("div", null, [
617
- g(Ye, {
618
- "model-value": r,
619
- "onUpdate:modelValue": s(a).updateItem,
620
- disabled: t.disabled,
621
- menu: t.menu
622
- }, null, 8, ["model-value", "onUpdate:modelValue", "disabled", "menu"])
623
- ])
624
- ])
625
- ]),
626
- _: 2
627
- }, 1024))), 128)),
628
- u("div", null, [
629
- g(f, {
630
- variant: "plain",
631
- icon: "add",
632
- label: s(e)("inventory.ingredientGroup.form.rules.addRule"),
633
- onClick: s(a).addItem
634
- }, null, 8, ["label", "onClick"])
635
- ])
636
- ])
637
- ];
638
- }),
639
- _: 1
640
- }, 512);
641
- };
642
- }
643
- }), pt = {
644
- key: 0,
645
- class: "text-fm-color-typo-primary fm-typo-en-body-lg-400"
646
- }, ft = { class: "flex gap-4" }, vt = /* @__PURE__ */ j({
647
- __name: "IngredientGroupDialog",
648
- props: {
649
- show: { type: Boolean },
650
- mode: { default: I.READ },
651
- modelValue: {}
652
- },
653
- emits: ["update:show"],
654
- setup(l) {
655
- const v = l, p = P(), k = ze(() => p.readCachedMenu()), i = w(
656
- () => k.result.value.state === Pe.success ? k.result.value.data : void 0
657
- ), m = Y(), { t: e } = U(), a = De(v, "show");
658
- function n() {
659
- return {
660
- _id: "",
661
- name: "",
662
- rules: []
663
- };
664
- }
665
- const o = V(n()), t = V(`${Math.random()}`);
666
- ge(
667
- () => v.show,
668
- (r) => {
669
- r && (o.value = z(v.modelValue ?? n()), t.value = o.value._id || `${Math.random()}`);
670
- }
671
- );
672
- const _ = w(() => {
673
- switch (v.mode) {
674
- case I.READ:
675
- return "";
676
- case I.UPDATE:
677
- return e("inventory.ingredientGroup.update.title");
678
- case I.CREATE:
679
- return e("inventory.ingredientGroup.create.title");
680
- }
681
- return "";
682
- }), c = w(() => {
683
- switch (v.mode) {
684
- case I.READ:
685
- return "";
686
- case I.UPDATE:
687
- return e("common.save");
688
- case I.CREATE:
689
- return e("common.add");
690
- }
691
- return "";
692
- }), f = V(), d = V(!1);
693
- async function y() {
694
- d.value = !0;
695
- const r = z(o.value);
696
- try {
697
- await p.createSkuGroup(r), a.value = !1, m.open({
698
- title: e("inventory.common.success"),
699
- message: e("inventory.ingredientGroup.create.success", { name: r.name }),
700
- type: "success"
701
- });
702
- } catch (b) {
703
- b instanceof ae || m.open({
704
- title: e("inventory.ingredientGroup.create.error.title"),
705
- message: e("inventory.ingredientGroup.create.error.message"),
706
- type: "error"
707
- });
708
- } finally {
709
- d.value = !1;
710
- }
711
- }
712
- async function G() {
713
- d.value = !0;
714
- const r = z(o.value);
715
- try {
716
- await p.updateSkuGroup(r), d.value = !1, a.value = !1, m.open({
717
- title: e("inventory.common.success"),
718
- message: e("inventory.ingredientGroup.update.success", { name: r.name }),
719
- type: "success"
720
- });
721
- } catch (b) {
722
- b instanceof ae || m.open({
723
- title: e("inventory.ingredientGroup.update.error.title"),
724
- message: e("inventory.ingredientGroup.update.error.message"),
725
- type: "error"
726
- });
727
- } finally {
728
- d.value = !1;
729
- }
730
- }
731
- function x() {
732
- var r, b;
733
- (b = (r = f.value) == null ? void 0 : r.validateInputs) == null || b.call(r);
734
- }
735
- function R() {
736
- switch (v.mode) {
737
- case I.READ:
738
- return;
739
- case I.UPDATE:
740
- return G();
741
- case I.CREATE:
742
- return y();
743
- }
744
- }
745
- return (r, b) => {
746
- const D = h("FmButton"), E = h("FmSideSheet");
747
- return S(), T(E, {
748
- "model-value": s(a),
749
- "onUpdate:modelValue": b[3] || (b[3] = ($) => ye(a) ? a.value = $ : null),
750
- header: _.value,
751
- "close-button": "",
752
- "dismiss-away": "",
753
- "max-width": 500
754
- }, {
755
- "side-sheet-footer": C(() => [
756
- u("div", ft, [
757
- g(D, {
758
- loading: d.value,
759
- label: c.value,
760
- onClick: x
761
- }, null, 8, ["loading", "label"]),
762
- g(D, {
763
- disabled: d.value,
764
- label: s(e)("common.close"),
765
- variant: "tertiary",
766
- onClick: b[2] || (b[2] = ($) => a.value = !1)
767
- }, null, 8, ["disabled", "label"])
768
- ])
769
- ]),
770
- default: C(() => [
771
- i.value ? (S(), T(mt, {
772
- menu: i.value,
773
- class: "w-full",
774
- ref_key: "hasValidationExpose",
775
- ref: f,
776
- key: t.value,
777
- "model-value": o.value,
778
- "onUpdate:modelValue": b[0] || (b[0] = ($) => o.value = $),
779
- mode: r.mode,
780
- disabled: d.value,
781
- onValidationSuccess: b[1] || (b[1] = ($) => R())
782
- }, null, 8, ["menu", "model-value", "mode", "disabled"])) : (S(), B("div", pt, "Loading.."))
783
- ]),
784
- _: 1
785
- }, 8, ["model-value", "header"]);
786
- };
787
- }
788
- }), gt = { class: "flex flex-col py-8" }, yt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _t = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, Vt = /* @__PURE__ */ j({
789
- __name: "IngredientGroupView",
790
- setup(l) {
791
- const v = P(), p = w(() => v.skuGroups), k = Ie(), { t: i } = U(), {
792
- createIngredientGroup: m,
793
- updateIngredientGroup: e,
794
- importIngredientGroups: a,
795
- exportIngredientGroups: n
796
- } = H(), { columnDefs: o, loading: t } = ie(Ue()), { ingredientGroupDialogProps: _ } = ie(H());
797
- function c(D) {
798
- switch (D) {
799
- case "add":
800
- return m();
801
- case "import":
802
- return a();
803
- case "export":
804
- return n();
805
- }
806
- }
807
- const f = V(""), d = V(!1), y = w(() => d.value || t.value), { breakpoints: G } = $e(), x = w(() => G.value.xs || G.value.sm), R = w(() => x.value ? 10 : 20), r = Ge(), b = w(() => [
808
- {
809
- label: i("inventory.ingredient.create.title"),
810
- value: "add",
811
- isPrimary: !0,
812
- prependIcon: "add"
813
- },
814
- { label: i("common.import"), value: "import" },
815
- { label: i("common.export"), value: "export" }
816
- ]);
817
- return (D, E) => {
818
- const $ = h("FmTable");
819
- return S(), T(Se, {
820
- title: s(i)("inventory.ingredientGroup.title"),
821
- actions: b.value,
822
- "onClick:action": c
823
- }, {
824
- default: C(() => [
825
- u("div", {
826
- class: _e([
827
- "flex flex-col gap-8 max-h-full",
828
- {
829
- "p-0": x.value,
830
- "px-24 ": !x.value
831
- }
832
- ])
833
- }, [
834
- g(Fe, {
835
- searchable: "",
836
- search: f.value,
837
- "onUpdate:search": E[0] || (E[0] = (M) => f.value = M)
838
- }, null, 8, ["search"]),
839
- g($, {
840
- style: be(s(r).tableHeight),
841
- "column-defs": s(o),
842
- "row-data": p.value,
843
- "search-value": f.value,
844
- loading: !s(k)._currentLocation || y.value,
845
- "loading-text": "Loading",
846
- onRowClick: E[1] || (E[1] = (M) => s(e)(M.original)),
847
- "page-size": R.value
848
- }, {
849
- "list-row": C((M) => [
850
- g(Ve, {
851
- row: M,
852
- onRowClick: s(e)
853
- }, ke({
854
- default: C((L) => {
855
- var J, Q, W, N, X, Z, ee, te, O, ne;
856
- return [
857
- u("div", gt, [
858
- u("div", yt, [
859
- g(s(le), {
860
- render: (W = (Q = (J = L.code) == null ? void 0 : J.column) == null ? void 0 : Q.columnDef) == null ? void 0 : W.cell,
861
- props: (X = (N = L.code) == null ? void 0 : N.getContext) == null ? void 0 : X.call(N)
862
- }, null, 8, ["render", "props"])
863
- ]),
864
- u("div", _t, [
865
- g(s(le), {
866
- render: (te = (ee = (Z = L.name) == null ? void 0 : Z.column) == null ? void 0 : ee.columnDef) == null ? void 0 : te.cell,
867
- props: (ne = (O = L.name) == null ? void 0 : O.getContext) == null ? void 0 : ne.call(O)
868
- }, null, 8, ["render", "props"])
869
- ])
870
- ])
871
- ];
872
- }),
873
- _: 2
874
- }, [
875
- d.value ? {
876
- name: "loading-text",
877
- fn: C(() => [
878
- u("div", null, A(s(i)("inventory.ingredient.table.importing")), 1)
879
- ]),
880
- key: "0"
881
- } : void 0
882
- ]), 1032, ["row", "onRowClick"])
883
- ]),
884
- _: 1
885
- }, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
886
- ], 2),
887
- (S(), T(xe, { to: "body" }, [
888
- g(vt, he(we(s(_))), null, 16)
889
- ]))
890
- ]),
891
- _: 1
892
- }, 8, ["title", "actions"]);
893
- };
894
- }
895
- });
896
- export {
897
- Vt as default
898
- };