@nivaro/react 0.3.57 → 0.3.58
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/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/shared/components/CollectionBrowserView.js +2633 -2590
- package/dist/shared/components/DataTable.js +247 -236
- package/dist/shared/components/ItemEditForm.js +1693 -1668
- package/dist/shared/components/ProfileView.js +716 -715
- package/dist/shared/components/RecordReadView.js +367 -364
- package/dist/shared/components/ReportView.js +64 -39
- package/dist/shared/components/alerts/AlertManagerView.js +284 -271
- package/dist/shared/components/cbv/row-focus.js +19 -0
- package/dist/shared/components/help-videos/HelpVideoPlayer.js +152 -147
- package/dist/shared/components/integrations/console/SignalCard.js +59 -59
- package/dist/shared/components/integrations/console/tone.js +52 -30
- package/dist/shared/components/item-edit/CatalogPickerField.js +525 -505
- package/dist/shared/components/item-edit/FieldRow.js +175 -173
- package/dist/shared/components/item-edit/InlineTableField.js +407 -402
- package/dist/shared/components/item-edit/M2MCombobox.js +313 -291
- package/dist/shared/components/item-edit/MidairCollisionDialog.js +1 -1
- package/dist/shared/components/item-edit/PlanGrid.js +826 -803
- package/dist/shared/components/item-edit/QuickCreateButton.js +115 -79
- package/dist/shared/components/item-edit/RecordLiveSync.js +77 -75
- package/dist/shared/components/item-edit/RelationCombobox.js +412 -328
- package/dist/shared/components/item-edit/RelationGroupedCombobox.js +147 -125
- package/dist/shared/components/item-edit/SummaryPanel.js +406 -392
- package/dist/shared/components/item-edit/option-disambiguate.js +44 -32
- package/dist/shared/components/item-edit/related-missing.js +45 -0
- package/dist/shared/components/item-edit/save-outcome.js +5 -5
- package/dist/shared/components/notifications/NotificationRulesEditor.js +130 -123
- package/dist/shared/components/panels/AccessDeniedPanel.js +52 -48
- package/dist/shared/components/panels/ItemLockBanner.js +2 -3
- package/dist/shared/components/panels/PipelinePanel.js +1027 -978
- package/dist/shared/components/panels/RevisionsPanel.js +4 -1
- package/dist/shared/components/panels/TaskPanel.js +265 -249
- package/dist/shared/components/panels/landing-state.js +27 -0
- package/dist/shared/components/pipeline/PipelineEditorView.js +86 -78
- package/dist/shared/components/profile/AiMemoryCard.js +12 -10
- package/dist/shared/components/queue/OwnerAvatars.js +80 -41
- package/dist/shared/components/queue/QueueQuickFilters.js +48 -48
- package/dist/shared/components/queue/QueueWorklist.js +357 -358
- package/dist/shared/components/queue/group-sums.js +27 -0
- package/dist/shared/components/widgets/ReviewListWidget.js +186 -168
- package/dist/shared/lib/back-closes.js +25 -0
- package/dist/shared/lib/form-usage-beacon.js +7 -7
- package/dist/shared/lib/list-page-memory.js +41 -0
- package/dist/shared/lib/live.js +44 -44
- package/dist/shared/lib/own-writes.js +76 -28
- package/dist/shared/lib/request-gate.js +110 -109
- package/dist/shared/lib/validation-rules.js +34 -19
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import { useState as H, useRef as Ee, useMemo as F, useEffect as Te, Fragment as
|
|
|
5
5
|
import { createPortal as Vn } from "react-dom";
|
|
6
6
|
import { useNivaroClient as Lt, useParentDraft as Wn, useReimportHandler as Dn, useItemEditAuth as Ur } from "../../context.js";
|
|
7
7
|
import { canOpenCatalogItem as en, openCatalogItem as tn } from "../../lib/catalog-item-open.js";
|
|
8
|
-
import { get as
|
|
8
|
+
import { get as R, del as Mn, patch as Hr, post as Yr } from "../../lib/commands.js";
|
|
9
9
|
import { evaluateBoolean as Un } from "../../lib/expression.js";
|
|
10
10
|
import { useLiveRefetchInterval as Hn } from "../../lib/live-queries.js";
|
|
11
11
|
import { tokenize as Yn, matchesSearch as Zn } from "../../lib/search-text.js";
|
|
@@ -17,71 +17,71 @@ import { useOverflowTip as rs } from "../TipLayer.js";
|
|
|
17
17
|
import { useColumnWidths as Zr, ResetColumnsButton as ir, ColResizeHandle as ns, fitWidth as ss } from "./catalog-columns.js";
|
|
18
18
|
import { orderCatalogMatches as as, rowMatchesFields as is } from "./catalog-search.js";
|
|
19
19
|
import { applyDisplayTemplate as ze } from "./helpers.js";
|
|
20
|
-
import { evalClientFormula as
|
|
20
|
+
import { evalClientFormula as Le } from "./InlineTableField.js";
|
|
21
21
|
import { isIntegerFieldType as Ot, checkNumberEntry as cr, mergePendingQtyRow as ls, decimalPlacesProblem as os, lineRuleErrors as ds, MAX_LINE_MONEY as cs } from "./line-qty.js";
|
|
22
22
|
import { resolveM2MRelatedCollection as us } from "./M2MCombobox.js";
|
|
23
23
|
import { useO2MStaging as ms } from "./O2MStagingContext.js";
|
|
24
24
|
import { RelationCombobox as fs, RelatedItemLabel as hs } from "./RelationCombobox.js";
|
|
25
|
-
const rn = (d,
|
|
26
|
-
let
|
|
27
|
-
for (const
|
|
28
|
-
if (
|
|
29
|
-
|
|
25
|
+
const rn = (d, h) => {
|
|
26
|
+
let y = d;
|
|
27
|
+
for (const N of h.split(".")) {
|
|
28
|
+
if (y == null || typeof y != "object") return;
|
|
29
|
+
y = y[N];
|
|
30
30
|
}
|
|
31
|
-
return
|
|
31
|
+
return y;
|
|
32
32
|
};
|
|
33
|
-
async function Et(d,
|
|
34
|
-
const
|
|
33
|
+
async function Et(d, h, y) {
|
|
34
|
+
const N = [];
|
|
35
35
|
for (let a = 1; a <= 50; a++) {
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
36
|
+
const b = await d.request(R(h, { ...y, limit: 1e3, page: a })).then((k) => k.data ?? []);
|
|
37
|
+
if (N.push(...b), b.length < 1e3) break;
|
|
38
38
|
}
|
|
39
|
-
return
|
|
39
|
+
return N;
|
|
40
40
|
}
|
|
41
|
-
function Me(d,
|
|
42
|
-
const
|
|
43
|
-
let
|
|
44
|
-
const a = (
|
|
45
|
-
if (typeof
|
|
46
|
-
const k =
|
|
47
|
-
return k == null || k === "" ? (
|
|
41
|
+
function Me(d, h) {
|
|
42
|
+
const y = {};
|
|
43
|
+
let N = !1;
|
|
44
|
+
const a = (b) => {
|
|
45
|
+
if (typeof b == "string" && b.startsWith("$parent.")) {
|
|
46
|
+
const k = h == null ? void 0 : h[b.slice(8)];
|
|
47
|
+
return k == null || k === "" ? (N = !0, b) : k;
|
|
48
48
|
}
|
|
49
|
-
return Array.isArray(
|
|
49
|
+
return Array.isArray(b) ? b.map(a) : b && typeof b == "object" ? Object.fromEntries(Object.entries(b).map(([k, j]) => [k, a(j)])) : b;
|
|
50
50
|
};
|
|
51
|
-
for (const [
|
|
51
|
+
for (const [b, k] of Object.entries(d ?? {}))
|
|
52
52
|
if (typeof k == "string" && k.startsWith("$parent.")) {
|
|
53
|
-
const j =
|
|
53
|
+
const j = h == null ? void 0 : h[k.slice(8)];
|
|
54
54
|
if (j == null || j === "") {
|
|
55
|
-
|
|
55
|
+
N = !0;
|
|
56
56
|
continue;
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
} else k && typeof k == "object" ?
|
|
60
|
-
return
|
|
58
|
+
y[b] = { _eq: j };
|
|
59
|
+
} else k && typeof k == "object" ? y[b] = a(k) : y[b] = { _eq: k };
|
|
60
|
+
return N ? null : y;
|
|
61
61
|
}
|
|
62
|
-
function Gr(d,
|
|
62
|
+
function Gr(d, h) {
|
|
63
63
|
if (!d) return !0;
|
|
64
|
-
for (const [
|
|
65
|
-
const a =
|
|
66
|
-
for (const [j,
|
|
64
|
+
for (const [y, N] of Object.entries(d)) {
|
|
65
|
+
const a = h == null ? void 0 : h[y], b = a == null ? null : String(a), k = N && typeof N == "object" ? N : { _eq: N };
|
|
66
|
+
for (const [j, w] of Object.entries(k))
|
|
67
67
|
switch (j) {
|
|
68
68
|
case "_eq":
|
|
69
|
-
if (
|
|
69
|
+
if (b !== String(w)) return !1;
|
|
70
70
|
break;
|
|
71
71
|
case "_neq":
|
|
72
|
-
if (
|
|
72
|
+
if (b === String(w)) return !1;
|
|
73
73
|
break;
|
|
74
74
|
case "_in":
|
|
75
|
-
if (!Array.isArray(
|
|
75
|
+
if (!Array.isArray(w) || !w.map(String).includes(b ?? "")) return !1;
|
|
76
76
|
break;
|
|
77
77
|
case "_nin":
|
|
78
|
-
if (Array.isArray(
|
|
78
|
+
if (Array.isArray(w) && w.map(String).includes(b ?? "")) return !1;
|
|
79
79
|
break;
|
|
80
80
|
case "_null":
|
|
81
|
-
if (
|
|
81
|
+
if (b !== null) return !1;
|
|
82
82
|
break;
|
|
83
83
|
case "_nnull":
|
|
84
|
-
if (
|
|
84
|
+
if (b === null) return !1;
|
|
85
85
|
break;
|
|
86
86
|
default:
|
|
87
87
|
return !1;
|
|
@@ -90,81 +90,92 @@ function Gr(d, p) {
|
|
|
90
90
|
return !0;
|
|
91
91
|
}
|
|
92
92
|
const bs = 2e3;
|
|
93
|
-
function ps(d,
|
|
94
|
-
const
|
|
95
|
-
if (Ot(
|
|
93
|
+
function ps(d, h) {
|
|
94
|
+
const y = Number(d);
|
|
95
|
+
if (Ot(h) && d.trim() !== "" && !Number.isNaN(y) && !Number.isInteger(y))
|
|
96
96
|
return "Whole numbers only";
|
|
97
|
-
const
|
|
98
|
-
return
|
|
97
|
+
const N = cr(d, { type: h, min: 0, label: "Quantity" });
|
|
98
|
+
return N.ok ? null : N.message;
|
|
99
99
|
}
|
|
100
|
-
function xs(d) {
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
function xs(d, h, y) {
|
|
101
|
+
const N = d.reduce((a, b) => {
|
|
102
|
+
const k = b[h], j = k != null && k !== "" ? k : y != null && y[h] ? Le(y[h], b) : null, w = Number(j);
|
|
103
|
+
return a + (j != null && Number.isFinite(w) ? w : 0);
|
|
104
|
+
}, 0);
|
|
105
|
+
return Math.round(N * 1e6) / 1e6;
|
|
106
|
+
}
|
|
107
|
+
function ys(d, h) {
|
|
108
|
+
const y = h.trim();
|
|
109
|
+
return y ? `${d} — ${y} not used` : d;
|
|
110
|
+
}
|
|
111
|
+
function gs(d) {
|
|
112
|
+
const h = { ...d.probe };
|
|
113
|
+
for (const [y, N] of Object.entries(d.compute)) {
|
|
114
|
+
const a = Le(N, h);
|
|
104
115
|
if (a === null) continue;
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
116
|
+
h[y] = a;
|
|
117
|
+
const b = d.ruleError(y, a, h);
|
|
118
|
+
if (b) return b;
|
|
108
119
|
if (Math.abs(a) > cs)
|
|
109
|
-
return `${d.labelOf(
|
|
120
|
+
return `${d.labelOf(y)} would be ${a.toLocaleString(void 0, { maximumFractionDigits: 2 })} — too large to save`;
|
|
110
121
|
}
|
|
111
122
|
return null;
|
|
112
123
|
}
|
|
113
|
-
function
|
|
114
|
-
const
|
|
115
|
-
for (const
|
|
116
|
-
for (const
|
|
117
|
-
if (
|
|
118
|
-
const a = d.lookup(
|
|
124
|
+
function ks(d) {
|
|
125
|
+
const h = Object.entries(d.copyFields ?? {}).filter(([, y]) => y === d.field).map(([y]) => y);
|
|
126
|
+
for (const y of h)
|
|
127
|
+
for (const N of d.related ?? []) {
|
|
128
|
+
if (N.copy_to !== y) continue;
|
|
129
|
+
const a = d.lookup(N.key);
|
|
119
130
|
if (a != null && a !== "") return a;
|
|
120
131
|
}
|
|
121
132
|
return d.catalogValue;
|
|
122
133
|
}
|
|
123
|
-
function
|
|
124
|
-
return d.map((
|
|
134
|
+
function ws(d, h) {
|
|
135
|
+
return d.map((y) => [y.id, ...h.map((N) => y[N])].map((N) => String(N ?? "")).join("")).join("");
|
|
125
136
|
}
|
|
126
|
-
function
|
|
127
|
-
const
|
|
128
|
-
if (
|
|
129
|
-
const
|
|
130
|
-
for (const
|
|
131
|
-
return
|
|
137
|
+
function Ns(d) {
|
|
138
|
+
const h = Object.keys(d).filter((N) => d[N].kind === "error");
|
|
139
|
+
if (h.length === 0) return d;
|
|
140
|
+
const y = { ...d };
|
|
141
|
+
for (const N of h) delete y[N];
|
|
142
|
+
return y;
|
|
132
143
|
}
|
|
133
|
-
function
|
|
134
|
-
const
|
|
135
|
-
if (!Number.isFinite(
|
|
136
|
-
const a =
|
|
144
|
+
function vs(d, h, y) {
|
|
145
|
+
const N = Number(d[h]);
|
|
146
|
+
if (!Number.isFinite(N) || N <= 0) return !1;
|
|
147
|
+
const a = y.find((k) => k in d);
|
|
137
148
|
if (!a) return !1;
|
|
138
|
-
const
|
|
139
|
-
return
|
|
149
|
+
const b = d[a];
|
|
150
|
+
return b == null || b === "" || Number(b) === 0;
|
|
140
151
|
}
|
|
141
|
-
function
|
|
152
|
+
function Gs({
|
|
142
153
|
relatedCollection: d,
|
|
143
|
-
manyField:
|
|
144
|
-
parentId:
|
|
145
|
-
parentCollection:
|
|
154
|
+
manyField: h,
|
|
155
|
+
parentId: y,
|
|
156
|
+
parentCollection: N,
|
|
146
157
|
config: a,
|
|
147
|
-
readOnly:
|
|
158
|
+
readOnly: b = !1
|
|
148
159
|
}) {
|
|
149
160
|
var Cr, Jr, Ir, zr, Qr, Br, Vr, Wr;
|
|
150
|
-
const k = Lt(), j = In(),
|
|
161
|
+
const k = Lt(), j = In(), w = ms(), P = Wn(), ee = Dn(), Y = a.editable_fields ?? [], _e = a.catalog_locked_fields ?? [], { isAdmin: Z } = Ur(), z = y === "new", ne = N && !z ? `?parent_collection=${encodeURIComponent(N)}&parent_id=${encodeURIComponent(y)}` : "", G = a.qty_field ?? "quantity", [se, xe] = H(/* @__PURE__ */ new Set()), Oe = Ee(!1), [U, Ae] = H(""), [ye, ue] = H({}), [ie, ae] = H(/* @__PURE__ */ new Set()), [Q, X] = H({}), [Se, me] = H({}), { data: Ke = [], isPending: q } = K({
|
|
151
162
|
queryKey: ["collection-relations", d],
|
|
152
|
-
queryFn: () => k.request(
|
|
163
|
+
queryFn: () => k.request(R(`/collections/${d}`)).then((e) => {
|
|
153
164
|
var t;
|
|
154
165
|
return ((t = e.data) == null ? void 0 : t.relations) ?? [];
|
|
155
166
|
}),
|
|
156
167
|
staleTime: 10 * 6e4
|
|
157
|
-
}),
|
|
168
|
+
}), g = F(
|
|
158
169
|
() => {
|
|
159
170
|
var e;
|
|
160
|
-
return ((e =
|
|
171
|
+
return ((e = Ke.find(
|
|
161
172
|
(t) => t.many_collection === d && t.many_field === a.item_field && !t.junction_field
|
|
162
173
|
)) == null ? void 0 : e.one_collection) ?? null;
|
|
163
174
|
},
|
|
164
|
-
[
|
|
175
|
+
[Ke, d, a.item_field]
|
|
165
176
|
), { data: L = [] } = K({
|
|
166
177
|
queryKey: ["field-config", d, null],
|
|
167
|
-
queryFn: () => k.request(
|
|
178
|
+
queryFn: () => k.request(R(`/field-config/${d}`)).then((e) => e.data ?? []),
|
|
168
179
|
staleTime: 6e4
|
|
169
180
|
}), le = ((Cr = L.find((e) => e.field === G)) == null ? void 0 : Cr.type) ?? null, B = (e, t, r) => {
|
|
170
181
|
var n;
|
|
@@ -179,18 +190,18 @@ function Ys({
|
|
|
179
190
|
{ ...r, [e]: t }
|
|
180
191
|
)[0]) == null ? void 0 : n.message) ?? null;
|
|
181
192
|
}, { data: $ } = K({
|
|
182
|
-
queryKey: ["col-meta",
|
|
183
|
-
queryFn: () => k.request(
|
|
184
|
-
enabled: !!
|
|
193
|
+
queryKey: ["col-meta", g],
|
|
194
|
+
queryFn: () => k.request(R(`/collections/${g}`)).then((e) => e.data),
|
|
195
|
+
enabled: !!g,
|
|
185
196
|
staleTime: 3e5
|
|
186
197
|
}), J = $ == null ? void 0 : $.display_template, E = F(() => {
|
|
187
198
|
const e = a.section_by.split(".")[0];
|
|
188
199
|
return (($ == null ? void 0 : $.relations) ?? []).find(
|
|
189
|
-
(t) => t.one_collection ===
|
|
200
|
+
(t) => t.one_collection === g && t.one_field === e && !!t.junction_field
|
|
190
201
|
) ?? null;
|
|
191
|
-
}, [$,
|
|
202
|
+
}, [$, g, a.section_by]), oe = (E == null ? void 0 : E.many_collection) ?? null, { data: lt = [] } = K({
|
|
192
203
|
queryKey: ["collection-relations", oe],
|
|
193
|
-
queryFn: () => k.request(
|
|
204
|
+
queryFn: () => k.request(R(`/collections/${oe}`)).then((e) => {
|
|
194
205
|
var t;
|
|
195
206
|
return ((t = e.data) == null ? void 0 : t.relations) ?? [];
|
|
196
207
|
}),
|
|
@@ -208,13 +219,13 @@ function Ys({
|
|
|
208
219
|
target: r,
|
|
209
220
|
labelPath: a.section_by.split(".").slice(1).join(".") || "id"
|
|
210
221
|
} : null;
|
|
211
|
-
}, [E, oe, lt, a.section_by]), i = P == null ? void 0 : P.draft, { resolvedFilter:
|
|
222
|
+
}, [E, oe, lt, a.section_by]), i = P == null ? void 0 : P.draft, { resolvedFilter: S, resolvedSectionFilter: I, resolvedLinkFilter: W, missingParents: D } = F(() => {
|
|
212
223
|
const e = [], t = (o) => {
|
|
213
224
|
if (typeof o == "string" && o.startsWith("$parent.")) {
|
|
214
|
-
const
|
|
215
|
-
return c == null || c === "" ? (e.push(
|
|
225
|
+
const p = o.slice(8), c = i == null ? void 0 : i[p];
|
|
226
|
+
return c == null || c === "" ? (e.push(p), o) : c;
|
|
216
227
|
}
|
|
217
|
-
return Array.isArray(o) ? o.map(t) : o && typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([
|
|
228
|
+
return Array.isArray(o) ? o.map(t) : o && typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([p, c]) => [p, t(c)])) : o;
|
|
218
229
|
}, r = a.filter ? t(a.filter) : void 0, n = a.section_filter ? t(a.section_filter) : void 0, l = a.link_filter ? t(a.link_filter) : void 0;
|
|
219
230
|
return {
|
|
220
231
|
resolvedFilter: r,
|
|
@@ -222,33 +233,33 @@ function Ys({
|
|
|
222
233
|
resolvedLinkFilter: l,
|
|
223
234
|
missingParents: [...new Set(e)]
|
|
224
235
|
};
|
|
225
|
-
}, [a.filter, a.section_filter, a.link_filter, i]),
|
|
226
|
-
if (!E || !I && !W) return
|
|
236
|
+
}, [a.filter, a.section_filter, a.link_filter, i]), fe = F(() => {
|
|
237
|
+
if (!E || !I && !W) return S;
|
|
227
238
|
const e = {
|
|
228
239
|
...I ?? {},
|
|
229
240
|
...W ? { _link: W } : {}
|
|
230
241
|
}, t = { [E.one_field]: { _some: e } };
|
|
231
|
-
return
|
|
232
|
-
}, [E, I, W,
|
|
242
|
+
return S ? { _and: [S, t] } : t;
|
|
243
|
+
}, [E, I, W, S]), T = F(() => {
|
|
233
244
|
const e = /* @__PURE__ */ new Set(["id"]);
|
|
234
245
|
$ && !E && e.add(a.section_by);
|
|
235
246
|
for (const t of [...(J ?? "").matchAll(/\{\{([\w.]+)\}\}/g)]) e.add(t[1]);
|
|
236
247
|
for (const t of Object.values(a.copy_fields ?? {})) e.add(t);
|
|
237
248
|
for (const t of a.columns ?? []) e.add(t.field);
|
|
238
249
|
return [...e].join(",");
|
|
239
|
-
}, [J, $, E, a.section_by, a.copy_fields, a.columns]), be = JSON.stringify(
|
|
250
|
+
}, [J, $, E, a.section_by, a.copy_fields, a.columns]), be = JSON.stringify(fe ?? null), { data: de = [], isLoading: qe } = K(
|
|
240
251
|
{
|
|
241
|
-
queryKey: ["catalog-picker",
|
|
252
|
+
queryKey: ["catalog-picker", g, T, be],
|
|
242
253
|
queryFn: () => k.request(
|
|
243
|
-
|
|
254
|
+
R(`/items/${g}`, {
|
|
244
255
|
limit: bs,
|
|
245
256
|
fields: T,
|
|
246
|
-
...
|
|
257
|
+
...fe ? { filter: JSON.stringify(fe) } : {}
|
|
247
258
|
})
|
|
248
259
|
).then((e) => e.data ?? []),
|
|
249
260
|
// Wait for the catalog meta: a to-many section path both narrows this
|
|
250
261
|
// read and must stay out of its `fields=`.
|
|
251
|
-
enabled: !!
|
|
262
|
+
enabled: !!g && !!$ && D.length === 0 && (!E || !!V),
|
|
252
263
|
staleTime: 6e4
|
|
253
264
|
}
|
|
254
265
|
), nn = JSON.stringify(I ?? null), { data: ot = [], isLoading: sn } = K({
|
|
@@ -302,17 +313,17 @@ function Ys({
|
|
|
302
313
|
for (const t of de) e.set(String(t.id), t);
|
|
303
314
|
return e;
|
|
304
315
|
}, [de]), { data: ge = [] } = K({
|
|
305
|
-
queryKey: ["o2m-rows", d,
|
|
316
|
+
queryKey: ["o2m-rows", d, h, y],
|
|
306
317
|
queryFn: () => k.request(
|
|
307
|
-
|
|
308
|
-
filter: JSON.stringify({ [
|
|
318
|
+
R(`/items/${d}`, {
|
|
319
|
+
filter: JSON.stringify({ [h]: { _eq: y } }),
|
|
309
320
|
limit: 1e3
|
|
310
321
|
})
|
|
311
322
|
).then((e) => e.data ?? []),
|
|
312
323
|
enabled: !z,
|
|
313
324
|
staleTime: 15e3
|
|
314
325
|
}), At = F(
|
|
315
|
-
() =>
|
|
326
|
+
() => ws(ge, [
|
|
316
327
|
a.item_field,
|
|
317
328
|
G,
|
|
318
329
|
...Y,
|
|
@@ -326,20 +337,20 @@ function Ys({
|
|
|
326
337
|
const t = Object.keys(Kt.current).filter(
|
|
327
338
|
(r) => Kt.current[r].kind === "error"
|
|
328
339
|
);
|
|
329
|
-
X((r) =>
|
|
340
|
+
X((r) => Ns(r)), me((r) => Object.keys(r).length === 0 ? r : {}), t.length > 0 && ue((r) => {
|
|
330
341
|
if (!t.some((l) => l in r)) return r;
|
|
331
342
|
const n = { ...r };
|
|
332
343
|
for (const l of t) delete n[l];
|
|
333
344
|
return n;
|
|
334
345
|
});
|
|
335
346
|
}, [At]);
|
|
336
|
-
const He = !z && !!
|
|
347
|
+
const He = !z && !!w, Re = w ? w.getPendingRows(d, h) : [], ut = He ? w.getPendingEdits(d, h) : /* @__PURE__ */ new Map(), ln = JSON.stringify([...ut.entries()]), mt = F(
|
|
337
348
|
() => ut.size === 0 ? ge : ge.map((e) => {
|
|
338
349
|
const t = ut.get(String(e.id));
|
|
339
350
|
return t ? { ...e, ...t } : e;
|
|
340
351
|
}),
|
|
341
352
|
[ge, ln]
|
|
342
|
-
), ft = !z &&
|
|
353
|
+
), ft = !z && w ? w.getPendingDeletes(d, h) : /* @__PURE__ */ new Set(), Ye = F(() => {
|
|
343
354
|
const e = /* @__PURE__ */ new Map();
|
|
344
355
|
for (const t of mt) {
|
|
345
356
|
const r = t[a.item_field];
|
|
@@ -361,39 +372,39 @@ function Ys({
|
|
|
361
372
|
() => pe.filter((e) => !ct.has(e.key)).map((e) => e.key),
|
|
362
373
|
[pe, ct]
|
|
363
374
|
), { data: hr = [] } = K({
|
|
364
|
-
queryKey: ["catalog-picker-labels",
|
|
375
|
+
queryKey: ["catalog-picker-labels", g, T, bt.join(",")],
|
|
365
376
|
queryFn: () => k.request(
|
|
366
|
-
|
|
377
|
+
R(`/items/${g}`, {
|
|
367
378
|
filter: JSON.stringify({ id: { _in: bt } }),
|
|
368
379
|
fields: T,
|
|
369
380
|
limit: bt.length
|
|
370
381
|
})
|
|
371
382
|
).then((e) => e.data ?? []),
|
|
372
|
-
enabled: !!
|
|
383
|
+
enabled: !!g && bt.length > 0,
|
|
373
384
|
staleTime: 6e4
|
|
374
385
|
}), { data: $e = [] } = K({
|
|
375
|
-
queryKey: ["pinned-items",
|
|
376
|
-
queryFn: () => k.request(
|
|
377
|
-
enabled: !!
|
|
386
|
+
queryKey: ["pinned-items", g],
|
|
387
|
+
queryFn: () => k.request(R(`/pinned/${g}`)).then((e) => e.data ?? []),
|
|
388
|
+
enabled: !!g && !!a.favorites,
|
|
378
389
|
staleTime: 6e4
|
|
379
390
|
}), Ct = F(() => new Set($e), [$e]), { data: Ze = [] } = K({
|
|
380
|
-
queryKey: ["pinned-item-rows",
|
|
391
|
+
queryKey: ["pinned-item-rows", g, T, $e.join(",")],
|
|
381
392
|
queryFn: () => k.request(
|
|
382
|
-
|
|
393
|
+
R(`/items/${g}`, {
|
|
383
394
|
filter: JSON.stringify({ id: { _in: $e } }),
|
|
384
395
|
fields: T,
|
|
385
396
|
limit: $e.length
|
|
386
397
|
})
|
|
387
398
|
).then((e) => e.data ?? []),
|
|
388
|
-
enabled: !!
|
|
399
|
+
enabled: !!g && !!a.favorites && $e.length > 0,
|
|
389
400
|
staleTime: 6e4
|
|
390
401
|
}), [pt, br] = H(/* @__PURE__ */ new Set());
|
|
391
402
|
async function pr(e) {
|
|
392
|
-
if (!(!
|
|
403
|
+
if (!(!g || pt.has(e))) {
|
|
393
404
|
br((t) => new Set(t).add(e));
|
|
394
405
|
try {
|
|
395
|
-
await k.request(Yr(`/pinned/${
|
|
396
|
-
}), await j.invalidateQueries({ queryKey: ["pinned-items",
|
|
406
|
+
await k.request(Yr(`/pinned/${g}/${e}/toggle`)).catch(() => {
|
|
407
|
+
}), await j.invalidateQueries({ queryKey: ["pinned-items", g] });
|
|
397
408
|
} finally {
|
|
398
409
|
br((t) => {
|
|
399
410
|
const r = new Set(t);
|
|
@@ -422,7 +433,7 @@ function Ys({
|
|
|
422
433
|
}
|
|
423
434
|
)
|
|
424
435
|
}
|
|
425
|
-
) : null, [
|
|
436
|
+
) : null, [he, dn] = H("");
|
|
426
437
|
Te(() => {
|
|
427
438
|
const e = setTimeout(() => dn(U), 300);
|
|
428
439
|
return () => clearTimeout(e);
|
|
@@ -431,9 +442,9 @@ function Ys({
|
|
|
431
442
|
var t;
|
|
432
443
|
const e = (t = [...(J ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : t[1];
|
|
433
444
|
return e && !e.includes(".") ? e : "id";
|
|
434
|
-
}, [J]), { shownSearchFields:
|
|
445
|
+
}, [J]), { shownSearchFields: Ce, otherSearchFields: kr } = F(() => {
|
|
435
446
|
const e = new Set(
|
|
436
|
-
(($ == null ? void 0 : $.relations) ?? []).filter((n) => n.one_collection ===
|
|
447
|
+
(($ == null ? void 0 : $.relations) ?? []).filter((n) => n.one_collection === g && n.one_field).map((n) => n.one_field)
|
|
437
448
|
), t = new Set(
|
|
438
449
|
(($ == null ? void 0 : $.fields) ?? []).filter((n) => (n.type === "string" || n.type === "text") && !e.has(n.field)).map((n) => n.field)
|
|
439
450
|
), r = /* @__PURE__ */ new Set();
|
|
@@ -443,14 +454,14 @@ function Ys({
|
|
|
443
454
|
shownSearchFields: [...r],
|
|
444
455
|
otherSearchFields: [...t].filter((n) => !r.has(n))
|
|
445
456
|
};
|
|
446
|
-
}, [$,
|
|
457
|
+
}, [$, g, J, a.columns]), Ge = F(() => {
|
|
447
458
|
const e = a.related_columns ?? [], t = e.findIndex((r) => r.stock === !0);
|
|
448
459
|
return t !== -1 ? t : e.findIndex((r) => r.key === "on_hand" && r.stock !== !1);
|
|
449
|
-
}, [a.related_columns]), te = Ge === -1 ? null : (a.related_columns ?? [])[Ge] ?? null, je = te ? Me(te.match, i) : null,
|
|
460
|
+
}, [a.related_columns]), te = Ge === -1 ? null : (a.related_columns ?? [])[Ge] ?? null, je = te ? Me(te.match, i) : null, Je = F(() => {
|
|
450
461
|
for (const e of Object.values((te == null ? void 0 : te.match) ?? {}))
|
|
451
462
|
if (typeof e == "string" && e.startsWith("$parent.")) return e.slice(8);
|
|
452
463
|
return null;
|
|
453
|
-
}, [te]), wr =
|
|
464
|
+
}, [te]), wr = Je ? i == null ? void 0 : i[Je] : null, cn = Je ? ((Jr = P == null ? void 0 : P.fieldLabels) == null ? void 0 : Jr[Je]) ?? M(Je) : null, Qe = g ? `nvr:catalog-in-stock:${g}:${d}.${h}` : null, [Nr, vr] = H(!1);
|
|
454
465
|
Te(() => {
|
|
455
466
|
if (Qe)
|
|
456
467
|
try {
|
|
@@ -467,10 +478,10 @@ function Ys({
|
|
|
467
478
|
}, re = !!te && Nr && je !== null, zt = F(() => {
|
|
468
479
|
if (!te) return null;
|
|
469
480
|
const e = (($ == null ? void 0 : $.relations) ?? []).find(
|
|
470
|
-
(t) => t.many_collection === te.collection && t.many_field === te.item_field && t.one_collection ===
|
|
481
|
+
(t) => t.many_collection === te.collection && t.many_field === te.item_field && t.one_collection === g && !!t.one_field && !t.junction_field
|
|
471
482
|
);
|
|
472
483
|
return (e == null ? void 0 : e.one_field) ?? null;
|
|
473
|
-
}, [te, $,
|
|
484
|
+
}, [te, $, g]), Qt = F(
|
|
474
485
|
() => re && zt && te && je ? { [zt]: { _some: { ...je, [te.value_field]: { _gt: 0 } } } } : null,
|
|
475
486
|
[re, zt, te, je]
|
|
476
487
|
), Bt = JSON.stringify(Qt), xt = re && !Qt ? 100 : 25, Vt = (e, t) => {
|
|
@@ -494,7 +505,7 @@ function Ys({
|
|
|
494
505
|
const e = new Date(Date.now() - yt * 864e5).toISOString(), t = { [Dt]: { _eq: Wt } };
|
|
495
506
|
Xe && (t[Xe] = { _gte: e });
|
|
496
507
|
const r = await k.request(
|
|
497
|
-
|
|
508
|
+
R(`/items/${d}`, {
|
|
498
509
|
fields: a.item_field,
|
|
499
510
|
filter: JSON.stringify(t),
|
|
500
511
|
limit: 500,
|
|
@@ -503,29 +514,29 @@ function Ys({
|
|
|
503
514
|
})
|
|
504
515
|
).then((l) => l.data ?? []).catch(() => []), n = [];
|
|
505
516
|
for (const l of r) {
|
|
506
|
-
const o = l[a.item_field],
|
|
507
|
-
if (
|
|
517
|
+
const o = l[a.item_field], p = o != null && typeof o == "object" ? o.id : o;
|
|
518
|
+
if (p != null && p !== "" && !n.includes(String(p)) && n.push(String(p)), n.length >= 150) break;
|
|
508
519
|
}
|
|
509
520
|
return n;
|
|
510
521
|
},
|
|
511
|
-
enabled: yt > 0 && !!Wt && !!Dt && !
|
|
522
|
+
enabled: yt > 0 && !!Wt && !!Dt && !b,
|
|
512
523
|
staleTime: 5 * 6e4
|
|
513
|
-
}), un = F(() => new Set(et), [et]), Mt = !!
|
|
524
|
+
}), un = F(() => new Set(et), [et]), Mt = !!g && he.trim().length > 0, { data: Ut = [], isFetching: mn } = K({
|
|
514
525
|
queryKey: [
|
|
515
526
|
"catalog-shown-search",
|
|
516
|
-
|
|
527
|
+
g,
|
|
517
528
|
T,
|
|
518
|
-
|
|
519
|
-
|
|
529
|
+
he,
|
|
530
|
+
Ce,
|
|
520
531
|
Bt,
|
|
521
532
|
xt
|
|
522
533
|
],
|
|
523
534
|
queryFn: () => k.request(
|
|
524
|
-
|
|
525
|
-
`/items/${
|
|
535
|
+
R(
|
|
536
|
+
`/items/${g}`,
|
|
526
537
|
Vt({
|
|
527
|
-
search:
|
|
528
|
-
search_fields:
|
|
538
|
+
search: he,
|
|
539
|
+
search_fields: Ce.join(","),
|
|
529
540
|
search_rank: "1",
|
|
530
541
|
fields: T,
|
|
531
542
|
limit: xt,
|
|
@@ -533,24 +544,24 @@ function Ys({
|
|
|
533
544
|
})
|
|
534
545
|
)
|
|
535
546
|
).then((e) => e.data ?? []),
|
|
536
|
-
enabled: Mt &&
|
|
547
|
+
enabled: Mt && Ce.length > 0,
|
|
537
548
|
staleTime: 3e4,
|
|
538
549
|
placeholderData: (e) => e
|
|
539
550
|
}), gt = kr.join(","), { data: _r = [], isFetching: fn } = K({
|
|
540
551
|
queryKey: [
|
|
541
552
|
"catalog-full-search",
|
|
542
|
-
|
|
553
|
+
g,
|
|
543
554
|
T,
|
|
544
|
-
|
|
555
|
+
he,
|
|
545
556
|
gt,
|
|
546
557
|
Bt,
|
|
547
558
|
xt
|
|
548
559
|
],
|
|
549
560
|
queryFn: () => k.request(
|
|
550
|
-
|
|
551
|
-
`/items/${
|
|
561
|
+
R(
|
|
562
|
+
`/items/${g}`,
|
|
552
563
|
Vt({
|
|
553
|
-
search:
|
|
564
|
+
search: he,
|
|
554
565
|
fields: [T, gt].filter(Boolean).join(","),
|
|
555
566
|
limit: xt,
|
|
556
567
|
sort: gr
|
|
@@ -563,19 +574,19 @@ function Ys({
|
|
|
563
574
|
}), hn = et.join(","), { data: Sr = [] } = K({
|
|
564
575
|
queryKey: [
|
|
565
576
|
"catalog-recent-search",
|
|
566
|
-
|
|
577
|
+
g,
|
|
567
578
|
T,
|
|
568
|
-
|
|
579
|
+
he,
|
|
569
580
|
gt,
|
|
570
581
|
hn,
|
|
571
582
|
Bt
|
|
572
583
|
],
|
|
573
584
|
queryFn: () => k.request(
|
|
574
|
-
|
|
575
|
-
`/items/${
|
|
585
|
+
R(
|
|
586
|
+
`/items/${g}`,
|
|
576
587
|
Vt(
|
|
577
588
|
{
|
|
578
|
-
search:
|
|
589
|
+
search: he,
|
|
579
590
|
fields: [T, gt].filter(Boolean).join(","),
|
|
580
591
|
limit: 10,
|
|
581
592
|
count: "false"
|
|
@@ -592,13 +603,13 @@ function Ys({
|
|
|
592
603
|
shown: Ut,
|
|
593
604
|
other: _r,
|
|
594
605
|
recent: Sr,
|
|
595
|
-
shownFields:
|
|
596
|
-
q:
|
|
606
|
+
shownFields: Ce,
|
|
607
|
+
q: he
|
|
597
608
|
}),
|
|
598
|
-
[Ut, _r, Sr,
|
|
609
|
+
[Ut, _r, Sr, Ce, he]
|
|
599
610
|
), bn = (e) => {
|
|
600
|
-
if (
|
|
601
|
-
const t = Yn(
|
|
611
|
+
if (Ce.length === 0 || Ut.some((r) => String(r.id) === String(e.id)) || is(e, Ce, he)) return null;
|
|
612
|
+
const t = Yn(he);
|
|
602
613
|
for (const r of kr) {
|
|
603
614
|
const n = e[r];
|
|
604
615
|
if (n == null || typeof n == "object") continue;
|
|
@@ -628,23 +639,23 @@ function Ys({
|
|
|
628
639
|
queryFn: async () => {
|
|
629
640
|
const r = {}, n = e.aggregate === "sum", l = n ? 150 : 400;
|
|
630
641
|
for (let o = 0; o < kt.length; o += l) {
|
|
631
|
-
const
|
|
642
|
+
const p = kt.slice(o, o + l);
|
|
632
643
|
let c = 1;
|
|
633
644
|
for (; ; ) {
|
|
634
645
|
const m = await k.request(
|
|
635
|
-
|
|
636
|
-
limit: n ? 1e3 :
|
|
646
|
+
R(`/items/${e.collection}`, {
|
|
647
|
+
limit: n ? 1e3 : p.length,
|
|
637
648
|
...n ? { page: c } : {},
|
|
638
649
|
fields: `${e.item_field},${e.value_field}`,
|
|
639
|
-
filter: JSON.stringify({ ...t, [e.item_field]: { _in:
|
|
650
|
+
filter: JSON.stringify({ ...t, [e.item_field]: { _in: p } })
|
|
640
651
|
})
|
|
641
652
|
).then((f) => f.data ?? []);
|
|
642
653
|
for (const f of m) {
|
|
643
654
|
const v = f[e.item_field];
|
|
644
655
|
if (v != null)
|
|
645
656
|
if (n) {
|
|
646
|
-
const
|
|
647
|
-
r[String(v)] = (Number(r[String(v)]) || 0) + (Number.isNaN(
|
|
657
|
+
const _ = Number(f[e.value_field]);
|
|
658
|
+
r[String(v)] = (Number(r[String(v)]) || 0) + (Number.isNaN(_) ? 0 : _);
|
|
648
659
|
} else
|
|
649
660
|
r[String(v)] = f[e.value_field];
|
|
650
661
|
}
|
|
@@ -654,7 +665,7 @@ function Ys({
|
|
|
654
665
|
}
|
|
655
666
|
return r;
|
|
656
667
|
},
|
|
657
|
-
enabled: !!
|
|
668
|
+
enabled: !!g && t !== null && kt.length > 0,
|
|
658
669
|
staleTime: 3e4
|
|
659
670
|
};
|
|
660
671
|
})
|
|
@@ -677,8 +688,8 @@ function Ys({
|
|
|
677
688
|
if (n === -1) return null;
|
|
678
689
|
const l = (c = wt[n]) == null ? void 0 : c.data;
|
|
679
690
|
if (l === void 0) return null;
|
|
680
|
-
const o = l[e],
|
|
681
|
-
return Number.isNaN(
|
|
691
|
+
const o = l[e], p = o == null || o === "" ? 0 : Number(o);
|
|
692
|
+
return Number.isNaN(p) ? null : r > p ? { available: p, qty: r } : null;
|
|
682
693
|
}, xn = (e) => {
|
|
683
694
|
const t = a.row_flags ?? [];
|
|
684
695
|
if (t.length === 0) return [];
|
|
@@ -701,21 +712,21 @@ function Ys({
|
|
|
701
712
|
},
|
|
702
713
|
[a.submission_errors]
|
|
703
714
|
), gn = Hn(6e4), { data: $r } = K({
|
|
704
|
-
queryKey: ["erp-submissions",
|
|
705
|
-
queryFn: () => k.request(
|
|
706
|
-
enabled: yn && !z && !!
|
|
715
|
+
queryKey: ["erp-submissions", N ?? "", String(y)],
|
|
716
|
+
queryFn: () => k.request(R(`/erp-submissions/${N}/${encodeURIComponent(y)}`)).then((e) => e.data ?? []),
|
|
717
|
+
enabled: yn && !z && !!N,
|
|
707
718
|
staleTime: 15e3,
|
|
708
719
|
refetchInterval: gn
|
|
709
720
|
}), Xt = F(() => {
|
|
710
721
|
const e = ($r ?? [])[0];
|
|
711
722
|
return !e || e.status !== "failed" ? null : Gn(e.payload, e.last_error);
|
|
712
723
|
}, [$r]), kn = pe.map((e) => e.key).join(","), { data: er } = K({
|
|
713
|
-
queryKey: ["catalog-suberr-idents",
|
|
724
|
+
queryKey: ["catalog-suberr-idents", g, Nt.join(","), kn],
|
|
714
725
|
queryFn: async () => {
|
|
715
726
|
const e = pe.map((r) => r.key);
|
|
716
727
|
if (e.length === 0) return {};
|
|
717
728
|
const t = await k.request(
|
|
718
|
-
|
|
729
|
+
R(`/items/${g}`, {
|
|
719
730
|
limit: e.length,
|
|
720
731
|
fields: ["id", ...Nt].join(","),
|
|
721
732
|
filter: JSON.stringify({ id: { _in: e } })
|
|
@@ -723,14 +734,14 @@ function Ys({
|
|
|
723
734
|
).then((r) => r.data ?? []);
|
|
724
735
|
return Object.fromEntries(t.map((r) => [String(r.id), r]));
|
|
725
736
|
},
|
|
726
|
-
enabled: !!
|
|
737
|
+
enabled: !!g && !!Xt && Nt.length > 0 && pe.length > 0,
|
|
727
738
|
staleTime: 6e4
|
|
728
739
|
}), wn = (e) => {
|
|
729
740
|
if (!Xt) return null;
|
|
730
741
|
const t = er == null ? void 0 : er[e], r = [
|
|
731
742
|
Kr(e),
|
|
732
743
|
...Nt.map((n) => {
|
|
733
|
-
const l = (t == null ? void 0 : t[n]) ??
|
|
744
|
+
const l = (t == null ? void 0 : t[n]) ?? Ie(e)[n];
|
|
734
745
|
return l != null && l !== "" ? String(l) : null;
|
|
735
746
|
})
|
|
736
747
|
].filter((n) => !!n).map(Xn);
|
|
@@ -742,21 +753,21 @@ function Ys({
|
|
|
742
753
|
const t = ge.map((f) => String(f.id));
|
|
743
754
|
if (t.length === 0) return {};
|
|
744
755
|
const r = e.m2m, n = await k.request(
|
|
745
|
-
|
|
756
|
+
R(`/items/${r.junction}`, {
|
|
746
757
|
limit: 1e3,
|
|
747
758
|
fields: `${r.fk_to_child},${r.related_field}`,
|
|
748
759
|
filter: JSON.stringify({ [r.fk_to_child]: { _in: t } })
|
|
749
760
|
})
|
|
750
|
-
).then((f) => f.data ?? []).catch(() => []), l = [...new Set(n.map((f) => String(f[r.related_field])))], o = r.label_field ?? "name",
|
|
751
|
-
|
|
761
|
+
).then((f) => f.data ?? []).catch(() => []), l = [...new Set(n.map((f) => String(f[r.related_field])))], o = r.label_field ?? "name", p = l.length ? await k.request(
|
|
762
|
+
R(`/items/${r.related_collection}`, {
|
|
752
763
|
limit: 500,
|
|
753
764
|
fields: `id,${o}`,
|
|
754
765
|
filter: JSON.stringify({ id: { _in: l } })
|
|
755
766
|
})
|
|
756
|
-
).then((f) => f.data ?? []).catch(() => []) : [], c = new Map(
|
|
767
|
+
).then((f) => f.data ?? []).catch(() => []) : [], c = new Map(p.map((f) => [String(f.id), String(f[o] ?? f.id)])), m = {};
|
|
757
768
|
for (const f of n) {
|
|
758
|
-
const v = String(f[r.fk_to_child]),
|
|
759
|
-
|
|
769
|
+
const v = String(f[r.fk_to_child]), _ = c.get(String(f[r.related_field]));
|
|
770
|
+
_ && (m[v] = m[v] ? `${m[v]}, ${_}` : _);
|
|
760
771
|
}
|
|
761
772
|
return m;
|
|
762
773
|
},
|
|
@@ -766,7 +777,7 @@ function Ys({
|
|
|
766
777
|
}), _n = (e, t) => {
|
|
767
778
|
var l, o;
|
|
768
779
|
if (!e.m2m) return t.row[e.field];
|
|
769
|
-
const r = vt.filter((
|
|
780
|
+
const r = vt.filter((p) => p.m2m).findIndex((p) => p.field === e.field);
|
|
770
781
|
if (r === -1) return;
|
|
771
782
|
const n = t.row.id;
|
|
772
783
|
if (n != null)
|
|
@@ -835,7 +846,7 @@ function Ys({
|
|
|
835
846
|
if (e == null || e === "") return "—";
|
|
836
847
|
const r = Number(e);
|
|
837
848
|
return t === "currency" ? Number.isNaN(r) ? String(e) : r.toLocaleString(void 0, { style: "currency", currency: "USD" }) : t === "number" ? Number.isNaN(r) ? String(e) : r.toLocaleString(void 0, { maximumFractionDigits: 2 }) : String(e);
|
|
838
|
-
}, qt =
|
|
849
|
+
}, qt = g ? `${g}:${d}.${h}` : null, Pe = Zr(qt && `${qt}:catalog`), we = Zr(qt && `${qt}:summary`), Er = Ee(null), jn = (e, t) => {
|
|
839
850
|
const r = ss(Er.current, t);
|
|
840
851
|
r != null && e.setWidth(t, r);
|
|
841
852
|
}, $t = (e, t, r, n, l) => {
|
|
@@ -846,7 +857,7 @@ function Ys({
|
|
|
846
857
|
ns,
|
|
847
858
|
{
|
|
848
859
|
label: r,
|
|
849
|
-
onResize: (
|
|
860
|
+
onResize: (p) => e.setWidth(t, p),
|
|
850
861
|
onFit: () => jn(e, t)
|
|
851
862
|
}
|
|
852
863
|
)
|
|
@@ -858,12 +869,12 @@ function Ys({
|
|
|
858
869
|
Xr,
|
|
859
870
|
{
|
|
860
871
|
text: ke(
|
|
861
|
-
|
|
872
|
+
ks({
|
|
862
873
|
field: n.field,
|
|
863
874
|
catalogValue: St(t, n.field),
|
|
864
875
|
copyFields: a.copy_fields,
|
|
865
876
|
related: a.related_columns,
|
|
866
|
-
lookup: (
|
|
877
|
+
lookup: (p) => tt(p, e)
|
|
867
878
|
}),
|
|
868
879
|
n.format
|
|
869
880
|
),
|
|
@@ -886,12 +897,12 @@ function Ys({
|
|
|
886
897
|
n.key
|
|
887
898
|
)),
|
|
888
899
|
/* @__PURE__ */ s("span", { "aria-hidden": !0, className: "ml-auto" })
|
|
889
|
-
] }), Tn = en(
|
|
900
|
+
] }), Tn = en(g), Ar = (e, t, r, n, l) => Tn ? /* @__PURE__ */ s(
|
|
890
901
|
"button",
|
|
891
902
|
{
|
|
892
903
|
type: "button",
|
|
893
904
|
"data-cpf-fit": n || void 0,
|
|
894
|
-
onClick: () =>
|
|
905
|
+
onClick: () => g && tn(g, e, i),
|
|
895
906
|
title: "View stock & planning detail",
|
|
896
907
|
className: C(
|
|
897
908
|
r,
|
|
@@ -914,7 +925,7 @@ function Ys({
|
|
|
914
925
|
}, Kr = (e) => {
|
|
915
926
|
const t = ct.get(e) ?? hr.find((r) => String(r.id) === e) ?? Ze.find((r) => String(r.id) === e);
|
|
916
927
|
return t ? ze(J, t) : `#${e}`;
|
|
917
|
-
},
|
|
928
|
+
}, Ie = (e) => ct.get(e) ?? hr.find((t) => String(t.id) === e) ?? Ze.find((t) => String(t.id) === e) ?? { id: e }, Ne = (e) => {
|
|
918
929
|
var n;
|
|
919
930
|
const t = z ? void 0 : Ye.get(e);
|
|
920
931
|
if (t) return ft.has(String(t.id)) ? null : Number(t[G] ?? 0);
|
|
@@ -974,14 +985,14 @@ function Ys({
|
|
|
974
985
|
const l = Me(r.match, i);
|
|
975
986
|
if (l === null) continue;
|
|
976
987
|
n = await k.request(
|
|
977
|
-
|
|
988
|
+
R(`/items/${r.collection}`, {
|
|
978
989
|
limit: 1,
|
|
979
990
|
fields: `${r.item_field},${r.value_field}`,
|
|
980
991
|
filter: JSON.stringify({ ...l, [r.item_field]: { _eq: e } })
|
|
981
992
|
})
|
|
982
993
|
).then((o) => {
|
|
983
|
-
var
|
|
984
|
-
return (c = (
|
|
994
|
+
var p, c;
|
|
995
|
+
return (c = (p = o.data) == null ? void 0 : p[0]) == null ? void 0 : c[r.value_field];
|
|
985
996
|
}).catch(() => {
|
|
986
997
|
});
|
|
987
998
|
}
|
|
@@ -997,9 +1008,9 @@ function Ys({
|
|
|
997
1008
|
if (o != null && o !== "") return o;
|
|
998
1009
|
}
|
|
999
1010
|
const r = (n = a.copy_fields) == null ? void 0 : n[t];
|
|
1000
|
-
return r ?
|
|
1011
|
+
return r ? Ie(e)[r] : void 0;
|
|
1001
1012
|
}, En = (e, t) => {
|
|
1002
|
-
if (
|
|
1013
|
+
if (b || !Y.includes(t)) return !1;
|
|
1003
1014
|
if (Z || !_e.includes(t)) return !0;
|
|
1004
1015
|
const r = Pn(e, t);
|
|
1005
1016
|
return r == null || r === "" || !(Number(r) > 0);
|
|
@@ -1009,23 +1020,23 @@ function Ys({
|
|
|
1009
1020
|
[a.item_field]: r.id ?? e,
|
|
1010
1021
|
[G]: t
|
|
1011
1022
|
};
|
|
1012
|
-
for (const [o,
|
|
1013
|
-
r[
|
|
1023
|
+
for (const [o, p] of Object.entries(a.copy_fields ?? {}))
|
|
1024
|
+
r[p] !== void 0 && (l[o] = r[p]);
|
|
1014
1025
|
Object.assign(l, n);
|
|
1015
|
-
for (const [o,
|
|
1016
|
-
const c =
|
|
1026
|
+
for (const [o, p] of Object.entries(a.compute_fields ?? {})) {
|
|
1027
|
+
const c = Le(p, l);
|
|
1017
1028
|
c !== null && (l[o] = c);
|
|
1018
1029
|
}
|
|
1019
1030
|
return l;
|
|
1020
1031
|
}
|
|
1021
1032
|
function Ln(e, t, r, n) {
|
|
1022
|
-
return
|
|
1033
|
+
return gs({
|
|
1023
1034
|
compute: a.compute_fields ?? {},
|
|
1024
1035
|
probe: { ...Ve(e, t, r), ...n, [G]: t },
|
|
1025
1036
|
ruleError: B,
|
|
1026
1037
|
labelOf: (l) => {
|
|
1027
1038
|
var o;
|
|
1028
|
-
return ((o = L.find((
|
|
1039
|
+
return ((o = L.find((p) => p.field === l)) == null ? void 0 : o.label) || M(l);
|
|
1029
1040
|
}
|
|
1030
1041
|
});
|
|
1031
1042
|
}
|
|
@@ -1044,39 +1055,39 @@ function Ys({
|
|
|
1044
1055
|
if (o > 0) {
|
|
1045
1056
|
const m = ht.get(e), f = (z ? void 0 : Ye.get(e)) ?? (m !== void 0 ? Re[m] : void 0) ?? {}, v = B(G, o, f) ?? Ln(e, o, r, f);
|
|
1046
1057
|
if (v) {
|
|
1047
|
-
X((
|
|
1058
|
+
X((_) => ({ ..._, [e]: { kind: "error", message: v } }));
|
|
1048
1059
|
return;
|
|
1049
1060
|
}
|
|
1050
1061
|
}
|
|
1051
1062
|
const c = o > 0 ? await Rn(e) : {};
|
|
1052
|
-
if (He &&
|
|
1063
|
+
if (He && w) {
|
|
1053
1064
|
const m = Ye.get(e);
|
|
1054
1065
|
if ((m == null ? void 0 : m.id) != null) {
|
|
1055
1066
|
const f = String(m.id);
|
|
1056
1067
|
if (o === 0) {
|
|
1057
|
-
|
|
1068
|
+
w.cancelPendingEdit(d, h, f), w.queueDelete(d, h, f);
|
|
1058
1069
|
return;
|
|
1059
1070
|
}
|
|
1060
|
-
ft.has(f) &&
|
|
1071
|
+
ft.has(f) && w.cancelPendingDelete(d, h, f);
|
|
1061
1072
|
const v = Ve(e, o, r, c);
|
|
1062
|
-
for (const
|
|
1063
|
-
m[
|
|
1064
|
-
for (const [
|
|
1065
|
-
const Fe =
|
|
1066
|
-
Fe !== null && (v[
|
|
1073
|
+
for (const x of Y)
|
|
1074
|
+
m[x] != null && m[x] !== "" && (v[x] = m[x]);
|
|
1075
|
+
for (const [x, A] of Object.entries(a.compute_fields ?? {})) {
|
|
1076
|
+
const Fe = Le(A, { ...m, ...v });
|
|
1077
|
+
Fe !== null && (v[x] = Fe);
|
|
1067
1078
|
}
|
|
1068
|
-
const
|
|
1069
|
-
Object.entries(v).filter(([
|
|
1079
|
+
const _ = ge.find((x) => String(x.id) === f) ?? {}, O = Object.fromEntries(
|
|
1080
|
+
Object.entries(v).filter(([x, A]) => String(A ?? "") !== String(_[x] ?? ""))
|
|
1070
1081
|
);
|
|
1071
|
-
Object.keys(
|
|
1082
|
+
Object.keys(O).length === 0 ? w.cancelPendingEdit(d, h, f) : (w.cancelPendingEdit(d, h, f), w.queueEdit(d, h, f, O));
|
|
1072
1083
|
return;
|
|
1073
1084
|
}
|
|
1074
1085
|
}
|
|
1075
1086
|
if (z || He) {
|
|
1076
1087
|
const m = ht.get(e);
|
|
1077
|
-
o === 0 ? m !== void 0 && (
|
|
1088
|
+
o === 0 ? m !== void 0 && (w == null || w.removeRow(d, h, m)) : m !== void 0 ? w == null || w.updateRow(
|
|
1078
1089
|
d,
|
|
1079
|
-
|
|
1090
|
+
h,
|
|
1080
1091
|
m,
|
|
1081
1092
|
ls(
|
|
1082
1093
|
Re[m],
|
|
@@ -1084,9 +1095,9 @@ function Ys({
|
|
|
1084
1095
|
Y,
|
|
1085
1096
|
a.compute_fields
|
|
1086
1097
|
)
|
|
1087
|
-
) :
|
|
1098
|
+
) : w == null || w.queueRow(
|
|
1088
1099
|
d,
|
|
1089
|
-
|
|
1100
|
+
h,
|
|
1090
1101
|
Ve(e, o, r, c)
|
|
1091
1102
|
);
|
|
1092
1103
|
return;
|
|
@@ -1098,22 +1109,22 @@ function Ys({
|
|
|
1098
1109
|
(m == null ? void 0 : m.id) != null && await k.request(Mn(`/items/${d}/${m.id}${ne}`));
|
|
1099
1110
|
else if ((m == null ? void 0 : m.id) != null) {
|
|
1100
1111
|
const f = Ve(e, o, r, c);
|
|
1101
|
-
for (const
|
|
1102
|
-
m[
|
|
1103
|
-
for (const [
|
|
1104
|
-
const Fe =
|
|
1105
|
-
Fe !== null && (f[
|
|
1112
|
+
for (const x of Y)
|
|
1113
|
+
m[x] != null && m[x] !== "" && (f[x] = m[x]);
|
|
1114
|
+
for (const [x, A] of Object.entries(a.compute_fields ?? {})) {
|
|
1115
|
+
const Fe = Le(A, { ...m, ...f });
|
|
1116
|
+
Fe !== null && (f[x] = Fe);
|
|
1106
1117
|
}
|
|
1107
|
-
const v = { ...m, ...f }, { id:
|
|
1108
|
-
await k.request(Hr(`/items/${d}/${m.id}${ne}`,
|
|
1118
|
+
const v = { ...m, ...f }, { id: _, ...O } = v;
|
|
1119
|
+
await k.request(Hr(`/items/${d}/${m.id}${ne}`, O));
|
|
1109
1120
|
} else
|
|
1110
1121
|
await k.request(
|
|
1111
1122
|
Yr(`/items/${d}${ne}`, {
|
|
1112
|
-
[
|
|
1123
|
+
[h]: y,
|
|
1113
1124
|
...Ve(e, o, r, c)
|
|
1114
1125
|
})
|
|
1115
1126
|
);
|
|
1116
|
-
j.invalidateQueries({ queryKey: ["o2m-rows", d,
|
|
1127
|
+
j.invalidateQueries({ queryKey: ["o2m-rows", d, h, y] });
|
|
1117
1128
|
} catch {
|
|
1118
1129
|
} finally {
|
|
1119
1130
|
ae((m) => {
|
|
@@ -1125,63 +1136,63 @@ function Ys({
|
|
|
1125
1136
|
async function An(e, t, r) {
|
|
1126
1137
|
const n = r.trim() === "" ? null : Number(r);
|
|
1127
1138
|
if (r.trim() !== "" && Number.isNaN(n)) return;
|
|
1128
|
-
const l = (
|
|
1129
|
-
const c = { ...
|
|
1139
|
+
const l = (p) => {
|
|
1140
|
+
const c = { ...p, [t]: n };
|
|
1130
1141
|
for (const [m, f] of Object.entries(a.compute_fields ?? {})) {
|
|
1131
|
-
const v =
|
|
1142
|
+
const v = Le(f, c);
|
|
1132
1143
|
v !== null && (c[m] = v);
|
|
1133
1144
|
}
|
|
1134
1145
|
return c;
|
|
1135
1146
|
}, o = z ? void 0 : Ye.get(e);
|
|
1136
1147
|
if ((o == null ? void 0 : o.id) == null) {
|
|
1137
|
-
const
|
|
1138
|
-
if (
|
|
1139
|
-
|
|
1148
|
+
const p = ht.get(e);
|
|
1149
|
+
if (p === void 0) return;
|
|
1150
|
+
w == null || w.updateRow(d, h, p, l(Re[p]));
|
|
1140
1151
|
return;
|
|
1141
1152
|
}
|
|
1142
|
-
if (He &&
|
|
1143
|
-
const
|
|
1144
|
-
Object.entries(
|
|
1153
|
+
if (He && w) {
|
|
1154
|
+
const p = l(o), c = ge.find((f) => String(f.id) === String(o.id)) ?? {}, m = Object.fromEntries(
|
|
1155
|
+
Object.entries(p).filter(
|
|
1145
1156
|
([f, v]) => f !== "id" && String(v ?? "") !== String(c[f] ?? "")
|
|
1146
1157
|
)
|
|
1147
1158
|
);
|
|
1148
|
-
|
|
1159
|
+
w.cancelPendingEdit(d, h, String(o.id)), Object.keys(m).length > 0 && w.queueEdit(d, h, String(o.id), m);
|
|
1149
1160
|
return;
|
|
1150
1161
|
}
|
|
1151
|
-
ae((
|
|
1162
|
+
ae((p) => new Set(p).add(e));
|
|
1152
1163
|
try {
|
|
1153
|
-
const { id:
|
|
1154
|
-
await k.request(Hr(`/items/${d}/${o.id}${ne}`, c)), j.invalidateQueries({ queryKey: ["o2m-rows", d,
|
|
1164
|
+
const { id: p, ...c } = l(o);
|
|
1165
|
+
await k.request(Hr(`/items/${d}/${o.id}${ne}`, c)), j.invalidateQueries({ queryKey: ["o2m-rows", d, h, y] });
|
|
1155
1166
|
} catch {
|
|
1156
1167
|
} finally {
|
|
1157
|
-
ae((
|
|
1158
|
-
const c = new Set(
|
|
1168
|
+
ae((p) => {
|
|
1169
|
+
const c = new Set(p);
|
|
1159
1170
|
return c.delete(e), c;
|
|
1160
1171
|
});
|
|
1161
1172
|
}
|
|
1162
1173
|
}
|
|
1163
1174
|
async function Kn(e) {
|
|
1164
|
-
if (e == null || e === "" || !
|
|
1165
|
-
const t = String(e), r =
|
|
1175
|
+
if (e == null || e === "" || !g) return;
|
|
1176
|
+
const t = String(e), r = Ie(t);
|
|
1166
1177
|
let n = r;
|
|
1167
1178
|
Object.keys(r).length <= 1 && (n = await k.request(
|
|
1168
|
-
|
|
1179
|
+
R(`/items/${g}`, {
|
|
1169
1180
|
filter: JSON.stringify({ id: { _eq: e } }),
|
|
1170
1181
|
fields: T,
|
|
1171
1182
|
limit: 1
|
|
1172
1183
|
})
|
|
1173
1184
|
).then((o) => {
|
|
1174
|
-
var
|
|
1175
|
-
return ((
|
|
1185
|
+
var p;
|
|
1186
|
+
return ((p = o.data) == null ? void 0 : p[0]) ?? { id: e };
|
|
1176
1187
|
}).catch(() => ({ id: e })));
|
|
1177
1188
|
const l = (Ne(t) ?? 0) + 1;
|
|
1178
1189
|
await st(t, String(l), n);
|
|
1179
1190
|
}
|
|
1180
1191
|
const Cn = pe.length, Ft = Object.keys(a.copy_fields ?? {}), We = Object.keys(a.compute_fields ?? {}), Tt = (e, t) => {
|
|
1181
1192
|
const r = Ne(e);
|
|
1182
|
-
if (
|
|
1193
|
+
if (b)
|
|
1183
1194
|
return /* @__PURE__ */ s("span", { className: "inline-block w-20 shrink-0 text-right tabular-nums text-slate-700 dark:text-slate-200", children: r && r > 0 ? r : "—" });
|
|
1184
|
-
const n = ye[e], l = n !== void 0 ? n : r && r > 0 ? String(r) : "", o = Q[e],
|
|
1195
|
+
const n = ye[e], l = n !== void 0 ? n : r && r > 0 ? String(r) : "", o = Q[e], p = () => X((m) => {
|
|
1185
1196
|
if (!(e in m)) return m;
|
|
1186
1197
|
const f = { ...m };
|
|
1187
1198
|
return delete f[e], f;
|
|
@@ -1191,21 +1202,27 @@ function Ys({
|
|
|
1191
1202
|
type: "number",
|
|
1192
1203
|
min: 0,
|
|
1193
1204
|
step: Ot(le) ? 1 : "any",
|
|
1194
|
-
disabled:
|
|
1205
|
+
disabled: b,
|
|
1195
1206
|
value: l,
|
|
1196
1207
|
placeholder: "0",
|
|
1197
1208
|
"aria-invalid": (o == null ? void 0 : o.kind) === "error" || void 0,
|
|
1198
|
-
onFocus:
|
|
1199
|
-
onChange: (m) =>
|
|
1209
|
+
onFocus: p,
|
|
1210
|
+
onChange: (m) => ue((f) => ({ ...f, [e]: m.target.value })),
|
|
1200
1211
|
onBlur: (m) => {
|
|
1201
1212
|
const f = m.target.value, v = ps(f, le);
|
|
1202
1213
|
if (v) {
|
|
1203
|
-
|
|
1214
|
+
ue((_) => {
|
|
1215
|
+
const O = { ..._ };
|
|
1216
|
+
return delete O[e], O;
|
|
1217
|
+
}), X((_) => ({
|
|
1218
|
+
..._,
|
|
1219
|
+
[e]: { kind: "error", message: ys(v, f) }
|
|
1220
|
+
}));
|
|
1204
1221
|
return;
|
|
1205
1222
|
}
|
|
1206
|
-
|
|
1207
|
-
const
|
|
1208
|
-
return delete
|
|
1223
|
+
ue((_) => {
|
|
1224
|
+
const O = { ..._ };
|
|
1225
|
+
return delete O[e], O;
|
|
1209
1226
|
}), st(e, f, t);
|
|
1210
1227
|
},
|
|
1211
1228
|
onKeyDown: (m) => {
|
|
@@ -1244,7 +1261,7 @@ function Ys({
|
|
|
1244
1261
|
"button",
|
|
1245
1262
|
{
|
|
1246
1263
|
type: "button",
|
|
1247
|
-
onClick:
|
|
1264
|
+
onClick: p,
|
|
1248
1265
|
className: "h-6 rounded border border-slate-200 px-2 text-[11px] text-slate-600 hover:bg-muted dark:border-border dark:text-slate-300",
|
|
1249
1266
|
children: "Keep"
|
|
1250
1267
|
}
|
|
@@ -1255,7 +1272,7 @@ function Ys({
|
|
|
1255
1272
|
type: "button",
|
|
1256
1273
|
onClick: () => {
|
|
1257
1274
|
const m = o.row;
|
|
1258
|
-
|
|
1275
|
+
p(), st(e, "0", m, { confirmedRemove: !0 });
|
|
1259
1276
|
},
|
|
1260
1277
|
className: "h-6 rounded bg-red-600 px-2 text-[11px] font-medium text-white hover:bg-red-700",
|
|
1261
1278
|
children: "Remove"
|
|
@@ -1266,11 +1283,11 @@ function Ys({
|
|
|
1266
1283
|
)
|
|
1267
1284
|
] });
|
|
1268
1285
|
}, Jn = (e, t, r) => {
|
|
1269
|
-
const n = `${e}:${t}`, l = Se[n], o = () =>
|
|
1286
|
+
const n = `${e}:${t}`, l = Se[n], o = () => me((f) => {
|
|
1270
1287
|
if (!(n in f)) return f;
|
|
1271
1288
|
const v = { ...f };
|
|
1272
1289
|
return delete v[n], v;
|
|
1273
|
-
}),
|
|
1290
|
+
}), p = r[t] == null ? "" : String(r[t]), c = L.find((f) => f.field === t), m = !Ot(c == null ? void 0 : c.type);
|
|
1274
1291
|
return /* @__PURE__ */ u("span", { className: "inline-flex shrink-0 flex-col items-end", children: [
|
|
1275
1292
|
/* @__PURE__ */ s(
|
|
1276
1293
|
"input",
|
|
@@ -1278,15 +1295,15 @@ function Ys({
|
|
|
1278
1295
|
type: "number",
|
|
1279
1296
|
min: 0,
|
|
1280
1297
|
step: m ? "0.01" : "any",
|
|
1281
|
-
defaultValue:
|
|
1298
|
+
defaultValue: p,
|
|
1282
1299
|
"aria-invalid": !!l || void 0,
|
|
1283
1300
|
onFocus: o,
|
|
1284
1301
|
onBlur: (f) => {
|
|
1285
1302
|
const v = f.target.value;
|
|
1286
|
-
if (v !==
|
|
1287
|
-
const
|
|
1288
|
-
if (
|
|
1289
|
-
f.target.value =
|
|
1303
|
+
if (v !== p) {
|
|
1304
|
+
const _ = c, O = (_ == null ? void 0 : _.label) || M(t), x = cr(v, { type: _ == null ? void 0 : _.type, label: O }), A = x.ok ? (m ? os(v, O) : null) ?? B(t, x.value, r) : x.message;
|
|
1305
|
+
if (A) {
|
|
1306
|
+
f.target.value = p, me((Fe) => ({ ...Fe, [n]: A }));
|
|
1290
1307
|
return;
|
|
1291
1308
|
}
|
|
1292
1309
|
}
|
|
@@ -1300,7 +1317,7 @@ function Ys({
|
|
|
1300
1317
|
l && "border-red-400 dark:border-red-600"
|
|
1301
1318
|
)
|
|
1302
1319
|
},
|
|
1303
|
-
`${n}:${
|
|
1320
|
+
`${n}:${p}`
|
|
1304
1321
|
),
|
|
1305
1322
|
l && /* @__PURE__ */ u(
|
|
1306
1323
|
"span",
|
|
@@ -1311,17 +1328,17 @@ function Ys({
|
|
|
1311
1328
|
children: [
|
|
1312
1329
|
/* @__PURE__ */ s(ar, { className: "mt-px h-3 w-3 shrink-0" }),
|
|
1313
1330
|
l,
|
|
1314
|
-
|
|
1331
|
+
p !== "" ? ` — still ${p}` : ""
|
|
1315
1332
|
]
|
|
1316
1333
|
}
|
|
1317
1334
|
)
|
|
1318
1335
|
] }, n);
|
|
1319
1336
|
};
|
|
1320
|
-
return !
|
|
1337
|
+
return !g && q ? /* @__PURE__ */ u("div", { className: "space-y-2 py-1", "aria-busy": "true", children: [
|
|
1321
1338
|
/* @__PURE__ */ s("div", { className: "h-8 w-full animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }),
|
|
1322
1339
|
/* @__PURE__ */ s("div", { className: "h-8 w-2/3 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" })
|
|
1323
|
-
] }) :
|
|
1324
|
-
!
|
|
1340
|
+
] }) : g ? /* @__PURE__ */ u("div", { ref: Er, className: "space-y-3", children: [
|
|
1341
|
+
!b && /* @__PURE__ */ u(ve, { children: [
|
|
1325
1342
|
/* @__PURE__ */ u("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
|
|
1326
1343
|
/* @__PURE__ */ u("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-2 dark:border-border", children: [
|
|
1327
1344
|
/* @__PURE__ */ s(Rt, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
@@ -1329,7 +1346,7 @@ function Ys({
|
|
|
1329
1346
|
"input",
|
|
1330
1347
|
{
|
|
1331
1348
|
value: U,
|
|
1332
|
-
onChange: (e) =>
|
|
1349
|
+
onChange: (e) => Ae(e.target.value),
|
|
1333
1350
|
placeholder: "Search catalog…",
|
|
1334
1351
|
className: "w-full bg-transparent text-[12px] outline-none placeholder:text-slate-400"
|
|
1335
1352
|
}
|
|
@@ -1353,13 +1370,13 @@ function Ys({
|
|
|
1353
1370
|
pn ? /* @__PURE__ */ s(ce, { className: "h-3 w-3 shrink-0 animate-spin" }) : /* @__PURE__ */ s(zn, { className: "h-3 w-3 shrink-0" }),
|
|
1354
1371
|
/* @__PURE__ */ u("span", { className: "truncate", children: [
|
|
1355
1372
|
"In stock",
|
|
1356
|
-
je !== null &&
|
|
1373
|
+
je !== null && Je && wr != null && /* @__PURE__ */ u(ve, { children: [
|
|
1357
1374
|
" at ",
|
|
1358
1375
|
/* @__PURE__ */ s(
|
|
1359
|
-
|
|
1376
|
+
Ss,
|
|
1360
1377
|
{
|
|
1361
|
-
parentCollection:
|
|
1362
|
-
field:
|
|
1378
|
+
parentCollection: N,
|
|
1379
|
+
field: Je,
|
|
1363
1380
|
id: wr
|
|
1364
1381
|
}
|
|
1365
1382
|
)
|
|
@@ -1490,9 +1507,9 @@ function Ys({
|
|
|
1490
1507
|
)
|
|
1491
1508
|
] });
|
|
1492
1509
|
})(),
|
|
1493
|
-
|
|
1510
|
+
he
|
|
1494
1511
|
),
|
|
1495
|
-
nr(r, e,
|
|
1512
|
+
nr(r, e, he),
|
|
1496
1513
|
/* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ie.has(r) && /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" }) }),
|
|
1497
1514
|
Tt(r, e)
|
|
1498
1515
|
]
|
|
@@ -1634,7 +1651,7 @@ function Ys({
|
|
|
1634
1651
|
}
|
|
1635
1652
|
),
|
|
1636
1653
|
!t && e.items.map((n, l) => {
|
|
1637
|
-
const o = Ne(n.id),
|
|
1654
|
+
const o = Ne(n.id), p = Zt(n.id);
|
|
1638
1655
|
return /* @__PURE__ */ u(
|
|
1639
1656
|
"div",
|
|
1640
1657
|
{
|
|
@@ -1642,17 +1659,17 @@ function Ys({
|
|
|
1642
1659
|
"flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
|
|
1643
1660
|
l % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1644
1661
|
(o ?? 0) > 0 && "bg-nvr-cyan/5",
|
|
1645
|
-
|
|
1662
|
+
p && "bg-amber-50 dark:bg-amber-900/15"
|
|
1646
1663
|
),
|
|
1647
1664
|
children: [
|
|
1648
1665
|
Jt(n.id),
|
|
1649
1666
|
sr(n.id, n.label),
|
|
1650
1667
|
nr(n.id, n.row),
|
|
1651
|
-
/* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ie.has(n.id) ? /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" }) :
|
|
1668
|
+
/* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ie.has(n.id) ? /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" }) : p && /* @__PURE__ */ s(
|
|
1652
1669
|
De,
|
|
1653
1670
|
{
|
|
1654
1671
|
className: "h-3.5 w-3.5 text-amber-500",
|
|
1655
|
-
"aria-label": `${Gt} ${
|
|
1672
|
+
"aria-label": `${Gt} ${p.available} — ${p.qty} requested`
|
|
1656
1673
|
}
|
|
1657
1674
|
) }),
|
|
1658
1675
|
Tt(n.id, n.row)
|
|
@@ -1665,17 +1682,17 @@ function Ys({
|
|
|
1665
1682
|
})
|
|
1666
1683
|
] }),
|
|
1667
1684
|
(a.builders ?? []).filter((e) => Gr(e.show_when, i)).map((e) => /* @__PURE__ */ s(
|
|
1668
|
-
|
|
1685
|
+
_s,
|
|
1669
1686
|
{
|
|
1670
1687
|
builder: e,
|
|
1671
1688
|
defaultItemField: a.item_field,
|
|
1672
|
-
catalogCol:
|
|
1689
|
+
catalogCol: g,
|
|
1673
1690
|
catalogFields: T,
|
|
1674
1691
|
tmpl: J,
|
|
1675
1692
|
currentQty: Ne,
|
|
1676
1693
|
addQty: (t, r, n) => st(t, String(r), n),
|
|
1677
1694
|
qtyStep: Ot(le) ? 1 : "any",
|
|
1678
|
-
readOnly:
|
|
1695
|
+
readOnly: b
|
|
1679
1696
|
},
|
|
1680
1697
|
e.label
|
|
1681
1698
|
))
|
|
@@ -1683,11 +1700,11 @@ function Ys({
|
|
|
1683
1700
|
/* @__PURE__ */ u("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
|
|
1684
1701
|
/* @__PURE__ */ u("div", { className: "flex items-center justify-between gap-2 border-b border-slate-200 bg-slate-50 px-3 py-2 dark:border-border dark:bg-muted", children: [
|
|
1685
1702
|
/* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Summary" }),
|
|
1686
|
-
!
|
|
1687
|
-
a.upload_template && !z && ee &&
|
|
1703
|
+
!b && /* @__PURE__ */ u("div", { className: "flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [
|
|
1704
|
+
a.upload_template && !z && ee && N && /* @__PURE__ */ s(
|
|
1688
1705
|
ts,
|
|
1689
1706
|
{
|
|
1690
|
-
collection:
|
|
1707
|
+
collection: N,
|
|
1691
1708
|
templateFilter: (e) => {
|
|
1692
1709
|
var t;
|
|
1693
1710
|
return e.name === a.upload_template && ((t = e.reimport) == null ? void 0 : t.enabled) === !0;
|
|
@@ -1703,7 +1720,7 @@ function Ys({
|
|
|
1703
1720
|
/* @__PURE__ */ s("div", { className: "w-64", children: /* @__PURE__ */ s(
|
|
1704
1721
|
fs,
|
|
1705
1722
|
{
|
|
1706
|
-
collection:
|
|
1723
|
+
collection: g,
|
|
1707
1724
|
value: null,
|
|
1708
1725
|
onChange: (e) => void Kn(e),
|
|
1709
1726
|
placeholder: "+ Add any item…"
|
|
@@ -1718,12 +1735,12 @@ function Ys({
|
|
|
1718
1735
|
c,
|
|
1719
1736
|
"w-20 shrink-0",
|
|
1720
1737
|
"text-right text-[11px] font-medium text-slate-500 dark:text-slate-400"
|
|
1721
|
-
) : /* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500 dark:text-slate-400", children: c }),
|
|
1738
|
+
) : /* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500 dark:text-slate-400", children: c }), p = (c) => Y.includes(c) && !b ? void 0 : `s:${c}`;
|
|
1722
1739
|
return /* @__PURE__ */ u("div", { children: [
|
|
1723
1740
|
/* @__PURE__ */ u("div", { className: "flex items-center gap-4 border-b border-slate-200 px-3 py-1.5 dark:border-border", children: [
|
|
1724
1741
|
/* @__PURE__ */ u("span", { className: "flex flex-1 items-center gap-1 text-[11px] font-medium text-slate-500 dark:text-slate-400", children: [
|
|
1725
1742
|
"Item",
|
|
1726
|
-
|
|
1743
|
+
b && /* @__PURE__ */ s(
|
|
1727
1744
|
ir,
|
|
1728
1745
|
{
|
|
1729
1746
|
show: we.customized,
|
|
@@ -1732,21 +1749,21 @@ function Ys({
|
|
|
1732
1749
|
}
|
|
1733
1750
|
)
|
|
1734
1751
|
] }),
|
|
1735
|
-
Ft.map((c) => /* @__PURE__ */ s(at, { children: o(M(c),
|
|
1752
|
+
Ft.map((c) => /* @__PURE__ */ s(at, { children: o(M(c), p(c)) }, c)),
|
|
1736
1753
|
o(M(G)),
|
|
1737
1754
|
We.map((c) => /* @__PURE__ */ s(at, { children: o(M(c), `s:${c}`) }, c)),
|
|
1738
|
-
!
|
|
1755
|
+
!b && /* @__PURE__ */ s("span", { className: "-my-1 flex w-6 shrink-0 justify-end", children: /* @__PURE__ */ s(ir, { show: we.customized, onReset: we.reset }) })
|
|
1739
1756
|
] }),
|
|
1740
1757
|
pe.map((c, m) => {
|
|
1741
|
-
const f = c.row.id != null ? String(c.row.id) : null, v = f != null && ft.has(f),
|
|
1758
|
+
const f = c.row.id != null ? String(c.row.id) : null, v = f != null && ft.has(f), _ = v ? null : Zt(c.key), O = v ? null : wn(c.key);
|
|
1742
1759
|
return /* @__PURE__ */ u(
|
|
1743
1760
|
"div",
|
|
1744
1761
|
{
|
|
1745
1762
|
className: C(
|
|
1746
1763
|
"border-b border-slate-100 px-3 py-2 last:border-b-0 dark:border-border/50",
|
|
1747
1764
|
m % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1748
|
-
|
|
1749
|
-
|
|
1765
|
+
_ && "bg-amber-50 dark:bg-amber-900/15",
|
|
1766
|
+
O && "bg-red-50/70 dark:bg-red-900/15",
|
|
1750
1767
|
v && "opacity-60"
|
|
1751
1768
|
),
|
|
1752
1769
|
children: [
|
|
@@ -1772,12 +1789,12 @@ function Ys({
|
|
|
1772
1789
|
children: f == null ? "New" : "Edited"
|
|
1773
1790
|
}
|
|
1774
1791
|
),
|
|
1775
|
-
|
|
1792
|
+
O && /* @__PURE__ */ s(
|
|
1776
1793
|
"span",
|
|
1777
1794
|
{
|
|
1778
1795
|
className: "shrink-0",
|
|
1779
1796
|
"data-tip": `This line was in the failed submission
|
|
1780
|
-
${
|
|
1797
|
+
${O}`,
|
|
1781
1798
|
"data-submission-error": !0,
|
|
1782
1799
|
children: /* @__PURE__ */ s(ar, { className: "h-3.5 w-3.5 text-red-500", strokeWidth: 2 })
|
|
1783
1800
|
}
|
|
@@ -1785,46 +1802,46 @@ ${A}`,
|
|
|
1785
1802
|
t && /* @__PURE__ */ s(
|
|
1786
1803
|
Xr,
|
|
1787
1804
|
{
|
|
1788
|
-
text: ke(St(
|
|
1805
|
+
text: ke(St(Ie(c.key), t.field), void 0),
|
|
1789
1806
|
className: "min-w-0 flex-1 text-slate-600 dark:text-slate-300"
|
|
1790
1807
|
}
|
|
1791
1808
|
),
|
|
1792
1809
|
!t && /* @__PURE__ */ s("span", { className: "flex-1" }),
|
|
1793
|
-
r.map((
|
|
1794
|
-
const
|
|
1795
|
-
return
|
|
1810
|
+
r.map((x) => {
|
|
1811
|
+
const A = St(Ie(c.key), x.field);
|
|
1812
|
+
return A == null || A === "" ? null : /* @__PURE__ */ s(
|
|
1796
1813
|
"span",
|
|
1797
1814
|
{
|
|
1798
1815
|
className: "shrink-0 rounded bg-slate-100 px-1.5 py-0.5 text-[10.5px] font-medium text-slate-600 dark:bg-muted dark:text-slate-300",
|
|
1799
|
-
children: String(
|
|
1816
|
+
children: String(A)
|
|
1800
1817
|
},
|
|
1801
|
-
|
|
1818
|
+
x.field
|
|
1802
1819
|
);
|
|
1803
1820
|
}),
|
|
1804
1821
|
Ft.map(
|
|
1805
|
-
(
|
|
1806
|
-
var
|
|
1807
|
-
return En(c.key,
|
|
1822
|
+
(x) => {
|
|
1823
|
+
var A;
|
|
1824
|
+
return En(c.key, x) ? Jn(c.key, x, c.row) : /* @__PURE__ */ s(
|
|
1808
1825
|
"span",
|
|
1809
1826
|
{
|
|
1810
|
-
"data-catalog-locked": !
|
|
1811
|
-
"data-tip": !
|
|
1827
|
+
"data-catalog-locked": !b && Y.includes(x) ? x : void 0,
|
|
1828
|
+
"data-tip": !b && Y.includes(x) ? "Set by the catalog — only an administrator can change it" : void 0,
|
|
1812
1829
|
...we.box(
|
|
1813
|
-
`s:${
|
|
1830
|
+
`s:${x}`,
|
|
1814
1831
|
"w-20 shrink-0",
|
|
1815
1832
|
"truncate text-right tabular-nums text-slate-600 dark:text-slate-300"
|
|
1816
1833
|
),
|
|
1817
|
-
children: ke(c.row[
|
|
1834
|
+
children: ke(c.row[x], (A = a.field_formats) == null ? void 0 : A[x])
|
|
1818
1835
|
},
|
|
1819
|
-
|
|
1836
|
+
x
|
|
1820
1837
|
);
|
|
1821
1838
|
}
|
|
1822
1839
|
),
|
|
1823
1840
|
/* @__PURE__ */ u("span", { className: "inline-flex w-20 shrink-0 items-center justify-end gap-1", children: [
|
|
1824
1841
|
ie.has(c.key) && /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" }),
|
|
1825
|
-
Tt(c.key,
|
|
1842
|
+
Tt(c.key, Ie(c.key))
|
|
1826
1843
|
] }),
|
|
1827
|
-
We.map((
|
|
1844
|
+
We.map((x) => {
|
|
1828
1845
|
var Dr, Mr;
|
|
1829
1846
|
if (v)
|
|
1830
1847
|
return /* @__PURE__ */ s(
|
|
@@ -1832,45 +1849,45 @@ ${A}`,
|
|
|
1832
1849
|
{
|
|
1833
1850
|
"data-tip": "Not counted — this line is removed when you save",
|
|
1834
1851
|
...we.box(
|
|
1835
|
-
`s:${
|
|
1852
|
+
`s:${x}`,
|
|
1836
1853
|
"w-20 shrink-0",
|
|
1837
1854
|
"text-right tabular-nums text-slate-400 dark:text-slate-500"
|
|
1838
1855
|
),
|
|
1839
1856
|
children: "—"
|
|
1840
1857
|
},
|
|
1841
|
-
|
|
1858
|
+
x
|
|
1842
1859
|
);
|
|
1843
|
-
const
|
|
1860
|
+
const A = c.row[x], Fe = A != null && A !== "" ? A : Le(((Dr = a.compute_fields) == null ? void 0 : Dr[x]) ?? "", c.row);
|
|
1844
1861
|
return /* @__PURE__ */ s(
|
|
1845
1862
|
"span",
|
|
1846
1863
|
{
|
|
1847
1864
|
...we.box(
|
|
1848
|
-
`s:${
|
|
1865
|
+
`s:${x}`,
|
|
1849
1866
|
"w-20 shrink-0",
|
|
1850
1867
|
"truncate text-right tabular-nums text-slate-600 dark:text-slate-300"
|
|
1851
1868
|
),
|
|
1852
|
-
children: ke(Fe, (Mr = a.field_formats) == null ? void 0 : Mr[
|
|
1869
|
+
children: ke(Fe, (Mr = a.field_formats) == null ? void 0 : Mr[x])
|
|
1853
1870
|
},
|
|
1854
|
-
|
|
1871
|
+
x
|
|
1855
1872
|
);
|
|
1856
1873
|
}),
|
|
1857
|
-
!
|
|
1874
|
+
!b && v && /* @__PURE__ */ s(
|
|
1858
1875
|
"button",
|
|
1859
1876
|
{
|
|
1860
1877
|
type: "button",
|
|
1861
|
-
onClick: () =>
|
|
1878
|
+
onClick: () => w == null ? void 0 : w.cancelPendingDelete(d, h, f),
|
|
1862
1879
|
className: "shrink-0 rounded px-1.5 py-0.5 text-[11px] font-medium text-nvr-navy underline dark:text-nvr-cyan",
|
|
1863
1880
|
children: "Undo"
|
|
1864
1881
|
}
|
|
1865
1882
|
),
|
|
1866
|
-
!
|
|
1883
|
+
!b && !v && /* @__PURE__ */ s(
|
|
1867
1884
|
"button",
|
|
1868
1885
|
{
|
|
1869
1886
|
type: "button",
|
|
1870
1887
|
title: "Remove (applies on Save)",
|
|
1871
1888
|
onClick: () => {
|
|
1872
|
-
if (!z &&
|
|
1873
|
-
|
|
1889
|
+
if (!z && w && f != null) {
|
|
1890
|
+
w.queueDelete(d, h, f);
|
|
1874
1891
|
return;
|
|
1875
1892
|
}
|
|
1876
1893
|
st(c.key, "0", {}, { confirmedRemove: !0 });
|
|
@@ -1883,57 +1900,57 @@ ${A}`,
|
|
|
1883
1900
|
}
|
|
1884
1901
|
),
|
|
1885
1902
|
(n.length > 0 || Or.length > 0 || vt.length > 0) && /* @__PURE__ */ u("div", { className: "mt-1 flex flex-wrap items-baseline gap-x-4 gap-y-0.5 pl-0.5 text-[11px]", children: [
|
|
1886
|
-
n.map((
|
|
1887
|
-
/* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children:
|
|
1903
|
+
n.map((x) => /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
|
|
1904
|
+
/* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: x.label ?? M(x.field.split(".")[0]) }),
|
|
1888
1905
|
" ",
|
|
1889
|
-
/* @__PURE__ */ s("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(St(
|
|
1890
|
-
] },
|
|
1891
|
-
Or.map((
|
|
1892
|
-
/* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children:
|
|
1906
|
+
/* @__PURE__ */ s("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(St(Ie(c.key), x.field), x.format) })
|
|
1907
|
+
] }, x.field)),
|
|
1908
|
+
Or.map((x) => /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
|
|
1909
|
+
/* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: x.label ?? M(x.key) }),
|
|
1893
1910
|
" ",
|
|
1894
|
-
/* @__PURE__ */ s("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(tt(
|
|
1895
|
-
] },
|
|
1911
|
+
/* @__PURE__ */ s("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(tt(x.key, c.key), x.format) })
|
|
1912
|
+
] }, x.key)),
|
|
1896
1913
|
qn(c.row),
|
|
1897
|
-
xn(c.row).map((
|
|
1914
|
+
xn(c.row).map((x) => /* @__PURE__ */ u(
|
|
1898
1915
|
"span",
|
|
1899
1916
|
{
|
|
1900
1917
|
className: "inline-flex items-center gap-1 whitespace-nowrap rounded bg-amber-50 px-1.5 py-px text-[10.5px] font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-300",
|
|
1901
|
-
"data-catalog-row-flag":
|
|
1918
|
+
"data-catalog-row-flag": x,
|
|
1902
1919
|
children: [
|
|
1903
1920
|
/* @__PURE__ */ s(De, { className: "h-3 w-3" }),
|
|
1904
|
-
|
|
1921
|
+
x
|
|
1905
1922
|
]
|
|
1906
1923
|
},
|
|
1907
|
-
|
|
1924
|
+
x
|
|
1908
1925
|
)),
|
|
1909
|
-
vt.map((
|
|
1910
|
-
const
|
|
1926
|
+
vt.map((x) => {
|
|
1927
|
+
const A = _n(x, c);
|
|
1911
1928
|
return /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
|
|
1912
|
-
/* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children:
|
|
1929
|
+
/* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: x.label ?? M(x.field) }),
|
|
1913
1930
|
" ",
|
|
1914
|
-
/* @__PURE__ */ s("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: l(
|
|
1915
|
-
] },
|
|
1931
|
+
/* @__PURE__ */ s("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: l(A, x.format) })
|
|
1932
|
+
] }, x.field);
|
|
1916
1933
|
})
|
|
1917
1934
|
] }),
|
|
1918
|
-
|
|
1935
|
+
_ && /* @__PURE__ */ u("p", { className: "mt-1 flex items-center gap-1 pl-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400", children: [
|
|
1919
1936
|
/* @__PURE__ */ s(De, { className: "h-3 w-3 shrink-0" }),
|
|
1920
1937
|
Gt,
|
|
1921
1938
|
" is ",
|
|
1922
|
-
ke(
|
|
1939
|
+
ke(_.available, "number"),
|
|
1923
1940
|
" —",
|
|
1924
1941
|
" ",
|
|
1925
|
-
ke(
|
|
1942
|
+
ke(_.qty, "number"),
|
|
1926
1943
|
" requested"
|
|
1927
1944
|
] }),
|
|
1928
|
-
!v &&
|
|
1945
|
+
!v && vs(
|
|
1929
1946
|
{
|
|
1930
1947
|
...c.row,
|
|
1931
1948
|
...Object.fromEntries(
|
|
1932
|
-
We.filter((
|
|
1933
|
-
var
|
|
1949
|
+
We.filter((x) => c.row[x] == null || c.row[x] === "").map((x) => {
|
|
1950
|
+
var A;
|
|
1934
1951
|
return [
|
|
1935
|
-
|
|
1936
|
-
|
|
1952
|
+
x,
|
|
1953
|
+
Le(((A = a.compute_fields) == null ? void 0 : A[x]) ?? "", c.row)
|
|
1937
1954
|
];
|
|
1938
1955
|
})
|
|
1939
1956
|
)
|
|
@@ -1958,45 +1975,46 @@ ${A}`,
|
|
|
1958
1975
|
);
|
|
1959
1976
|
}),
|
|
1960
1977
|
(() => {
|
|
1961
|
-
const c = pe.filter((
|
|
1962
|
-
const
|
|
1963
|
-
return !(
|
|
1964
|
-
}), m = (
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1978
|
+
const c = pe.filter((_) => {
|
|
1979
|
+
const O = _.row.id != null ? String(_.row.id) : null;
|
|
1980
|
+
return !(O != null && ft.has(O));
|
|
1981
|
+
}), m = (_) => xs(
|
|
1982
|
+
c.map((O) => O.row),
|
|
1983
|
+
_,
|
|
1984
|
+
a.compute_fields
|
|
1985
|
+
), f = (_) => {
|
|
1986
|
+
var O;
|
|
1987
|
+
return ((O = a.field_formats) == null ? void 0 : O[_]) ?? "number";
|
|
1988
|
+
}, v = (_) => /* @__PURE__ */ s(
|
|
1971
1989
|
"span",
|
|
1972
1990
|
{
|
|
1973
1991
|
...we.box(
|
|
1974
|
-
`s:${
|
|
1992
|
+
`s:${_}`,
|
|
1975
1993
|
"w-20 shrink-0",
|
|
1976
1994
|
"truncate text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100"
|
|
1977
1995
|
),
|
|
1978
|
-
children: ke(m(
|
|
1996
|
+
children: ke(m(_), f(_))
|
|
1979
1997
|
},
|
|
1980
|
-
|
|
1998
|
+
_
|
|
1981
1999
|
);
|
|
1982
2000
|
return /* @__PURE__ */ u("div", { className: "flex items-center gap-4 border-t border-slate-200 bg-slate-50 px-3 py-1.5 dark:border-border dark:bg-muted/40", children: [
|
|
1983
2001
|
/* @__PURE__ */ s("span", { className: "flex-1 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Total" }),
|
|
1984
|
-
Ft.map((
|
|
1985
|
-
const
|
|
1986
|
-
return
|
|
2002
|
+
Ft.map((_) => {
|
|
2003
|
+
const O = p(_);
|
|
2004
|
+
return O ? /* @__PURE__ */ s("span", { ...we.box(O, "w-20 shrink-0") }, _) : /* @__PURE__ */ s("span", { className: "w-20 shrink-0" }, _);
|
|
1987
2005
|
}),
|
|
1988
2006
|
/* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: ke(m(G), "number") }),
|
|
1989
2007
|
We.map(v),
|
|
1990
|
-
!
|
|
2008
|
+
!b && /* @__PURE__ */ s("span", { className: "w-6 shrink-0" })
|
|
1991
2009
|
] });
|
|
1992
2010
|
})()
|
|
1993
2011
|
] });
|
|
1994
2012
|
})()
|
|
1995
2013
|
] }),
|
|
1996
|
-
on &&
|
|
1997
|
-
|
|
2014
|
+
on && g && /* @__PURE__ */ s(
|
|
2015
|
+
$s,
|
|
1998
2016
|
{
|
|
1999
|
-
catalogCol:
|
|
2017
|
+
catalogCol: g,
|
|
2000
2018
|
tmpl: J,
|
|
2001
2019
|
sectionBy: a.section_by,
|
|
2002
2020
|
sectionM2M: V,
|
|
@@ -2018,25 +2036,25 @@ ${A}`,
|
|
|
2018
2036
|
d
|
|
2019
2037
|
] });
|
|
2020
2038
|
}
|
|
2021
|
-
function
|
|
2039
|
+
function _s({
|
|
2022
2040
|
builder: d,
|
|
2023
|
-
defaultItemField:
|
|
2024
|
-
catalogCol:
|
|
2025
|
-
catalogFields:
|
|
2041
|
+
defaultItemField: h,
|
|
2042
|
+
catalogCol: y,
|
|
2043
|
+
catalogFields: N,
|
|
2026
2044
|
tmpl: a,
|
|
2027
|
-
currentQty:
|
|
2045
|
+
currentQty: b,
|
|
2028
2046
|
addQty: k,
|
|
2029
2047
|
qtyStep: j,
|
|
2030
|
-
readOnly:
|
|
2048
|
+
readOnly: w
|
|
2031
2049
|
}) {
|
|
2032
|
-
const P = Lt(), ee = d.item_field ??
|
|
2050
|
+
const P = Lt(), ee = d.item_field ?? h, [Y, _e] = H(!1), [Z, z] = H({}), [ne, G] = H("1"), [se, xe] = H(!1), Oe = F(
|
|
2033
2051
|
() => [
|
|
2034
2052
|
"id",
|
|
2035
2053
|
ee,
|
|
2036
2054
|
...d.attributes.flatMap((q) => [`${q.field}.id`, `${q.field}.${q.label_field}`])
|
|
2037
2055
|
].join(","),
|
|
2038
2056
|
[ee, d.attributes]
|
|
2039
|
-
), { data: U = [], isLoading:
|
|
2057
|
+
), { data: U = [], isLoading: Ae } = K({
|
|
2040
2058
|
queryKey: [
|
|
2041
2059
|
"catalog-builder",
|
|
2042
2060
|
d.collection,
|
|
@@ -2044,7 +2062,7 @@ function Ns({
|
|
|
2044
2062
|
JSON.stringify(d.filter ?? null)
|
|
2045
2063
|
],
|
|
2046
2064
|
queryFn: () => P.request(
|
|
2047
|
-
|
|
2065
|
+
R(`/items/${d.collection}`, {
|
|
2048
2066
|
limit: 2e3,
|
|
2049
2067
|
fields: Oe,
|
|
2050
2068
|
...d.filter ? { filter: JSON.stringify(d.filter) } : {}
|
|
@@ -2052,46 +2070,46 @@ function Ns({
|
|
|
2052
2070
|
).then((q) => q.data ?? []),
|
|
2053
2071
|
enabled: Y,
|
|
2054
2072
|
staleTime: 6e4
|
|
2055
|
-
}), ye = (q,
|
|
2073
|
+
}), ye = (q, g) => {
|
|
2056
2074
|
var le;
|
|
2057
|
-
const L = q[
|
|
2075
|
+
const L = q[g];
|
|
2058
2076
|
if (L == null) return null;
|
|
2059
2077
|
if (typeof L == "object") {
|
|
2060
|
-
const B = L, $ = ((le = d.attributes.find((J) => J.field ===
|
|
2078
|
+
const B = L, $ = ((le = d.attributes.find((J) => J.field === g)) == null ? void 0 : le.label_field) ?? "id";
|
|
2061
2079
|
return { id: String(B.id ?? ""), label: String(B[$] ?? B.id ?? "") };
|
|
2062
2080
|
}
|
|
2063
2081
|
return { id: String(L), label: String(L) };
|
|
2064
|
-
},
|
|
2065
|
-
(
|
|
2082
|
+
}, ue = (q) => U.filter(
|
|
2083
|
+
(g) => d.attributes.slice(0, q).every((L) => {
|
|
2066
2084
|
var B;
|
|
2067
2085
|
const le = Z[L.field];
|
|
2068
|
-
return le ? ((B = ye(
|
|
2086
|
+
return le ? ((B = ye(g, L.field)) == null ? void 0 : B.id) === le : !0;
|
|
2069
2087
|
})
|
|
2070
2088
|
), ie = d.attributes.every((q) => Z[q.field]), ae = ie ? U.find(
|
|
2071
|
-
(q) => d.attributes.every((
|
|
2089
|
+
(q) => d.attributes.every((g) => {
|
|
2072
2090
|
var L;
|
|
2073
|
-
return ((L = ye(q,
|
|
2091
|
+
return ((L = ye(q, g.field)) == null ? void 0 : L.id) === Z[g.field];
|
|
2074
2092
|
})
|
|
2075
2093
|
) : void 0, Q = (ae == null ? void 0 : ae[ee]) != null ? String(ae[ee]) : null, { data: X } = K({
|
|
2076
|
-
queryKey: ["catalog-builder-item",
|
|
2094
|
+
queryKey: ["catalog-builder-item", y, N, Q],
|
|
2077
2095
|
queryFn: () => P.request(
|
|
2078
|
-
|
|
2096
|
+
R(`/items/${y}`, {
|
|
2079
2097
|
filter: JSON.stringify({ id: { _eq: Q } }),
|
|
2080
|
-
fields:
|
|
2098
|
+
fields: N,
|
|
2081
2099
|
limit: 1
|
|
2082
2100
|
})
|
|
2083
2101
|
).then((q) => {
|
|
2084
|
-
var
|
|
2085
|
-
return ((
|
|
2102
|
+
var g;
|
|
2103
|
+
return ((g = q.data) == null ? void 0 : g[0]) ?? null;
|
|
2086
2104
|
}),
|
|
2087
2105
|
enabled: !!Q,
|
|
2088
2106
|
staleTime: 6e4
|
|
2089
|
-
}), Se = Number(ne),
|
|
2090
|
-
async function
|
|
2091
|
-
if (!(!
|
|
2107
|
+
}), Se = Number(ne), me = !!Q && !!X && !se && ne.trim() !== "" && Number.isFinite(Se) && Se > 0 && (j === "any" || Number.isInteger(Se));
|
|
2108
|
+
async function Ke() {
|
|
2109
|
+
if (!(!me || !Q || !X)) {
|
|
2092
2110
|
xe(!0);
|
|
2093
2111
|
try {
|
|
2094
|
-
await k(Q, (
|
|
2112
|
+
await k(Q, (b(Q) ?? 0) + Se, X), z({}), G("1");
|
|
2095
2113
|
} finally {
|
|
2096
2114
|
xe(!1);
|
|
2097
2115
|
}
|
|
@@ -2118,13 +2136,13 @@ function Ns({
|
|
|
2118
2136
|
]
|
|
2119
2137
|
}
|
|
2120
2138
|
),
|
|
2121
|
-
Y && /* @__PURE__ */ s("div", { className: "space-y-2 border-t border-slate-200 p-3 dark:border-border", children:
|
|
2139
|
+
Y && /* @__PURE__ */ s("div", { className: "space-y-2 border-t border-slate-200 p-3 dark:border-border", children: Ae ? /* @__PURE__ */ u("div", { className: "flex items-center gap-2 py-2 text-slate-400", children: [
|
|
2122
2140
|
/* @__PURE__ */ s(ce, { className: "h-4 w-4 animate-spin" }),
|
|
2123
2141
|
" Loading options…"
|
|
2124
2142
|
] }) : /* @__PURE__ */ u("div", { className: "flex flex-wrap items-end gap-3", children: [
|
|
2125
|
-
d.attributes.map((q,
|
|
2143
|
+
d.attributes.map((q, g) => {
|
|
2126
2144
|
const L = /* @__PURE__ */ new Map();
|
|
2127
|
-
for (const B of
|
|
2145
|
+
for (const B of ue(g)) {
|
|
2128
2146
|
const $ = ye(B, q.field);
|
|
2129
2147
|
$ != null && $.id && L.set($.id, $.label);
|
|
2130
2148
|
}
|
|
@@ -2132,16 +2150,16 @@ function Ns({
|
|
|
2132
2150
|
([, B], [, $]) => B.localeCompare($, void 0, { numeric: !0 })
|
|
2133
2151
|
);
|
|
2134
2152
|
return /* @__PURE__ */ s(
|
|
2135
|
-
|
|
2153
|
+
qs,
|
|
2136
2154
|
{
|
|
2137
2155
|
label: M(q.field),
|
|
2138
2156
|
value: Z[q.field] ?? null,
|
|
2139
2157
|
valueLabel: Z[q.field] ? L.get(Z[q.field]) ?? Z[q.field] : null,
|
|
2140
2158
|
options: le,
|
|
2141
|
-
disabled:
|
|
2159
|
+
disabled: g > 0 && !Z[d.attributes[g - 1].field],
|
|
2142
2160
|
onChange: (B) => z(($) => {
|
|
2143
2161
|
const J = {};
|
|
2144
|
-
for (let E = 0; E <
|
|
2162
|
+
for (let E = 0; E < g; E++) {
|
|
2145
2163
|
const oe = d.attributes[E].field;
|
|
2146
2164
|
$[oe] && (J[oe] = $[oe]);
|
|
2147
2165
|
}
|
|
@@ -2153,11 +2171,11 @@ function Ns({
|
|
|
2153
2171
|
}),
|
|
2154
2172
|
/* @__PURE__ */ s("div", { className: "flex min-h-[28px] flex-1 items-center gap-2", children: Q && X ? /* @__PURE__ */ u(ve, { children: [
|
|
2155
2173
|
/* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: ze(a, X) }),
|
|
2156
|
-
(
|
|
2157
|
-
|
|
2174
|
+
(b(Q) ?? 0) > 0 && /* @__PURE__ */ u("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#00728d] dark:bg-nvr-cyan/15 dark:text-nvr-cyan", children: [
|
|
2175
|
+
b(Q),
|
|
2158
2176
|
" in summary"
|
|
2159
2177
|
] }),
|
|
2160
|
-
!
|
|
2178
|
+
!w && /* @__PURE__ */ u(ve, { children: [
|
|
2161
2179
|
/* @__PURE__ */ s(
|
|
2162
2180
|
"input",
|
|
2163
2181
|
{
|
|
@@ -2168,7 +2186,7 @@ function Ns({
|
|
|
2168
2186
|
"aria-label": "Quantity to add",
|
|
2169
2187
|
onChange: (q) => G(q.target.value),
|
|
2170
2188
|
onKeyDown: (q) => {
|
|
2171
|
-
q.key === "Enter" && (q.preventDefault(),
|
|
2189
|
+
q.key === "Enter" && (q.preventDefault(), Ke());
|
|
2172
2190
|
},
|
|
2173
2191
|
className: "h-7 w-20 shrink-0 rounded border border-slate-200 bg-white px-2 text-right text-[12px] outline-none focus:border-nvr-cyan dark:border-border dark:bg-background"
|
|
2174
2192
|
}
|
|
@@ -2177,8 +2195,8 @@ function Ns({
|
|
|
2177
2195
|
"button",
|
|
2178
2196
|
{
|
|
2179
2197
|
type: "button",
|
|
2180
|
-
onClick: () => void
|
|
2181
|
-
disabled: !
|
|
2198
|
+
onClick: () => void Ke(),
|
|
2199
|
+
disabled: !me,
|
|
2182
2200
|
className: "flex h-7 shrink-0 items-center gap-1 rounded bg-nvr-cyan px-2.5 text-[12px] font-medium text-white hover:bg-nvr-cyan/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan focus-visible:ring-offset-1 disabled:opacity-50",
|
|
2183
2201
|
children: [
|
|
2184
2202
|
se ? /* @__PURE__ */ s(ce, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ s(Qn, { className: "h-3.5 w-3.5" }),
|
|
@@ -2191,58 +2209,58 @@ function Ns({
|
|
|
2191
2209
|
] }) })
|
|
2192
2210
|
] });
|
|
2193
2211
|
}
|
|
2194
|
-
function
|
|
2212
|
+
function Ss({
|
|
2195
2213
|
parentCollection: d,
|
|
2196
|
-
field:
|
|
2197
|
-
id:
|
|
2214
|
+
field: h,
|
|
2215
|
+
id: y
|
|
2198
2216
|
}) {
|
|
2199
2217
|
var j;
|
|
2200
|
-
const
|
|
2218
|
+
const N = Lt(), { data: a = [] } = K({
|
|
2201
2219
|
queryKey: ["collection-relations", d],
|
|
2202
|
-
queryFn: () =>
|
|
2220
|
+
queryFn: () => N.request(R(`/collections/${d}`)).then((w) => {
|
|
2203
2221
|
var P;
|
|
2204
|
-
return ((P =
|
|
2222
|
+
return ((P = w.data) == null ? void 0 : P.relations) ?? [];
|
|
2205
2223
|
}),
|
|
2206
2224
|
enabled: !!d,
|
|
2207
2225
|
staleTime: 10 * 6e4
|
|
2208
|
-
}),
|
|
2209
|
-
(
|
|
2226
|
+
}), b = ((j = a.find(
|
|
2227
|
+
(w) => w.many_collection === d && w.many_field === h && !w.junction_field
|
|
2210
2228
|
)) == null ? void 0 : j.one_collection) ?? null, { data: k } = K({
|
|
2211
|
-
queryKey: ["col-meta",
|
|
2212
|
-
queryFn: () =>
|
|
2213
|
-
enabled: !!
|
|
2229
|
+
queryKey: ["col-meta", b],
|
|
2230
|
+
queryFn: () => N.request(R(`/collections/${b}`)).then((w) => w.data),
|
|
2231
|
+
enabled: !!b,
|
|
2214
2232
|
staleTime: 3e5
|
|
2215
2233
|
});
|
|
2216
|
-
return
|
|
2234
|
+
return b ? /* @__PURE__ */ s(hs, { collection: b, id: y, displayTemplate: k == null ? void 0 : k.display_template }) : /* @__PURE__ */ u(ve, { children: [
|
|
2217
2235
|
"this ",
|
|
2218
|
-
M(
|
|
2236
|
+
M(h)
|
|
2219
2237
|
] });
|
|
2220
2238
|
}
|
|
2221
2239
|
function Xr({
|
|
2222
2240
|
text: d,
|
|
2223
|
-
highlight:
|
|
2224
|
-
className:
|
|
2225
|
-
...
|
|
2241
|
+
highlight: h,
|
|
2242
|
+
className: y,
|
|
2243
|
+
...N
|
|
2226
2244
|
}) {
|
|
2227
2245
|
const a = rs(d);
|
|
2228
|
-
return /* @__PURE__ */ s("span", { ref: a, className: C("truncate",
|
|
2246
|
+
return /* @__PURE__ */ s("span", { ref: a, className: C("truncate", y), ...N, children: h ? /* @__PURE__ */ s(dr, { text: d, query: h }) : d });
|
|
2229
2247
|
}
|
|
2230
|
-
function
|
|
2248
|
+
function qs({
|
|
2231
2249
|
label: d,
|
|
2232
|
-
value:
|
|
2233
|
-
valueLabel:
|
|
2234
|
-
options:
|
|
2250
|
+
value: h,
|
|
2251
|
+
valueLabel: y,
|
|
2252
|
+
options: N,
|
|
2235
2253
|
disabled: a,
|
|
2236
|
-
onChange:
|
|
2254
|
+
onChange: b
|
|
2237
2255
|
}) {
|
|
2238
|
-
const [k, j] = H(!1),
|
|
2256
|
+
const [k, j] = H(!1), w = Ee(null);
|
|
2239
2257
|
return Te(() => {
|
|
2240
2258
|
if (!k) return;
|
|
2241
2259
|
const P = (ee) => {
|
|
2242
|
-
|
|
2260
|
+
w.current && !w.current.contains(ee.target) && j(!1);
|
|
2243
2261
|
};
|
|
2244
2262
|
return document.addEventListener("mousedown", P), () => document.removeEventListener("mousedown", P);
|
|
2245
|
-
}, [k]), /* @__PURE__ */ u("div", { ref:
|
|
2263
|
+
}, [k]), /* @__PURE__ */ u("div", { ref: w, className: "relative", children: [
|
|
2246
2264
|
/* @__PURE__ */ s("p", { className: "mb-1 text-[10px] font-medium text-slate-500 dark:text-slate-400", children: d }),
|
|
2247
2265
|
/* @__PURE__ */ u(
|
|
2248
2266
|
"button",
|
|
@@ -2252,18 +2270,18 @@ function _s({
|
|
|
2252
2270
|
onClick: () => j((P) => !P),
|
|
2253
2271
|
className: "flex w-44 items-center justify-between rounded border border-slate-200 bg-white px-2 py-1.5 text-left text-[12px] text-slate-700 hover:border-slate-300 disabled:opacity-50 dark:border-border dark:bg-background dark:text-slate-200",
|
|
2254
2272
|
children: [
|
|
2255
|
-
/* @__PURE__ */ s("span", { className: C("truncate", !
|
|
2273
|
+
/* @__PURE__ */ s("span", { className: C("truncate", !y && "text-slate-400"), children: y ?? "Select…" }),
|
|
2256
2274
|
/* @__PURE__ */ s(Bn, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
|
|
2257
2275
|
]
|
|
2258
2276
|
}
|
|
2259
2277
|
),
|
|
2260
2278
|
k && /* @__PURE__ */ u("div", { className: "absolute z-50 mt-1 max-h-52 w-44 overflow-y-auto rounded-md border border-border bg-popover py-1 shadow-md", children: [
|
|
2261
|
-
|
|
2279
|
+
h && /* @__PURE__ */ u(
|
|
2262
2280
|
"button",
|
|
2263
2281
|
{
|
|
2264
2282
|
type: "button",
|
|
2265
2283
|
onClick: () => {
|
|
2266
|
-
|
|
2284
|
+
b(null), j(!1);
|
|
2267
2285
|
},
|
|
2268
2286
|
className: "flex w-full items-center gap-1.5 border-b border-slate-100 px-2 py-1 text-left text-[12px] text-slate-500 hover:bg-muted dark:border-border dark:text-slate-400",
|
|
2269
2287
|
children: [
|
|
@@ -2272,16 +2290,16 @@ function _s({
|
|
|
2272
2290
|
]
|
|
2273
2291
|
}
|
|
2274
2292
|
),
|
|
2275
|
-
|
|
2293
|
+
N.map(([P, ee]) => /* @__PURE__ */ s(
|
|
2276
2294
|
"button",
|
|
2277
2295
|
{
|
|
2278
2296
|
type: "button",
|
|
2279
2297
|
onClick: () => {
|
|
2280
|
-
|
|
2298
|
+
b(P), j(!1);
|
|
2281
2299
|
},
|
|
2282
2300
|
className: C(
|
|
2283
2301
|
"block w-full truncate px-2 py-1 text-left text-[12px] hover:bg-muted",
|
|
2284
|
-
P ===
|
|
2302
|
+
P === h ? "font-medium text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
|
|
2285
2303
|
),
|
|
2286
2304
|
children: ee
|
|
2287
2305
|
},
|
|
@@ -2290,16 +2308,16 @@ function _s({
|
|
|
2290
2308
|
] })
|
|
2291
2309
|
] });
|
|
2292
2310
|
}
|
|
2293
|
-
function
|
|
2311
|
+
function $s({
|
|
2294
2312
|
catalogCol: d,
|
|
2295
|
-
tmpl:
|
|
2296
|
-
sectionBy:
|
|
2297
|
-
sectionM2M:
|
|
2313
|
+
tmpl: h,
|
|
2314
|
+
sectionBy: y,
|
|
2315
|
+
sectionM2M: N,
|
|
2298
2316
|
pinnedSet: a,
|
|
2299
|
-
pinnedIds:
|
|
2317
|
+
pinnedIds: b,
|
|
2300
2318
|
savingIds: k,
|
|
2301
2319
|
relatedCols: j,
|
|
2302
|
-
parentDraft:
|
|
2320
|
+
parentDraft: w,
|
|
2303
2321
|
onToggle: P,
|
|
2304
2322
|
onClose: ee,
|
|
2305
2323
|
anchor: Y
|
|
@@ -2312,20 +2330,20 @@ function Ss({
|
|
|
2312
2330
|
var i;
|
|
2313
2331
|
(i = Oe.current) == null || i.focus();
|
|
2314
2332
|
}, []), Te(() => {
|
|
2315
|
-
const i = (
|
|
2316
|
-
|
|
2333
|
+
const i = (S) => {
|
|
2334
|
+
S.key === "Escape" && (S.stopPropagation(), ee());
|
|
2317
2335
|
};
|
|
2318
2336
|
return window.addEventListener("keydown", i, !0), () => window.removeEventListener("keydown", i, !0);
|
|
2319
2337
|
}, [ee]);
|
|
2320
2338
|
const U = F(() => {
|
|
2321
|
-
var
|
|
2322
|
-
const i = (
|
|
2339
|
+
var S;
|
|
2340
|
+
const i = (S = [...(h ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : S[1];
|
|
2323
2341
|
return i && !i.includes(".") ? i : "id";
|
|
2324
|
-
}, [
|
|
2342
|
+
}, [h]), Ae = !N && y.includes(".") ? `*,${y}` : "*", ye = 50, { data: ue, isFetching: ie } = K({
|
|
2325
2343
|
queryKey: ["favorites-manager-list", d, ne, U, se],
|
|
2326
2344
|
queryFn: () => _e.request(
|
|
2327
|
-
|
|
2328
|
-
fields:
|
|
2345
|
+
R(`/items/${d}`, {
|
|
2346
|
+
fields: Ae,
|
|
2329
2347
|
limit: ye,
|
|
2330
2348
|
page: se,
|
|
2331
2349
|
sort: U,
|
|
@@ -2334,97 +2352,97 @@ function Ss({
|
|
|
2334
2352
|
),
|
|
2335
2353
|
staleTime: 3e4,
|
|
2336
2354
|
placeholderData: (i) => i
|
|
2337
|
-
}), ae = ((
|
|
2338
|
-
queryKey: ["favorites-manager-pinned", d,
|
|
2355
|
+
}), ae = ((ue == null ? void 0 : ue.data) ?? []).filter((i) => !a.has(String(i.id))), Q = (ue == null ? void 0 : ue.total) ?? ae.length, X = Math.max(1, Math.ceil(Q / ye)), { data: Se = [] } = K({
|
|
2356
|
+
queryKey: ["favorites-manager-pinned", d, Ae, b.join(",")],
|
|
2339
2357
|
queryFn: () => _e.request(
|
|
2340
|
-
|
|
2341
|
-
filter: JSON.stringify({ id: { _in:
|
|
2342
|
-
fields:
|
|
2343
|
-
limit:
|
|
2358
|
+
R(`/items/${d}`, {
|
|
2359
|
+
filter: JSON.stringify({ id: { _in: b } }),
|
|
2360
|
+
fields: Ae,
|
|
2361
|
+
limit: b.length,
|
|
2344
2362
|
sort: U
|
|
2345
2363
|
})
|
|
2346
2364
|
).then((i) => i.data ?? []),
|
|
2347
|
-
enabled:
|
|
2365
|
+
enabled: b.length > 0,
|
|
2348
2366
|
staleTime: 3e4
|
|
2349
|
-
}),
|
|
2367
|
+
}), me = F(() => {
|
|
2350
2368
|
const i = /* @__PURE__ */ new Set();
|
|
2351
|
-
for (const
|
|
2352
|
-
for (const
|
|
2369
|
+
for (const S of ae) i.add(String(S.id));
|
|
2370
|
+
for (const S of b) i.add(S);
|
|
2353
2371
|
return [...i];
|
|
2354
|
-
}, [ae,
|
|
2355
|
-
queryKey: ["favorites-manager-sections",
|
|
2372
|
+
}, [ae, b]), { data: Ke = /* @__PURE__ */ new Map() } = K({
|
|
2373
|
+
queryKey: ["favorites-manager-sections", N == null ? void 0 : N.junction, me.join(",")],
|
|
2356
2374
|
queryFn: async () => {
|
|
2357
|
-
const i =
|
|
2375
|
+
const i = N, S = await Et(_e, `/items/${i.junction}`, {
|
|
2358
2376
|
fields: `${i.fkToItem},${i.fkToSection}`,
|
|
2359
|
-
filter: JSON.stringify({ [i.fkToItem]: { _in:
|
|
2360
|
-
}), I = [...new Set(
|
|
2377
|
+
filter: JSON.stringify({ [i.fkToItem]: { _in: me } })
|
|
2378
|
+
}), I = [...new Set(S.map((T) => String(T[i.fkToSection])))], W = I.length ? await Et(_e, `/items/${i.target}`, {
|
|
2361
2379
|
fields: `id,${i.labelPath}`,
|
|
2362
2380
|
filter: JSON.stringify({ id: { _in: I } })
|
|
2363
2381
|
}) : [], D = new Map(
|
|
2364
2382
|
W.map((T) => [String(T.id), String(rn(T, i.labelPath) ?? "")])
|
|
2365
|
-
),
|
|
2366
|
-
for (const T of
|
|
2383
|
+
), fe = /* @__PURE__ */ new Map();
|
|
2384
|
+
for (const T of S) {
|
|
2367
2385
|
const be = D.get(String(T[i.fkToSection]));
|
|
2368
2386
|
if (!be) continue;
|
|
2369
|
-
const de = String(T[i.fkToItem]), qe =
|
|
2370
|
-
qe.includes(be) || qe.push(be),
|
|
2387
|
+
const de = String(T[i.fkToItem]), qe = fe.get(de) ?? [];
|
|
2388
|
+
qe.includes(be) || qe.push(be), fe.set(de, qe);
|
|
2371
2389
|
}
|
|
2372
|
-
return
|
|
2390
|
+
return fe;
|
|
2373
2391
|
},
|
|
2374
|
-
enabled: !!
|
|
2392
|
+
enabled: !!N && me.length > 0,
|
|
2375
2393
|
staleTime: 6e4
|
|
2376
|
-
}), q = (i) =>
|
|
2377
|
-
const
|
|
2378
|
-
return typeof
|
|
2394
|
+
}), q = (i) => h ? ze(h, i) : String(i.cifa_number ?? i.name ?? `#${i.id}`), g = (i) => {
|
|
2395
|
+
const S = i.description ?? i.long_description ?? i.name;
|
|
2396
|
+
return typeof S == "string" && S.trim() && S.trim() !== q(i) ? S : "";
|
|
2379
2397
|
}, L = (i) => {
|
|
2380
|
-
if (
|
|
2381
|
-
if (!
|
|
2382
|
-
const
|
|
2383
|
-
return
|
|
2384
|
-
}, le = (i,
|
|
2385
|
-
if (
|
|
2398
|
+
if (N) return (Ke.get(String(i.id)) ?? []).join(", ");
|
|
2399
|
+
if (!y) return "";
|
|
2400
|
+
const S = ze(`{{${y}}}`, i);
|
|
2401
|
+
return S === `{{${y}}}` ? "" : S;
|
|
2402
|
+
}, le = (i, S) => {
|
|
2403
|
+
if (S === "presence")
|
|
2386
2404
|
return i == null || i === "" || Number(i) === 0 ? "No" : "Yes";
|
|
2387
2405
|
if (i == null || i === "") return "—";
|
|
2388
2406
|
const I = Number(i);
|
|
2389
|
-
return
|
|
2407
|
+
return S === "currency" && Number.isFinite(I) ? I.toLocaleString("en-US", { style: "currency", currency: "USD" }) : S === "number" && Number.isFinite(I) ? I.toLocaleString() : String(i);
|
|
2390
2408
|
}, B = lr({
|
|
2391
2409
|
queries: j.map((i) => {
|
|
2392
|
-
const
|
|
2410
|
+
const S = Me(i.match, w);
|
|
2393
2411
|
return {
|
|
2394
2412
|
queryKey: [
|
|
2395
2413
|
"favorites-manager-related",
|
|
2396
2414
|
i.key,
|
|
2397
2415
|
i.collection,
|
|
2398
|
-
JSON.stringify(
|
|
2399
|
-
|
|
2416
|
+
JSON.stringify(S),
|
|
2417
|
+
me.join(",")
|
|
2400
2418
|
],
|
|
2401
2419
|
queryFn: async () => {
|
|
2402
2420
|
const I = await _e.request(
|
|
2403
|
-
|
|
2404
|
-
filter: JSON.stringify({ [i.item_field]: { _in:
|
|
2421
|
+
R(`/items/${i.collection}`, {
|
|
2422
|
+
filter: JSON.stringify({ [i.item_field]: { _in: me }, ...S ?? {} }),
|
|
2405
2423
|
fields: `${i.item_field},${i.value_field}`,
|
|
2406
2424
|
limit: 1e3
|
|
2407
2425
|
})
|
|
2408
2426
|
).then((D) => D.data ?? []), W = /* @__PURE__ */ new Map();
|
|
2409
2427
|
for (const D of I) {
|
|
2410
|
-
const
|
|
2411
|
-
be === void 0 ? W.set(
|
|
2428
|
+
const fe = String(D[i.item_field]), T = D[i.value_field], be = W.get(fe);
|
|
2429
|
+
be === void 0 ? W.set(fe, T) : Number.isFinite(Number(be)) && Number.isFinite(Number(T)) && W.set(fe, Number(be) + Number(T));
|
|
2412
2430
|
}
|
|
2413
2431
|
return W;
|
|
2414
2432
|
},
|
|
2415
|
-
enabled:
|
|
2433
|
+
enabled: me.length > 0 && (i.match === void 0 || S !== null),
|
|
2416
2434
|
staleTime: 3e4
|
|
2417
2435
|
};
|
|
2418
2436
|
})
|
|
2419
2437
|
}), $ = j.filter(
|
|
2420
|
-
(i) => i.match !== void 0 && Me(i.match,
|
|
2438
|
+
(i) => i.match !== void 0 && Me(i.match, w) === null
|
|
2421
2439
|
), J = (i) => {
|
|
2422
|
-
const
|
|
2440
|
+
const S = a.has(i);
|
|
2423
2441
|
return /* @__PURE__ */ s(
|
|
2424
2442
|
"button",
|
|
2425
2443
|
{
|
|
2426
2444
|
type: "button",
|
|
2427
|
-
title:
|
|
2445
|
+
title: S ? "Remove from favorites" : "Add to favorites",
|
|
2428
2446
|
disabled: k.has(i),
|
|
2429
2447
|
onClick: () => P(i),
|
|
2430
2448
|
className: "shrink-0 rounded p-1 transition-colors hover:bg-amber-100/60 dark:hover:bg-amber-400/10",
|
|
@@ -2433,20 +2451,20 @@ function Ss({
|
|
|
2433
2451
|
{
|
|
2434
2452
|
className: C(
|
|
2435
2453
|
"h-4 w-4",
|
|
2436
|
-
|
|
2454
|
+
S ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
|
|
2437
2455
|
)
|
|
2438
2456
|
}
|
|
2439
2457
|
)
|
|
2440
2458
|
}
|
|
2441
2459
|
);
|
|
2442
|
-
}, E = (i,
|
|
2443
|
-
const I = String(i.id), W =
|
|
2460
|
+
}, E = (i, S) => /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s("td", { colSpan: 4 + j.length, className: C("border-b px-3 py-1.5", S), children: i }) }), oe = (i, S) => {
|
|
2461
|
+
const I = String(i.id), W = g(i);
|
|
2444
2462
|
return /* @__PURE__ */ u(
|
|
2445
2463
|
"tr",
|
|
2446
2464
|
{
|
|
2447
2465
|
className: C(
|
|
2448
2466
|
"border-b border-slate-100 dark:border-border/50",
|
|
2449
|
-
|
|
2467
|
+
S % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30"
|
|
2450
2468
|
),
|
|
2451
2469
|
children: [
|
|
2452
2470
|
/* @__PURE__ */ s("td", { className: "px-2 py-1", children: J(I) }),
|
|
@@ -2454,7 +2472,7 @@ function Ss({
|
|
|
2454
2472
|
"button",
|
|
2455
2473
|
{
|
|
2456
2474
|
type: "button",
|
|
2457
|
-
onClick: () => tn(d, I,
|
|
2475
|
+
onClick: () => tn(d, I, w),
|
|
2458
2476
|
title: "View stock & planning detail",
|
|
2459
2477
|
className: "text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600",
|
|
2460
2478
|
children: q(i)
|
|
@@ -2462,9 +2480,9 @@ function Ss({
|
|
|
2462
2480
|
) : q(i) }),
|
|
2463
2481
|
/* @__PURE__ */ s("td", { className: "max-w-0 px-2 py-1", children: /* @__PURE__ */ s("p", { className: "truncate text-slate-600 dark:text-slate-300", "data-tip": W || void 0, children: W || "—" }) }),
|
|
2464
2482
|
/* @__PURE__ */ s("td", { className: "px-2 py-1", children: /* @__PURE__ */ s("p", { className: "truncate text-slate-500 dark:text-slate-400", children: L(i) || "—" }) }),
|
|
2465
|
-
j.map((D,
|
|
2483
|
+
j.map((D, fe) => {
|
|
2466
2484
|
var de, qe;
|
|
2467
|
-
const T = D.match !== void 0 && Me(D.match,
|
|
2485
|
+
const T = D.match !== void 0 && Me(D.match, w) === null, be = T || (qe = (de = B[fe]) == null ? void 0 : de.data) == null ? void 0 : qe.get(I);
|
|
2468
2486
|
return /* @__PURE__ */ s(
|
|
2469
2487
|
"td",
|
|
2470
2488
|
{
|
|
@@ -2478,7 +2496,7 @@ function Ss({
|
|
|
2478
2496
|
},
|
|
2479
2497
|
I
|
|
2480
2498
|
);
|
|
2481
|
-
}, lt = (Y == null ? void 0 : Y.closest('[role="dialog"]')) ?? document.body, V = Z.trim() ? Se.filter((i) => es(`${q(i)} ${
|
|
2499
|
+
}, lt = (Y == null ? void 0 : Y.closest('[role="dialog"]')) ?? document.body, V = Z.trim() ? Se.filter((i) => es(`${q(i)} ${g(i)} ${L(i)}`, Z)) : Se;
|
|
2482
2500
|
return Vn(
|
|
2483
2501
|
/* @__PURE__ */ u("div", { className: "fixed inset-0 z-[125]", role: "presentation", children: [
|
|
2484
2502
|
/* @__PURE__ */ s(
|
|
@@ -2563,7 +2581,7 @@ function Ss({
|
|
|
2563
2581
|
/* @__PURE__ */ u("span", { className: "flex items-center gap-1.5", children: [
|
|
2564
2582
|
/* @__PURE__ */ s(it, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
|
|
2565
2583
|
/* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Your favorites" }),
|
|
2566
|
-
/* @__PURE__ */ s("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children:
|
|
2584
|
+
/* @__PURE__ */ s("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: b.length })
|
|
2567
2585
|
] }),
|
|
2568
2586
|
"border-slate-200 bg-amber-50/70 dark:border-border dark:bg-amber-900/10"
|
|
2569
2587
|
),
|
|
@@ -2572,10 +2590,10 @@ function Ss({
|
|
|
2572
2590
|
{
|
|
2573
2591
|
colSpan: 4 + j.length,
|
|
2574
2592
|
className: "border-b border-slate-100 px-4 py-3 text-center text-[11px] text-slate-400 dark:border-border/50",
|
|
2575
|
-
children:
|
|
2593
|
+
children: b.length === 0 ? "No favorites yet — star the items you order most." : "No favorites match your search."
|
|
2576
2594
|
}
|
|
2577
2595
|
) }),
|
|
2578
|
-
V.map((i,
|
|
2596
|
+
V.map((i, S) => oe(i, S)),
|
|
2579
2597
|
E(
|
|
2580
2598
|
/* @__PURE__ */ u("span", { className: "flex items-center gap-1.5", children: [
|
|
2581
2599
|
/* @__PURE__ */ s(Rt, { className: "h-3 w-3 shrink-0 text-slate-400" }),
|
|
@@ -2593,7 +2611,7 @@ function Ss({
|
|
|
2593
2611
|
children: ne.trim() ? `No CIFAs match "${ne}".` : "No catalog items."
|
|
2594
2612
|
}
|
|
2595
2613
|
) }),
|
|
2596
|
-
ae.map((i,
|
|
2614
|
+
ae.map((i, S) => oe(i, S))
|
|
2597
2615
|
] })
|
|
2598
2616
|
] }) }),
|
|
2599
2617
|
X > 1 && /* @__PURE__ */ u("div", { className: "flex shrink-0 items-center justify-between border-t border-slate-200 px-3 py-2 dark:border-border", children: [
|
|
@@ -2645,13 +2663,15 @@ function Ss({
|
|
|
2645
2663
|
);
|
|
2646
2664
|
}
|
|
2647
2665
|
export {
|
|
2648
|
-
|
|
2666
|
+
Gs as CatalogPickerField,
|
|
2649
2667
|
cs as MAX_LINE_MONEY,
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2668
|
+
xs as footerSum,
|
|
2669
|
+
ks as gridPriceValue,
|
|
2670
|
+
vs as isUnpricedLine,
|
|
2671
|
+
Ns as issuesAfterLinesChanged,
|
|
2672
|
+
gs as lineComputeError,
|
|
2654
2673
|
Gr as matchesShowWhen,
|
|
2655
2674
|
ps as qtyEntryProblem,
|
|
2656
|
-
|
|
2675
|
+
ys as refusedQtyNote,
|
|
2676
|
+
ws as savedLinesSignature
|
|
2657
2677
|
};
|