@feedmepos/mf-inventory-portal 0.0.22-dev.37 → 0.0.22-dev.39
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.
- package/dist/{ApprovalView-Dco0PkEf.js → ApprovalView-YBjWyBq4.js} +3 -3
- package/dist/{BindingsDialog-DrCU_kIA.js → BindingsDialog-oK4_xDZt.js} +1 -1
- package/dist/{BindingsPicker-BMIIrlG6.js → BindingsPicker-CJHX_7QM.js} +1 -1
- package/dist/{BindingsTable-BHRmkL1P.js → BindingsTable-DEc3HXZc.js} +1 -1
- package/dist/ClosingTemplateView-Bboz1gdL.js +1688 -0
- package/dist/{FmDroppableField-Bl7A98it.js → FmDroppableField-BuSz9msU.js} +1 -1
- package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-DQw4pBwH.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-Bq4bEWjV.js} +67 -67
- package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DPCrkcZU.js +364 -0
- package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-3OkJNtvH.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-JM-cmNLZ.js} +1 -1
- package/dist/{IngredientsView-m44wAwSR.js → IngredientsView-BXK0zGFz.js} +5 -5
- package/dist/{IntegrationView-B4gCx21K.js → IntegrationView-DFRBrmVo.js} +2 -2
- package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-D1frNXtV.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-B460Nmkl.js} +1 -1
- package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-Dbs29jm_.js → PremiumBadge.vue_vue_type_script_setup_true_lang-CNlrEPRu.js} +2 -2
- package/dist/{PurchaseOrderPrintPreview-lKu0y_xw.js → PurchaseOrderPrintPreview-FN4L7Qqq.js} +1 -1
- package/dist/{ReceiveRequestView-DflWKxgq.js → ReceiveRequestView-DsNqfWpF.js} +969 -959
- package/dist/{RecipeView-DfsXdlPn.js → RecipeView-B7wqxZwE.js} +4 -4
- package/dist/{StockView-BSeSpxkV.js → StockView-DVu5Zdsm.js} +5 -5
- package/dist/{SupplierView-DPWh1si_.js → SupplierView-D3JRJVHh.js} +3 -3
- package/dist/{TransferDetails.vue_vue_type_script_setup_true_lang-Dt1lRW3W.js → TransferDetails.vue_vue_type_script_setup_true_lang-D0QlYVuG.js} +5 -5
- package/dist/{TransferTemplateView-DGOT4oZN.js → TransferTemplateView-B2H9PqR1.js} +10 -10
- package/dist/{UnitView-X9bCqAWe.js → UnitView-DbFREhtT.js} +4 -4
- package/dist/{WarehouseView-BphA-Peq.js → WarehouseView-BWrqHrZP.js} +2 -2
- package/dist/api/closing-template.d.ts +6 -4
- package/dist/{app-DZiCiBV7.js → app-kckHf3TJ.js} +173 -171
- package/dist/app.js +1 -1
- package/dist/components/map/GoogleMap.vue.d.ts +4 -4
- package/dist/{decimal-Bx1Y3uW1.js → decimal-DiIydfIX.js} +1 -1
- package/dist/{defineDeepModel-4XZbatJF.js → defineDeepModel-o5pX7BIA.js} +1 -1
- package/dist/{format-time-from-id-CFJvgP70.js → format-time-from-id-DTKueVJm.js} +1 -1
- package/dist/{purchase-order-transaction-type-Ds7YRAAp.js → purchase-order-transaction-type-D6FBij-r.js} +2 -2
- package/dist/{supplier-BhJT8KOX.js → supplier-ap_eyUzS.js} +1 -1
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/{use-template-enabled-locations-2-BrEPVOpT.js → use-template-enabled-locations-2-D4xMV6ZC.js} +1 -1
- package/dist/views/closing-template/closing-template-import/ClosingTemplateImport.vue.d.ts +2 -0
- package/dist/views/closing-template/closing-template-import/ClosingTemplateImportItem.vue.d.ts +12 -0
- package/dist/views/closing-template/closing-template-import/ClosingTemplateImportItemProps.d.ts +7 -0
- package/dist/views/closing-template/composables/use-closing-template-actions.d.ts +11 -4
- package/dist/views/closing-template/composables/use-closing-template-table.d.ts +16 -15
- package/dist/views/closing-template/helpers/import-export.helper.d.ts +58 -0
- package/dist/views/transfer-template/composables/use-transfer-template-actions.d.ts +1 -1
- package/dist/{xlsx-B9lpxKgq.js → xlsx-DhbO8Ka1.js} +1 -1
- package/dist/{xlsx.util-DP5wVnRT.js → xlsx.util-DfUIhfkt.js} +1 -1
- package/package.json +1 -1
- package/dist/ClosingTemplateView-kiej8Nah.js +0 -1072
- package/dist/FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DBh79EM_.js +0 -372
|
@@ -0,0 +1,1688 @@
|
|
|
1
|
+
import { ref as S, h as M, defineComponent as H, resolveComponent as F, openBlock as w, createElementBlock as $, createElementVNode as h, normalizeClass as O, createTextVNode as oe, toDisplayString as R, createCommentVNode as J, createVNode as T, withCtx as A, Fragment as z, renderList as W, computed as I, watch as Ae, unref as _, createSlots as Ye, createBlock as U, isRef as je, normalizeStyle as Oe, Teleport as Ke, normalizeProps as Ge, guardReactiveProps as Je, mergeProps as We } from "vue";
|
|
2
|
+
import { u as qe, _ as Xe, a as Qe } from "./FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-DPCrkcZU.js";
|
|
3
|
+
import { useCoreStore as ae, useI18n as K } from "@feedmepos/mf-common";
|
|
4
|
+
import { useDialogChild as Ze, useSnackbar as ee, useDialog as re, FmButtonVariant as Me, components as N, useProxiedModel as et, useBreakpoints as tt } from "@feedmepos/ui-library";
|
|
5
|
+
import { defineStore as Ee, storeToRefs as Pe } from "pinia";
|
|
6
|
+
import { D as Re, R as B, F as L } from "./row-action.enum-PMKMRrZR.js";
|
|
7
|
+
import { n as nt, i as ie, c as Ue, f as ot, u as ce, h as st, R as lt, A as at, y as rt, X as it, Y as Fe } from "./app-kckHf3TJ.js";
|
|
8
|
+
import { a as se, b as Ve, d as Ne, s as Be, r as ct } from "./xlsx.util-DfUIhfkt.js";
|
|
9
|
+
import { F as mt } from "./FmDroppableField-BuSz9msU.js";
|
|
10
|
+
import { c as ut, F as j, _ as Le } from "./TableActionableRow.vue_vue_type_script_setup_true_lang-DlNJ6kRg.js";
|
|
11
|
+
import { f as dt } from "./format-time-from-id-DTKueVJm.js";
|
|
12
|
+
import "vue-router";
|
|
13
|
+
import { d as pt } from "./defineDeepModel-o5pX7BIA.js";
|
|
14
|
+
import { u as ft } from "./use-template-enabled-locations-2-D4xMV6ZC.js";
|
|
15
|
+
const te = nt((c, o) => {
|
|
16
|
+
function n() {
|
|
17
|
+
var e;
|
|
18
|
+
return `business_${((e = ae().currentBusiness.value) == null ? void 0 : e._id) ?? ""}`;
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
async getRecentPublishingJob() {
|
|
22
|
+
const l = n(), t = `${c.inventoryBackendUrl}/${l}/closing-template/publish/recent`;
|
|
23
|
+
return o.get(t);
|
|
24
|
+
},
|
|
25
|
+
async startNewPublish() {
|
|
26
|
+
const l = n(), t = `${c.inventoryBackendUrl}/${l}/closing-template/publish`;
|
|
27
|
+
return o.post(t);
|
|
28
|
+
},
|
|
29
|
+
async getTemplate(l) {
|
|
30
|
+
const t = n(), e = `${c.inventoryBackendUrl}/${t}/closing-template/${l}`;
|
|
31
|
+
return o.get(e);
|
|
32
|
+
},
|
|
33
|
+
async readTemplates() {
|
|
34
|
+
const l = n(), t = `${c.inventoryBackendUrl}/${l}/closing-template`;
|
|
35
|
+
return o.get(t);
|
|
36
|
+
},
|
|
37
|
+
async createTemplate(l) {
|
|
38
|
+
const t = n(), e = `${c.inventoryBackendUrl}/${t}/closing-template`;
|
|
39
|
+
return o.post(e, l);
|
|
40
|
+
},
|
|
41
|
+
async updateTemplate(l) {
|
|
42
|
+
const t = n(), e = `${c.inventoryBackendUrl}/${t}/closing-template`;
|
|
43
|
+
return o.put(e, l);
|
|
44
|
+
},
|
|
45
|
+
async deleteTemplate(l) {
|
|
46
|
+
const t = n(), e = `${c.inventoryBackendUrl}/${t}/closing-template`;
|
|
47
|
+
return o.delete(e, { _id: l._id, _rev: l._rev });
|
|
48
|
+
},
|
|
49
|
+
async importTemplates(l) {
|
|
50
|
+
const t = n(), e = `${c.inventoryBackendUrl}/${t}/closing-template/import`;
|
|
51
|
+
return o.post(e, l);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}), ne = Ee(
|
|
55
|
+
"closingTable",
|
|
56
|
+
function() {
|
|
57
|
+
const { t: o } = K(), n = le(), l = S({}), t = S(new Array()), e = S(!1), p = ie(), i = te();
|
|
58
|
+
async function r() {
|
|
59
|
+
if (t.value = [], !!p._currentLocation) {
|
|
60
|
+
e.value = !0;
|
|
61
|
+
try {
|
|
62
|
+
const [g, f] = await Promise.all([
|
|
63
|
+
i.readTemplates(),
|
|
64
|
+
i.getRecentPublishingJob()
|
|
65
|
+
]).delayed(1e3);
|
|
66
|
+
t.value = g, l.value = f;
|
|
67
|
+
} catch (g) {
|
|
68
|
+
console.log("Something went wrong when fetching templates:", g);
|
|
69
|
+
} finally {
|
|
70
|
+
e.value = !1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async function d(g) {
|
|
75
|
+
if (!t.value.find((f) => f._id) && p._currentLocation) {
|
|
76
|
+
e.value = !0;
|
|
77
|
+
try {
|
|
78
|
+
const [f] = await Promise.all([
|
|
79
|
+
i.getTemplate(g),
|
|
80
|
+
new Promise((s) => setTimeout(s, 1e3))
|
|
81
|
+
]);
|
|
82
|
+
t.value = [f];
|
|
83
|
+
} catch (f) {
|
|
84
|
+
console.log("Something went wrong when fetching templates:", f);
|
|
85
|
+
} finally {
|
|
86
|
+
e.value = !1;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function m(g, f) {
|
|
91
|
+
switch (f = Ue(f), g) {
|
|
92
|
+
case B.Details:
|
|
93
|
+
return n.viewTemplate(f);
|
|
94
|
+
case B.Edit:
|
|
95
|
+
return n.updateTemplate(f);
|
|
96
|
+
case B.Delete:
|
|
97
|
+
return n.deleteTemplate(f, e, r);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
columnDefs: [
|
|
102
|
+
{
|
|
103
|
+
id: "_id",
|
|
104
|
+
accessorKey: "_id",
|
|
105
|
+
header: () => o("inventory.closing.table.createdAt"),
|
|
106
|
+
cell(g) {
|
|
107
|
+
return dt(`${g.getValue()}`);
|
|
108
|
+
},
|
|
109
|
+
enableSorting: !0
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: "name",
|
|
113
|
+
accessorKey: "name",
|
|
114
|
+
header: () => o("inventory.closing.table.name"),
|
|
115
|
+
enableSorting: !0,
|
|
116
|
+
size: 200
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: "noOfItems",
|
|
120
|
+
accessorKey: "items.length",
|
|
121
|
+
header: () => o("inventory.closing.table.noOfItems"),
|
|
122
|
+
enableSorting: !1,
|
|
123
|
+
meta: {
|
|
124
|
+
width: "10rem",
|
|
125
|
+
textAlign: "right"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: "enabledLocations",
|
|
130
|
+
accessorKey: "locations.length",
|
|
131
|
+
header: () => "Enabled outlets",
|
|
132
|
+
cell(g) {
|
|
133
|
+
var s;
|
|
134
|
+
const f = (s = g.row.original.locations) == null ? void 0 : s.length;
|
|
135
|
+
return f ? `${f}` : "All";
|
|
136
|
+
},
|
|
137
|
+
enableSorting: !1,
|
|
138
|
+
meta: {
|
|
139
|
+
width: "10rem",
|
|
140
|
+
textAlign: "right"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: "ref",
|
|
145
|
+
accessorKey: "ref",
|
|
146
|
+
header: () => o("inventory.closing.table.reference"),
|
|
147
|
+
enableSorting: !1,
|
|
148
|
+
size: "auto"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
id: "status",
|
|
152
|
+
header: () => "Status",
|
|
153
|
+
enableSorting: !1,
|
|
154
|
+
cell(g) {
|
|
155
|
+
var k;
|
|
156
|
+
const f = g.row.original, s = f._rev, a = (k = l.value.publishedRevs) == null ? void 0 : k[f._id], v = s === a;
|
|
157
|
+
return M(
|
|
158
|
+
"div",
|
|
159
|
+
{
|
|
160
|
+
class: "flex"
|
|
161
|
+
},
|
|
162
|
+
M(
|
|
163
|
+
"div",
|
|
164
|
+
{
|
|
165
|
+
class: [
|
|
166
|
+
"fm-status-badge",
|
|
167
|
+
v ? "fm-status-badge-success-secondary" : "fm-status-badge-info-secondary"
|
|
168
|
+
]
|
|
169
|
+
},
|
|
170
|
+
v ? "Published" : "Unpublished"
|
|
171
|
+
)
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
id: "action",
|
|
177
|
+
cell(g) {
|
|
178
|
+
const f = g.row.original, s = [
|
|
179
|
+
Re[B.Edit],
|
|
180
|
+
Re[B.Delete]
|
|
181
|
+
];
|
|
182
|
+
return ut(s, (a) => m(a, f));
|
|
183
|
+
},
|
|
184
|
+
enableSorting: !1,
|
|
185
|
+
size: 40,
|
|
186
|
+
meta: {
|
|
187
|
+
cellClass: "",
|
|
188
|
+
headerClass: ""
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
recentPublish: l,
|
|
193
|
+
templates: t,
|
|
194
|
+
loading: e,
|
|
195
|
+
fetchTemplates: r,
|
|
196
|
+
loadTemplate: d
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
var me = /* @__PURE__ */ ((c) => (c.Ingredients = "Ingredients", c))(me || {});
|
|
201
|
+
function gt(c) {
|
|
202
|
+
const o = c.sku, n = new Set(c.disabledMeasurements);
|
|
203
|
+
return [
|
|
204
|
+
{
|
|
205
|
+
code: o.code,
|
|
206
|
+
name: o.name,
|
|
207
|
+
unit: o.unit.abbrev,
|
|
208
|
+
enabled: !n.has(o.unit._id)
|
|
209
|
+
},
|
|
210
|
+
...o.unit.measurements.map((e) => ({
|
|
211
|
+
unit: e.abbrev,
|
|
212
|
+
enabled: !n.has(e.id)
|
|
213
|
+
}))
|
|
214
|
+
];
|
|
215
|
+
}
|
|
216
|
+
function ze() {
|
|
217
|
+
return [
|
|
218
|
+
{
|
|
219
|
+
id: "code",
|
|
220
|
+
name: "Code"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
id: "name",
|
|
224
|
+
name: "Name"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
id: "unit",
|
|
228
|
+
name: "Unit"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
id: "enabled",
|
|
232
|
+
name: "Enabled"
|
|
233
|
+
}
|
|
234
|
+
];
|
|
235
|
+
}
|
|
236
|
+
function vt(c) {
|
|
237
|
+
var i;
|
|
238
|
+
const n = ae().currentBusiness.value, t = (i = c.map((r) => {
|
|
239
|
+
var s;
|
|
240
|
+
const d = r.items.flatMap(gt), m = ze(), b = [
|
|
241
|
+
["Template ID", r._id],
|
|
242
|
+
["Template name", r.name],
|
|
243
|
+
["Business name", n == null ? void 0 : n.name],
|
|
244
|
+
["Business ID", n == null ? void 0 : n._id],
|
|
245
|
+
["Menu version", n == null ? void 0 : n.menuVersion],
|
|
246
|
+
[
|
|
247
|
+
"Locations",
|
|
248
|
+
...(s = r.locations) != null && s.length ? [r.locations.map((a) => `${a.name} (${a.dbName})`)] : ["All"]
|
|
249
|
+
],
|
|
250
|
+
["Reference", r.ref ?? ""],
|
|
251
|
+
[],
|
|
252
|
+
m.map((a) => a.name),
|
|
253
|
+
...d.map((a) => m.map((v) => a[v.id]))
|
|
254
|
+
], g = m.map((a) => `system:${a.id}`), f = se(b, g);
|
|
255
|
+
return { name: r.name, sheet: f };
|
|
256
|
+
}).reduce(
|
|
257
|
+
(r, d) => {
|
|
258
|
+
var b;
|
|
259
|
+
const m = d.name.slice(0, 12);
|
|
260
|
+
return (b = r.sheetOccurence)[m] ?? (b[m] = 0), r.sheetOccurence[m] += 1, r.sheets[`${m} (${r.sheetOccurence[m]})`] = d.sheet, r;
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
sheets: {},
|
|
264
|
+
sheetOccurence: {}
|
|
265
|
+
}
|
|
266
|
+
)) == null ? void 0 : i.sheets, e = `${n == null ? void 0 : n.name} closing templates (${ot(/* @__PURE__ */ new Date())}).xlsx`, p = Ve(t);
|
|
267
|
+
return Ne(p, e), e;
|
|
268
|
+
}
|
|
269
|
+
function yt() {
|
|
270
|
+
const c = ae(), o = ce(), n = c.currentBusiness.value, l = ze(), t = [
|
|
271
|
+
["Template ID", "(System ID, leave empty to create new)"],
|
|
272
|
+
["Template Name", "New template"],
|
|
273
|
+
["Business name", n == null ? void 0 : n.name],
|
|
274
|
+
["Business ID", n == null ? void 0 : n._id],
|
|
275
|
+
["Menu version", n == null ? void 0 : n.menuVersion],
|
|
276
|
+
["Location codes", "All", "(or fill location name by cell, refer to destination list)"],
|
|
277
|
+
["Reference:"],
|
|
278
|
+
[],
|
|
279
|
+
l.map((m) => m.name)
|
|
280
|
+
], e = l.map((m) => `system:${m.id}`), p = se(t, e), i = se(
|
|
281
|
+
o.skus.flatMap((m) => [[m.code, m.name, m.unit.abbrev], ...m.unit.measurements.map((g) => ["", "", g.abbrev])]),
|
|
282
|
+
["Code", "Name", "Units", "Enabled (true/false)"]
|
|
283
|
+
), r = Ve({
|
|
284
|
+
Template: p,
|
|
285
|
+
Ingredients: i
|
|
286
|
+
}), d = `${n == null ? void 0 : n.name} transfer templates import.xlsx`;
|
|
287
|
+
return Ne(r, d), d;
|
|
288
|
+
}
|
|
289
|
+
function ht(c) {
|
|
290
|
+
if (`${c[0]}`.toLocaleLowerCase() === "all")
|
|
291
|
+
return [];
|
|
292
|
+
const o = /(.*) \(((warehouse_|restaurant_).{24,})\)/, l = ie().locationByDbName;
|
|
293
|
+
return c.map((t) => {
|
|
294
|
+
const e = new Array(), p = t.trim(), i = o.exec(p);
|
|
295
|
+
if (!i)
|
|
296
|
+
return e.push(`Enabled location value of ${p} cannot be read.`), {
|
|
297
|
+
errors: e
|
|
298
|
+
};
|
|
299
|
+
const r = i[1], d = i[2], m = l[d];
|
|
300
|
+
return m ? (r !== m.name && e.push(
|
|
301
|
+
`Location id ${d} has non-matching name. Found ${r} but expected ${m.name}`
|
|
302
|
+
), {
|
|
303
|
+
errors: e,
|
|
304
|
+
location: m
|
|
305
|
+
}) : (e.push(`Location (${r}) of id ${d} is not found.`), {
|
|
306
|
+
errors: e
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function bt(c) {
|
|
311
|
+
const [
|
|
312
|
+
o,
|
|
313
|
+
n,
|
|
314
|
+
l,
|
|
315
|
+
t,
|
|
316
|
+
e,
|
|
317
|
+
p,
|
|
318
|
+
i,
|
|
319
|
+
r
|
|
320
|
+
] = Be(c);
|
|
321
|
+
return {
|
|
322
|
+
id: `${n[1] ?? ""}`.trim(),
|
|
323
|
+
name: `${l[1] ?? ""}`.trim(),
|
|
324
|
+
locations: i.slice(1).map((d) => `${d}`.trim()).filter((d) => d),
|
|
325
|
+
reference: `${r[1] ?? ""}`.trim()
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function _t(c) {
|
|
329
|
+
const [
|
|
330
|
+
o,
|
|
331
|
+
n,
|
|
332
|
+
l,
|
|
333
|
+
t,
|
|
334
|
+
e,
|
|
335
|
+
p,
|
|
336
|
+
i,
|
|
337
|
+
r,
|
|
338
|
+
d,
|
|
339
|
+
m,
|
|
340
|
+
...b
|
|
341
|
+
] = Be(c);
|
|
342
|
+
if (!o || !o.length || o.some((v) => v.length && !v.startsWith("system:")))
|
|
343
|
+
throw new Error("Missing meta header. Excel file does not come from the template.");
|
|
344
|
+
const g = o.map((v) => v.split(":")[1]), s = ["code", "name", "unit", "enabled"].filter((v) => !g.includes(v));
|
|
345
|
+
if (s.length)
|
|
346
|
+
throw new Error(
|
|
347
|
+
`Missing meta headers (${s.join()}). Excel file does not come from the template.`
|
|
348
|
+
);
|
|
349
|
+
return b.map((v, k) => {
|
|
350
|
+
const u = {};
|
|
351
|
+
for (const C in g) {
|
|
352
|
+
const y = g[C];
|
|
353
|
+
Object.assign(u, { [y]: v[C] });
|
|
354
|
+
}
|
|
355
|
+
return {
|
|
356
|
+
index: k,
|
|
357
|
+
data: u
|
|
358
|
+
};
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
function xt(c) {
|
|
362
|
+
return c.reduce(
|
|
363
|
+
(o, n) => {
|
|
364
|
+
var e;
|
|
365
|
+
const l = n.data, t = n.index;
|
|
366
|
+
return l.unit && (l.code ? o.result.push({ parent: n, children: [] }) : o.result.length ? (e = o.result.at(-1)) == null || e.children.push(n) : o.errors.push(`Cannot find parent for row ${t + 9}`)), o;
|
|
367
|
+
},
|
|
368
|
+
{ result: new Array(), errors: new Array() }
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
function wt(c) {
|
|
372
|
+
const o = c.parent.data, n = new Array(), t = ce().skuByCode[o.code ?? ""];
|
|
373
|
+
if (!t)
|
|
374
|
+
return n.push(`Cannot find ingredient of code ${o.code} ${o.name}`), { errors: n };
|
|
375
|
+
const e = {
|
|
376
|
+
sku: t
|
|
377
|
+
};
|
|
378
|
+
o.unit !== t.unit.abbrev ? n.push(
|
|
379
|
+
`Expected base unit ${t.unit.abbrev} for (${o.code}) ${o.name} but got ${o.unit} instead.`
|
|
380
|
+
) : (!o.enabled || `${o.enabled}`.toLocaleLowerCase() === "false") && (e.disabledMeasurements ?? (e.disabledMeasurements = []), e.disabledMeasurements.push(t.unit._id));
|
|
381
|
+
for (const i of c.children) {
|
|
382
|
+
const r = i.data, d = t.unit.measurements.find((m) => m.abbrev === r.unit);
|
|
383
|
+
if (!d) {
|
|
384
|
+
n.push(
|
|
385
|
+
`Cannot find measurement unit of ${r.unit} for (${o.code}) ${o.name}.`
|
|
386
|
+
);
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
(!r.enabled || `${r.enabled}`.toLocaleLowerCase() === "false") && (e.disabledMeasurements ?? (e.disabledMeasurements = []), e.disabledMeasurements.push(d.id));
|
|
390
|
+
}
|
|
391
|
+
const p = new Set(e.disabledMeasurements);
|
|
392
|
+
return p.has(t.unit._id) && e.sku.unit.measurements.every((i) => p.has(i.id)) && n.push(`Ingredient ${t.code} - ${t.name} must have at least one unit enabled.`), { errors: n, templateItem: e };
|
|
393
|
+
}
|
|
394
|
+
function kt(c) {
|
|
395
|
+
const o = c.SheetNames.filter(
|
|
396
|
+
(e) => !Object.values(me).map(String).includes(e)
|
|
397
|
+
), l = ne().templates, t = st(l, "_id");
|
|
398
|
+
try {
|
|
399
|
+
return o.reduce(
|
|
400
|
+
(e, p) => {
|
|
401
|
+
const i = new Array(), r = c.Sheets[p], d = bt(r), m = ht(d.locations), b = m.filter((u) => u.location).map((u) => u.location);
|
|
402
|
+
i.push(...m.flatMap((u) => u.errors));
|
|
403
|
+
const g = _t(r).filter(
|
|
404
|
+
(u) => u.data.code || u.data.unit
|
|
405
|
+
), f = xt(g);
|
|
406
|
+
i.push(...f.errors);
|
|
407
|
+
const s = f.result.map(
|
|
408
|
+
(u) => wt(u)
|
|
409
|
+
);
|
|
410
|
+
i.push(...s.flatMap((u) => u.errors));
|
|
411
|
+
const a = s.filter((u) => u.templateItem).map((u) => u.templateItem);
|
|
412
|
+
if (d.id) {
|
|
413
|
+
const u = t[d.id];
|
|
414
|
+
if (!u) {
|
|
415
|
+
const y = {
|
|
416
|
+
_id: d.id,
|
|
417
|
+
_rev: "",
|
|
418
|
+
name: d.name || `(unnamed from sheet ${p || "<unnamed sheet>"})`,
|
|
419
|
+
items: []
|
|
420
|
+
};
|
|
421
|
+
return i.push(`Template ID ${d.id} is not found.`), e.importUpdateResult.push({
|
|
422
|
+
type: "update",
|
|
423
|
+
original: y,
|
|
424
|
+
template: y,
|
|
425
|
+
excelSheetName: p,
|
|
426
|
+
errors: i
|
|
427
|
+
}), e;
|
|
428
|
+
}
|
|
429
|
+
const C = {
|
|
430
|
+
type: "update",
|
|
431
|
+
original: u,
|
|
432
|
+
template: {
|
|
433
|
+
...u,
|
|
434
|
+
name: d.name,
|
|
435
|
+
locations: b.length ? b : null,
|
|
436
|
+
ref: d.reference,
|
|
437
|
+
items: a
|
|
438
|
+
},
|
|
439
|
+
excelSheetName: p,
|
|
440
|
+
errors: i
|
|
441
|
+
};
|
|
442
|
+
return e.importUpdateResult.push(C), e;
|
|
443
|
+
}
|
|
444
|
+
const k = {
|
|
445
|
+
type: "create",
|
|
446
|
+
template: {
|
|
447
|
+
name: d.id,
|
|
448
|
+
locations: b,
|
|
449
|
+
ref: d.reference,
|
|
450
|
+
items: a
|
|
451
|
+
},
|
|
452
|
+
excelSheetName: p,
|
|
453
|
+
errors: i
|
|
454
|
+
};
|
|
455
|
+
return e.importCreateResult.push(k), e;
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
invalidExcel: !1,
|
|
459
|
+
importCreateResult: new Array(),
|
|
460
|
+
importUpdateResult: new Array()
|
|
461
|
+
}
|
|
462
|
+
);
|
|
463
|
+
} catch (e) {
|
|
464
|
+
return {
|
|
465
|
+
invalidExcel: !0,
|
|
466
|
+
invalidExcelMessage: (e == null ? void 0 : e.message) ?? "Invalid excel",
|
|
467
|
+
importCreateResult: [],
|
|
468
|
+
importUpdateResult: []
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
const Tt = { class: "flex items-center gap-12 pl-8" }, $t = { class: "flex flex-col" }, Ct = { class: "fm-typo-en-body-md-400 text-fm-color-typo-primary flex items-center gap-4" }, Dt = {
|
|
473
|
+
key: 0,
|
|
474
|
+
class: "text-fm-color-typo-secondary fm-typo-en-body-sm-400"
|
|
475
|
+
}, St = { key: 0 }, Ie = /* @__PURE__ */ H({
|
|
476
|
+
__name: "ClosingTemplateImportItem",
|
|
477
|
+
props: {
|
|
478
|
+
type: {},
|
|
479
|
+
name: {},
|
|
480
|
+
locations: {},
|
|
481
|
+
items: {},
|
|
482
|
+
errors: {}
|
|
483
|
+
},
|
|
484
|
+
setup(c) {
|
|
485
|
+
return (o, n) => {
|
|
486
|
+
var e, p, i;
|
|
487
|
+
const l = F("FmIcon"), t = F("FmTooltip");
|
|
488
|
+
return w(), $("div", Tt, [
|
|
489
|
+
n[0] || (n[0] = h("div", null, "•", -1)),
|
|
490
|
+
h("div", $t, [
|
|
491
|
+
h("div", Ct, [
|
|
492
|
+
h("div", {
|
|
493
|
+
class: O({
|
|
494
|
+
"text-fm-color-system-error-300": o.errors.length
|
|
495
|
+
})
|
|
496
|
+
}, [
|
|
497
|
+
oe(R(o.name) + " ", 1),
|
|
498
|
+
o.type === "create" ? (w(), $("span", Dt, "(new)")) : J("", !0)
|
|
499
|
+
], 2),
|
|
500
|
+
o.errors.length ? (w(), $("div", St, [
|
|
501
|
+
T(t, { "z-index": 50 }, {
|
|
502
|
+
content: A(() => [
|
|
503
|
+
h("ol", null, [
|
|
504
|
+
(w(!0), $(z, null, W(o.errors, (r, d) => (w(), $("li", { key: d }, R(r), 1))), 128))
|
|
505
|
+
])
|
|
506
|
+
]),
|
|
507
|
+
default: A(() => [
|
|
508
|
+
T(l, {
|
|
509
|
+
name: "error",
|
|
510
|
+
size: "sm",
|
|
511
|
+
color: "system-error-300"
|
|
512
|
+
})
|
|
513
|
+
]),
|
|
514
|
+
_: 1
|
|
515
|
+
})
|
|
516
|
+
])) : J("", !0)
|
|
517
|
+
]),
|
|
518
|
+
h("div", {
|
|
519
|
+
class: O([
|
|
520
|
+
"fm-typo-en-body-sm-400",
|
|
521
|
+
{
|
|
522
|
+
"text-fm-color-system-error-200": o.errors.length,
|
|
523
|
+
"text-fm-color-typo-secondary": !o.errors.length
|
|
524
|
+
}
|
|
525
|
+
])
|
|
526
|
+
}, R((e = o.locations) != null && e.length ? `${(p = o.locations) == null ? void 0 : p.length} locations` : "All locations") + ", " + R(`${(i = o.items) == null ? void 0 : i.length} items`), 3)
|
|
527
|
+
])
|
|
528
|
+
]);
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
}), Mt = { class: "flex flex-col gap-24" }, Rt = {
|
|
532
|
+
key: 0,
|
|
533
|
+
class: "flex items-center gap-8"
|
|
534
|
+
}, Ft = { class: "flex flex-col gap-8" }, It = { class: "line-clamp-2 text-ellipsis break-all" }, At = {
|
|
535
|
+
key: 2,
|
|
536
|
+
class: "shrink-0"
|
|
537
|
+
}, Et = {
|
|
538
|
+
key: 0,
|
|
539
|
+
class: "flex flex-col"
|
|
540
|
+
}, Pt = { class: "text-fm-color-system-error-300 fm-typo-en-body-sm-400" }, Ut = {
|
|
541
|
+
key: 0,
|
|
542
|
+
class: "max-h-[200px] overflow-y-auto flex flex-col gap-8"
|
|
543
|
+
}, Vt = { class: "fm-typo-en-body-lg-600" }, Nt = /* @__PURE__ */ H({
|
|
544
|
+
__name: "ClosingTemplateImport",
|
|
545
|
+
setup(c) {
|
|
546
|
+
const o = S(null), n = Ze(), l = ee(), t = S(!1), e = S(!1), p = S(new Array()), i = S([]), r = S([]), d = I(
|
|
547
|
+
() => !!p.value.length || i.value.some((f) => f.errors.length) || r.value.some((f) => f.errors.length)
|
|
548
|
+
), m = I(
|
|
549
|
+
() => !!i.value.length || !!r.value.length
|
|
550
|
+
), { t: b } = K();
|
|
551
|
+
async function g(f) {
|
|
552
|
+
p.value = [], i.value = [], r.value = [];
|
|
553
|
+
try {
|
|
554
|
+
t.value = !0;
|
|
555
|
+
const [s] = await Promise.all([
|
|
556
|
+
ct(f),
|
|
557
|
+
// fake buffer
|
|
558
|
+
new Promise((u) => setTimeout(u, 1e3))
|
|
559
|
+
]);
|
|
560
|
+
if (!s.SheetNames.filter(
|
|
561
|
+
(u) => !Object.values(me).map(String).includes(u)
|
|
562
|
+
).find((u) => u)) {
|
|
563
|
+
p.value.push(b("inventory.ingredient.import.fileError.noSheet"));
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
const k = kt(s);
|
|
567
|
+
if (k.invalidExcel) {
|
|
568
|
+
p.value.push(
|
|
569
|
+
k.invalidExcelMessage ?? b("inventory.ingredient.import.fileError.invalidExcel")
|
|
570
|
+
);
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
if (i.value = k.importCreateResult, r.value = k.importUpdateResult, !i.value.length && !r.value.length) {
|
|
574
|
+
p.value.push(b("inventory.ingredient.import.fileError.noData"));
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
n.emitData(k);
|
|
578
|
+
} catch (s) {
|
|
579
|
+
l.open({
|
|
580
|
+
title: b("inventory.ingredient.import.fileError.unableToRead"),
|
|
581
|
+
message: s == null ? void 0 : s.message,
|
|
582
|
+
type: "error"
|
|
583
|
+
}), console.error("Error in reading file", s);
|
|
584
|
+
} finally {
|
|
585
|
+
p.value.length && l.open({
|
|
586
|
+
title: b("inventory.ingredient.import.fileError.invalidExcel"),
|
|
587
|
+
type: "error"
|
|
588
|
+
}), t.value = !1;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return Ae(o, (f) => {
|
|
592
|
+
f && g(f);
|
|
593
|
+
}), (f, s) => {
|
|
594
|
+
const a = F("FmCircularProgress"), v = F("FmIcon"), k = F("FmButton");
|
|
595
|
+
return w(), $("div", Mt, [
|
|
596
|
+
s[2] || (s[2] = h("div", { class: "fm-typo-en-body-md-400" }, "Import closing templates from excel sheets.", -1)),
|
|
597
|
+
e.value ? (w(), $("div", Rt, [
|
|
598
|
+
h("div", null, [
|
|
599
|
+
T(a, {
|
|
600
|
+
size: "md",
|
|
601
|
+
color: "neutral-gray-200"
|
|
602
|
+
})
|
|
603
|
+
]),
|
|
604
|
+
s[1] || (s[1] = h("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, "Loading...", -1))
|
|
605
|
+
])) : (w(), $(z, { key: 1 }, [
|
|
606
|
+
T(mt, {
|
|
607
|
+
class: O({
|
|
608
|
+
"w-full": !0,
|
|
609
|
+
"h-[200px]": !o.value
|
|
610
|
+
}),
|
|
611
|
+
accept: ".xlsx",
|
|
612
|
+
onFileUpload: s[0] || (s[0] = (u) => o.value = u),
|
|
613
|
+
label: _(b)("inventory.ingredient.import.uploadTemplate"),
|
|
614
|
+
"button-label": _(b)("inventory.ingredient.import.selectFile")
|
|
615
|
+
}, Ye({ _: 2 }, [
|
|
616
|
+
o.value ? {
|
|
617
|
+
name: "default",
|
|
618
|
+
fn: A(({ openFileDialog: u }) => [
|
|
619
|
+
h("div", Ft, [
|
|
620
|
+
h("div", {
|
|
621
|
+
class: O([
|
|
622
|
+
"fm-corner-radius-md p-16 flex items-center gap-16",
|
|
623
|
+
{
|
|
624
|
+
"border border-fm-color-neutral-gray-100": t.value,
|
|
625
|
+
"border border-fm-color-neutral-gray-200": !t.value && !d.value,
|
|
626
|
+
"border border-fm-color-system-error-200": d.value
|
|
627
|
+
}
|
|
628
|
+
])
|
|
629
|
+
}, [
|
|
630
|
+
t.value ? (w(), U(a, {
|
|
631
|
+
key: 0,
|
|
632
|
+
size: "md",
|
|
633
|
+
color: "neutral-gray-200"
|
|
634
|
+
})) : (w(), U(v, {
|
|
635
|
+
key: 1,
|
|
636
|
+
name: d.value ? "error" : "attach_file",
|
|
637
|
+
outline: "",
|
|
638
|
+
color: d.value ? "system-error-300" : void 0
|
|
639
|
+
}, null, 8, ["name", "color"])),
|
|
640
|
+
h("div", {
|
|
641
|
+
class: O([
|
|
642
|
+
"fm-typo-en-body-md-400 flex-1 h-[36px] flex items-center",
|
|
643
|
+
{
|
|
644
|
+
"text-fm-color-typo-disabled": t.value,
|
|
645
|
+
"text-fm-color-typo-primary": !t.value
|
|
646
|
+
}
|
|
647
|
+
])
|
|
648
|
+
}, [
|
|
649
|
+
h("div", It, R(o.value.name), 1)
|
|
650
|
+
], 2),
|
|
651
|
+
t.value ? J("", !0) : (w(), $("div", At, [
|
|
652
|
+
T(k, {
|
|
653
|
+
label: _(b)("inventory.ingredient.import.replaceFile"),
|
|
654
|
+
variant: d.value ? "destructive" : "secondary",
|
|
655
|
+
"prepend-icon": d.value ? void 0 : "autorenew",
|
|
656
|
+
onClick: u
|
|
657
|
+
}, null, 8, ["label", "variant", "prepend-icon", "onClick"])
|
|
658
|
+
]))
|
|
659
|
+
], 2),
|
|
660
|
+
p.value.length ? (w(), $("div", Et, [
|
|
661
|
+
(w(!0), $(z, null, W(p.value, (C, y) => (w(), $("div", {
|
|
662
|
+
key: y,
|
|
663
|
+
class: "flex gap-8 items-center"
|
|
664
|
+
}, [
|
|
665
|
+
T(v, {
|
|
666
|
+
name: "error",
|
|
667
|
+
size: "sm",
|
|
668
|
+
color: "system-error-300"
|
|
669
|
+
}),
|
|
670
|
+
h("div", Pt, R(C), 1)
|
|
671
|
+
]))), 128))
|
|
672
|
+
])) : J("", !0)
|
|
673
|
+
])
|
|
674
|
+
]),
|
|
675
|
+
key: "0"
|
|
676
|
+
} : void 0
|
|
677
|
+
]), 1032, ["class", "label", "button-label"]),
|
|
678
|
+
m.value ? (w(), $("div", Ut, [
|
|
679
|
+
h("div", Vt, R(_(b)("inventory.ingredient.import.summary")), 1),
|
|
680
|
+
(w(!0), $(z, null, W(i.value, (u, C) => (w(), U(Ie, {
|
|
681
|
+
key: C,
|
|
682
|
+
name: u.template.name,
|
|
683
|
+
locations: u.template.locations,
|
|
684
|
+
items: u.template.items,
|
|
685
|
+
errors: u.errors,
|
|
686
|
+
type: "create"
|
|
687
|
+
}, null, 8, ["name", "locations", "items", "errors"]))), 128)),
|
|
688
|
+
(w(!0), $(z, null, W(r.value, (u) => (w(), U(Ie, {
|
|
689
|
+
key: u.template._id,
|
|
690
|
+
name: u.template.name,
|
|
691
|
+
locations: u.template.locations,
|
|
692
|
+
items: u.template.items,
|
|
693
|
+
errors: u.errors,
|
|
694
|
+
type: "update"
|
|
695
|
+
}, null, 8, ["name", "locations", "items", "errors"]))), 128))
|
|
696
|
+
])) : J("", !0)
|
|
697
|
+
], 64))
|
|
698
|
+
]);
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
}), le = Ee("closingTemplateActions", () => {
|
|
702
|
+
const { t: c } = K(), o = re(), n = ee(), l = te(), t = ne(), { loading: e } = Pe(t), p = S({});
|
|
703
|
+
function i() {
|
|
704
|
+
p.value = {
|
|
705
|
+
mode: L.CREATE,
|
|
706
|
+
show: !0,
|
|
707
|
+
"onUpdate:show"(a) {
|
|
708
|
+
p.value.show = a;
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
function r(a) {
|
|
713
|
+
p.value = {
|
|
714
|
+
mode: L.UPDATE,
|
|
715
|
+
modelValue: a,
|
|
716
|
+
show: !0,
|
|
717
|
+
"onUpdate:show"(v) {
|
|
718
|
+
p.value.show = v;
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
function d(a, v, k) {
|
|
723
|
+
o.open({
|
|
724
|
+
title: `Confirm deleting template ${a.name}?`,
|
|
725
|
+
message: "Deleted template can no longer be retrieved",
|
|
726
|
+
primaryActions: {
|
|
727
|
+
text: "Delete",
|
|
728
|
+
variant: Me.Destructive,
|
|
729
|
+
close: !0
|
|
730
|
+
},
|
|
731
|
+
secondaryActions: {
|
|
732
|
+
text: "Cancel",
|
|
733
|
+
variant: Me.Plain,
|
|
734
|
+
close: !0
|
|
735
|
+
}
|
|
736
|
+
}).onPrimary(async () => {
|
|
737
|
+
n.open({
|
|
738
|
+
title: `Deleting ${a.name}`,
|
|
739
|
+
type: "info"
|
|
740
|
+
});
|
|
741
|
+
try {
|
|
742
|
+
v.value = !0;
|
|
743
|
+
const [u] = await Promise.allSettled([
|
|
744
|
+
l.deleteTemplate(a),
|
|
745
|
+
new Promise((C) => setTimeout(C, 1e3))
|
|
746
|
+
]);
|
|
747
|
+
if (u.status === "rejected") throw u.reason;
|
|
748
|
+
n.open({
|
|
749
|
+
title: `Deleted ${a.name}`,
|
|
750
|
+
type: "success"
|
|
751
|
+
});
|
|
752
|
+
} catch (u) {
|
|
753
|
+
n.open({
|
|
754
|
+
title: `Unable to delete ${a.name}`,
|
|
755
|
+
message: `See error from server: ${u}`,
|
|
756
|
+
type: "error"
|
|
757
|
+
}), console.error("error on deleting closing template", u);
|
|
758
|
+
} finally {
|
|
759
|
+
v.value = !1, k();
|
|
760
|
+
}
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
const m = S({});
|
|
764
|
+
function b(a) {
|
|
765
|
+
m.value = {
|
|
766
|
+
template: a,
|
|
767
|
+
show: !0,
|
|
768
|
+
"onUpdate:show"(v) {
|
|
769
|
+
m.value.show = v;
|
|
770
|
+
},
|
|
771
|
+
"onAction:edit"() {
|
|
772
|
+
m.value.show = !1, r(Ue(a));
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
function g() {
|
|
777
|
+
const a = vt(t.templates);
|
|
778
|
+
n.open({
|
|
779
|
+
title: c("inventory.ingredient.export.success"),
|
|
780
|
+
message: c("inventory.ingredient.export.filename", [a]),
|
|
781
|
+
type: "success"
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
function f() {
|
|
785
|
+
t.loading || o.open({
|
|
786
|
+
title: c("inventory.ingredient.import.title"),
|
|
787
|
+
contentComponent: Nt,
|
|
788
|
+
overlay: !0,
|
|
789
|
+
closeButton: !0,
|
|
790
|
+
primaryActions: {
|
|
791
|
+
text: c("common.import"),
|
|
792
|
+
close: !1
|
|
793
|
+
},
|
|
794
|
+
secondaryActions: {
|
|
795
|
+
text: c("common.close"),
|
|
796
|
+
close: !0
|
|
797
|
+
},
|
|
798
|
+
tertiaryActions: {
|
|
799
|
+
text: c("inventory.ingredient.import.actions.downloadTemplate"),
|
|
800
|
+
close: !1,
|
|
801
|
+
variant: "plain"
|
|
802
|
+
}
|
|
803
|
+
}).onPrimary((a) => {
|
|
804
|
+
if (!a) {
|
|
805
|
+
n.open({
|
|
806
|
+
title: c("inventory.ingredient.import.error.noData"),
|
|
807
|
+
type: "error"
|
|
808
|
+
});
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
if (!a.importCreateResult.length && !a.importUpdateResult.length) {
|
|
812
|
+
n.open({
|
|
813
|
+
title: c("inventory.ingredient.import.error.invalidContent"),
|
|
814
|
+
message: c("inventory.ingredient.import.error.noImportData"),
|
|
815
|
+
type: "error"
|
|
816
|
+
});
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
if (a.importCreateResult.some((v) => v.errors.length) || a.importUpdateResult.some((v) => v.errors.length)) {
|
|
820
|
+
n.open({
|
|
821
|
+
title: c("inventory.ingredient.import.error.invalidContent"),
|
|
822
|
+
message: c("inventory.ingredient.import.error.hasErrors"),
|
|
823
|
+
type: "error"
|
|
824
|
+
});
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
o.close(), s(a);
|
|
828
|
+
}).onTertiary(yt);
|
|
829
|
+
}
|
|
830
|
+
async function s(a) {
|
|
831
|
+
e.value = !0;
|
|
832
|
+
try {
|
|
833
|
+
const v = [
|
|
834
|
+
...a.importCreateResult.map(
|
|
835
|
+
(y) => y.template
|
|
836
|
+
),
|
|
837
|
+
...a.importUpdateResult.map(
|
|
838
|
+
(y) => y.template
|
|
839
|
+
)
|
|
840
|
+
], k = 100;
|
|
841
|
+
let u = 0;
|
|
842
|
+
const C = () => {
|
|
843
|
+
u += k, n.open({
|
|
844
|
+
title: c("inventory.ingredient.import.progress", [
|
|
845
|
+
Math.min(u, v.length),
|
|
846
|
+
v.length
|
|
847
|
+
])
|
|
848
|
+
});
|
|
849
|
+
};
|
|
850
|
+
for (const y of v.chunk(100))
|
|
851
|
+
C(), await l.importTemplates(y);
|
|
852
|
+
n.open({
|
|
853
|
+
title: c("inventory.ingredient.import.success"),
|
|
854
|
+
type: "success"
|
|
855
|
+
});
|
|
856
|
+
} catch (v) {
|
|
857
|
+
n.open({
|
|
858
|
+
title: c("inventory.ingredient.import.error.failed"),
|
|
859
|
+
message: c("inventory.ingredient.import.error.systemMessage", [v == null ? void 0 : v.message]),
|
|
860
|
+
type: "error"
|
|
861
|
+
}), console.error("Error in importing skus", a, v);
|
|
862
|
+
} finally {
|
|
863
|
+
e.value = !1, t.fetchTemplates();
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
return {
|
|
867
|
+
createTemplate: i,
|
|
868
|
+
viewTemplate: b,
|
|
869
|
+
updateTemplate: r,
|
|
870
|
+
deleteTemplate: d,
|
|
871
|
+
exportTemplates: g,
|
|
872
|
+
importTemplates: f,
|
|
873
|
+
templateDialogProps: p,
|
|
874
|
+
templateDetailsProps: m
|
|
875
|
+
};
|
|
876
|
+
});
|
|
877
|
+
var G = /* @__PURE__ */ ((c) => (c.Name = "Name", c.Unit = "Unit", c.Delete = "Delete", c))(G || {});
|
|
878
|
+
function Bt(c) {
|
|
879
|
+
return {
|
|
880
|
+
columnDefs: I(() => {
|
|
881
|
+
const n = c.items.map((t) => t.sku.unit.measurements.length).reduce((t, e) => Math.max(t, e), 0);
|
|
882
|
+
return [
|
|
883
|
+
{
|
|
884
|
+
id: "Name",
|
|
885
|
+
header: () => "Name",
|
|
886
|
+
enableSorting: !1,
|
|
887
|
+
size: 400,
|
|
888
|
+
cell(t) {
|
|
889
|
+
const e = t.row.original;
|
|
890
|
+
return M(
|
|
891
|
+
"div",
|
|
892
|
+
{
|
|
893
|
+
class: "flex flex-col"
|
|
894
|
+
},
|
|
895
|
+
[
|
|
896
|
+
M(
|
|
897
|
+
"span",
|
|
898
|
+
{ class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary line-clamp-1" },
|
|
899
|
+
e.sku.name
|
|
900
|
+
),
|
|
901
|
+
M(
|
|
902
|
+
"span",
|
|
903
|
+
{ class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary line-clamp-1" },
|
|
904
|
+
e.sku.code
|
|
905
|
+
)
|
|
906
|
+
]
|
|
907
|
+
);
|
|
908
|
+
}
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
id: "Unit",
|
|
912
|
+
header: () => "Enable unit",
|
|
913
|
+
enableSorting: !1,
|
|
914
|
+
size: "auto",
|
|
915
|
+
cell(t) {
|
|
916
|
+
var p, i, r;
|
|
917
|
+
const e = t.row.original;
|
|
918
|
+
return M(
|
|
919
|
+
N.FmFormGroup,
|
|
920
|
+
{
|
|
921
|
+
value: e.sku.unit._id,
|
|
922
|
+
modelValue: !((p = e.disabledMeasurements) != null && p.includes(e.sku.unit._id))
|
|
923
|
+
},
|
|
924
|
+
M(
|
|
925
|
+
"div",
|
|
926
|
+
{
|
|
927
|
+
class: "flex items-center gap-4"
|
|
928
|
+
},
|
|
929
|
+
[
|
|
930
|
+
M(N.FmCheckbox, {
|
|
931
|
+
value: e.sku.unit._id,
|
|
932
|
+
modelValue: !((i = e.disabledMeasurements) != null && i.includes(e.sku.unit._id)),
|
|
933
|
+
disabled: c.disabled || !((r = e.disabledMeasurements) != null && r.includes(e.sku.unit._id)) && e.sku.unit.measurements.every(
|
|
934
|
+
(d) => {
|
|
935
|
+
var m;
|
|
936
|
+
return (m = e.disabledMeasurements) == null ? void 0 : m.includes(d.id);
|
|
937
|
+
}
|
|
938
|
+
),
|
|
939
|
+
"onUpdate:modelValue"(d) {
|
|
940
|
+
var m;
|
|
941
|
+
if (d)
|
|
942
|
+
c.updateItem({
|
|
943
|
+
...e,
|
|
944
|
+
disabledMeasurements: (m = e.disabledMeasurements) == null ? void 0 : m.filter(
|
|
945
|
+
(b) => b !== e.sku.unit._id
|
|
946
|
+
)
|
|
947
|
+
});
|
|
948
|
+
else {
|
|
949
|
+
const b = e.disabledMeasurements ?? [];
|
|
950
|
+
c.updateItem({
|
|
951
|
+
...e,
|
|
952
|
+
disabledMeasurements: [...b, e.sku.unit._id]
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
}),
|
|
957
|
+
M(
|
|
958
|
+
N.FmTooltip,
|
|
959
|
+
{ zIndex: 51 },
|
|
960
|
+
{
|
|
961
|
+
content() {
|
|
962
|
+
return e.sku.unit.abbrev;
|
|
963
|
+
},
|
|
964
|
+
default() {
|
|
965
|
+
return M(
|
|
966
|
+
"div",
|
|
967
|
+
{ class: "line-clamp-2 fm-typo-en-body-lg-400" },
|
|
968
|
+
e.sku.unit.abbrev
|
|
969
|
+
);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
)
|
|
973
|
+
]
|
|
974
|
+
)
|
|
975
|
+
);
|
|
976
|
+
}
|
|
977
|
+
},
|
|
978
|
+
...Array.from({ length: Math.max(n, 0) }).map(
|
|
979
|
+
(t, e) => ({
|
|
980
|
+
id: `measurement${e}`,
|
|
981
|
+
header: () => "",
|
|
982
|
+
enableSorting: !1,
|
|
983
|
+
size: "auto",
|
|
984
|
+
cell(p) {
|
|
985
|
+
var d, m, b, g;
|
|
986
|
+
const i = p.row.original, r = i.sku.unit.measurements[e];
|
|
987
|
+
return r ? M(
|
|
988
|
+
N.FmFormGroup,
|
|
989
|
+
{
|
|
990
|
+
modelValue: !((d = i.disabledMeasurements) != null && d.includes(r.id)),
|
|
991
|
+
value: r.id
|
|
992
|
+
},
|
|
993
|
+
M(
|
|
994
|
+
"div",
|
|
995
|
+
{
|
|
996
|
+
class: "flex items-center gap-4"
|
|
997
|
+
},
|
|
998
|
+
[
|
|
999
|
+
M(N.FmCheckbox, {
|
|
1000
|
+
value: r.id,
|
|
1001
|
+
modelValue: !((m = i.disabledMeasurements) != null && m.includes(r.id)),
|
|
1002
|
+
disabled: c.disabled || !((b = i.disabledMeasurements) != null && b.includes(r.id)) && ((g = i.disabledMeasurements) == null ? void 0 : g.includes(i.sku.unit._id)) && i.sku.unit.measurements.filter((f) => f.id != r.id).every((f) => {
|
|
1003
|
+
var s;
|
|
1004
|
+
return (s = i.disabledMeasurements) == null ? void 0 : s.includes(f.id);
|
|
1005
|
+
}),
|
|
1006
|
+
"onUpdate:modelValue"(f) {
|
|
1007
|
+
var s;
|
|
1008
|
+
if (f)
|
|
1009
|
+
c.updateItem({
|
|
1010
|
+
...i,
|
|
1011
|
+
disabledMeasurements: (s = i.disabledMeasurements) == null ? void 0 : s.filter(
|
|
1012
|
+
(a) => a !== r.id
|
|
1013
|
+
)
|
|
1014
|
+
});
|
|
1015
|
+
else {
|
|
1016
|
+
const a = i.disabledMeasurements ?? [];
|
|
1017
|
+
c.updateItem({
|
|
1018
|
+
...i,
|
|
1019
|
+
disabledMeasurements: [...a, r.id]
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
}),
|
|
1024
|
+
M(
|
|
1025
|
+
N.FmTooltip,
|
|
1026
|
+
{ zIndex: 51 },
|
|
1027
|
+
{
|
|
1028
|
+
content() {
|
|
1029
|
+
return r.abbrev;
|
|
1030
|
+
},
|
|
1031
|
+
default() {
|
|
1032
|
+
return M(
|
|
1033
|
+
"div",
|
|
1034
|
+
{ class: "line-clamp-2 fm-typo-en-body-lg-400" },
|
|
1035
|
+
r.abbrev
|
|
1036
|
+
);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
)
|
|
1040
|
+
]
|
|
1041
|
+
)
|
|
1042
|
+
) : null;
|
|
1043
|
+
}
|
|
1044
|
+
})
|
|
1045
|
+
),
|
|
1046
|
+
{
|
|
1047
|
+
id: "Delete",
|
|
1048
|
+
header: "",
|
|
1049
|
+
cell(t) {
|
|
1050
|
+
const e = t.row.original;
|
|
1051
|
+
return M(
|
|
1052
|
+
"div",
|
|
1053
|
+
{ class: "w-full flex justify-end" },
|
|
1054
|
+
M(N.FmButton, {
|
|
1055
|
+
class: "delete-button",
|
|
1056
|
+
key: e.sku._id,
|
|
1057
|
+
type: "button",
|
|
1058
|
+
icon: "delete",
|
|
1059
|
+
variant: "tertiary",
|
|
1060
|
+
size: "md",
|
|
1061
|
+
disabled: c.disabled,
|
|
1062
|
+
onClick: () => {
|
|
1063
|
+
c.deleteItem(e);
|
|
1064
|
+
}
|
|
1065
|
+
})
|
|
1066
|
+
);
|
|
1067
|
+
},
|
|
1068
|
+
enableSorting: !1,
|
|
1069
|
+
size: 40,
|
|
1070
|
+
meta: {
|
|
1071
|
+
cellClass: "",
|
|
1072
|
+
headerClass: ""
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
];
|
|
1076
|
+
})
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
const Lt = { class: "flex flex-col gap-16 py-12" }, zt = { class: "flex" }, Ht = { class: "flex-1 flex flex-col" }, Yt = { class: "fm-typo-en-title-sm-600 text-fm-color-typo-primary" }, jt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, Ot = { class: "flex flex-col gap-4" }, Kt = /* @__PURE__ */ H({
|
|
1080
|
+
__name: "ClosingTemplateItem",
|
|
1081
|
+
props: {
|
|
1082
|
+
cellByColId: {},
|
|
1083
|
+
row: {}
|
|
1084
|
+
},
|
|
1085
|
+
setup(c) {
|
|
1086
|
+
const o = c, n = I(() => o.row), l = I(
|
|
1087
|
+
() => n.value.getVisibleCells().filter((t) => t.column.id !== G.Name && t.column.id !== G.Delete)
|
|
1088
|
+
);
|
|
1089
|
+
return (t, e) => {
|
|
1090
|
+
var p, i, r, d, m;
|
|
1091
|
+
return w(), $("div", Lt, [
|
|
1092
|
+
h("div", zt, [
|
|
1093
|
+
h("div", Ht, [
|
|
1094
|
+
h("div", Yt, R(n.value.original.sku.name), 1),
|
|
1095
|
+
h("div", jt, R(n.value.original.sku.code), 1)
|
|
1096
|
+
]),
|
|
1097
|
+
h("div", null, [
|
|
1098
|
+
T(_(j), {
|
|
1099
|
+
render: (r = (i = (p = t.cellByColId[_(G).Delete]) == null ? void 0 : p.column) == null ? void 0 : i.columnDef) == null ? void 0 : r.cell,
|
|
1100
|
+
props: (m = (d = t.cellByColId[_(G).Delete]) == null ? void 0 : d.getContext) == null ? void 0 : m.call(d)
|
|
1101
|
+
}, null, 8, ["render", "props"])
|
|
1102
|
+
])
|
|
1103
|
+
]),
|
|
1104
|
+
h("div", Ot, [
|
|
1105
|
+
e[0] || (e[0] = h("div", { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, "Enabled units", -1)),
|
|
1106
|
+
(w(!0), $(z, null, W(l.value, (b) => {
|
|
1107
|
+
var g, f, s;
|
|
1108
|
+
return w(), $("div", {
|
|
1109
|
+
key: b.id
|
|
1110
|
+
}, [
|
|
1111
|
+
T(_(j), {
|
|
1112
|
+
render: (f = (g = b.column) == null ? void 0 : g.columnDef) == null ? void 0 : f.cell,
|
|
1113
|
+
props: (s = b.getContext) == null ? void 0 : s.call(b)
|
|
1114
|
+
}, null, 8, ["render", "props"])
|
|
1115
|
+
]);
|
|
1116
|
+
}), 128))
|
|
1117
|
+
])
|
|
1118
|
+
]);
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
}), Gt = { class: "flex flex-col gap-16" }, Jt = { class: "flex flex-col gap-24" }, Wt = { class: "flex flex-col gap-16" }, qt = { class: "flex items-center" }, Xt = { class: "flex flex-col gap-16" }, Qt = { class: "flex items-center" }, Zt = { class: "flex-1 gap-8 fm-typo-en-title-sm-800" }, en = /* @__PURE__ */ H({
|
|
1122
|
+
__name: "ClosingTemplateForm",
|
|
1123
|
+
props: {
|
|
1124
|
+
modelValue: {},
|
|
1125
|
+
disabled: { type: Boolean }
|
|
1126
|
+
},
|
|
1127
|
+
setup(c, { expose: o }) {
|
|
1128
|
+
const n = c, l = pt(), { t } = K(), e = ce(), p = re(), {
|
|
1129
|
+
promptSelectLocations: i,
|
|
1130
|
+
columnDefs: r,
|
|
1131
|
+
rowData: d
|
|
1132
|
+
} = ft({
|
|
1133
|
+
getLocations() {
|
|
1134
|
+
return l.locations;
|
|
1135
|
+
},
|
|
1136
|
+
setLocations(s) {
|
|
1137
|
+
l.locations = s;
|
|
1138
|
+
}
|
|
1139
|
+
}), m = S();
|
|
1140
|
+
o({
|
|
1141
|
+
validateInputs: () => {
|
|
1142
|
+
var s, a;
|
|
1143
|
+
(a = (s = m.value) == null ? void 0 : s.validateInputs) == null || a.call(s);
|
|
1144
|
+
},
|
|
1145
|
+
resetInputsValidation: () => {
|
|
1146
|
+
var s, a;
|
|
1147
|
+
(a = (s = m.value) == null ? void 0 : s.resetInputsValidation) == null || a.call(s);
|
|
1148
|
+
},
|
|
1149
|
+
resetInputs: () => {
|
|
1150
|
+
var s, a;
|
|
1151
|
+
(a = (s = m.value) == null ? void 0 : s.resetInputs) == null || a.call(s);
|
|
1152
|
+
}
|
|
1153
|
+
});
|
|
1154
|
+
const b = Bt({
|
|
1155
|
+
updateItem: (s) => {
|
|
1156
|
+
l.items = l.items.map((a) => a.sku._id !== s.sku._id ? a : s);
|
|
1157
|
+
},
|
|
1158
|
+
deleteItem: (s) => {
|
|
1159
|
+
l.items = l.items.filter((a) => a.sku._id !== s.sku._id);
|
|
1160
|
+
},
|
|
1161
|
+
get items() {
|
|
1162
|
+
return l.items;
|
|
1163
|
+
},
|
|
1164
|
+
get disabled() {
|
|
1165
|
+
return n.disabled;
|
|
1166
|
+
}
|
|
1167
|
+
}), g = I(() => b.columnDefs.value);
|
|
1168
|
+
function f() {
|
|
1169
|
+
const s = e.skus.map((v) => ({
|
|
1170
|
+
label: v.name,
|
|
1171
|
+
sublabel: v.code,
|
|
1172
|
+
value: v
|
|
1173
|
+
})), a = s.filter((v) => {
|
|
1174
|
+
var k;
|
|
1175
|
+
return (k = l.items) == null ? void 0 : k.find((u) => u.sku._id === v.value._id);
|
|
1176
|
+
}).map((v) => v.value);
|
|
1177
|
+
p.open({
|
|
1178
|
+
title: t("inventory.closing.form.items.selectItem"),
|
|
1179
|
+
closeButton: !0,
|
|
1180
|
+
contentComponent: rt,
|
|
1181
|
+
contentComponentProps: {
|
|
1182
|
+
modelValue: a,
|
|
1183
|
+
items: s,
|
|
1184
|
+
virtualScroll: !0
|
|
1185
|
+
},
|
|
1186
|
+
primaryActions: {
|
|
1187
|
+
text: t("common.confirm"),
|
|
1188
|
+
close: !0
|
|
1189
|
+
},
|
|
1190
|
+
secondaryActions: {
|
|
1191
|
+
text: t("common.close"),
|
|
1192
|
+
close: !0,
|
|
1193
|
+
variant: "tertiary"
|
|
1194
|
+
}
|
|
1195
|
+
}).onPrimary((v) => {
|
|
1196
|
+
const k = l.items ?? [], u = v.map((C) => {
|
|
1197
|
+
const y = k.find((D) => D.sku._id === C._id);
|
|
1198
|
+
return y || {
|
|
1199
|
+
sku: C
|
|
1200
|
+
};
|
|
1201
|
+
});
|
|
1202
|
+
u.sort((C, y) => C.sku.code.localeCompare(y.sku.code)), l.items = u;
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
return (s, a) => {
|
|
1206
|
+
const v = F("FmTextField"), k = F("FmButton"), u = F("FmTable"), C = F("FmFormGroup"), y = F("FmForm");
|
|
1207
|
+
return w(), U(y, {
|
|
1208
|
+
ref_key: "formRef",
|
|
1209
|
+
ref: m,
|
|
1210
|
+
class: "flex flex-col gap-32",
|
|
1211
|
+
disabled: s.disabled
|
|
1212
|
+
}, {
|
|
1213
|
+
default: A(() => [
|
|
1214
|
+
h("div", Gt, [
|
|
1215
|
+
h("div", Jt, [
|
|
1216
|
+
T(v, {
|
|
1217
|
+
label: _(t)("inventory.closing.form.name"),
|
|
1218
|
+
"label-mark": "required",
|
|
1219
|
+
modelValue: _(l).name,
|
|
1220
|
+
"onUpdate:modelValue": a[0] || (a[0] = (x) => _(l).name = x),
|
|
1221
|
+
rules: [_(lt)()]
|
|
1222
|
+
}, null, 8, ["label", "modelValue", "rules"]),
|
|
1223
|
+
T(v, {
|
|
1224
|
+
label: _(t)("inventory.closing.form.reference"),
|
|
1225
|
+
"label-mark": "optional",
|
|
1226
|
+
modelValue: _(l).ref,
|
|
1227
|
+
"onUpdate:modelValue": a[1] || (a[1] = (x) => _(l).ref = x)
|
|
1228
|
+
}, null, 8, ["label", "modelValue"])
|
|
1229
|
+
])
|
|
1230
|
+
]),
|
|
1231
|
+
h("div", Wt, [
|
|
1232
|
+
h("div", qt, [
|
|
1233
|
+
a[3] || (a[3] = h("div", { class: "flex-1 fm-typo-en-title-sm-600" }, "Locations", -1)),
|
|
1234
|
+
T(k, {
|
|
1235
|
+
disabled: s.disabled,
|
|
1236
|
+
label: "Select location",
|
|
1237
|
+
"prepend-icon": "add",
|
|
1238
|
+
variant: "plain",
|
|
1239
|
+
class: "border-2 rounded-lg border-fm-color-primary",
|
|
1240
|
+
onClick: _(i)
|
|
1241
|
+
}, null, 8, ["disabled", "onClick"])
|
|
1242
|
+
]),
|
|
1243
|
+
T(u, {
|
|
1244
|
+
"column-defs": _(r),
|
|
1245
|
+
"row-data": _(d),
|
|
1246
|
+
"shrink-at": 9999,
|
|
1247
|
+
onRowClick: _(i),
|
|
1248
|
+
"hide-footer": ""
|
|
1249
|
+
}, null, 8, ["column-defs", "row-data", "onRowClick"])
|
|
1250
|
+
]),
|
|
1251
|
+
h("div", Xt, [
|
|
1252
|
+
h("div", Qt, [
|
|
1253
|
+
h("div", Zt, R(_(t)("inventory.closing.form.items.title")), 1),
|
|
1254
|
+
T(k, {
|
|
1255
|
+
disabled: s.disabled,
|
|
1256
|
+
label: _(t)("inventory.closing.form.items.addItem"),
|
|
1257
|
+
"prepend-icon": "add",
|
|
1258
|
+
variant: "plain",
|
|
1259
|
+
class: "border-2 rounded-lg border-fm-color-primary",
|
|
1260
|
+
onClick: a[2] || (a[2] = (x) => f()),
|
|
1261
|
+
size: "md"
|
|
1262
|
+
}, null, 8, ["disabled", "label"])
|
|
1263
|
+
]),
|
|
1264
|
+
(w(), U(u, {
|
|
1265
|
+
"column-defs": g.value,
|
|
1266
|
+
"row-data": _(l).items,
|
|
1267
|
+
key: _(l).items.map((x) => x.sku._id).join("."),
|
|
1268
|
+
"hide-footer": "",
|
|
1269
|
+
"page-size": _(l).items.length
|
|
1270
|
+
}, {
|
|
1271
|
+
"list-row": A((x) => [
|
|
1272
|
+
(w(), U(Le, {
|
|
1273
|
+
row: x,
|
|
1274
|
+
key: _(l).items.map((D) => D.sku._id).join(".")
|
|
1275
|
+
}, {
|
|
1276
|
+
default: A((D) => [
|
|
1277
|
+
T(Kt, {
|
|
1278
|
+
row: x,
|
|
1279
|
+
"cell-by-col-id": D
|
|
1280
|
+
}, null, 8, ["row", "cell-by-col-id"])
|
|
1281
|
+
]),
|
|
1282
|
+
_: 2
|
|
1283
|
+
}, 1032, ["row"]))
|
|
1284
|
+
]),
|
|
1285
|
+
_: 1
|
|
1286
|
+
}, 8, ["column-defs", "row-data", "page-size"])),
|
|
1287
|
+
T(C, {
|
|
1288
|
+
"model-value": _(l).items.length,
|
|
1289
|
+
rules: [_(at)(1)]
|
|
1290
|
+
}, null, 8, ["model-value", "rules"])
|
|
1291
|
+
])
|
|
1292
|
+
]),
|
|
1293
|
+
_: 1
|
|
1294
|
+
}, 8, ["disabled"]);
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
}), tn = { class: "flex items-center" }, nn = { class: "fm-typo-en-title-md-800" }, on = { class: "flex gap-4" }, sn = /* @__PURE__ */ H({
|
|
1298
|
+
__name: "ClosingTemplateDialog",
|
|
1299
|
+
props: {
|
|
1300
|
+
mode: {},
|
|
1301
|
+
modelValue: {},
|
|
1302
|
+
show: { type: Boolean }
|
|
1303
|
+
},
|
|
1304
|
+
emits: ["update:show", "submitted"],
|
|
1305
|
+
setup(c, { expose: o, emit: n }) {
|
|
1306
|
+
var C;
|
|
1307
|
+
const l = c, t = n, e = te(), p = ee(), { t: i } = K(), r = et(l, "show");
|
|
1308
|
+
function d() {
|
|
1309
|
+
return {
|
|
1310
|
+
_id: "",
|
|
1311
|
+
name: "",
|
|
1312
|
+
items: []
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
const m = S(l.modelValue ?? d()), b = S(((C = l.modelValue) == null ? void 0 : C._id) ?? `${Math.random()}`);
|
|
1316
|
+
Ae(
|
|
1317
|
+
() => l.show,
|
|
1318
|
+
(y) => {
|
|
1319
|
+
var x;
|
|
1320
|
+
y && (m.value = l.modelValue ?? d(), b.value = ((x = l.modelValue) == null ? void 0 : x._id) ?? `${Math.random()}`);
|
|
1321
|
+
}
|
|
1322
|
+
);
|
|
1323
|
+
const g = S(!1), f = I(() => {
|
|
1324
|
+
switch (l.mode) {
|
|
1325
|
+
case L.READ:
|
|
1326
|
+
return "";
|
|
1327
|
+
case L.CREATE:
|
|
1328
|
+
return i("inventory.closing.template.create.title");
|
|
1329
|
+
case L.UPDATE:
|
|
1330
|
+
return i("inventory.closing.template.update.title");
|
|
1331
|
+
}
|
|
1332
|
+
return "";
|
|
1333
|
+
}), s = S();
|
|
1334
|
+
o({
|
|
1335
|
+
validateInputs: () => {
|
|
1336
|
+
var y, x;
|
|
1337
|
+
(x = (y = s.value) == null ? void 0 : y.validateInputs) == null || x.call(y);
|
|
1338
|
+
},
|
|
1339
|
+
resetInputsValidation: () => {
|
|
1340
|
+
var y, x;
|
|
1341
|
+
(x = (y = s.value) == null ? void 0 : y.resetInputsValidation) == null || x.call(y);
|
|
1342
|
+
},
|
|
1343
|
+
resetInputs: () => {
|
|
1344
|
+
var y, x;
|
|
1345
|
+
(x = (y = s.value) == null ? void 0 : y.resetInputs) == null || x.call(y);
|
|
1346
|
+
}
|
|
1347
|
+
});
|
|
1348
|
+
async function a() {
|
|
1349
|
+
const y = m.value;
|
|
1350
|
+
if (y) {
|
|
1351
|
+
g.value = !0;
|
|
1352
|
+
try {
|
|
1353
|
+
await e.createTemplate(y), await new Promise((x) => setTimeout(x, 1e3)), p.open({
|
|
1354
|
+
title: i("inventory.closing.template.create.success"),
|
|
1355
|
+
message: i("inventory.closing.template.create.successMessage"),
|
|
1356
|
+
type: "success"
|
|
1357
|
+
}), t("update:show", !1), t("submitted");
|
|
1358
|
+
} catch (x) {
|
|
1359
|
+
p.open({
|
|
1360
|
+
title: i("inventory.closing.template.create.error"),
|
|
1361
|
+
message: i("inventory.closing.template.create.errorMessage"),
|
|
1362
|
+
type: "error"
|
|
1363
|
+
}), console.error("Error in creating closing template", x);
|
|
1364
|
+
} finally {
|
|
1365
|
+
g.value = !1;
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
async function v() {
|
|
1370
|
+
const y = m.value;
|
|
1371
|
+
if (y) {
|
|
1372
|
+
g.value = !0;
|
|
1373
|
+
try {
|
|
1374
|
+
await e.updateTemplate({
|
|
1375
|
+
...y,
|
|
1376
|
+
_rev: y._rev ?? ""
|
|
1377
|
+
}), await new Promise((x) => setTimeout(x, 1e3)), p.open({
|
|
1378
|
+
title: i("inventory.closing.template.update.success"),
|
|
1379
|
+
message: i("inventory.closing.template.update.successMessage"),
|
|
1380
|
+
type: "success"
|
|
1381
|
+
}), t("update:show", !1), t("submitted");
|
|
1382
|
+
} catch (x) {
|
|
1383
|
+
p.open({
|
|
1384
|
+
title: i("inventory.closing.template.update.error"),
|
|
1385
|
+
message: i("inventory.closing.template.update.errorMessage"),
|
|
1386
|
+
type: "error"
|
|
1387
|
+
}), console.error("Error in updating closing template", x);
|
|
1388
|
+
} finally {
|
|
1389
|
+
g.value = !1;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
function k() {
|
|
1394
|
+
switch (l.mode) {
|
|
1395
|
+
case L.CREATE:
|
|
1396
|
+
return a();
|
|
1397
|
+
case L.UPDATE:
|
|
1398
|
+
return v();
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
function u() {
|
|
1402
|
+
var y, x;
|
|
1403
|
+
(x = (y = s.value) == null ? void 0 : y.validateInputs) == null || x.call(y);
|
|
1404
|
+
}
|
|
1405
|
+
return (y, x) => {
|
|
1406
|
+
const D = F("FmButton"), V = F("FmSideSheet");
|
|
1407
|
+
return w(), U(V, {
|
|
1408
|
+
modelValue: _(r),
|
|
1409
|
+
"onUpdate:modelValue": x[2] || (x[2] = (Y) => je(r) ? r.value = Y : null),
|
|
1410
|
+
"dismiss-away": "",
|
|
1411
|
+
"close-button": "",
|
|
1412
|
+
"max-width": 800
|
|
1413
|
+
}, {
|
|
1414
|
+
"side-sheet-header": A(() => [
|
|
1415
|
+
h("div", tn, [
|
|
1416
|
+
h("div", nn, R(f.value), 1)
|
|
1417
|
+
])
|
|
1418
|
+
]),
|
|
1419
|
+
default: A(() => [
|
|
1420
|
+
(w(), U(en, {
|
|
1421
|
+
class: "w-full",
|
|
1422
|
+
ref_key: "formRef",
|
|
1423
|
+
ref: s,
|
|
1424
|
+
onValidationSuccess: k,
|
|
1425
|
+
"model-value": m.value,
|
|
1426
|
+
"onUpdate:modelValue": x[0] || (x[0] = (Y) => m.value = Y),
|
|
1427
|
+
disabled: g.value,
|
|
1428
|
+
key: b.value
|
|
1429
|
+
}, null, 8, ["model-value", "disabled"]))
|
|
1430
|
+
]),
|
|
1431
|
+
"side-sheet-footer": A(() => [
|
|
1432
|
+
h("div", on, [
|
|
1433
|
+
T(D, {
|
|
1434
|
+
loading: g.value,
|
|
1435
|
+
label: _(i)("common.save"),
|
|
1436
|
+
onClick: u
|
|
1437
|
+
}, null, 8, ["loading", "label"]),
|
|
1438
|
+
T(D, {
|
|
1439
|
+
disabled: g.value,
|
|
1440
|
+
variant: "tertiary",
|
|
1441
|
+
label: _(i)("common.close"),
|
|
1442
|
+
onClick: x[1] || (x[1] = (Y) => t("update:show", !1))
|
|
1443
|
+
}, null, 8, ["disabled", "label"])
|
|
1444
|
+
])
|
|
1445
|
+
]),
|
|
1446
|
+
_: 1
|
|
1447
|
+
}, 8, ["modelValue"]);
|
|
1448
|
+
};
|
|
1449
|
+
}
|
|
1450
|
+
}), ln = {};
|
|
1451
|
+
function an(c, o) {
|
|
1452
|
+
return w(), $("div");
|
|
1453
|
+
}
|
|
1454
|
+
const rn = /* @__PURE__ */ it(ln, [["render", an]]), cn = { class: "flex flex-col gap-40" }, mn = { key: 0 }, un = {
|
|
1455
|
+
key: 1,
|
|
1456
|
+
class: "flex gap-8 items-center"
|
|
1457
|
+
}, dn = {
|
|
1458
|
+
key: 2,
|
|
1459
|
+
class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary"
|
|
1460
|
+
}, pn = {
|
|
1461
|
+
key: 3,
|
|
1462
|
+
class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary flex flex-col gap-12"
|
|
1463
|
+
}, fn = { key: 4 }, gn = { class: "flex sm:flex-col xs:flex-col justify-end gap-8 w-full mb-16" }, vn = /* @__PURE__ */ H({
|
|
1464
|
+
__name: "ClosingTemplatePublish",
|
|
1465
|
+
emits: ["close"],
|
|
1466
|
+
setup(c, { emit: o }) {
|
|
1467
|
+
const n = S(!1), l = ee(), t = te(), e = ne(), p = o;
|
|
1468
|
+
async function i() {
|
|
1469
|
+
n.value = !0;
|
|
1470
|
+
try {
|
|
1471
|
+
await t.startNewPublish().delayed(1e3), l.open({
|
|
1472
|
+
title: "Success",
|
|
1473
|
+
message: "You may refresh after a while to review publish status",
|
|
1474
|
+
type: "success"
|
|
1475
|
+
}), m();
|
|
1476
|
+
} catch (b) {
|
|
1477
|
+
l.open({
|
|
1478
|
+
title: "Something went wrong",
|
|
1479
|
+
message: "Please try again",
|
|
1480
|
+
type: "error"
|
|
1481
|
+
}), console.error("error on creating publish task", b);
|
|
1482
|
+
} finally {
|
|
1483
|
+
n.value = !1;
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
const r = I(() => e.recentPublish.recentJob), d = I(
|
|
1487
|
+
() => e.templates.length && (!r.value || r.value.outlets.length === r.value.completed.length)
|
|
1488
|
+
);
|
|
1489
|
+
function m() {
|
|
1490
|
+
p("close");
|
|
1491
|
+
}
|
|
1492
|
+
return (b, g) => {
|
|
1493
|
+
const f = F("FmCircularProgress"), s = F("FmButton");
|
|
1494
|
+
return w(), $("div", cn, [
|
|
1495
|
+
_(e).templates.length ? n.value ? (w(), $("div", un, [
|
|
1496
|
+
h("div", null, [
|
|
1497
|
+
T(f, {
|
|
1498
|
+
size: "md",
|
|
1499
|
+
color: "neutral-gray-300"
|
|
1500
|
+
})
|
|
1501
|
+
]),
|
|
1502
|
+
g[0] || (g[0] = h("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-primary" }, [
|
|
1503
|
+
h("span", null, "Sending a task to publish templates to all outlets...")
|
|
1504
|
+
], -1))
|
|
1505
|
+
])) : r.value ? r.value.outlets.length === r.value.completed.length ? (w(), $("div", pn, [
|
|
1506
|
+
h("p", null, [
|
|
1507
|
+
oe(" Your recent publishing task at " + R(_(Fe)(new Date(r.value.createdAt))) + " has ", 1),
|
|
1508
|
+
g[1] || (g[1] = h("span", { class: "fm-typo-en-body-lg-600" }, "completed", -1)),
|
|
1509
|
+
oe(" at " + R(_(Fe)(new Date(r.value.updatedAt))) + ". ", 1)
|
|
1510
|
+
]),
|
|
1511
|
+
g[2] || (g[2] = h("p", null, "Do you want to publish to all outlets?", -1))
|
|
1512
|
+
])) : (w(), $("div", fn, " Your recent publishing task is still pending (" + R(r.value.completed.length) + " / " + R(r.value.outlets.length) + "). Please wait until all publishing task has completed. ", 1)) : (w(), $("div", dn, " You have no recent publish activity. Do you want to publish to all outlets? ")) : (w(), $("div", mn, "You have no template to publish.")),
|
|
1513
|
+
h("div", gn, [
|
|
1514
|
+
T(s, {
|
|
1515
|
+
disabled: !d.value,
|
|
1516
|
+
loading: n.value,
|
|
1517
|
+
label: "Publish to all outlets",
|
|
1518
|
+
onClick: i
|
|
1519
|
+
}, null, 8, ["disabled", "loading"]),
|
|
1520
|
+
T(s, {
|
|
1521
|
+
variant: "tertiary",
|
|
1522
|
+
label: "Close",
|
|
1523
|
+
onClick: m
|
|
1524
|
+
})
|
|
1525
|
+
])
|
|
1526
|
+
]);
|
|
1527
|
+
};
|
|
1528
|
+
}
|
|
1529
|
+
}), yn = { class: "flex-1 flex flex-col gap-8" }, hn = { class: "flex flex-col" }, bn = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _n = { class: "fm-typo-en-body-lg-600 text-fm-color-typo-primary" }, xn = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary line-clamp-2" }, wn = { class: "fm-typo-en-body-lg-400 line-clamp-2" }, Vn = /* @__PURE__ */ H({
|
|
1530
|
+
__name: "ClosingTemplateView",
|
|
1531
|
+
setup(c) {
|
|
1532
|
+
const { t: o } = K(), { createTemplate: n, updateTemplate: l, exportTemplates: t, importTemplates: e } = le(), { templateDialogProps: p, templateDetailsProps: i } = Pe(le()), r = ie(), d = re(), m = ne(), b = qe(), { breakpoints: g } = tt();
|
|
1533
|
+
r.watchLocation(m.fetchTemplates);
|
|
1534
|
+
const f = I(() => m.loading), s = S(""), a = I(() => g.value.xs || g.value.sm), v = I(() => a.value ? 10 : 20);
|
|
1535
|
+
function k(D) {
|
|
1536
|
+
switch (D) {
|
|
1537
|
+
case B.Add:
|
|
1538
|
+
return n();
|
|
1539
|
+
case "publish":
|
|
1540
|
+
return u();
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
function u() {
|
|
1544
|
+
d.open({
|
|
1545
|
+
title: "Publish closing templates",
|
|
1546
|
+
contentComponent: vn,
|
|
1547
|
+
contentComponentProps: {
|
|
1548
|
+
onClose() {
|
|
1549
|
+
d.close();
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
function C(D) {
|
|
1555
|
+
return D;
|
|
1556
|
+
}
|
|
1557
|
+
const y = I(() => {
|
|
1558
|
+
const D = [
|
|
1559
|
+
{
|
|
1560
|
+
label: o("inventory.closing.template.create.title"),
|
|
1561
|
+
value: B.Add,
|
|
1562
|
+
isPrimary: !0,
|
|
1563
|
+
prependIcon: "add"
|
|
1564
|
+
}
|
|
1565
|
+
];
|
|
1566
|
+
return a.value ? D : [
|
|
1567
|
+
...D,
|
|
1568
|
+
{
|
|
1569
|
+
label: "Publish",
|
|
1570
|
+
value: "publish",
|
|
1571
|
+
isPrimary: !1
|
|
1572
|
+
}
|
|
1573
|
+
];
|
|
1574
|
+
}), x = I(() => {
|
|
1575
|
+
const D = [
|
|
1576
|
+
{
|
|
1577
|
+
icon: "refresh",
|
|
1578
|
+
onClick: m.fetchTemplates
|
|
1579
|
+
},
|
|
1580
|
+
{
|
|
1581
|
+
icon: "upload_file",
|
|
1582
|
+
onClick: e
|
|
1583
|
+
},
|
|
1584
|
+
{
|
|
1585
|
+
icon: "ios_share",
|
|
1586
|
+
onClick: t
|
|
1587
|
+
}
|
|
1588
|
+
];
|
|
1589
|
+
return a.value ? [{ icon: "publish", onClick: u }, ...D] : D;
|
|
1590
|
+
});
|
|
1591
|
+
return (D, V) => {
|
|
1592
|
+
const Y = F("FmTable");
|
|
1593
|
+
return w(), $(z, null, [
|
|
1594
|
+
T(Xe, {
|
|
1595
|
+
title: _(o)("inventory.closing.template.title"),
|
|
1596
|
+
actions: y.value,
|
|
1597
|
+
"onClick:action": k
|
|
1598
|
+
}, {
|
|
1599
|
+
default: A(() => [
|
|
1600
|
+
h("div", {
|
|
1601
|
+
class: O([
|
|
1602
|
+
"flex flex-col gap-8 max-h-full",
|
|
1603
|
+
{
|
|
1604
|
+
"p-0": a.value,
|
|
1605
|
+
"px-24 ": !a.value
|
|
1606
|
+
}
|
|
1607
|
+
])
|
|
1608
|
+
}, [
|
|
1609
|
+
T(Qe, {
|
|
1610
|
+
searchable: "",
|
|
1611
|
+
search: s.value,
|
|
1612
|
+
"onUpdate:search": V[0] || (V[0] = (E) => s.value = E),
|
|
1613
|
+
actions: x.value
|
|
1614
|
+
}, null, 8, ["search", "actions"]),
|
|
1615
|
+
T(Y, {
|
|
1616
|
+
style: Oe(_(b).tableHeight),
|
|
1617
|
+
"column-defs": _(m).columnDefs,
|
|
1618
|
+
"row-data": _(m).templates,
|
|
1619
|
+
"search-value": s.value,
|
|
1620
|
+
loading: f.value,
|
|
1621
|
+
onRowClick: V[1] || (V[1] = (E) => _(l)(E.original)),
|
|
1622
|
+
"page-size": v.value
|
|
1623
|
+
}, {
|
|
1624
|
+
"list-row": A((E) => [
|
|
1625
|
+
T(Le, {
|
|
1626
|
+
row: E,
|
|
1627
|
+
onRowClick: (P) => _(l)(P)
|
|
1628
|
+
}, {
|
|
1629
|
+
default: A((P) => {
|
|
1630
|
+
var ue, de, pe, q, fe, ge, ve, ye, X, he, be, _e, xe, we, ke, Q, Te, $e, Ce, De, Z, Se;
|
|
1631
|
+
return [
|
|
1632
|
+
h("div", yn, [
|
|
1633
|
+
h("div", hn, [
|
|
1634
|
+
h("div", bn, [
|
|
1635
|
+
T(_(j), {
|
|
1636
|
+
render: (pe = (de = (ue = P._id) == null ? void 0 : ue.column) == null ? void 0 : de.columnDef) == null ? void 0 : pe.cell,
|
|
1637
|
+
props: (fe = (q = P._id) == null ? void 0 : q.getContext) == null ? void 0 : fe.call(q)
|
|
1638
|
+
}, null, 8, ["render", "props"])
|
|
1639
|
+
]),
|
|
1640
|
+
h("div", _n, [
|
|
1641
|
+
T(_(j), {
|
|
1642
|
+
render: (ye = (ve = (ge = P.name) == null ? void 0 : ge.column) == null ? void 0 : ve.columnDef) == null ? void 0 : ye.cell,
|
|
1643
|
+
props: (he = (X = P.name) == null ? void 0 : X.getContext) == null ? void 0 : he.call(X)
|
|
1644
|
+
}, null, 8, ["render", "props"])
|
|
1645
|
+
]),
|
|
1646
|
+
h("div", null, R((be = E.original.locations) != null && be.length ? `Enabled for ${(_e = E.original.locations) == null ? void 0 : _e.length} outlets` : "Enabled for all outlets"), 1),
|
|
1647
|
+
h("div", xn, R([
|
|
1648
|
+
...E.original.items.slice(0, 3).map((He) => He.sku.name),
|
|
1649
|
+
...E.original.items.length >= 3 ? [`and ${E.original.items.length - 3} more items`] : []
|
|
1650
|
+
].join(", ")), 1),
|
|
1651
|
+
h("div", wn, [
|
|
1652
|
+
T(_(j), {
|
|
1653
|
+
render: (ke = (we = (xe = P.ref) == null ? void 0 : xe.column) == null ? void 0 : we.columnDef) == null ? void 0 : ke.cell,
|
|
1654
|
+
props: (Te = (Q = P.ref) == null ? void 0 : Q.getContext) == null ? void 0 : Te.call(Q)
|
|
1655
|
+
}, null, 8, ["render", "props"])
|
|
1656
|
+
])
|
|
1657
|
+
]),
|
|
1658
|
+
h("div", null, [
|
|
1659
|
+
T(_(j), {
|
|
1660
|
+
render: (De = (Ce = ($e = P.status) == null ? void 0 : $e.column) == null ? void 0 : Ce.columnDef) == null ? void 0 : De.cell,
|
|
1661
|
+
props: (Se = (Z = P.status) == null ? void 0 : Z.getContext) == null ? void 0 : Se.call(Z)
|
|
1662
|
+
}, null, 8, ["render", "props"])
|
|
1663
|
+
])
|
|
1664
|
+
])
|
|
1665
|
+
];
|
|
1666
|
+
}),
|
|
1667
|
+
_: 2
|
|
1668
|
+
}, 1032, ["row", "onRowClick"])
|
|
1669
|
+
]),
|
|
1670
|
+
_: 1
|
|
1671
|
+
}, 8, ["style", "column-defs", "row-data", "search-value", "loading", "page-size"])
|
|
1672
|
+
], 2)
|
|
1673
|
+
]),
|
|
1674
|
+
_: 1
|
|
1675
|
+
}, 8, ["title", "actions"]),
|
|
1676
|
+
(w(), U(Ke, { to: "body" }, [
|
|
1677
|
+
T(rn, Ge(Je(_(i))), null, 16),
|
|
1678
|
+
T(sn, We(_(p), {
|
|
1679
|
+
onSubmitted: V[2] || (V[2] = (E) => _(m).fetchTemplates())
|
|
1680
|
+
}), null, 16)
|
|
1681
|
+
]))
|
|
1682
|
+
], 64);
|
|
1683
|
+
};
|
|
1684
|
+
}
|
|
1685
|
+
});
|
|
1686
|
+
export {
|
|
1687
|
+
Vn as default
|
|
1688
|
+
};
|