@nivaro/react 0.3.99 → 0.3.101
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/useFormSchema.js +82 -85
- package/dist/hooks/useSessionRecorder.js +206 -175
- package/dist/index.d.ts +84 -16
- package/dist/index.js +627 -622
- package/dist/lib/commands.js +15 -11
- package/dist/shared/components/ActivityEntry.js +5 -5
- package/dist/shared/components/CollectionBrowserView.js +516 -503
- package/dist/shared/components/ItemEditForm.js +3471 -3465
- package/dist/shared/components/JobsTray.js +76 -61
- package/dist/shared/components/MyWorkView.js +133 -126
- package/dist/shared/components/NotificationBell.js +322 -289
- package/dist/shared/components/RecordCompare.js +38 -40
- package/dist/shared/components/RecordReadView.js +119 -119
- package/dist/shared/components/TipLayer.js +56 -41
- package/dist/shared/components/cbv/FoundElsewhere.js +61 -0
- package/dist/shared/components/integrations/console/SignalCard.js +40 -40
- package/dist/shared/components/integrations/console/drill/SubmissionDrill.js +95 -73
- package/dist/shared/components/integrations/console/drill/status.js +23 -18
- package/dist/shared/components/item-edit/InlineGridField.js +45 -45
- package/dist/shared/components/item-edit/InlineTableField.js +750 -749
- package/dist/shared/components/item-edit/QuickPickerDialog.js +44 -44
- package/dist/shared/components/item-edit/RawEditSheet.js +122 -114
- package/dist/shared/components/item-edit/RecordInsights.js +86 -86
- package/dist/shared/components/item-edit/RelationCombobox.js +454 -378
- package/dist/shared/components/item-edit/SummaryPanel.js +56 -48
- package/dist/shared/components/item-edit/header-path-preview.js +46 -34
- package/dist/shared/components/item-edit/related-missing.js +75 -19
- package/dist/shared/components/notifications/DeliveryChips.js +1 -2
- package/dist/shared/components/notifications/NotificationCenterView.js +249 -226
- package/dist/shared/components/panels/AccessDeniedPanel.js +31 -28
- package/dist/shared/components/panels/BackgroundMove.js +242 -0
- package/dist/shared/components/panels/MoveAdvisory.js +204 -0
- package/dist/shared/components/panels/PipelinePanel.js +1459 -1220
- package/dist/shared/components/panels/RecordIntegrityBanner.js +113 -112
- package/dist/shared/components/profile/ActivityFeedCard.js +322 -0
- package/dist/shared/components/profile/DayTimeline.js +145 -140
- package/dist/shared/components/profile/PersonAccess.js +679 -383
- package/dist/shared/components/profile/PersonActivity.js +404 -427
- package/dist/shared/components/profile/PersonDidPanel.js +248 -134
- package/dist/shared/components/profile/PersonProfile.js +33 -32
- package/dist/shared/components/profile/journey-view.js +166 -0
- package/dist/shared/lib/activity-sentence.js +319 -236
- package/dist/shared/lib/commands.js +18 -14
- package/dist/shared/lib/error-hints.js +1 -1
- package/dist/shared/lib/job-failure-text.js +12 -0
- package/dist/shared/lib/jobs-tray.js +60 -41
- package/dist/shared/lib/move-failure.js +19 -0
- package/dist/shared/lib/obligation-banner.js +22 -21
- package/dist/shared/lib/partner-failure.js +83 -0
- package/dist/shared/lib/prefetch.js +73 -73
- package/dist/shared/lib/replay-checkout.js +18 -13
- package/dist/shared/lib/replay-context.js +90 -77
- package/dist/shared/lib/replay-idle.js +21 -0
- package/dist/shared/lib/replay-socket.js +21 -17
- package/dist/shared/lib/rum.js +56 -51
- package/dist/shared/lib/safe-error.js +17 -13
- package/dist/shared/lib/stale-chunk.js +69 -26
- package/dist/shared/lib/system-collections.js +20 -0
- package/package.json +1 -1
|
@@ -1,47 +1,48 @@
|
|
|
1
1
|
import { jsx as l, jsxs as k, Fragment as Ln } from "react/jsx-runtime";
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Loader2 as Rn, ListChecks as
|
|
4
|
-
import { useState as J, useMemo as K, useEffect as ge, useRef as ae, useId as
|
|
5
|
-
import { createPortal as
|
|
6
|
-
import { changeReasonChallenge as to, ChangeReasonDialog as
|
|
2
|
+
import { useQueryClient as pl, useQuery as Ye, useQueries as dn } from "@tanstack/react-query";
|
|
3
|
+
import { Loader2 as Rn, ListChecks as ja, SquarePen as La, Rows3 as Ta, PanelBottomOpen as Ra, Zap as Ma, Clock as Zi, History as ei, AlertTriangle as hr, ChevronRight as hl, GripVertical as Zs, FileUp as el, GripHorizontal as Ka, X as Pa, Lock as Da } from "lucide-react";
|
|
4
|
+
import { useState as J, useMemo as K, useEffect as ge, useRef as ae, useId as Wa, useCallback as Rt, Fragment as eo } from "react";
|
|
5
|
+
import { createPortal as Ua } from "react-dom";
|
|
6
|
+
import { changeReasonChallenge as to, ChangeReasonDialog as Ba } from "./ChangeReasonDialog.js";
|
|
7
7
|
import { toast as be } from "sonner";
|
|
8
|
-
import { useNivaroClient as si, useDrilldown as
|
|
9
|
-
import { get as de, post as Le, patch as ii, del as
|
|
10
|
-
import { useAfterIdle as
|
|
11
|
-
import { evaluateNumeric as wt, evaluateBoolean as
|
|
8
|
+
import { useNivaroClient as si, useDrilldown as Ja, useParentDraft as Qa, useReimportHandler as za, useItemEditAuth as Fa, fieldDrilldownConfig as tl } from "../../context.js";
|
|
9
|
+
import { get as de, post as Le, patch as ii, del as gl } from "../../lib/commands.js";
|
|
10
|
+
import { useAfterIdle as Va } from "../../lib/defer.js";
|
|
11
|
+
import { evaluateNumeric as wt, evaluateBoolean as Ha } from "../../lib/expression.js";
|
|
12
12
|
import { numericIntlOptions as St } from "../../lib/format-value.js";
|
|
13
|
-
import { isOwnWrite as
|
|
14
|
-
import { useOptionalRealtime as
|
|
15
|
-
import { useRecordReader as
|
|
16
|
-
import { midairCollisionOf as
|
|
17
|
-
import { restoreSkippedNote as
|
|
13
|
+
import { isOwnWrite as Ya } from "../../lib/own-writes.js";
|
|
14
|
+
import { useOptionalRealtime as Ga } from "../../lib/realtime.js";
|
|
15
|
+
import { useRecordReader as Ca } from "../../lib/record-loader.js";
|
|
16
|
+
import { midairCollisionOf as Xa } from "../../lib/record-outbox.js";
|
|
17
|
+
import { restoreSkippedNote as Za } from "../../lib/restore-skipped.js";
|
|
18
18
|
import { userErrorMessage as Tn } from "../../lib/safe-error.js";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
19
|
+
import { isFileCollection as nl } from "../../lib/system-collections.js";
|
|
20
|
+
import { titleCase as ve, cn as xe, formatRelative as rl, toLocalDateString as ed } from "../../lib/utils.js";
|
|
21
|
+
import { formulaInputsChanged as td } from "../../lib/write-formula.js";
|
|
22
|
+
import { ImportFromFileButton as nd } from "../import/ImportFromFileButton.js";
|
|
23
|
+
import { OWN_RECORD_WRITES_EVENT as il } from "../panels/RecordIntegrityBanner.js";
|
|
24
|
+
import { Sheet as rd, SheetContent as id, SheetHeader as od, SheetTitle as sd } from "../ui/sheet.js";
|
|
25
|
+
import { useAddendumO2M as ld, useAddendumView as ad } from "./AddendumFieldContext.js";
|
|
26
|
+
import { resolveCompareEndpoint as dd, useCompareSeries as cd, compareColumnClosed as zt, fmtMoney as no, CompareProposalBanner as ud, CompareStripChips as fd, GridStatChip as md, CompareCell as ro, compareRowFor as io, compareColumnSum as pd, ReconcileAction as hd } from "./CompareSeries.js";
|
|
26
27
|
import { FieldRenderer as jn } from "./FieldRenderer.js";
|
|
27
|
-
import { primaryControl as
|
|
28
|
-
import { GridBulkEditDialog as
|
|
29
|
-
import { parseJson as oo, SENTINEL_FIELDS as fo, applyDisplayTemplate as mr, EMPTY_NESTED_OPS as ti, SYSTEM_FIELDS as
|
|
30
|
-
import { lineLabelOf as ni, rowBaseBookFor as
|
|
31
|
-
import { NUMBER_FIELD_TYPES as
|
|
32
|
-
import { LineCollisionDialog as
|
|
28
|
+
import { primaryControl as gd, nameFieldControl as bd } from "./field-a11y.js";
|
|
29
|
+
import { GridBulkEditDialog as yd } from "./GridBulkEditDialog.js";
|
|
30
|
+
import { parseJson as oo, SENTINEL_FIELDS as fo, applyDisplayTemplate as mr, EMPTY_NESTED_OPS as ti, SYSTEM_FIELDS as ol } from "./helpers.js";
|
|
31
|
+
import { lineLabelOf as ni, rowBaseBookFor as wd, writeLineGuarded as vd, lineConflictKey as xd, resolveLineCollision as _d, snapshotRowBases as kd, incrementGuarded as Nd } from "./line-midair.js";
|
|
32
|
+
import { NUMBER_FIELD_TYPES as Sd, checkNumberEntry as $d, changedRowFields as sl, lineRuleErrors as qd, computedColumnErrors as Ed, zeroQtyColumn as ll, dropRevertedFields as Od, isRealLineEdit as Id } from "./line-qty.js";
|
|
33
|
+
import { LineCollisionDialog as Ad } from "./MidairCollisionDialog.js";
|
|
33
34
|
import { NestedRelationEditor as so } from "./NestedRelationEditor.js";
|
|
34
|
-
import { useO2MStaging as
|
|
35
|
+
import { useO2MStaging as jd, useLiveRows as Ld, useStagedRelations as Td } from "./O2MStagingContext.js";
|
|
35
36
|
import { RelationCombobox as lo } from "./RelationCombobox.js";
|
|
36
|
-
import { useRowCommentCounts as
|
|
37
|
-
import { RowHistorySheet as
|
|
38
|
-
import { useRowMatches as
|
|
39
|
-
import { RowWatchButton as
|
|
40
|
-
import { RuleProvenanceChip as
|
|
41
|
-
import { normalizeSetAllRows as
|
|
42
|
-
import { resolveOptionFilterTokens as
|
|
43
|
-
function
|
|
44
|
-
const b =
|
|
37
|
+
import { useRowCommentCounts as Rd, RowCommentButton as Md } from "./RowComments.js";
|
|
38
|
+
import { RowHistorySheet as al, parseImportStamp as Kd } from "./RowHistorySheet.js";
|
|
39
|
+
import { useRowMatches as Pd, RowMatchDot as dl, rowFromCandidate as Dd, RowMatchPanel as Wd } from "./RowMatchPanel.js";
|
|
40
|
+
import { RowWatchButton as Ud } from "./RowWatchButton.js";
|
|
41
|
+
import { RuleProvenanceChip as Bd } from "./RuleProvenancePopover.js";
|
|
42
|
+
import { normalizeSetAllRows as Jd, SetAllRowsButton as Qd } from "./SetAllRowsButton.js";
|
|
43
|
+
import { resolveOptionFilterTokens as bl } from "../../lib/option-filter-tokens.js";
|
|
44
|
+
function cl(s, u) {
|
|
45
|
+
const b = s[u.field], A = b == null || b === "", U = u.op ?? "eq";
|
|
45
46
|
if (U === "null") return A;
|
|
46
47
|
if (U === "nnull") return !A;
|
|
47
48
|
if (A) return !1;
|
|
@@ -51,24 +52,24 @@ function dl(o, u) {
|
|
|
51
52
|
const ee = String(u.value ?? "");
|
|
52
53
|
return U === "neq" ? B !== ee : B === ee;
|
|
53
54
|
}
|
|
54
|
-
function ao(
|
|
55
|
+
function ao(s, u) {
|
|
55
56
|
var A, U;
|
|
56
57
|
if (!(u != null && u.length)) return [];
|
|
57
58
|
const b = [];
|
|
58
59
|
for (const B of u)
|
|
59
|
-
!((A = B == null ? void 0 : B.when) != null && A.field) || !((U = B == null ? void 0 : B.expect) != null && U.field) ||
|
|
60
|
+
!((A = B == null ? void 0 : B.when) != null && A.field) || !((U = B == null ? void 0 : B.expect) != null && U.field) || cl(s, B.when) && (cl(s, B.expect) || b.push(B.label || `${B.when.field} vs ${B.expect.field}`));
|
|
60
61
|
return b;
|
|
61
62
|
}
|
|
62
|
-
const
|
|
63
|
+
const zd = {
|
|
63
64
|
lt: "<",
|
|
64
65
|
gt: ">",
|
|
65
66
|
quot: '"',
|
|
66
67
|
amp: "&",
|
|
67
68
|
"#39": "'"
|
|
68
69
|
};
|
|
69
|
-
function
|
|
70
|
+
function Fd(s, u) {
|
|
70
71
|
const b = [];
|
|
71
|
-
return { rows:
|
|
72
|
+
return { rows: s.map((U) => {
|
|
72
73
|
const B = [], ee = { ...U };
|
|
73
74
|
for (const [oe, Q] of u) {
|
|
74
75
|
const R = U[oe];
|
|
@@ -77,8 +78,8 @@ function zd(o, u) {
|
|
|
77
78
|
return b.push(B), ee;
|
|
78
79
|
}), dropped: b };
|
|
79
80
|
}
|
|
80
|
-
function
|
|
81
|
-
saved:
|
|
81
|
+
function ul({
|
|
82
|
+
saved: s,
|
|
82
83
|
onDelete: u
|
|
83
84
|
}) {
|
|
84
85
|
const [b, A] = J(!1);
|
|
@@ -94,18 +95,18 @@ function cl({
|
|
|
94
95
|
"data-tip": b ? "Click again to delete" : "Delete line",
|
|
95
96
|
"data-armed": b ? "" : void 0,
|
|
96
97
|
onClick: (U) => {
|
|
97
|
-
if (U.stopPropagation(),
|
|
98
|
+
if (U.stopPropagation(), s && !b) {
|
|
98
99
|
A(!0);
|
|
99
100
|
return;
|
|
100
101
|
}
|
|
101
102
|
A(!1), u(U);
|
|
102
103
|
},
|
|
103
104
|
className: b ? "rounded bg-red-50 p-0.5 text-red-600 dark:bg-red-900/20 dark:text-red-400" : "rounded p-0.5 text-slate-300 hover:text-red-500",
|
|
104
|
-
children: /* @__PURE__ */ l(
|
|
105
|
+
children: /* @__PURE__ */ l(Pa, { className: "h-3 w-3" })
|
|
105
106
|
}
|
|
106
107
|
);
|
|
107
108
|
}
|
|
108
|
-
function
|
|
109
|
+
function Vd({ children: s }) {
|
|
109
110
|
const [u, b] = J(null);
|
|
110
111
|
return /* @__PURE__ */ k(
|
|
111
112
|
"span",
|
|
@@ -119,8 +120,8 @@ function Fd({ children: o }) {
|
|
|
119
120
|
onMouseLeave: () => b(null),
|
|
120
121
|
children: [
|
|
121
122
|
/* @__PURE__ */ l(hr, { className: "h-3 w-3 shrink-0 text-amber-500" }),
|
|
122
|
-
/* @__PURE__ */ l("span", { className: "min-w-0 truncate", children:
|
|
123
|
-
u &&
|
|
123
|
+
/* @__PURE__ */ l("span", { className: "min-w-0 truncate", children: s }),
|
|
124
|
+
u && Ua(
|
|
124
125
|
/* @__PURE__ */ l(
|
|
125
126
|
"div",
|
|
126
127
|
{
|
|
@@ -135,11 +136,11 @@ function Fd({ children: o }) {
|
|
|
135
136
|
}
|
|
136
137
|
);
|
|
137
138
|
}
|
|
138
|
-
function
|
|
139
|
-
if (typeof
|
|
140
|
-
const u =
|
|
139
|
+
function Hd(s) {
|
|
140
|
+
if (typeof s != "string" || !s.trim()) return [];
|
|
141
|
+
const u = s.replace(
|
|
141
142
|
/&(lt|gt|quot|amp|#39);/g,
|
|
142
|
-
(B, ee) =>
|
|
143
|
+
(B, ee) => zd[ee] ?? ""
|
|
143
144
|
), b = [], A = /"detail"\s*:\s*"((?:[^"\\]|\\.)*)"/g;
|
|
144
145
|
let U = A.exec(u);
|
|
145
146
|
for (; U; ) {
|
|
@@ -165,7 +166,7 @@ const mo = /* @__PURE__ */ new Set([
|
|
|
165
166
|
"group",
|
|
166
167
|
"divider"
|
|
167
168
|
]), pr = "__all__";
|
|
168
|
-
function
|
|
169
|
+
function yl(s, u, b, A) {
|
|
169
170
|
if (u <= 0) return [];
|
|
170
171
|
let U;
|
|
171
172
|
for (b === "front" ? U = Array.from({ length: u }, (Q, R) => u - R) : b === "back" ? U = Array.from({ length: u }, (Q, R) => R + 1) : b === "shape" && A && A.some((Q) => Q > 0) ? U = A.slice(0, u).map((Q) => Math.max(0, Q)) : U = Array.from({ length: u }, () => 1); U.length < u; ) U.push(0);
|
|
@@ -173,42 +174,42 @@ function bl(o, u, b, A) {
|
|
|
173
174
|
let oe = 0;
|
|
174
175
|
for (let Q = 0; Q < u; Q++)
|
|
175
176
|
if (Q === u - 1)
|
|
176
|
-
ee.push(Math.round((
|
|
177
|
+
ee.push(Math.round((s - oe) * 100) / 100);
|
|
177
178
|
else {
|
|
178
|
-
const R = Math.floor(
|
|
179
|
+
const R = Math.floor(s * U[Q] / B * 100) / 100;
|
|
179
180
|
ee.push(R), oe += R;
|
|
180
181
|
}
|
|
181
182
|
return ee;
|
|
182
183
|
}
|
|
183
184
|
const co = 1e3;
|
|
184
|
-
function
|
|
185
|
+
function Yd(s) {
|
|
185
186
|
let u = 0;
|
|
186
|
-
for (let b = 0; b <
|
|
187
|
+
for (let b = 0; b < s.length; b++) u = u * 31 + s.charCodeAt(b) | 0;
|
|
187
188
|
return u;
|
|
188
189
|
}
|
|
189
|
-
function
|
|
190
|
-
if (
|
|
190
|
+
function Gd(s) {
|
|
191
|
+
if (s.line_number != null && s.line_number !== "") return `line ${s.line_number}`;
|
|
191
192
|
for (const u of ["year", "name", "title", "label", "number"]) {
|
|
192
|
-
const b =
|
|
193
|
+
const b = s[u];
|
|
193
194
|
if (b != null && b !== "" && typeof b != "object") return String(b).slice(0, 60);
|
|
194
195
|
}
|
|
195
196
|
return null;
|
|
196
197
|
}
|
|
197
|
-
function Ft(
|
|
198
|
-
return wt(
|
|
198
|
+
function Ft(s, u) {
|
|
199
|
+
return wt(s, u);
|
|
199
200
|
}
|
|
200
|
-
function uo(
|
|
201
|
+
function uo(s, u) {
|
|
201
202
|
return u.map((b) => {
|
|
202
|
-
const A =
|
|
203
|
-
return String(A !== void 0 ? A ?? "" :
|
|
203
|
+
const A = s[`__m2m_${b}`];
|
|
204
|
+
return String(A !== void 0 ? A ?? "" : s[b] ?? "");
|
|
204
205
|
}).join("\0");
|
|
205
206
|
}
|
|
206
|
-
function po(
|
|
207
|
-
return typeof
|
|
207
|
+
function po(s, u, b, A) {
|
|
208
|
+
return typeof s != "string" ? s : s === "$parent.id" ? b : s.startsWith("$parent.") ? A == null ? void 0 : A[s.slice(8)] : s.startsWith("$row.") ? u[s.slice(5)] : s;
|
|
208
209
|
}
|
|
209
|
-
function oi(
|
|
210
|
+
function oi(s, u, b, A) {
|
|
210
211
|
const U = {};
|
|
211
|
-
for (const [ee, oe] of Object.entries(
|
|
212
|
+
for (const [ee, oe] of Object.entries(s.filters ?? {})) {
|
|
212
213
|
const Q = po(oe, u, b, A);
|
|
213
214
|
if (Q == null || Q === "") return null;
|
|
214
215
|
if (ee.startsWith("_")) {
|
|
@@ -225,23 +226,23 @@ function oi(o, u, b, A) {
|
|
|
225
226
|
U[ee] = R;
|
|
226
227
|
}
|
|
227
228
|
const B = {};
|
|
228
|
-
for (const [ee, oe] of Object.entries(
|
|
229
|
+
for (const [ee, oe] of Object.entries(s.defaults ?? {})) {
|
|
229
230
|
const Q = po(oe, u, b, A);
|
|
230
231
|
Q != null && Q !== "" && (B[ee] = Q);
|
|
231
232
|
}
|
|
232
233
|
return { query: U, seed: B };
|
|
233
234
|
}
|
|
234
|
-
function ri(
|
|
235
|
+
function ri(s, u) {
|
|
235
236
|
return u.split(".").reduce(
|
|
236
237
|
(b, A) => b && typeof b == "object" ? b[A] : void 0,
|
|
237
|
-
|
|
238
|
+
s
|
|
238
239
|
);
|
|
239
240
|
}
|
|
240
|
-
function
|
|
241
|
-
return u === "presence" ?
|
|
241
|
+
function Cd(s, u, b) {
|
|
242
|
+
return u === "presence" ? s != null && String(s).trim() !== "" ? "Yes" : "No" : s == null || s === "" ? "—" : u === "currency" && Number.isFinite(Number(s)) ? Number(s).toLocaleString("en-US", St(b, "currency")) : String(s);
|
|
242
243
|
}
|
|
243
|
-
function
|
|
244
|
-
config:
|
|
244
|
+
function Xd({
|
|
245
|
+
config: s,
|
|
245
246
|
relatedCollection: u,
|
|
246
247
|
manyField: b,
|
|
247
248
|
parentId: A,
|
|
@@ -259,7 +260,7 @@ function Cd({
|
|
|
259
260
|
stagedBase: te
|
|
260
261
|
}) {
|
|
261
262
|
const Se = si(), [We, fe] = J(!1), [ze, we] = J(null), [Y, ye] = J({}), [Ge, Te] = J(null), qe = K(
|
|
262
|
-
() => (
|
|
263
|
+
() => (s.columns ?? []).map(
|
|
263
264
|
(F) => typeof F == "string" ? {
|
|
264
265
|
path: F,
|
|
265
266
|
label: void 0,
|
|
@@ -268,13 +269,13 @@ function Cd({
|
|
|
268
269
|
width: void 0
|
|
269
270
|
} : F
|
|
270
271
|
),
|
|
271
|
-
[
|
|
272
|
+
[s.columns]
|
|
272
273
|
), Ze = K(
|
|
273
|
-
() =>
|
|
274
|
-
[
|
|
274
|
+
() => bl(s.filter, ee, A),
|
|
275
|
+
[s.filter, ee, A]
|
|
275
276
|
), $t = K(() => {
|
|
276
277
|
const F = /* @__PURE__ */ new Set(["id"]);
|
|
277
|
-
|
|
278
|
+
s.group_by && F.add(s.group_by);
|
|
278
279
|
const M = (L) => {
|
|
279
280
|
/^__\w+__$/.test(L) || F.add(L);
|
|
280
281
|
};
|
|
@@ -283,15 +284,15 @@ function Cd({
|
|
|
283
284
|
for (const H of (L.formula ?? "").matchAll(/\{\{\s*([\w.]+)\s*\}\}/g)) M(H[1]);
|
|
284
285
|
}
|
|
285
286
|
return [...F].join(",");
|
|
286
|
-
}, [qe,
|
|
287
|
+
}, [qe, s.group_by]), { data: le = [], isFetching: at } = Ye({
|
|
287
288
|
queryKey: [
|
|
288
289
|
"allocate-options",
|
|
289
|
-
|
|
290
|
+
s.collection,
|
|
290
291
|
JSON.stringify(Ze ?? null),
|
|
291
292
|
$t
|
|
292
293
|
],
|
|
293
294
|
queryFn: () => Se.request(
|
|
294
|
-
de(`/items/${
|
|
295
|
+
de(`/items/${s.collection}`, {
|
|
295
296
|
...Ze ? { filter: JSON.stringify(Ze) } : {},
|
|
296
297
|
fields: $t,
|
|
297
298
|
limit: 500
|
|
@@ -302,21 +303,21 @@ function Cd({
|
|
|
302
303
|
}), vt = K(() => {
|
|
303
304
|
const F = /* @__PURE__ */ new Map();
|
|
304
305
|
for (const M of U) {
|
|
305
|
-
const L = M[
|
|
306
|
+
const L = M[s.target_field];
|
|
306
307
|
L != null && F.set(String(L), M);
|
|
307
308
|
}
|
|
308
309
|
return F;
|
|
309
|
-
}, [U,
|
|
310
|
+
}, [U, s.target_field]);
|
|
310
311
|
function Re(F) {
|
|
311
312
|
const M = vt.get(F), L = (M == null ? void 0 : M.id) != null ? String(M.id) : null, H = !!(L && (re != null && re.has(L))), pe = (je ?? []).findIndex(
|
|
312
|
-
(Ee) => String(Ee[
|
|
313
|
+
(Ee) => String(Ee[s.target_field]) === F
|
|
313
314
|
);
|
|
314
315
|
let $ = 0;
|
|
315
|
-
if (pe >= 0) $ = Number((je ?? [])[pe][
|
|
316
|
+
if (pe >= 0) $ = Number((je ?? [])[pe][s.value_field]) || 0;
|
|
316
317
|
else if (M && !H) {
|
|
317
318
|
const Ee = L ? D == null ? void 0 : D.get(L) : void 0;
|
|
318
319
|
$ = Number(
|
|
319
|
-
Ee &&
|
|
320
|
+
Ee && s.value_field in Ee ? Ee[s.value_field] : M[s.value_field]
|
|
320
321
|
) || 0;
|
|
321
322
|
}
|
|
322
323
|
return { savedRow: M, pendingIdx: pe, amount: $, deleted: H };
|
|
@@ -332,14 +333,14 @@ function Cd({
|
|
|
332
333
|
const { savedRow: $, pendingIdx: Ee, deleted: me } = Re(F), z = ($ == null ? void 0 : $.id) != null ? String($.id) : null;
|
|
333
334
|
H === null || H === 0 ? Ee >= 0 ? R.removeRow(u, b, Ee) : z && !me && (R.cancelPendingEdit(u, b, z), R.queueDelete(u, b, z)) : Ee >= 0 ? R.updateRow(u, b, Ee, {
|
|
334
335
|
...(je ?? [])[Ee],
|
|
335
|
-
[
|
|
336
|
+
[s.value_field]: H
|
|
336
337
|
}) : z ? (me && R.cancelPendingDelete(u, b, z), R.queueEdit(u, b, z, {
|
|
337
|
-
[
|
|
338
|
+
[s.value_field]: H,
|
|
338
339
|
...(te == null ? void 0 : te(z)) ?? {}
|
|
339
340
|
})) : R.queueRow(u, b, {
|
|
340
341
|
...B,
|
|
341
|
-
[
|
|
342
|
-
[
|
|
342
|
+
[s.target_field]: F,
|
|
343
|
+
[s.value_field]: H
|
|
343
344
|
});
|
|
344
345
|
return;
|
|
345
346
|
}
|
|
@@ -347,18 +348,18 @@ function Cd({
|
|
|
347
348
|
we(F);
|
|
348
349
|
try {
|
|
349
350
|
if (H === null || H === 0)
|
|
350
|
-
(pe == null ? void 0 : pe.id) != null && await Se.request(
|
|
351
|
+
(pe == null ? void 0 : pe.id) != null && await Se.request(gl(`/items/${u}/${pe.id}`));
|
|
351
352
|
else if ((pe == null ? void 0 : pe.id) != null) {
|
|
352
|
-
if (Number(pe[
|
|
353
|
-
const $ = { [
|
|
353
|
+
if (Number(pe[s.value_field]) !== H) {
|
|
354
|
+
const $ = { [s.value_field]: H };
|
|
354
355
|
Ne ? await Ne(String(pe.id), $) : await Se.request(ii(`/items/${u}/${pe.id}`, $));
|
|
355
356
|
}
|
|
356
357
|
} else
|
|
357
358
|
await Se.request(
|
|
358
359
|
Le(`/items/${u}`, {
|
|
359
360
|
...B,
|
|
360
|
-
[
|
|
361
|
-
[
|
|
361
|
+
[s.target_field]: F,
|
|
362
|
+
[s.value_field]: H,
|
|
362
363
|
[b]: A
|
|
363
364
|
})
|
|
364
365
|
);
|
|
@@ -372,7 +373,7 @@ function Cd({
|
|
|
372
373
|
return wt(F, (H) => H in L ? L[H] : ri(M, H));
|
|
373
374
|
}
|
|
374
375
|
function _e(F) {
|
|
375
|
-
const M = vt.get(F), L = Number((M == null ? void 0 : M[
|
|
376
|
+
const M = vt.get(F), L = Number((M == null ? void 0 : M[s.value_field]) ?? 0) || 0, H = Y[F], pe = se ? Re(F).amount : L;
|
|
376
377
|
return { __input__: H !== void 0 && H !== "" ? Number(H) || 0 : pe, __saved__: L };
|
|
377
378
|
}
|
|
378
379
|
function Mn(F, M) {
|
|
@@ -380,9 +381,9 @@ function Cd({
|
|
|
380
381
|
return L === null ? "—" : L.toLocaleString("en-US", { style: "currency", currency: "USD" });
|
|
381
382
|
}
|
|
382
383
|
function xt(F) {
|
|
383
|
-
if (!
|
|
384
|
-
const M = vt.get(String(F.id)), L = Number((M == null ? void 0 : M[
|
|
385
|
-
return Ue(
|
|
384
|
+
if (!s.value_max) return null;
|
|
385
|
+
const M = vt.get(String(F.id)), L = Number((M == null ? void 0 : M[s.value_field]) ?? 0) || 0;
|
|
386
|
+
return Ue(s.value_max, F, { __input__: L, __saved__: L });
|
|
386
387
|
}
|
|
387
388
|
return /* @__PURE__ */ k(Ln, { children: [
|
|
388
389
|
/* @__PURE__ */ l(
|
|
@@ -394,8 +395,8 @@ function Cd({
|
|
|
394
395
|
children: "Allocate…"
|
|
395
396
|
}
|
|
396
397
|
),
|
|
397
|
-
/* @__PURE__ */ l(
|
|
398
|
-
/* @__PURE__ */ l(
|
|
398
|
+
/* @__PURE__ */ l(rd, { open: We, onOpenChange: fe, children: /* @__PURE__ */ k(id, { side: "right", className: "w-[92vw] sm:max-w-[1200px] overflow-y-auto p-0", children: [
|
|
399
|
+
/* @__PURE__ */ l(od, { className: "border-b border-slate-200 px-5 py-3", children: /* @__PURE__ */ l(sd, { className: "text-[14px]", children: s.title ?? "Allocate" }) }),
|
|
399
400
|
/* @__PURE__ */ k("div", { className: "p-4", children: [
|
|
400
401
|
/* @__PURE__ */ l("p", { className: "mb-2 text-[11px] text-slate-400", children: "Enter an amount to allocate a line — clearing it removes the allocation." }),
|
|
401
402
|
at ? /* @__PURE__ */ l("div", { className: "py-10 text-center", children: /* @__PURE__ */ l(Rn, { className: "inline h-4 w-4 animate-spin text-slate-400" }) }) : le.length === 0 ? /* @__PURE__ */ l("p", { className: "py-10 text-center text-[12px] text-slate-400", children: "No eligible rows for the current record's filters." }) : /* @__PURE__ */ l("div", { className: "overflow-x-auto rounded-lg border border-slate-200", children: /* @__PURE__ */ k("table", { className: "w-full text-left text-[12px]", children: [
|
|
@@ -408,12 +409,12 @@ function Cd({
|
|
|
408
409
|
},
|
|
409
410
|
M
|
|
410
411
|
)),
|
|
411
|
-
/* @__PURE__ */ l("th", { className: "whitespace-nowrap px-2.5 py-1.5 text-[11px] font-medium text-slate-500", children:
|
|
412
|
+
/* @__PURE__ */ l("th", { className: "whitespace-nowrap px-2.5 py-1.5 text-[11px] font-medium text-slate-500", children: s.value_label ?? "Allocate" })
|
|
412
413
|
] }) }),
|
|
413
414
|
/* @__PURE__ */ l("tbody", { className: "divide-y divide-slate-100", children: (() => {
|
|
414
|
-
const F = (me) =>
|
|
415
|
+
const F = (me) => s.group_by ? String(ri(me, s.group_by) ?? "—") : "";
|
|
415
416
|
let M = le, L = [];
|
|
416
|
-
|
|
417
|
+
s.group_by && (L = [...new Set(le.map(F))], M = L.flatMap(
|
|
417
418
|
(me) => le.filter((z) => F(z) === me)
|
|
418
419
|
));
|
|
419
420
|
const H = Ge ?? new Set(
|
|
@@ -425,7 +426,7 @@ function Cd({
|
|
|
425
426
|
let Ee = null;
|
|
426
427
|
for (const me of M) {
|
|
427
428
|
const z = String(me.id), x = F(me);
|
|
428
|
-
if (
|
|
429
|
+
if (s.group_by && x !== Ee) {
|
|
429
430
|
Ee = x;
|
|
430
431
|
const q = le.filter((Fe) => F(Fe) === x), S = q.filter(
|
|
431
432
|
(Fe) => Re(String(Fe.id)).amount > 0
|
|
@@ -460,7 +461,7 @@ function Cd({
|
|
|
460
461
|
className: "flex w-full items-center gap-1.5 text-left",
|
|
461
462
|
children: [
|
|
462
463
|
/* @__PURE__ */ l(
|
|
463
|
-
|
|
464
|
+
hl,
|
|
464
465
|
{
|
|
465
466
|
className: xe(
|
|
466
467
|
"h-3 w-3 shrink-0 text-slate-400 transition-transform",
|
|
@@ -499,12 +500,12 @@ function Cd({
|
|
|
499
500
|
)
|
|
500
501
|
);
|
|
501
502
|
}
|
|
502
|
-
if (
|
|
503
|
+
if (s.group_by && !H.has(x)) continue;
|
|
503
504
|
const Mt = Re(z), Kn = Mt.amount > 0 ? Mt.savedRow ?? {} : void 0, dt = Y[z] ?? (Mt.amount > 0 ? String(Mt.amount) : "");
|
|
504
505
|
$.push(
|
|
505
506
|
/* @__PURE__ */ k("tr", { className: xe(Kn && "bg-nvr-cyan/5"), children: [
|
|
506
507
|
qe.map((q, S) => {
|
|
507
|
-
const rt = q.formula ? Mn(q.formula, me) :
|
|
508
|
+
const rt = q.formula ? Mn(q.formula, me) : Cd(ri(me, q.path ?? ""), q.format);
|
|
508
509
|
return /* @__PURE__ */ l(
|
|
509
510
|
"td",
|
|
510
511
|
{
|
|
@@ -556,8 +557,8 @@ function Cd({
|
|
|
556
557
|
] }) })
|
|
557
558
|
] });
|
|
558
559
|
}
|
|
559
|
-
function
|
|
560
|
-
config:
|
|
560
|
+
function Zd({
|
|
561
|
+
config: s,
|
|
561
562
|
rows: u,
|
|
562
563
|
relatedCollection: b,
|
|
563
564
|
computedWriteFields: A,
|
|
@@ -565,11 +566,11 @@ function Xd({
|
|
|
565
566
|
}) {
|
|
566
567
|
const B = si(), [ee, oe] = J(!1), [Q, R] = J(!1), se = async () => {
|
|
567
568
|
R(!1);
|
|
568
|
-
const je = Object.keys(
|
|
569
|
+
const je = Object.keys(s.set).filter((D) => A.has(D));
|
|
569
570
|
if (je.length > 0) {
|
|
570
571
|
const D = je[0];
|
|
571
572
|
be.error(
|
|
572
|
-
`${
|
|
573
|
+
`${s.label}: "${D}" is calculated from ${A.get(D)} and cannot be set directly — target those fields instead`,
|
|
573
574
|
{ duration: 12e3 }
|
|
574
575
|
);
|
|
575
576
|
return;
|
|
@@ -577,28 +578,28 @@ function Xd({
|
|
|
577
578
|
oe(!0);
|
|
578
579
|
try {
|
|
579
580
|
const D = await B.request(de(`/collections/${b}`)).then((Y) => Y.data), re = ((D == null ? void 0 : D.relations) ?? []).find(
|
|
580
|
-
(Y) => Y.one_collection === b && Y.one_field ===
|
|
581
|
+
(Y) => Y.one_collection === b && Y.one_field === s.relation
|
|
581
582
|
);
|
|
582
583
|
if (!(re != null && re.many_collection) || !(re != null && re.many_field)) {
|
|
583
584
|
be.error(
|
|
584
|
-
`${
|
|
585
|
+
`${s.label}: "${s.relation}" is not a relation on ${b}`
|
|
585
586
|
);
|
|
586
587
|
return;
|
|
587
588
|
}
|
|
588
589
|
const Ne = u.map((Y) => Y.id).filter((Y) => Y != null);
|
|
589
590
|
if (Ne.length === 0) {
|
|
590
|
-
be.message(`${
|
|
591
|
+
be.message(`${s.label}: no saved rows to update`);
|
|
591
592
|
return;
|
|
592
593
|
}
|
|
593
594
|
const te = await B.request(
|
|
594
595
|
de(`/items/${re.many_collection}`, {
|
|
595
596
|
filter: JSON.stringify({ [re.many_field]: { _in: Ne } }),
|
|
596
|
-
fields: `id,${re.many_field},${
|
|
597
|
+
fields: `id,${re.many_field},${s.aggregate.field}`,
|
|
597
598
|
limit: "2000"
|
|
598
599
|
})
|
|
599
|
-
).then((Y) => Y.data ?? []), Se =
|
|
600
|
+
).then((Y) => Y.data ?? []), Se = s.aggregate.op ?? "sum", We = /* @__PURE__ */ new Map();
|
|
600
601
|
for (const Y of te) {
|
|
601
|
-
const ye = String(Y[re.many_field] ?? ""), Ge = Number(Y[
|
|
602
|
+
const ye = String(Y[re.many_field] ?? ""), Ge = Number(Y[s.aggregate.field]);
|
|
602
603
|
!ye || Number.isNaN(Ge) || We.set(ye, [...We.get(ye) ?? [], Ge]);
|
|
603
604
|
}
|
|
604
605
|
const fe = (Y) => {
|
|
@@ -608,12 +609,12 @@ function Xd({
|
|
|
608
609
|
let ze = 0, we = 0;
|
|
609
610
|
for (const Y of u) {
|
|
610
611
|
const ye = { ...Y, __agg__: fe(Y.id) };
|
|
611
|
-
if (
|
|
612
|
+
if (s.guard && !Ha(s.guard, ye)) {
|
|
612
613
|
we++;
|
|
613
614
|
continue;
|
|
614
615
|
}
|
|
615
616
|
const Ge = {};
|
|
616
|
-
for (const [Te, qe] of Object.entries(
|
|
617
|
+
for (const [Te, qe] of Object.entries(s.set)) {
|
|
617
618
|
const Ze = Ft(qe, ye);
|
|
618
619
|
Ze != null && Number.isFinite(Ze) && (Ge[Te] = Math.round(Ze * 100) / 100);
|
|
619
620
|
}
|
|
@@ -624,16 +625,16 @@ function Xd({
|
|
|
624
625
|
await U(Y, Ge), ze++;
|
|
625
626
|
}
|
|
626
627
|
be.success(
|
|
627
|
-
`${
|
|
628
|
+
`${s.label}: ${ze} row${ze === 1 ? "" : "s"} updated` + (we > 0 ? `, ${we} unchanged` : "")
|
|
628
629
|
);
|
|
629
630
|
} catch {
|
|
630
|
-
be.error(`${
|
|
631
|
+
be.error(`${s.label} failed`);
|
|
631
632
|
} finally {
|
|
632
633
|
oe(!1);
|
|
633
634
|
}
|
|
634
635
|
};
|
|
635
636
|
return Q ? /* @__PURE__ */ k("span", { className: "inline-flex items-center gap-1.5 text-[11px]", children: [
|
|
636
|
-
/* @__PURE__ */ l("span", { className: "text-slate-600 dark:text-slate-300", children:
|
|
637
|
+
/* @__PURE__ */ l("span", { className: "text-slate-600 dark:text-slate-300", children: s.confirm ?? "Apply to all rows?" }),
|
|
637
638
|
/* @__PURE__ */ l(
|
|
638
639
|
"button",
|
|
639
640
|
{
|
|
@@ -657,17 +658,17 @@ function Xd({
|
|
|
657
658
|
{
|
|
658
659
|
type: "button",
|
|
659
660
|
disabled: ee,
|
|
660
|
-
onClick: () =>
|
|
661
|
+
onClick: () => s.confirm ? R(!0) : void se(),
|
|
661
662
|
className: xe(
|
|
662
663
|
"rounded px-2 py-0.5 text-[11px] font-medium disabled:opacity-50",
|
|
663
|
-
|
|
664
|
+
s.variant === "danger" ? "border border-red-200 text-red-600 hover:bg-red-50 dark:border-red-800 dark:hover:bg-red-900/20" : "border border-slate-200 text-slate-600 hover:bg-slate-50 dark:border-border dark:hover:bg-muted"
|
|
664
665
|
),
|
|
665
|
-
children: ee ? "Working…" :
|
|
666
|
+
children: ee ? "Working…" : s.label
|
|
666
667
|
}
|
|
667
668
|
);
|
|
668
669
|
}
|
|
669
|
-
function
|
|
670
|
-
config:
|
|
670
|
+
function ec({
|
|
671
|
+
config: s,
|
|
671
672
|
matchCfg: u,
|
|
672
673
|
rows: b,
|
|
673
674
|
parentId: A,
|
|
@@ -675,17 +676,17 @@ function Zd({
|
|
|
675
676
|
relatedCollection: B,
|
|
676
677
|
manyField: ee
|
|
677
678
|
}) {
|
|
678
|
-
const oe = si(), Q =
|
|
679
|
+
const oe = si(), Q = pl(), [R, se] = J(!1), [je, D] = J(null), re = async () => {
|
|
679
680
|
if (R) return;
|
|
680
681
|
se(!0), D(null);
|
|
681
|
-
const Ne =
|
|
682
|
-
...
|
|
682
|
+
const Ne = s.fk_field, te = s.alloc_qty_field, Se = s.candidates.min_capacity ?? 1, We = [
|
|
683
|
+
...s.candidates.capacity_formula.matchAll(/\{\{\s*(\w+)\s*\}\}/g)
|
|
683
684
|
].map((Te) => Te[1]), fe = {};
|
|
684
685
|
let ze = 0, we = 0, Y = 0;
|
|
685
|
-
const ye = [], Ge = (Te, qe) =>
|
|
686
|
+
const ye = [], Ge = (Te, qe) => Nd(oe, u.collection, Te, te, qe);
|
|
686
687
|
try {
|
|
687
688
|
for (let qe = 0; qe < b.length; qe++) {
|
|
688
|
-
const Ze = b[qe], $t = Number(Ze[
|
|
689
|
+
const Ze = b[qe], $t = Number(Ze[s.row_qty_field]);
|
|
689
690
|
if (!Number.isFinite($t) || $t <= 0) continue;
|
|
690
691
|
const le = oi(u, Ze, A, U);
|
|
691
692
|
if (!le) continue;
|
|
@@ -700,8 +701,8 @@ function Zd({
|
|
|
700
701
|
if (Re <= 0) continue;
|
|
701
702
|
const Pe = oi(
|
|
702
703
|
{
|
|
703
|
-
collection:
|
|
704
|
-
filters:
|
|
704
|
+
collection: s.candidates.collection,
|
|
705
|
+
filters: s.candidates.filters,
|
|
705
706
|
defaults: {}
|
|
706
707
|
},
|
|
707
708
|
Ze,
|
|
@@ -710,10 +711,10 @@ function Zd({
|
|
|
710
711
|
);
|
|
711
712
|
if (!Pe) continue;
|
|
712
713
|
const Ue = await oe.request(
|
|
713
|
-
de(`/items/${
|
|
714
|
+
de(`/items/${s.candidates.collection}`, {
|
|
714
715
|
filter: JSON.stringify(Pe.query),
|
|
715
716
|
fields: ["id", ...We].join(","),
|
|
716
|
-
...
|
|
717
|
+
...s.candidates.sort ? { sort: s.candidates.sort } : {},
|
|
717
718
|
limit: 500
|
|
718
719
|
})
|
|
719
720
|
).then((M) => M.data ?? []);
|
|
@@ -735,7 +736,7 @@ function Zd({
|
|
|
735
736
|
const F = Re;
|
|
736
737
|
for (const M of Ue) {
|
|
737
738
|
if (Re <= 0) break;
|
|
738
|
-
const L = String(M.id), pe = (Ft(
|
|
739
|
+
const L = String(M.id), pe = (Ft(s.candidates.capacity_formula, M) ?? 0) - (xt[L] ?? 0) - (fe[L] ?? 0);
|
|
739
740
|
if (pe < Se) continue;
|
|
740
741
|
const $ = Math.min(Re, pe), Ee = at.find((me) => String(me[Ne]) === L);
|
|
741
742
|
if (Ee) {
|
|
@@ -771,19 +772,19 @@ function Zd({
|
|
|
771
772
|
disabled: R,
|
|
772
773
|
onClick: () => void re(),
|
|
773
774
|
className: "h-6 px-2.5 rounded border border-nvr-cyan text-nvr-cyan hover:bg-nvr-cyan/10 transition-colors disabled:opacity-50",
|
|
774
|
-
children: R ? "Allocating…" :
|
|
775
|
+
children: R ? "Allocating…" : s.label ?? "Auto allocate"
|
|
775
776
|
}
|
|
776
777
|
),
|
|
777
778
|
je && /* @__PURE__ */ l("span", { className: "text-[11px] text-slate-500", children: je })
|
|
778
779
|
] });
|
|
779
780
|
}
|
|
780
|
-
function
|
|
781
|
-
return
|
|
781
|
+
function tc(s) {
|
|
782
|
+
return s.filter(
|
|
782
783
|
(u) => u.group_key === "__apply_values__" && !mo.has(u.type ?? "") && !fo.has(u.field) && !u.readonly && !(u.computed_type === "write" && u.computed_formula) && u.interface !== "formula-column" && u.interface !== "match-agg-column" && u.interface !== "relation-path"
|
|
783
784
|
);
|
|
784
785
|
}
|
|
785
|
-
function
|
|
786
|
-
relatedCollection:
|
|
786
|
+
function Vc({
|
|
787
|
+
relatedCollection: s,
|
|
787
788
|
manyField: u,
|
|
788
789
|
parentId: b,
|
|
789
790
|
parentCollection: A,
|
|
@@ -827,7 +828,7 @@ function zc({
|
|
|
827
828
|
editorMode: pe
|
|
828
829
|
}) {
|
|
829
830
|
var Cs, Xs;
|
|
830
|
-
const $ = si(), Ee =
|
|
831
|
+
const $ = si(), Ee = Ca(), me = Ja(), z = pl(), x = jd(), Mt = Ld(), Kn = Td(), dt = ld()[M ?? ""] ?? [], q = b === "new", S = Qa(), rt = za(), Kt = Ga(), Vt = `nvr_grid_editor_${s}_${M ?? u}`, [li, gr] = J(() => {
|
|
831
832
|
if (typeof localStorage > "u") return null;
|
|
832
833
|
try {
|
|
833
834
|
const e = localStorage.getItem(Vt);
|
|
@@ -856,7 +857,7 @@ function zc({
|
|
|
856
857
|
localStorage.setItem(Vt, e);
|
|
857
858
|
} catch {
|
|
858
859
|
}
|
|
859
|
-
}, Ht = `nvr_grid_split_h_${
|
|
860
|
+
}, Ht = `nvr_grid_split_h_${s}`, [br, ho] = J(() => {
|
|
860
861
|
if (typeof localStorage > "u") return 320;
|
|
861
862
|
try {
|
|
862
863
|
const e = Number(localStorage.getItem(Ht));
|
|
@@ -882,7 +883,7 @@ function zc({
|
|
|
882
883
|
const t = n.detail;
|
|
883
884
|
if (!t || typeof t.target != "string" || !t.target || A && t.collection !== A) return;
|
|
884
885
|
const r = M ?? u;
|
|
885
|
-
if (!(t.grid !== r && t.grid !==
|
|
886
|
+
if (!(t.grid !== r && t.grid !== s)) {
|
|
886
887
|
if (t.handled = !0, !bo.current) {
|
|
887
888
|
vr.current = { target: t.target, value: t.value ?? null };
|
|
888
889
|
return;
|
|
@@ -891,7 +892,7 @@ function zc({
|
|
|
891
892
|
}
|
|
892
893
|
};
|
|
893
894
|
return window.addEventListener("nvr:grid-apply-field", e), () => window.removeEventListener("nvr:grid-apply-field", e);
|
|
894
|
-
}, [L, A, M, u,
|
|
895
|
+
}, [L, A, M, u, s]), ge(() => {
|
|
895
896
|
const e = wr.current;
|
|
896
897
|
if (!e || !$e) return;
|
|
897
898
|
const n = (t) => {
|
|
@@ -903,7 +904,7 @@ function zc({
|
|
|
903
904
|
};
|
|
904
905
|
return e.addEventListener("keydown", n), () => e.removeEventListener("keydown", n);
|
|
905
906
|
}, [$e]);
|
|
906
|
-
const [cn,
|
|
907
|
+
const [cn, vl] = J(!1), [Pt, xr] = J(/* @__PURE__ */ new Set()), [Dn, yo] = J(!1), wo = (e) => xr((n) => {
|
|
907
908
|
const t = new Set(n);
|
|
908
909
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
909
910
|
}), vo = xt ? xt.line_field ?? "line_number" : null, { data: _r } = Ye({
|
|
@@ -911,26 +912,26 @@ function zc({
|
|
|
911
912
|
queryFn: () => $.request(de(`/erp-submissions/${A}/${encodeURIComponent(String(b))}`)).then((e) => e.data ?? []),
|
|
912
913
|
enabled: !!xt && !!A && !q && !!b,
|
|
913
914
|
staleTime: 15e3
|
|
914
|
-
}),
|
|
915
|
+
}), xl = K(() => {
|
|
915
916
|
const e = /* @__PURE__ */ new Map(), n = _r == null ? void 0 : _r[0];
|
|
916
917
|
if (!n || n.status !== "failed") return e;
|
|
917
918
|
const t = n.response, r = t && typeof t == "object" && Array.isArray(t.orderDetailResponse) ? t.orderDetailResponse : [];
|
|
918
919
|
for (const i of r)
|
|
919
920
|
if (Array.isArray(i == null ? void 0 : i.orderLineDetails))
|
|
920
|
-
for (const
|
|
921
|
-
const a = typeof (
|
|
921
|
+
for (const o of i.orderLineDetails) {
|
|
922
|
+
const a = typeof (o == null ? void 0 : o.lineStatus) == "string" ? o.lineStatus.trim().toUpperCase() : "";
|
|
922
923
|
if (!["ERROR", "FAILED"].includes(a)) continue;
|
|
923
|
-
const c = String((
|
|
924
|
+
const c = String((o == null ? void 0 : o.lineNumber) ?? "");
|
|
924
925
|
if (!c || e.has(c)) continue;
|
|
925
|
-
const d =
|
|
926
|
+
const d = Hd(o == null ? void 0 : o.lineDetailedMessage), g = d.find(
|
|
926
927
|
(p) => new RegExp(`^Line(?:Number)?\\s*${c}\\s*:`, "i").test(p.trim())
|
|
927
928
|
) ?? d[0];
|
|
928
929
|
g && e.set(c, g.replace(/^Line(?:Number)?\s*\d+\s*:\s*/i, ""));
|
|
929
930
|
}
|
|
930
931
|
if (e.size > 0 || !n.last_error) return e;
|
|
931
932
|
for (const i of n.last_error.split(" · ")) {
|
|
932
|
-
const
|
|
933
|
-
|
|
933
|
+
const o = i.trim().match(/^Line(?:Number)?\s+(\d+)\s*:\s*(.*)$/i);
|
|
934
|
+
o && !e.has(o[1]) && e.set(o[1], o[2] || i.trim());
|
|
934
935
|
}
|
|
935
936
|
return e;
|
|
936
937
|
}, [_r]), xo = ae(!1), [_o, di] = J(q && !!F);
|
|
@@ -941,18 +942,18 @@ function zc({
|
|
|
941
942
|
return;
|
|
942
943
|
}
|
|
943
944
|
xo.current = !0, $.request(
|
|
944
|
-
de(`/items/${
|
|
945
|
+
de(`/items/${s}`, {
|
|
945
946
|
filter: JSON.stringify({ [u]: { _eq: F } }),
|
|
946
947
|
limit: co
|
|
947
948
|
})
|
|
948
949
|
).then((e) => {
|
|
949
950
|
for (const n of e.data ?? [])
|
|
950
|
-
x.queueRow(
|
|
951
|
+
x.queueRow(s, u, { __prefilled: !0, ...n });
|
|
951
952
|
di(!1);
|
|
952
953
|
}).catch(() => di(!1));
|
|
953
954
|
}
|
|
954
955
|
}, []);
|
|
955
|
-
const [
|
|
956
|
+
const [_l, ko] = J(!1), kl = K(
|
|
956
957
|
() => /* @__PURE__ */ new Set([
|
|
957
958
|
"id",
|
|
958
959
|
u,
|
|
@@ -965,7 +966,7 @@ function zc({
|
|
|
965
966
|
"creator"
|
|
966
967
|
]),
|
|
967
968
|
[u]
|
|
968
|
-
), No = ae(/* @__PURE__ */ new WeakMap()),
|
|
969
|
+
), No = ae(/* @__PURE__ */ new WeakMap()), Nl = async (e) => {
|
|
969
970
|
const n = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set([
|
|
970
971
|
...Object.keys(Ve),
|
|
971
972
|
...Object.keys(ir)
|
|
@@ -974,21 +975,21 @@ function zc({
|
|
|
974
975
|
[...t].map(async (r) => {
|
|
975
976
|
const i = He.get(r);
|
|
976
977
|
if (!(i != null && i.one_collection)) return;
|
|
977
|
-
const
|
|
978
|
+
const o = [
|
|
978
979
|
...new Set(
|
|
979
980
|
e.map((d) => d[r]).filter((d) => d != null && d !== "").map(String)
|
|
980
981
|
)
|
|
981
982
|
];
|
|
982
|
-
if (
|
|
983
|
+
if (o.length === 0) return;
|
|
983
984
|
const a = [Ve[r], ir[r]].filter(
|
|
984
985
|
(d) => !!d
|
|
985
986
|
), c = a.length === 1 ? a[0] : { _and: a };
|
|
986
987
|
try {
|
|
987
988
|
const d = await $.request(
|
|
988
989
|
de(`/items/${i.one_collection}`, {
|
|
989
|
-
filter: JSON.stringify({ _and: [c, { id: { _in:
|
|
990
|
+
filter: JSON.stringify({ _and: [c, { id: { _in: o } }] }),
|
|
990
991
|
fields: "id",
|
|
991
|
-
limit:
|
|
992
|
+
limit: o.length
|
|
992
993
|
})
|
|
993
994
|
), m = new Set((d.data ?? []).map((g) => String(g.id)));
|
|
994
995
|
for (const g of e) {
|
|
@@ -1000,23 +1001,23 @@ function zc({
|
|
|
1000
1001
|
}
|
|
1001
1002
|
})
|
|
1002
1003
|
), n;
|
|
1003
|
-
},
|
|
1004
|
+
}, Sl = async (e) => {
|
|
1004
1005
|
if (x)
|
|
1005
1006
|
try {
|
|
1006
1007
|
const t = (await $.request(
|
|
1007
|
-
de(`/items/${
|
|
1008
|
+
de(`/items/${s}`, {
|
|
1008
1009
|
filter: JSON.stringify({ [u]: { _eq: e } }),
|
|
1009
1010
|
limit: co
|
|
1010
1011
|
})
|
|
1011
1012
|
)).data ?? [], r = t.map((g) => {
|
|
1012
1013
|
const p = {};
|
|
1013
1014
|
for (const [h, v] of Object.entries(g))
|
|
1014
|
-
!
|
|
1015
|
+
!kl.has(h) && v != null && typeof v != "object" && (p[h] = v);
|
|
1015
1016
|
return p;
|
|
1016
|
-
}), i = await
|
|
1017
|
-
en(
|
|
1017
|
+
}), i = await Nl(r), { rows: o, dropped: a } = Fd(r, i);
|
|
1018
|
+
en(o).forEach((g, p) => {
|
|
1018
1019
|
var h;
|
|
1019
|
-
(h = a[p]) != null && h.length && No.current.set(g, new Set(a[p])), x.queueRow(
|
|
1020
|
+
(h = a[p]) != null && h.length && No.current.set(g, new Set(a[p])), x.queueRow(s, u, g);
|
|
1020
1021
|
});
|
|
1021
1022
|
const d = a.filter((g) => g.length > 0).length, m = [...new Set(a.flat())].map(
|
|
1022
1023
|
(g) => {
|
|
@@ -1030,25 +1031,25 @@ function zc({
|
|
|
1030
1031
|
} catch {
|
|
1031
1032
|
be.error("Could not copy lines");
|
|
1032
1033
|
}
|
|
1033
|
-
}, ut = A && !q ? `?parent_collection=${encodeURIComponent(A)}&parent_id=${encodeURIComponent(b)}` : "", [Oe, Wn] = J(null), [
|
|
1034
|
-
queryKey: ["o2m-row-revisions",
|
|
1034
|
+
}, ut = A && !q ? `?parent_collection=${encodeURIComponent(A)}&parent_id=${encodeURIComponent(b)}` : "", [Oe, Wn] = J(null), [$l, ci] = J(null), [So, kr] = J(!1), [ql, $o] = J(!1), { data: El = [], isLoading: Ol } = Ye({
|
|
1035
|
+
queryKey: ["o2m-row-revisions", s, Oe == null ? void 0 : Oe.id],
|
|
1035
1036
|
queryFn: () => $.request(
|
|
1036
|
-
de("/revisions", { collection:
|
|
1037
|
+
de("/revisions", { collection: s, item: String(Oe == null ? void 0 : Oe.id) })
|
|
1037
1038
|
).then((e) => e.data ?? []),
|
|
1038
1039
|
enabled: !!(Oe != null && Oe.id),
|
|
1039
1040
|
staleTime: 15e3
|
|
1040
|
-
}), { data: Yt, isLoading:
|
|
1041
|
-
queryKey: ["o2m-field-snapshots",
|
|
1041
|
+
}), { data: Yt, isLoading: Il } = Ye({
|
|
1042
|
+
queryKey: ["o2m-field-snapshots", s, u, b],
|
|
1042
1043
|
queryFn: () => $.request(
|
|
1043
1044
|
de("/revisions/o2m-snapshots", {
|
|
1044
|
-
collection:
|
|
1045
|
+
collection: s,
|
|
1045
1046
|
many_field: u,
|
|
1046
1047
|
parent_id: b
|
|
1047
1048
|
})
|
|
1048
1049
|
),
|
|
1049
1050
|
enabled: So && !q,
|
|
1050
1051
|
staleTime: 15e3
|
|
1051
|
-
}),
|
|
1052
|
+
}), Al = K(
|
|
1052
1053
|
() => ((Yt == null ? void 0 : Yt.data) ?? []).map((e) => ({
|
|
1053
1054
|
id: e.revision_id,
|
|
1054
1055
|
delta: e.delta ?? null,
|
|
@@ -1063,19 +1064,19 @@ function zc({
|
|
|
1063
1064
|
})),
|
|
1064
1065
|
[Yt]
|
|
1065
1066
|
);
|
|
1066
|
-
async function
|
|
1067
|
+
async function jl(e) {
|
|
1067
1068
|
$o(!0);
|
|
1068
1069
|
try {
|
|
1069
1070
|
const n = await $.request(
|
|
1070
1071
|
Le("/revisions/o2m-restore", {
|
|
1071
|
-
collection:
|
|
1072
|
+
collection: s,
|
|
1072
1073
|
many_field: u,
|
|
1073
1074
|
parent_id: b,
|
|
1074
1075
|
target_timestamp: e
|
|
1075
1076
|
})
|
|
1076
|
-
), t =
|
|
1077
|
-
t && be.warning(t, { duration: 1e4 }), z.invalidateQueries({ queryKey: ["o2m-rows",
|
|
1078
|
-
queryKey: ["o2m-field-snapshots",
|
|
1077
|
+
), t = Za(n);
|
|
1078
|
+
t && be.warning(t, { duration: 1e4 }), z.invalidateQueries({ queryKey: ["o2m-rows", s, u, b] }), z.invalidateQueries({
|
|
1079
|
+
queryKey: ["o2m-field-snapshots", s, u, b]
|
|
1079
1080
|
}), kr(!1);
|
|
1080
1081
|
} catch {
|
|
1081
1082
|
} finally {
|
|
@@ -1088,13 +1089,13 @@ function zc({
|
|
|
1088
1089
|
(D ?? []).filter((e) => e.target_type === "lock").map((e) => e.target_field)
|
|
1089
1090
|
),
|
|
1090
1091
|
[D]
|
|
1091
|
-
), [f, Be] = J(null), ft =
|
|
1092
|
+
), [f, Be] = J(null), ft = Wa(), Bn = (e, n) => `${ft}-${e}-${n}`, Ce = ae(null), qo = (e, n) => e && e !== "new" && !e.startsWith("pending:") ? `${s}:${e}:${n}` : void 0, qt = ae(null), Nr = (e, n) => {
|
|
1092
1093
|
!e || typeof window > "u" || window.dispatchEvent(new CustomEvent("nvr:cell-editing", { detail: { cell: e, state: n } }));
|
|
1093
|
-
},
|
|
1094
|
+
}, Ll = (e) => {
|
|
1094
1095
|
var t, r, i;
|
|
1095
1096
|
const n = ((i = (r = (t = e.target) == null ? void 0 : t.closest) == null ? void 0 : r.call(t, "[data-grid-cell]")) == null ? void 0 : i.getAttribute("data-grid-cell")) ?? null;
|
|
1096
1097
|
n !== qt.current && (qt.current && Nr(qt.current, "end"), qt.current = n, n && Nr(n, "start"));
|
|
1097
|
-
},
|
|
1098
|
+
}, Tl = (e) => {
|
|
1098
1099
|
var t, r;
|
|
1099
1100
|
(r = (t = e.relatedTarget) == null ? void 0 : t.closest) != null && r.call(t, "[data-grid-cell]") || (qt.current && Nr(qt.current, "end"), qt.current = null);
|
|
1100
1101
|
};
|
|
@@ -1106,7 +1107,7 @@ function zc({
|
|
|
1106
1107
|
);
|
|
1107
1108
|
const un = ae(null);
|
|
1108
1109
|
ge(() => {
|
|
1109
|
-
const e = f == null ? void 0 : f.rowId, n = e && e !== "new" && !e.startsWith("pending:") ? `${
|
|
1110
|
+
const e = f == null ? void 0 : f.rowId, n = e && e !== "new" && !e.startsWith("pending:") ? `${s}:${e}` : null;
|
|
1110
1111
|
n !== un.current && (typeof window > "u" || (un.current && window.dispatchEvent(
|
|
1111
1112
|
new CustomEvent("nvr:row-editing", {
|
|
1112
1113
|
detail: { row: un.current, state: "end" }
|
|
@@ -1114,7 +1115,7 @@ function zc({
|
|
|
1114
1115
|
), n && window.dispatchEvent(
|
|
1115
1116
|
new CustomEvent("nvr:row-editing", { detail: { row: n, state: "start" } })
|
|
1116
1117
|
), un.current = n));
|
|
1117
|
-
}, [f == null ? void 0 : f.rowId,
|
|
1118
|
+
}, [f == null ? void 0 : f.rowId, s]), ge(
|
|
1118
1119
|
() => () => {
|
|
1119
1120
|
un.current && typeof window < "u" && window.dispatchEvent(
|
|
1120
1121
|
new CustomEvent("nvr:row-editing", {
|
|
@@ -1184,22 +1185,22 @@ function zc({
|
|
|
1184
1185
|
return document.addEventListener("mousedown", e, !0), () => document.removeEventListener("mousedown", e, !0);
|
|
1185
1186
|
}, [f, L]);
|
|
1186
1187
|
const [_t, fn] = J(!1), [jo, Et] = J(null), [Qn, $r] = J(null), [Lo, To] = J(!1);
|
|
1187
|
-
async function
|
|
1188
|
+
async function Rl() {
|
|
1188
1189
|
if (!Qn) return;
|
|
1189
1190
|
To(!0);
|
|
1190
1191
|
const e = [];
|
|
1191
1192
|
let n = "";
|
|
1192
1193
|
for (const r of Qn.groups) {
|
|
1193
1194
|
const i = [];
|
|
1194
|
-
for (const
|
|
1195
|
+
for (const o of r.members)
|
|
1195
1196
|
try {
|
|
1196
|
-
await $.request(Le(`/items/${r.collection}`, { ...
|
|
1197
|
+
await $.request(Le(`/items/${r.collection}`, { ...o, [r.fkField]: r.rowId }));
|
|
1197
1198
|
} catch (a) {
|
|
1198
|
-
i.push(
|
|
1199
|
+
i.push(o), n || (n = ml(a));
|
|
1199
1200
|
}
|
|
1200
1201
|
i.length && e.push({ ...r, members: i });
|
|
1201
1202
|
}
|
|
1202
|
-
To(!1), z.invalidateQueries({ queryKey: ["o2m-rows",
|
|
1203
|
+
To(!1), z.invalidateQueries({ queryKey: ["o2m-rows", s, u, b] });
|
|
1203
1204
|
const t = e.reduce((r, i) => r + i.members.length, 0);
|
|
1204
1205
|
$r(
|
|
1205
1206
|
t > 0 ? {
|
|
@@ -1208,35 +1209,35 @@ function zc({
|
|
|
1208
1209
|
} : null
|
|
1209
1210
|
);
|
|
1210
1211
|
}
|
|
1211
|
-
const [qr, zn] = J(null), Ie =
|
|
1212
|
+
const [qr, zn] = J(null), Ie = ad(), [fi, Ml] = J(() => {
|
|
1212
1213
|
var e;
|
|
1213
1214
|
return Ne === pr ? pr : Ne && (re != null && re.some((n) => n.name === Ne)) ? Ne : (e = re == null ? void 0 : re[0]) == null ? void 0 : e.name;
|
|
1214
1215
|
});
|
|
1215
1216
|
function Ro(e) {
|
|
1216
|
-
|
|
1217
|
+
Ml(e);
|
|
1217
1218
|
}
|
|
1218
1219
|
const pt = ae(null), Fn = ae(!1), Er = (e) => {
|
|
1219
1220
|
const n = e;
|
|
1220
1221
|
return !n || !(n instanceof HTMLElement) ? !1 : n.isConnected ? !!(n.closest("[data-o2m-editing]") || n.closest("[data-radix-popper-content-wrapper]") || n.closest("[data-nvr-combobox-panel]") || n.closest('[role="dialog"]') || n.closest("[data-omx-overlay]")) : !0;
|
|
1221
1222
|
}, { data: mi } = Ye({
|
|
1222
|
-
queryKey: ["auto-table-layout",
|
|
1223
|
+
queryKey: ["auto-table-layout", s],
|
|
1223
1224
|
queryFn: () => $.request(
|
|
1224
|
-
de("/collection-layouts", { collection:
|
|
1225
|
+
de("/collection-layouts", { collection: s })
|
|
1225
1226
|
).then((e) => (e.data ?? []).find((n) => n.layout_type === "table") ?? null),
|
|
1226
1227
|
enabled: !U,
|
|
1227
1228
|
staleTime: 5 * 6e4
|
|
1228
1229
|
}), Ct = U ?? (mi == null ? void 0 : mi.id) ?? null, { data: ce = [], isLoading: Mo } = Ye({
|
|
1229
|
-
queryKey: ["field-config",
|
|
1230
|
+
queryKey: ["field-config", s, Ct],
|
|
1230
1231
|
queryFn: () => $.request(
|
|
1231
1232
|
de(
|
|
1232
|
-
`/field-config/${
|
|
1233
|
+
`/field-config/${s}`,
|
|
1233
1234
|
Ct ? { layout_id: String(Ct) } : void 0
|
|
1234
1235
|
)
|
|
1235
1236
|
).then((e) => e.data ?? []),
|
|
1236
1237
|
staleTime: 6e4
|
|
1237
1238
|
}), { data: Me = [] } = Ye({
|
|
1238
|
-
queryKey: ["collection-meta",
|
|
1239
|
-
queryFn: () => $.request(de(`/collections/${
|
|
1239
|
+
queryKey: ["collection-meta", s],
|
|
1240
|
+
queryFn: () => $.request(de(`/collections/${s}`)).then((e) => {
|
|
1240
1241
|
const n = e.data;
|
|
1241
1242
|
return (n == null ? void 0 : n.relations) ?? [];
|
|
1242
1243
|
}),
|
|
@@ -1268,13 +1269,13 @@ function zc({
|
|
|
1268
1269
|
} = Ye({
|
|
1269
1270
|
queryKey: [
|
|
1270
1271
|
"o2m-rows",
|
|
1271
|
-
|
|
1272
|
+
s,
|
|
1272
1273
|
u,
|
|
1273
1274
|
b,
|
|
1274
1275
|
Or ? JSON.stringify(Or) : ""
|
|
1275
1276
|
],
|
|
1276
1277
|
queryFn: () => $.request(
|
|
1277
|
-
de(`/items/${
|
|
1278
|
+
de(`/items/${s}`, {
|
|
1278
1279
|
filter: JSON.stringify(
|
|
1279
1280
|
Or ? { _and: [{ [u]: { _eq: b } }, Or] } : { [u]: { _eq: b } }
|
|
1280
1281
|
),
|
|
@@ -1284,8 +1285,8 @@ function zc({
|
|
|
1284
1285
|
enabled: !q,
|
|
1285
1286
|
staleTime: 3e4
|
|
1286
1287
|
}), kt = K(
|
|
1287
|
-
() =>
|
|
1288
|
-
[$,
|
|
1288
|
+
() => wd($, s),
|
|
1289
|
+
[$, s]
|
|
1289
1290
|
);
|
|
1290
1291
|
ge(() => {
|
|
1291
1292
|
!q && !L && kt.noteRows(Je);
|
|
@@ -1301,19 +1302,19 @@ function zc({
|
|
|
1301
1302
|
for (const r of e) t.set(r.rowId, r);
|
|
1302
1303
|
return [...t.values()];
|
|
1303
1304
|
});
|
|
1304
|
-
},
|
|
1305
|
-
queryKey: ["o2m-cell-provenance",
|
|
1305
|
+
}, Kl = Va(2e3), { data: gn } = Ye({
|
|
1306
|
+
queryKey: ["o2m-cell-provenance", s, u, b, Ir],
|
|
1306
1307
|
queryFn: () => $.request(
|
|
1307
1308
|
de("/revisions/o2m-cell-provenance", {
|
|
1308
|
-
collection:
|
|
1309
|
+
collection: s,
|
|
1309
1310
|
many_field: u,
|
|
1310
1311
|
parent_id: b
|
|
1311
1312
|
})
|
|
1312
1313
|
).then((e) => ({ data: e.data ?? {}, created: e.created ?? {} })),
|
|
1313
|
-
enabled:
|
|
1314
|
+
enabled: Kl && !!B && !q && Je.length > 0,
|
|
1314
1315
|
staleTime: 6e4,
|
|
1315
1316
|
placeholderData: (e) => e
|
|
1316
|
-
}),
|
|
1317
|
+
}), Pl = !!(at != null && at.enabled) && typeof (at == null ? void 0 : at.field) == "string", { data: it } = Ye({
|
|
1317
1318
|
queryKey: [
|
|
1318
1319
|
"line-aging",
|
|
1319
1320
|
A ?? "",
|
|
@@ -1328,31 +1329,31 @@ function zc({
|
|
|
1328
1329
|
parent_id: b
|
|
1329
1330
|
})
|
|
1330
1331
|
).then((e) => e.data ?? null),
|
|
1331
|
-
enabled:
|
|
1332
|
+
enabled: Pl && !q && !!A,
|
|
1332
1333
|
staleTime: 6e4,
|
|
1333
1334
|
placeholderData: (e) => e
|
|
1334
1335
|
}), Ko = K(
|
|
1335
1336
|
() => new Set(it != null && it.overdue ? it.overdue_ids : []),
|
|
1336
1337
|
[it]
|
|
1337
|
-
), Po = it != null && it.overdue ? `${it.label} still missing · ${it.days} ${it.days === 1 ? "day" : "days"} on the clock (limit ${it.threshold_days})` : void 0, bi = (gn == null ? void 0 : gn.data) ?? {},
|
|
1338
|
-
const n =
|
|
1338
|
+
), Po = it != null && it.overdue ? `${it.label} still missing · ${it.days} ${it.days === 1 ? "day" : "days"} on the clock (limit ${it.threshold_days})` : void 0, bi = (gn == null ? void 0 : gn.data) ?? {}, Dl = (gn == null ? void 0 : gn.created) ?? {}, jr = (e) => {
|
|
1339
|
+
const n = Dl[e];
|
|
1339
1340
|
if (!n) return null;
|
|
1340
|
-
const t =
|
|
1341
|
-
return t ? `From ${t.template} · ${
|
|
1341
|
+
const t = Kd(n.comment);
|
|
1342
|
+
return t ? `From ${t.template} · ${rl(n.at)} by ${n.who}` : null;
|
|
1342
1343
|
}, Zt = je ?? [], Do = dn({
|
|
1343
1344
|
queries: Zt.map((e) => ({
|
|
1344
1345
|
queryKey: [
|
|
1345
1346
|
"resolve-cascade",
|
|
1346
1347
|
S == null ? void 0 : S.collection,
|
|
1347
1348
|
e.parent_field,
|
|
1348
|
-
|
|
1349
|
+
s,
|
|
1349
1350
|
e.child_field
|
|
1350
1351
|
],
|
|
1351
1352
|
queryFn: () => $.request(
|
|
1352
1353
|
de("/data-model/resolve-cascade", {
|
|
1353
1354
|
parent_collection: S.collection,
|
|
1354
1355
|
parent_field: e.parent_field,
|
|
1355
|
-
child_collection:
|
|
1356
|
+
child_collection: s,
|
|
1356
1357
|
child_field: e.child_field
|
|
1357
1358
|
})
|
|
1358
1359
|
).then((n) => n.data),
|
|
@@ -1362,8 +1363,8 @@ function zc({
|
|
|
1362
1363
|
}), Ve = K(() => {
|
|
1363
1364
|
const e = {};
|
|
1364
1365
|
return !S || !Zt.length || Zt.forEach((n, t) => {
|
|
1365
|
-
var
|
|
1366
|
-
const r = (
|
|
1366
|
+
var o;
|
|
1367
|
+
const r = (o = Do[t]) == null ? void 0 : o.data;
|
|
1367
1368
|
if (!r || r.type === "none") return;
|
|
1368
1369
|
const i = S.draft[n.parent_field];
|
|
1369
1370
|
i == null || i === "" || (r.type === "direct_fk" ? e[n.child_field] = { [r.filter_column]: { _eq: i } } : r.type === "m2m_junction" && (e[n.child_field] = {
|
|
@@ -1380,15 +1381,15 @@ function zc({
|
|
|
1380
1381
|
const e = {};
|
|
1381
1382
|
for (const r of Zt) {
|
|
1382
1383
|
if (!Ve[r.child_field]) continue;
|
|
1383
|
-
const i = ((n = S == null ? void 0 : S.fieldLabels) == null ? void 0 : n[r.parent_field]) ?? ve(r.parent_field),
|
|
1384
|
-
|
|
1384
|
+
const i = ((n = S == null ? void 0 : S.fieldLabels) == null ? void 0 : n[r.parent_field]) ?? ve(r.parent_field), o = e[t = r.child_field] ?? (e[t] = { labels: [], keys: [] });
|
|
1385
|
+
o.labels.push(i), o.keys.push(r.parent_field);
|
|
1385
1386
|
}
|
|
1386
1387
|
return e;
|
|
1387
|
-
}, [Zt, Ve, S == null ? void 0 : S.fieldLabels]), W = Q === "pending", P = x ? x.getPendingRows(
|
|
1388
|
+
}, [Zt, Ve, S == null ? void 0 : S.fieldLabels]), W = Q === "pending", P = x ? x.getPendingRows(s, u) : [], C = W && x ? x.getPendingEdits(s, u) : /* @__PURE__ */ new Map(), [Tr, Rr] = J({});
|
|
1388
1389
|
ge(() => {
|
|
1389
1390
|
Ce.current || Rr({});
|
|
1390
1391
|
}, [Ir]);
|
|
1391
|
-
const Qe = W && x ? x.getPendingDeletes(
|
|
1392
|
+
const Qe = W && x ? x.getPendingDeletes(s, u) : /* @__PURE__ */ new Set(), yi = K(
|
|
1392
1393
|
() => new Map(
|
|
1393
1394
|
ce.filter((e) => e.computed_type === "write" && !!e.computed_formula).map((e) => [e.field, String(e.computed_formula)])
|
|
1394
1395
|
),
|
|
@@ -1405,7 +1406,7 @@ function zc({
|
|
|
1405
1406
|
return {};
|
|
1406
1407
|
}
|
|
1407
1408
|
})() : e.options : {}, t = n.match ?? {}, r = {}, i = [];
|
|
1408
|
-
let
|
|
1409
|
+
let o = !1;
|
|
1409
1410
|
for (const [a, c] of Object.entries(t.filters ?? {})) {
|
|
1410
1411
|
if (typeof c == "string" && c.startsWith("$row.")) {
|
|
1411
1412
|
i.push([a, c.slice(5)]);
|
|
@@ -1413,7 +1414,7 @@ function zc({
|
|
|
1413
1414
|
}
|
|
1414
1415
|
const d = po(c, {}, b, S == null ? void 0 : S.draft);
|
|
1415
1416
|
if (d == null || d === "") {
|
|
1416
|
-
|
|
1417
|
+
o = !0;
|
|
1417
1418
|
continue;
|
|
1418
1419
|
}
|
|
1419
1420
|
if (a.startsWith("_")) {
|
|
@@ -1434,7 +1435,7 @@ function zc({
|
|
|
1434
1435
|
collection: t.collection ?? "",
|
|
1435
1436
|
parentClauses: r,
|
|
1436
1437
|
rowKeys: i,
|
|
1437
|
-
unresolved:
|
|
1438
|
+
unresolved: o,
|
|
1438
1439
|
aggregate: n.aggregate ?? "sum",
|
|
1439
1440
|
valueField: n.value_field ?? "",
|
|
1440
1441
|
formula: typeof n.formula == "string" ? n.formula : null,
|
|
@@ -1465,7 +1466,7 @@ function zc({
|
|
|
1465
1466
|
enabled: !e.unresolved && !!e.collection && !q,
|
|
1466
1467
|
staleTime: 3e4
|
|
1467
1468
|
}))
|
|
1468
|
-
}),
|
|
1469
|
+
}), Wl = K(() => {
|
|
1469
1470
|
const e = /* @__PURE__ */ new Map();
|
|
1470
1471
|
return wi.forEach((n, t) => {
|
|
1471
1472
|
var r;
|
|
@@ -1492,7 +1493,7 @@ function zc({
|
|
|
1492
1493
|
const e = new Set(Wo);
|
|
1493
1494
|
for (const n of Qo) e.add(n);
|
|
1494
1495
|
return we != null && we.includes(".") && e.add(we), [...e];
|
|
1495
|
-
}, [Wo, Qo, we]),
|
|
1496
|
+
}, [Wo, Qo, we]), Ul = P.map((e) => String(e.id ?? "")).join(","), xi = K(() => {
|
|
1496
1497
|
const e = /* @__PURE__ */ new Set(), n = (t) => {
|
|
1497
1498
|
const r = t == null ? "" : String(t);
|
|
1498
1499
|
r && !r.startsWith("pending:") && r !== "new" && e.add(r);
|
|
@@ -1504,17 +1505,17 @@ function zc({
|
|
|
1504
1505
|
for (const r of (t == null ? void 0 : t.rows) ?? []) n(r.id);
|
|
1505
1506
|
}
|
|
1506
1507
|
return [...e];
|
|
1507
|
-
}, [Je,
|
|
1508
|
+
}, [Je, Ul, Ie, dt]), { data: Ae } = Ye({
|
|
1508
1509
|
queryKey: [
|
|
1509
1510
|
"o2m-resolve-paths",
|
|
1510
|
-
|
|
1511
|
+
s,
|
|
1511
1512
|
u,
|
|
1512
1513
|
b,
|
|
1513
1514
|
vi.join(","),
|
|
1514
1515
|
xi.join(",")
|
|
1515
1516
|
],
|
|
1516
1517
|
queryFn: () => $.request(
|
|
1517
|
-
de(`/items/${
|
|
1518
|
+
de(`/items/${s}/resolve-paths`, {
|
|
1518
1519
|
ids: xi.join(","),
|
|
1519
1520
|
paths: vi.join(",")
|
|
1520
1521
|
})
|
|
@@ -1539,14 +1540,14 @@ function zc({
|
|
|
1539
1540
|
e = [...e].sort((t, r) => n(t) - n(r));
|
|
1540
1541
|
}
|
|
1541
1542
|
if (fe && (e = [...e].sort((n, t) => {
|
|
1542
|
-
const r = W ? C.get(String(n.id)) : void 0, i = W ? C.get(String(t.id)) : void 0,
|
|
1543
|
+
const r = W ? C.get(String(n.id)) : void 0, i = W ? C.get(String(t.id)) : void 0, o = (r == null ? void 0 : r[fe]) ?? n[fe], a = (i == null ? void 0 : i[fe]) ?? t[fe];
|
|
1543
1544
|
let c = 0;
|
|
1544
|
-
return
|
|
1545
|
+
return o == null && a == null ? c = 0 : o == null ? c = 1 : a == null ? c = -1 : typeof o == "number" && typeof a == "number" ? c = o - a : c = String(o).localeCompare(String(a), void 0, { sensitivity: "base" }), ze === "desc" ? -c : c;
|
|
1545
1546
|
})), we && ht) {
|
|
1546
1547
|
const n = (t) => String(t[we] ?? "").trim();
|
|
1547
1548
|
e = [...e].sort((t, r) => {
|
|
1548
|
-
const i = n(t),
|
|
1549
|
-
return i ===
|
|
1549
|
+
const i = n(t), o = n(r);
|
|
1550
|
+
return i === o ? 0 : i ? o ? i.localeCompare(o, void 0, { sensitivity: "base" }) : -1 : 1;
|
|
1550
1551
|
});
|
|
1551
1552
|
}
|
|
1552
1553
|
return e;
|
|
@@ -1559,7 +1560,7 @@ function zc({
|
|
|
1559
1560
|
fe,
|
|
1560
1561
|
ze,
|
|
1561
1562
|
we
|
|
1562
|
-
]), zo = !!we && !!ht, Mr = we ? `nvr_grid_sections:${
|
|
1563
|
+
]), zo = !!we && !!ht, Mr = we ? `nvr_grid_sections:${s}:${M ?? u}` : null, [Fo, Bl] = J(() => {
|
|
1563
1564
|
if (!Mr || typeof localStorage > "u") return /* @__PURE__ */ new Set();
|
|
1564
1565
|
try {
|
|
1565
1566
|
const e = localStorage.getItem(Mr), n = e ? JSON.parse(e) : null;
|
|
@@ -1567,7 +1568,7 @@ function zc({
|
|
|
1567
1568
|
} catch {
|
|
1568
1569
|
return /* @__PURE__ */ new Set();
|
|
1569
1570
|
}
|
|
1570
|
-
}), Hn = (e) => String(e[we ?? ""] ?? "").trim() || "Uncategorized",
|
|
1571
|
+
}), Hn = (e) => String(e[we ?? ""] ?? "").trim() || "Uncategorized", Jl = (e) => Bl((n) => {
|
|
1571
1572
|
const t = new Set(n);
|
|
1572
1573
|
if (t.has(e) ? t.delete(e) : t.add(e), Mr)
|
|
1573
1574
|
try {
|
|
@@ -1575,17 +1576,17 @@ function zc({
|
|
|
1575
1576
|
} catch {
|
|
1576
1577
|
}
|
|
1577
1578
|
return t;
|
|
1578
|
-
}),
|
|
1579
|
+
}), Ql = (e) => {
|
|
1579
1580
|
const n = [];
|
|
1580
1581
|
for (const t of Ke) {
|
|
1581
1582
|
const r = oo(t.options) ?? {}, i = r.aggregate;
|
|
1582
1583
|
if (!i || t.interface === "formula-column" || t.interface === "match-agg-column") continue;
|
|
1583
|
-
const
|
|
1584
|
+
const o = e.map((d) => {
|
|
1584
1585
|
const m = String(d.id), g = C.has(m) ? { ...d, ...C.get(m) } : d;
|
|
1585
1586
|
return Number(he(g)[t.field]);
|
|
1586
1587
|
}).filter((d) => !Number.isNaN(d));
|
|
1587
1588
|
let a = null;
|
|
1588
|
-
if (i === "count" ? a = e.length :
|
|
1589
|
+
if (i === "count" ? a = e.length : o.length > 0 && (i === "sum" ? a = o.reduce((d, m) => d + m, 0) : i === "avg" ? a = o.reduce((d, m) => d + m, 0) / o.length : i === "min" ? a = Math.min(...o) : i === "max" && (a = Math.max(...o))), a === null) continue;
|
|
1589
1590
|
const c = r.format === "currency" ? a.toLocaleString("en-US", {
|
|
1590
1591
|
...St(r, "currency"),
|
|
1591
1592
|
currency: r.currency || "USD"
|
|
@@ -1606,9 +1607,9 @@ function zc({
|
|
|
1606
1607
|
if (!_i.length) return e;
|
|
1607
1608
|
const t = n === void 0 ? Vo(e.id) : n, r = { ...e };
|
|
1608
1609
|
for (const i of _i) {
|
|
1609
|
-
const
|
|
1610
|
-
if (t && !
|
|
1611
|
-
const a = Ft(
|
|
1610
|
+
const o = i.computed_formula;
|
|
1611
|
+
if (t && !td(o, r, t)) continue;
|
|
1612
|
+
const a = Ft(o, r);
|
|
1612
1613
|
a !== null && (r[i.field] = a);
|
|
1613
1614
|
}
|
|
1614
1615
|
return r;
|
|
@@ -1619,10 +1620,10 @@ function zc({
|
|
|
1619
1620
|
if (!(n.startsWith("pending:") || n === "new"))
|
|
1620
1621
|
return O.find((t) => String(t.id) === n);
|
|
1621
1622
|
}
|
|
1622
|
-
const
|
|
1623
|
+
const zl = /* @__PURE__ */ new Set(["__apply_values__", "__create_with_defaults__"]), Yn = (e) => e === "select-multiple-m2m" || (e ?? "").endsWith("-m2m");
|
|
1623
1624
|
function ki(e) {
|
|
1624
1625
|
const n = Me.find(
|
|
1625
|
-
(r) => r.one_collection ===
|
|
1626
|
+
(r) => r.one_collection === s && (r.one_field === e.field || r.junction_field != null && r.many_collection === e.field)
|
|
1626
1627
|
);
|
|
1627
1628
|
if (!n) return null;
|
|
1628
1629
|
const t = Me.find(
|
|
@@ -1636,12 +1637,12 @@ function zc({
|
|
|
1636
1637
|
};
|
|
1637
1638
|
}
|
|
1638
1639
|
const Ni = JSON.stringify([...C.entries()]) + "|" + [...Qe].sort().join(",") + "|" + JSON.stringify(P), Gn = (e, n = []) => {
|
|
1639
|
-
var
|
|
1640
|
+
var o;
|
|
1640
1641
|
if (!G) return e;
|
|
1641
1642
|
const t = new Set(n);
|
|
1642
1643
|
for (const a of O) {
|
|
1643
1644
|
const c = Number(
|
|
1644
|
-
(W ? (
|
|
1645
|
+
(W ? (o = C.get(String(a.id))) == null ? void 0 : o[G] : void 0) ?? a[G]
|
|
1645
1646
|
);
|
|
1646
1647
|
Number.isFinite(c) && t.add(c);
|
|
1647
1648
|
}
|
|
@@ -1694,16 +1695,16 @@ function zc({
|
|
|
1694
1695
|
},
|
|
1695
1696
|
[Ot, Cn]
|
|
1696
1697
|
), $i = K(() => Re != null && Re.length ? Re.map((e) => ({ ...e, result: wt(e.value, tn) })) : null, [Re, tn]), Kr = K(
|
|
1697
|
-
() => Pe != null && Pe.endpoint ?
|
|
1698
|
+
() => Pe != null && Pe.endpoint ? dd(Pe.endpoint, Ot) : null,
|
|
1698
1699
|
[Pe == null ? void 0 : Pe.endpoint, Ot]
|
|
1699
|
-
), qi =
|
|
1700
|
+
), qi = cd({
|
|
1700
1701
|
client: $,
|
|
1701
1702
|
endpoint: Kr,
|
|
1702
1703
|
enabled: !!Pe && !q
|
|
1703
1704
|
}), j = Pe && !q ? qi.data ?? null : null, Yo = !!Pe && !q && !!Kr && qi.isLoading, Go = !!Pe && !q && qi.isError, Xn = Rt(
|
|
1704
1705
|
(e) => e.label || ve(e.field),
|
|
1705
1706
|
[]
|
|
1706
|
-
), { isAdmin: bn } =
|
|
1707
|
+
), { isAdmin: bn } = Fa(), Pr = Rt(
|
|
1707
1708
|
(e) => {
|
|
1708
1709
|
var n;
|
|
1709
1710
|
return !bn && ((n = oo(e.options)) == null ? void 0 : n.admin_only_edit) === !0;
|
|
@@ -1717,7 +1718,7 @@ function zc({
|
|
|
1717
1718
|
if (e.startsWith("pending:")) {
|
|
1718
1719
|
const r = Number(e.slice(8)), i = P[r];
|
|
1719
1720
|
i && x && x.updateRow(
|
|
1720
|
-
|
|
1721
|
+
s,
|
|
1721
1722
|
u,
|
|
1722
1723
|
r,
|
|
1723
1724
|
he({ ...i, ...n })
|
|
@@ -1725,7 +1726,7 @@ function zc({
|
|
|
1725
1726
|
return;
|
|
1726
1727
|
}
|
|
1727
1728
|
if (W && x) {
|
|
1728
|
-
x.queueEdit(
|
|
1729
|
+
x.queueEdit(s, u, e, {
|
|
1729
1730
|
...n,
|
|
1730
1731
|
_change_reason: t,
|
|
1731
1732
|
...pn(e)
|
|
@@ -1733,17 +1734,17 @@ function zc({
|
|
|
1733
1734
|
return;
|
|
1734
1735
|
}
|
|
1735
1736
|
try {
|
|
1736
|
-
await Li(`/items/${
|
|
1737
|
+
await Li(`/items/${s}/${e}`, e, {
|
|
1737
1738
|
...n,
|
|
1738
1739
|
_change_reason: t
|
|
1739
|
-
}), z.invalidateQueries({ queryKey: ["o2m-rows",
|
|
1740
|
+
}), z.invalidateQueries({ queryKey: ["o2m-rows", s, u, b] });
|
|
1740
1741
|
} catch (r) {
|
|
1741
1742
|
be.error(`Could not save: ${Tn(r, "unknown error")}`);
|
|
1742
1743
|
}
|
|
1743
1744
|
},
|
|
1744
1745
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1745
|
-
[P, x, W,
|
|
1746
|
-
), Zn = Kr ? `nvr_compare_dismiss:${Kr}` : null, [Co,
|
|
1746
|
+
[P, x, W, s, u, $, z, b]
|
|
1747
|
+
), Zn = Kr ? `nvr_compare_dismiss:${Kr}` : null, [Co, Fl] = J(() => {
|
|
1747
1748
|
try {
|
|
1748
1749
|
return !Zn || typeof window > "u" ? /* @__PURE__ */ new Set() : new Set(JSON.parse(window.localStorage.getItem(Zn) ?? "[]"));
|
|
1749
1750
|
} catch {
|
|
@@ -1757,7 +1758,7 @@ function zc({
|
|
|
1757
1758
|
[j == null ? void 0 : j.proposals, Co]
|
|
1758
1759
|
), Oi = Rt(
|
|
1759
1760
|
(e, n = !0) => {
|
|
1760
|
-
|
|
1761
|
+
Fl((t) => {
|
|
1761
1762
|
const r = new Set(t);
|
|
1762
1763
|
r.add(e.id);
|
|
1763
1764
|
try {
|
|
@@ -1768,19 +1769,19 @@ function zc({
|
|
|
1768
1769
|
});
|
|
1769
1770
|
},
|
|
1770
1771
|
[Zn]
|
|
1771
|
-
),
|
|
1772
|
+
), Vl = Rt(
|
|
1772
1773
|
(e) => {
|
|
1773
1774
|
if (!j) return;
|
|
1774
1775
|
const n = j.key_field, t = e.change_reason ?? e.label, r = (a) => a == null || a === "" || Number(a) === 0;
|
|
1775
1776
|
let i = 0;
|
|
1776
|
-
const
|
|
1777
|
+
const o = (x == null ? void 0 : x.getPendingEdits(s, u)) ?? /* @__PURE__ */ new Map();
|
|
1777
1778
|
for (const a of e.rows) {
|
|
1778
1779
|
if (a.category != null) continue;
|
|
1779
|
-
const c = O.find((p) => String(p[n]) === String(a.key)), d = P.findIndex((p) => String(p[n]) === String(a.key)), m = c ? { ...c, ...
|
|
1780
|
+
const c = O.find((p) => String(p[n]) === String(a.key)), d = P.findIndex((p) => String(p[n]) === String(a.key)), m = c ? { ...c, ...o.get(String(c.id)) ?? {} } : d >= 0 ? P[d] : null, g = {};
|
|
1780
1781
|
for (const [p, h] of Object.entries(a.values))
|
|
1781
1782
|
zt(j, a.key, p) || m && !r(m[p]) || (g[p] = h);
|
|
1782
1783
|
Object.keys(g).length !== 0 && (i++, c ? yn(String(c.id), g, t) : d >= 0 ? yn(`pending:${d}`, g, t) : x && x.queueRow(
|
|
1783
|
-
|
|
1784
|
+
s,
|
|
1784
1785
|
u,
|
|
1785
1786
|
Gn(he({ [n]: a.key, ...g, _change_reason: t }))
|
|
1786
1787
|
));
|
|
@@ -1795,21 +1796,21 @@ function zc({
|
|
|
1795
1796
|
O,
|
|
1796
1797
|
P,
|
|
1797
1798
|
x,
|
|
1798
|
-
|
|
1799
|
+
s,
|
|
1799
1800
|
u,
|
|
1800
1801
|
yn,
|
|
1801
1802
|
Oi
|
|
1802
1803
|
]
|
|
1803
|
-
),
|
|
1804
|
+
), Hl = Rt(
|
|
1804
1805
|
(e) => {
|
|
1805
1806
|
var v;
|
|
1806
1807
|
if (!((v = _e == null ? void 0 : _e.fields) != null && v.length)) return;
|
|
1807
1808
|
const n = wt(_e.remaining, tn), t = n == null || !Number.isFinite(n) ? 0 : Math.round(n * 100) / 100;
|
|
1808
1809
|
if (t <= 0) return;
|
|
1809
|
-
const r = _e.only_empty !== !1, i = (N) => N == null || N === "" || Number(N) === 0,
|
|
1810
|
+
const r = _e.only_empty !== !1, i = (N) => N == null || N === "" || Number(N) === 0, o = (x == null ? void 0 : x.getPendingEdits(s, u)) ?? /* @__PURE__ */ new Map(), a = (x == null ? void 0 : x.getPendingDeletes(s, u)) ?? /* @__PURE__ */ new Set(), c = j == null ? void 0 : j.key_field, d = [];
|
|
1810
1811
|
for (const N of O) {
|
|
1811
1812
|
const y = String(N.id);
|
|
1812
|
-
a.has(y) || d.push({ id: y, row: { ...N, ...
|
|
1813
|
+
a.has(y) || d.push({ id: y, row: { ...N, ...o.get(y) ?? {} } });
|
|
1813
1814
|
}
|
|
1814
1815
|
P.forEach((N, y) => d.push({ id: `pending:${y}`, row: N })), c && d.sort((N, y) => Number(N.row[c] ?? 0) - Number(y.row[c] ?? 0));
|
|
1815
1816
|
const m = [], g = [];
|
|
@@ -1820,7 +1821,7 @@ function zc({
|
|
|
1820
1821
|
be.message("Nothing to spread into — every target is filled or closed");
|
|
1821
1822
|
return;
|
|
1822
1823
|
}
|
|
1823
|
-
const p =
|
|
1824
|
+
const p = yl(
|
|
1824
1825
|
t,
|
|
1825
1826
|
m.length,
|
|
1826
1827
|
e === "shape" ? "even" : e,
|
|
@@ -1845,7 +1846,7 @@ function zc({
|
|
|
1845
1846
|
_e,
|
|
1846
1847
|
tn,
|
|
1847
1848
|
x,
|
|
1848
|
-
|
|
1849
|
+
s,
|
|
1849
1850
|
u,
|
|
1850
1851
|
j,
|
|
1851
1852
|
O,
|
|
@@ -1856,15 +1857,15 @@ function zc({
|
|
|
1856
1857
|
ge(() => {
|
|
1857
1858
|
if (nn) {
|
|
1858
1859
|
if (Ho || mn) {
|
|
1859
|
-
nn(
|
|
1860
|
+
nn(s, u, null);
|
|
1860
1861
|
return;
|
|
1861
1862
|
}
|
|
1862
|
-
nn(
|
|
1863
|
+
nn(s, u, Cn);
|
|
1863
1864
|
}
|
|
1864
|
-
}, [nn,
|
|
1865
|
+
}, [nn, s, u, Cn, Ho, mn]);
|
|
1865
1866
|
const Zo = ae(() => {
|
|
1866
1867
|
});
|
|
1867
|
-
Zo.current = () => nn == null ? void 0 : nn(
|
|
1868
|
+
Zo.current = () => nn == null ? void 0 : nn(s, u, null), ge(() => () => Zo.current(), []);
|
|
1868
1869
|
const er = K(() => {
|
|
1869
1870
|
const e = /* @__PURE__ */ new Map();
|
|
1870
1871
|
for (const n of ce) {
|
|
@@ -1877,7 +1878,7 @@ function zc({
|
|
|
1877
1878
|
t = null;
|
|
1878
1879
|
}
|
|
1879
1880
|
const i = (Array.isArray(t == null ? void 0 : t.pinned_options) ? t.pinned_options : []).filter(
|
|
1880
|
-
(
|
|
1881
|
+
(o) => o && typeof o.parent_field == "string" && typeof o.parent_collection == "string" && typeof o.source_field == "string"
|
|
1881
1882
|
);
|
|
1882
1883
|
i.length && e.set(n.field, i);
|
|
1883
1884
|
}
|
|
@@ -1891,28 +1892,28 @@ function zc({
|
|
|
1891
1892
|
for (const i of Object.values(r))
|
|
1892
1893
|
Array.isArray(i) && e.push(
|
|
1893
1894
|
...i.filter(
|
|
1894
|
-
(
|
|
1895
|
+
(o) => o && typeof o.parent_field == "string" && typeof o.parent_collection == "string" && typeof o.source_field == "string"
|
|
1895
1896
|
)
|
|
1896
1897
|
);
|
|
1897
1898
|
}
|
|
1898
1899
|
return e;
|
|
1899
|
-
}, [je]),
|
|
1900
|
+
}, [je]), Yl = K(() => {
|
|
1900
1901
|
var n, t;
|
|
1901
1902
|
const e = /* @__PURE__ */ new Map();
|
|
1902
1903
|
for (const r of [...er.values(), es])
|
|
1903
1904
|
for (const i of r) {
|
|
1904
|
-
const
|
|
1905
|
-
if (
|
|
1906
|
-
const a = `${i.parent_collection}|${String(
|
|
1905
|
+
const o = (n = S == null ? void 0 : S.draft) == null ? void 0 : n[i.parent_field];
|
|
1906
|
+
if (o == null || o === "" || typeof o == "object") continue;
|
|
1907
|
+
const a = `${i.parent_collection}|${String(o)}`;
|
|
1907
1908
|
e.has(a) || e.set(a, {
|
|
1908
1909
|
collection: i.parent_collection,
|
|
1909
|
-
id: String(
|
|
1910
|
+
id: String(o),
|
|
1910
1911
|
fields: /* @__PURE__ */ new Set(["id"])
|
|
1911
1912
|
}), (t = e.get(a)) == null || t.fields.add(i.source_field);
|
|
1912
1913
|
}
|
|
1913
1914
|
return [...e.entries()];
|
|
1914
1915
|
}, [er, es, S == null ? void 0 : S.draft]), ts = dn({
|
|
1915
|
-
queries:
|
|
1916
|
+
queries: Yl.map(([e, n]) => ({
|
|
1916
1917
|
queryKey: ["pinned-parent", n.collection, n.id, [...n.fields].sort().join(",")],
|
|
1917
1918
|
queryFn: () => Ee(n.collection, n.id, [...n.fields]).then((t) => [e, t]).catch(() => [e, null]),
|
|
1918
1919
|
staleTime: 6e4
|
|
@@ -1923,29 +1924,29 @@ function zc({
|
|
|
1923
1924
|
return e;
|
|
1924
1925
|
}, [ts]), ns = (e, n) => {
|
|
1925
1926
|
var t, r, i;
|
|
1926
|
-
for (const
|
|
1927
|
-
if ((t =
|
|
1928
|
-
const m =
|
|
1927
|
+
for (const o of e) {
|
|
1928
|
+
if ((t = o.when) != null && t.field) {
|
|
1929
|
+
const m = o.when.field.startsWith("$parent.") ? (r = S == null ? void 0 : S.draft) == null ? void 0 : r[o.when.field.slice(8)] : n[o.when.field], g = o.when.op ?? "eq", p = o.when.value, h = m == null ? "" : String(m);
|
|
1929
1930
|
if (!(g === "nnull" ? h !== "" : g === "null" ? h === "" : g === "neq" ? h !== String(p ?? "") : g === "in" ? (Array.isArray(p) ? p.map(String) : String(p ?? "").split(",").map((N) => N.trim())).includes(h) : h === String(p ?? ""))) continue;
|
|
1930
1931
|
}
|
|
1931
|
-
const a = (i = S == null ? void 0 : S.draft) == null ? void 0 : i[
|
|
1932
|
+
const a = (i = S == null ? void 0 : S.draft) == null ? void 0 : i[o.parent_field];
|
|
1932
1933
|
if (a == null || a === "") continue;
|
|
1933
|
-
const c = Dr.get(`${
|
|
1934
|
+
const c = Dr.get(`${o.parent_collection}|${String(a)}`), d = c == null ? void 0 : c[o.source_field];
|
|
1934
1935
|
if (!(d == null || d === ""))
|
|
1935
|
-
return { id: d, tag:
|
|
1936
|
+
return { id: d, tag: o.tag ?? "Default" };
|
|
1936
1937
|
}
|
|
1937
1938
|
return null;
|
|
1938
1939
|
}, wn = (e, n) => {
|
|
1939
1940
|
const t = er.get(e);
|
|
1940
1941
|
return t ? ns(t, n) : null;
|
|
1941
1942
|
}, ke = ce.filter(
|
|
1942
|
-
(e) => !e.hidden && (!mo.has(e.type) || Yn(e.interface)) && e.field !== u && e.field !== "id" && (!Ct || e.layout_assigned === !0) && !fo.has(e.field) && !
|
|
1943
|
-
), It = re && re.length >= 2 && fi !== pr ? re.find((e) => e.name === fi) : void 0,
|
|
1943
|
+
(e) => !e.hidden && (!mo.has(e.type) || Yn(e.interface)) && e.field !== u && e.field !== "id" && (!Ct || e.layout_assigned === !0) && !fo.has(e.field) && !zl.has(e.group_key ?? "")
|
|
1944
|
+
), It = re && re.length >= 2 && fi !== pr ? re.find((e) => e.name === fi) : void 0, Gl = new Set(
|
|
1944
1945
|
(te ?? []).map((e) => typeof e == "string" ? e : e.field)
|
|
1945
1946
|
), rs = It ? new Set(
|
|
1946
1947
|
It.columns.filter((e) => {
|
|
1947
1948
|
const n = e.indexOf(".");
|
|
1948
|
-
return n < 0 ? !0 : !
|
|
1949
|
+
return n < 0 ? !0 : !Gl.has(e.slice(0, n));
|
|
1949
1950
|
})
|
|
1950
1951
|
) : null, is = rs ? ke.filter((e) => rs.has(e.field)) : [], vn = K(() => {
|
|
1951
1952
|
if (!It) return [];
|
|
@@ -1966,7 +1967,7 @@ function zc({
|
|
|
1966
1967
|
const e = /* @__PURE__ */ new Map();
|
|
1967
1968
|
for (const n of rn) {
|
|
1968
1969
|
const t = Me.find(
|
|
1969
|
-
(r) => r.one_collection ===
|
|
1970
|
+
(r) => r.one_collection === s && r.one_field === n
|
|
1970
1971
|
);
|
|
1971
1972
|
e.set(
|
|
1972
1973
|
n,
|
|
@@ -1974,7 +1975,7 @@ function zc({
|
|
|
1974
1975
|
);
|
|
1975
1976
|
}
|
|
1976
1977
|
return e;
|
|
1977
|
-
}, [rn, Me,
|
|
1978
|
+
}, [rn, Me, s]), xn = K(
|
|
1978
1979
|
() => [
|
|
1979
1980
|
...new Set(
|
|
1980
1981
|
[...At.values()].filter((e) => !!e).map((e) => e.grandCollection)
|
|
@@ -2014,19 +2015,19 @@ function zc({
|
|
|
2014
2015
|
const t = At.get(n);
|
|
2015
2016
|
if (!t) continue;
|
|
2016
2017
|
const r = as.get(t.grandCollection) ?? [], i = /* @__PURE__ */ new Map();
|
|
2017
|
-
for (const
|
|
2018
|
-
if (
|
|
2018
|
+
for (const o of vn) {
|
|
2019
|
+
if (o.relationField !== n) continue;
|
|
2019
2020
|
const a = r.find(
|
|
2020
|
-
(c) => c.many_collection === t.grandCollection && c.many_field ===
|
|
2021
|
+
(c) => c.many_collection === t.grandCollection && c.many_field === o.memberField && !c.junction_field
|
|
2021
2022
|
);
|
|
2022
|
-
a != null && a.one_collection && i.set(
|
|
2023
|
+
a != null && a.one_collection && i.set(o.memberField, a);
|
|
2023
2024
|
}
|
|
2024
2025
|
e.set(n, i);
|
|
2025
2026
|
}
|
|
2026
2027
|
return e;
|
|
2027
2028
|
}, [rn, At, as, vn]), Ur = K(() => O.map((e) => String(e.id)), [O]), tr = K(
|
|
2028
|
-
() => `nvr-gf-${Math.abs(
|
|
2029
|
-
[
|
|
2029
|
+
() => `nvr-gf-${Math.abs(Yd(`${s}:${M ?? u}`)) % 1e5}`,
|
|
2030
|
+
[s, M, u]
|
|
2030
2031
|
), ds = K(() => {
|
|
2031
2032
|
if (!Y) return null;
|
|
2032
2033
|
const e = [];
|
|
@@ -2049,20 +2050,20 @@ function zc({
|
|
|
2049
2050
|
q,
|
|
2050
2051
|
W,
|
|
2051
2052
|
R
|
|
2052
|
-
]), [_n,
|
|
2053
|
+
]), [_n, Cl] = J(150), cs = ae(null);
|
|
2053
2054
|
ge(() => {
|
|
2054
2055
|
const e = cs.current;
|
|
2055
2056
|
if (!e || O.length <= _n) return;
|
|
2056
2057
|
const n = new IntersectionObserver(
|
|
2057
2058
|
(t) => {
|
|
2058
|
-
t.some((r) => r.isIntersecting) &&
|
|
2059
|
+
t.some((r) => r.isIntersecting) && Cl((r) => r + 150);
|
|
2059
2060
|
},
|
|
2060
2061
|
{ rootMargin: "400px" }
|
|
2061
2062
|
);
|
|
2062
2063
|
return n.observe(e), () => n.disconnect();
|
|
2063
2064
|
}, [O.length, _n]);
|
|
2064
|
-
const
|
|
2065
|
-
|
|
2065
|
+
const Xl = Ur.join(","), Zl = Rd(
|
|
2066
|
+
s,
|
|
2066
2067
|
Ur,
|
|
2067
2068
|
!!ee && !q
|
|
2068
2069
|
), us = dn({
|
|
@@ -2071,12 +2072,12 @@ function zc({
|
|
|
2071
2072
|
return {
|
|
2072
2073
|
queryKey: [
|
|
2073
2074
|
"o2m-rows",
|
|
2074
|
-
|
|
2075
|
+
s,
|
|
2075
2076
|
u,
|
|
2076
2077
|
b,
|
|
2077
2078
|
"summary-members",
|
|
2078
2079
|
e,
|
|
2079
|
-
|
|
2080
|
+
Xl
|
|
2080
2081
|
],
|
|
2081
2082
|
queryFn: () => n ? $.request(
|
|
2082
2083
|
de(`/items/${n.grandCollection}`, {
|
|
@@ -2091,10 +2092,10 @@ function zc({
|
|
|
2091
2092
|
}), Br = K(() => {
|
|
2092
2093
|
const e = /* @__PURE__ */ new Map();
|
|
2093
2094
|
return rn.forEach((n, t) => {
|
|
2094
|
-
var
|
|
2095
|
+
var o;
|
|
2095
2096
|
const r = At.get(n), i = /* @__PURE__ */ new Map();
|
|
2096
2097
|
if (r)
|
|
2097
|
-
for (const a of ((
|
|
2098
|
+
for (const a of ((o = us[t]) == null ? void 0 : o.data) ?? []) {
|
|
2098
2099
|
const c = String(a[r.fkField]);
|
|
2099
2100
|
i.has(c) || i.set(c, []), i.get(c).push(a);
|
|
2100
2101
|
}
|
|
@@ -2103,18 +2104,18 @@ function zc({
|
|
|
2103
2104
|
}, [rn, At, us]), fs = Kn == null ? void 0 : Kn.report;
|
|
2104
2105
|
ge(() => {
|
|
2105
2106
|
if (!fs || !te || te.length === 0) return;
|
|
2106
|
-
const e = `${
|
|
2107
|
-
const
|
|
2107
|
+
const e = `${s}.${u}`, n = (r, i) => {
|
|
2108
|
+
const o = {};
|
|
2108
2109
|
for (const [a, c] of Object.entries(r))
|
|
2109
|
-
a.startsWith("__") || a === "id" || c !== null && typeof c == "object" || (
|
|
2110
|
-
return
|
|
2110
|
+
a.startsWith("__") || a === "id" || c !== null && typeof c == "object" || (o[`${i}.${a}`] = c);
|
|
2111
|
+
return o;
|
|
2111
2112
|
}, t = {};
|
|
2112
2113
|
for (const r of te) {
|
|
2113
|
-
const i = typeof r == "string" ? r : r.field,
|
|
2114
|
-
(d) => d.one_collection ===
|
|
2114
|
+
const i = typeof r == "string" ? r : r.field, o = Me.find(
|
|
2115
|
+
(d) => d.one_collection === s && d.one_field === i
|
|
2115
2116
|
);
|
|
2116
|
-
if (!(
|
|
2117
|
-
const a =
|
|
2117
|
+
if (!(o != null && o.many_collection) || !o.many_field) continue;
|
|
2118
|
+
const a = o.many_field, c = { created: [], updated: [], deleted: [] };
|
|
2118
2119
|
for (const d of P) {
|
|
2119
2120
|
const m = d[`__o2m_${i}`];
|
|
2120
2121
|
if (!Array.isArray(m)) continue;
|
|
@@ -2138,37 +2139,37 @@ function zc({
|
|
|
2138
2139
|
for (const g of (d == null ? void 0 : d.get(String(m))) ?? [])
|
|
2139
2140
|
g.id != null && c.deleted.push(g.id);
|
|
2140
2141
|
}
|
|
2141
|
-
(c.created.length || c.updated.length || c.deleted.length) && (t[
|
|
2142
|
+
(c.created.length || c.updated.length || c.deleted.length) && (t[o.many_collection] = c);
|
|
2142
2143
|
}
|
|
2143
2144
|
fs(e, Object.keys(t).length > 0 ? t : null);
|
|
2144
2145
|
});
|
|
2145
2146
|
const Ii = K(() => {
|
|
2146
2147
|
const e = /* @__PURE__ */ new Map(), n = (t, r) => {
|
|
2147
|
-
r == null || r === "" || (e.has(t) || e.set(t, []), e.get(t).push(String(r)));
|
|
2148
|
+
r == null || r === "" || nl(t) || (e.has(t) || e.set(t, []), e.get(t).push(String(r)));
|
|
2148
2149
|
};
|
|
2149
2150
|
for (const [t, r] of Br) {
|
|
2150
2151
|
const i = Wr.get(t);
|
|
2151
2152
|
if (!(!i || i.size === 0)) {
|
|
2152
|
-
for (const
|
|
2153
|
-
for (const a of
|
|
2153
|
+
for (const o of r.values())
|
|
2154
|
+
for (const a of o)
|
|
2154
2155
|
for (const [c, d] of i)
|
|
2155
2156
|
d.one_collection && n(d.one_collection, a[c]);
|
|
2156
|
-
for (const
|
|
2157
|
-
const a =
|
|
2157
|
+
for (const o of P) {
|
|
2158
|
+
const a = o[`__o2m_${t}`];
|
|
2158
2159
|
if (Array.isArray(a))
|
|
2159
2160
|
for (const c of a)
|
|
2160
2161
|
for (const [d, m] of i)
|
|
2161
2162
|
m.one_collection && n(m.one_collection, c[d]);
|
|
2162
2163
|
}
|
|
2163
|
-
for (const [,
|
|
2164
|
-
const a =
|
|
2164
|
+
for (const [, o] of C) {
|
|
2165
|
+
const a = o[`__nested_ops_${t}`];
|
|
2165
2166
|
if (a)
|
|
2166
2167
|
for (const c of [...a.created ?? [], ...(a.updated ?? []).map((d) => d.changes)])
|
|
2167
2168
|
for (const [d, m] of i)
|
|
2168
2169
|
m.one_collection && n(m.one_collection, c[d]);
|
|
2169
2170
|
}
|
|
2170
|
-
for (const [
|
|
2171
|
-
if (
|
|
2171
|
+
for (const [o, a] of Object.entries(Tr))
|
|
2172
|
+
if (o.endsWith(`|${t}`))
|
|
2172
2173
|
for (const c of a)
|
|
2173
2174
|
for (const [d, m] of i)
|
|
2174
2175
|
m.one_collection && n(m.one_collection, c[d]);
|
|
@@ -2179,14 +2180,14 @@ function zc({
|
|
|
2179
2180
|
}, [Br, Wr, P, C, Tr]), { data: ms = {} } = Ye({
|
|
2180
2181
|
queryKey: [
|
|
2181
2182
|
"summary-m2o-display",
|
|
2182
|
-
|
|
2183
|
+
s,
|
|
2183
2184
|
...Array.from(Ii.entries()).flat(2)
|
|
2184
2185
|
],
|
|
2185
2186
|
queryFn: async () => {
|
|
2186
2187
|
const e = {};
|
|
2187
2188
|
return await Promise.all(
|
|
2188
2189
|
[...Ii.entries()].map(async ([n, t]) => {
|
|
2189
|
-
var
|
|
2190
|
+
var o;
|
|
2190
2191
|
const [r, i] = await Promise.all([
|
|
2191
2192
|
$.request(
|
|
2192
2193
|
de(`/collections/${n}`)
|
|
@@ -2201,7 +2202,7 @@ function zc({
|
|
|
2201
2202
|
e[n] = {};
|
|
2202
2203
|
for (const a of i.data ?? [])
|
|
2203
2204
|
e[n][String(a.id)] = mr(
|
|
2204
|
-
(
|
|
2205
|
+
(o = r.data) == null ? void 0 : o.display_template,
|
|
2205
2206
|
a
|
|
2206
2207
|
);
|
|
2207
2208
|
})
|
|
@@ -2210,15 +2211,15 @@ function zc({
|
|
|
2210
2211
|
enabled: Ii.size > 0,
|
|
2211
2212
|
staleTime: 6e4
|
|
2212
2213
|
}), { data: Ai } = Ye({
|
|
2213
|
-
queryKey: ["collection-display-meta",
|
|
2214
|
+
queryKey: ["collection-display-meta", s],
|
|
2214
2215
|
queryFn: () => $.request(
|
|
2215
|
-
de(`/collections/${
|
|
2216
|
+
de(`/collections/${s}`)
|
|
2216
2217
|
).then((e) => e.data),
|
|
2217
|
-
enabled: !!
|
|
2218
|
+
enabled: !!s,
|
|
2218
2219
|
staleTime: 10 * 6e4
|
|
2219
2220
|
}), ps = K(
|
|
2220
2221
|
() => vn.map(({ relationField: e, memberField: n }) => {
|
|
2221
|
-
const t = At.get(e), i = (t ? ls.get(t.grandCollection) ?? [] : []).find((
|
|
2222
|
+
const t = At.get(e), i = (t ? ls.get(t.grandCollection) ?? [] : []).find((o) => o.field === n);
|
|
2222
2223
|
return {
|
|
2223
2224
|
field: `${e}.${n}`,
|
|
2224
2225
|
type: "presentation",
|
|
@@ -2251,11 +2252,11 @@ function zc({
|
|
|
2251
2252
|
}
|
|
2252
2253
|
const r = String(n.id), i = Tr[`${r}|${e}`];
|
|
2253
2254
|
if (i) return i;
|
|
2254
|
-
const
|
|
2255
|
-
if (!a) return
|
|
2255
|
+
const o = ((m = Br.get(e)) == null ? void 0 : m.get(r)) ?? [], a = (g = C.get(r)) == null ? void 0 : g[`__nested_ops_${e}`];
|
|
2256
|
+
if (!a) return o;
|
|
2256
2257
|
const c = new Set((a.deleted ?? []).map(String)), d = new Map((a.updated ?? []).map((p) => [String(p.id), p.changes]));
|
|
2257
2258
|
return [
|
|
2258
|
-
...
|
|
2259
|
+
...o.filter((p) => !c.has(String(p.id))).map(
|
|
2259
2260
|
(p) => d.has(String(p.id)) ? { ...p, ...d.get(String(p.id)) } : p
|
|
2260
2261
|
),
|
|
2261
2262
|
...a.created ?? []
|
|
@@ -2265,11 +2266,11 @@ function zc({
|
|
|
2265
2266
|
var m;
|
|
2266
2267
|
const r = e.field.indexOf(".");
|
|
2267
2268
|
if (r < 0) return "—";
|
|
2268
|
-
const i = e.field.slice(0, r),
|
|
2269
|
+
const i = e.field.slice(0, r), o = e.field.slice(r + 1), a = hs(i, n, t);
|
|
2269
2270
|
if (a.length === 0) return "—";
|
|
2270
|
-
const c = (m = Wr.get(i)) == null ? void 0 : m.get(
|
|
2271
|
+
const c = (m = Wr.get(i)) == null ? void 0 : m.get(o), d = a.map((g) => {
|
|
2271
2272
|
var h;
|
|
2272
|
-
const p = g[
|
|
2273
|
+
const p = g[o];
|
|
2273
2274
|
return p == null || p === "" ? null : c != null && c.one_collection ? ((h = ms[c.one_collection]) == null ? void 0 : h[String(p)]) ?? String(p) : String(p);
|
|
2274
2275
|
}).filter((g) => !!g);
|
|
2275
2276
|
return d.length > 0 ? d.join(", ") : "—";
|
|
@@ -2278,11 +2279,11 @@ function zc({
|
|
|
2278
2279
|
var m;
|
|
2279
2280
|
const t = e.field.indexOf(".");
|
|
2280
2281
|
if (t < 0) return "—";
|
|
2281
|
-
const r = e.field.slice(0, t), i = e.field.slice(t + 1),
|
|
2282
|
-
if (
|
|
2282
|
+
const r = e.field.slice(0, t), i = e.field.slice(t + 1), o = hs(r, n, !1);
|
|
2283
|
+
if (o.length === 0) return "—";
|
|
2283
2284
|
const a = (m = Wr.get(r)) == null ? void 0 : m.get(i);
|
|
2284
2285
|
if (!(a != null && a.one_collection) || !me) return nr(e, n, !1);
|
|
2285
|
-
const c = a.one_collection, d =
|
|
2286
|
+
const c = a.one_collection, d = o.map((g) => {
|
|
2286
2287
|
var h;
|
|
2287
2288
|
const p = g[i];
|
|
2288
2289
|
return p == null || p === "" ? null : { id: String(p), label: ((h = ms[c]) == null ? void 0 : h[String(p)]) ?? String(p) };
|
|
@@ -2300,17 +2301,17 @@ function zc({
|
|
|
2300
2301
|
`${g.id}:${p}`
|
|
2301
2302
|
)) });
|
|
2302
2303
|
}
|
|
2303
|
-
const Ke = It && (is.length > 0 || ps.length > 0) ? [...is, ...ps] : ke, kn = ae(null), [
|
|
2304
|
+
const Ke = It && (is.length > 0 || ps.length > 0) ? [...is, ...ps] : ke, kn = ae(null), [ea, ji] = J(0), gs = ae(/* @__PURE__ */ new Map()), Dt = ae(0), bs = 1e4, gt = (e) => gs.current.set(String(e), Date.now());
|
|
2304
2305
|
ge(() => {
|
|
2305
2306
|
const e = (n) => {
|
|
2306
2307
|
var r;
|
|
2307
2308
|
const t = ((r = n.detail) == null ? void 0 : r.writes) ?? [];
|
|
2308
|
-
for (const i of t) i.collection ===
|
|
2309
|
+
for (const i of t) i.collection === s && gt(i.id);
|
|
2309
2310
|
};
|
|
2310
|
-
return window.addEventListener(
|
|
2311
|
-
}, [
|
|
2312
|
-
const i = await
|
|
2313
|
-
key: `${
|
|
2311
|
+
return window.addEventListener(il, e), () => window.removeEventListener(il, e);
|
|
2312
|
+
}, [s]), hn.current = async (e, n, t, r) => {
|
|
2313
|
+
const i = await vd($, kt, e, n, t, {
|
|
2314
|
+
key: `${s}.${u}`,
|
|
2314
2315
|
label: ni(O, n, G),
|
|
2315
2316
|
...r !== void 0 ? { base: r } : {}
|
|
2316
2317
|
});
|
|
@@ -2319,24 +2320,24 @@ function zc({
|
|
|
2319
2320
|
const Li = async (e, n, t) => {
|
|
2320
2321
|
const r = await hn.current(e, n, t);
|
|
2321
2322
|
return r || Vn(), r;
|
|
2322
|
-
},
|
|
2323
|
+
}, ta = async (e) => {
|
|
2323
2324
|
const n = Ar ?? [];
|
|
2324
2325
|
hi(null);
|
|
2325
2326
|
let t = 0;
|
|
2326
2327
|
for (const r of n) {
|
|
2327
2328
|
const i = new Set(
|
|
2328
|
-
r.conflicts.filter((a) => e.has(
|
|
2329
|
-
),
|
|
2330
|
-
if (
|
|
2329
|
+
r.conflicts.filter((a) => e.has(xd(r, a.field))).map((a) => a.field)
|
|
2330
|
+
), o = _d(r.mine, i);
|
|
2331
|
+
if (o) {
|
|
2331
2332
|
r.latest > 0 && kt.set(r.rowId, r.latest);
|
|
2332
2333
|
try {
|
|
2333
|
-
await hn.current(r.url, r.rowId,
|
|
2334
|
+
await hn.current(r.url, r.rowId, o) && t++;
|
|
2334
2335
|
} catch (a) {
|
|
2335
2336
|
be.error(`${r.label}: ${Tn(a, "could not save")}`);
|
|
2336
2337
|
}
|
|
2337
2338
|
}
|
|
2338
2339
|
}
|
|
2339
|
-
Vn(), z.invalidateQueries({ queryKey: ["o2m-rows",
|
|
2340
|
+
Vn(), z.invalidateQueries({ queryKey: ["o2m-rows", s, u, b] }), t === 0 && n.length > 0 && be.success("Kept the newer values");
|
|
2340
2341
|
}, rr = ke.map((e) => e.field).filter((e) => !e.includes(".")).join(","), jt = Rt(
|
|
2341
2342
|
(e) => {
|
|
2342
2343
|
const n = {};
|
|
@@ -2347,12 +2348,12 @@ function zc({
|
|
|
2347
2348
|
return n;
|
|
2348
2349
|
},
|
|
2349
2350
|
[rr]
|
|
2350
|
-
),
|
|
2351
|
+
), na = (e, n) => {
|
|
2351
2352
|
for (const t of Object.keys(n)) if (String(e[t] ?? "") !== String(n[t] ?? "")) return !1;
|
|
2352
2353
|
return !0;
|
|
2353
2354
|
}, Qr = (e, n) => {
|
|
2354
2355
|
const t = gs.current.get(e);
|
|
2355
|
-
return t && n - t < bs ? !0 :
|
|
2356
|
+
return t && n - t < bs ? !0 : Ya(s, e);
|
|
2356
2357
|
};
|
|
2357
2358
|
ge(() => {
|
|
2358
2359
|
if (q || mn || !rr) return;
|
|
@@ -2363,8 +2364,8 @@ function zc({
|
|
|
2363
2364
|
const e = kn.current, n = Date.now(), t = /* @__PURE__ */ new Set();
|
|
2364
2365
|
let r = !1;
|
|
2365
2366
|
for (const i of Je) {
|
|
2366
|
-
const
|
|
2367
|
-
t.add(
|
|
2367
|
+
const o = String(i.id);
|
|
2368
|
+
t.add(o), (Qr(o, n) || !e.has(o) && n - Dt.current < bs) && (e.set(o, jt(i)), r = !0);
|
|
2368
2369
|
}
|
|
2369
2370
|
for (const i of [...e.keys()])
|
|
2370
2371
|
!t.has(i) && Qr(i, n) && (e.delete(i), r = !0);
|
|
@@ -2373,44 +2374,44 @@ function zc({
|
|
|
2373
2374
|
const bt = K(() => {
|
|
2374
2375
|
const e = kn.current;
|
|
2375
2376
|
if (!e || q) return null;
|
|
2376
|
-
const n = Date.now(), t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = [],
|
|
2377
|
+
const n = Date.now(), t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = [], o = /* @__PURE__ */ new Set();
|
|
2377
2378
|
for (const a of Je) {
|
|
2378
2379
|
const c = String(a.id);
|
|
2379
|
-
|
|
2380
|
+
o.add(c);
|
|
2380
2381
|
const d = e.get(c);
|
|
2381
2382
|
if (!d) {
|
|
2382
2383
|
t.add(c);
|
|
2383
2384
|
continue;
|
|
2384
2385
|
}
|
|
2385
|
-
Qr(c, n) ||
|
|
2386
|
+
Qr(c, n) || na(jt(a), d) || r.add(c);
|
|
2386
2387
|
}
|
|
2387
|
-
for (const a of e.keys())
|
|
2388
|
+
for (const a of e.keys()) o.has(a) || i.push(a);
|
|
2388
2389
|
return t.size === 0 && r.size === 0 && i.length === 0 ? null : { added: t, changed: r, removed: i, total: t.size + r.size + i.length };
|
|
2389
|
-
}, [Je,
|
|
2390
|
+
}, [Je, ea, Ni, q, jt]), ra = () => {
|
|
2390
2391
|
kn.current = new Map(Je.map((e) => [String(e.id), jt(e)])), ji((e) => e + 1);
|
|
2391
2392
|
}, Nn = ae(null), [zr, ys] = J({}), Sn = K(() => {
|
|
2392
2393
|
const e = Nn.current, n = f == null ? void 0 : f.rowId;
|
|
2393
2394
|
if (!e || !n || e.rowId !== n || n === "new" || n.startsWith("pending:")) return [];
|
|
2394
|
-
const t = Je.find((
|
|
2395
|
+
const t = Je.find((o) => String(o.id) === n);
|
|
2395
2396
|
if (!t || Qr(n, Date.now())) return [];
|
|
2396
2397
|
const r = jt(t), i = [];
|
|
2397
|
-
for (const
|
|
2398
|
-
if (String(r[
|
|
2399
|
-
const a = ce.find((c) => c.field ===
|
|
2400
|
-
(a == null ? void 0 : a.computed_type) === "write" && a.computed_formula || i.push({ field:
|
|
2398
|
+
for (const o of Object.keys(r)) {
|
|
2399
|
+
if (String(r[o] ?? "") === String(e.snap[o] ?? "") || String(zr[o] ?? "\0") === String(r[o] ?? "") || String((f == null ? void 0 : f.draft[o]) ?? "") === String(r[o] ?? "")) continue;
|
|
2400
|
+
const a = ce.find((c) => c.field === o);
|
|
2401
|
+
(a == null ? void 0 : a.computed_type) === "write" && a.computed_formula || i.push({ field: o, label: (a == null ? void 0 : a.label) || ve(o), theirs: r[o], was: e.snap[o] });
|
|
2401
2402
|
}
|
|
2402
2403
|
return i;
|
|
2403
2404
|
}, [Je, f == null ? void 0 : f.rowId, f == null ? void 0 : f.draft, zr, jt, ce]), ws = (e) => {
|
|
2404
2405
|
if (!e || Sn.length === 0 || (f == null ? void 0 : f.rowId) !== e) return null;
|
|
2405
2406
|
const n = (i) => i == null || i === "" ? "∅" : String(i).slice(0, 40), t = (i) => {
|
|
2406
|
-
const
|
|
2407
|
+
const o = { ...zr }, a = {};
|
|
2407
2408
|
for (const c of Sn)
|
|
2408
|
-
i && c.field !== i || (a[c.field] = c.theirs,
|
|
2409
|
-
zi(a), ys(
|
|
2409
|
+
i && c.field !== i || (a[c.field] = c.theirs, o[c.field] = c.theirs, Nn.current && (Nn.current.snap[c.field] = c.theirs));
|
|
2410
|
+
zi(a), ys(o), (!i || Sn.length === 1) && Ui(e);
|
|
2410
2411
|
}, r = () => {
|
|
2411
2412
|
const i = { ...zr };
|
|
2412
|
-
for (const
|
|
2413
|
-
i[
|
|
2413
|
+
for (const o of Sn)
|
|
2414
|
+
i[o.field] = o.theirs, Nn.current && (Nn.current.snap[o.field] = o.theirs);
|
|
2414
2415
|
ys(i), Ui(e);
|
|
2415
2416
|
};
|
|
2416
2417
|
return /* @__PURE__ */ k(
|
|
@@ -2423,8 +2424,8 @@ function zc({
|
|
|
2423
2424
|
/* @__PURE__ */ k("span", { className: "min-w-0 flex-1", children: [
|
|
2424
2425
|
"Changed by others while you edit:",
|
|
2425
2426
|
" ",
|
|
2426
|
-
Sn.map((i,
|
|
2427
|
-
|
|
2427
|
+
Sn.map((i, o) => /* @__PURE__ */ k("span", { "data-row-remote-field": i.field, children: [
|
|
2428
|
+
o > 0 && " · ",
|
|
2428
2429
|
/* @__PURE__ */ l("span", { className: "font-medium", children: i.label }),
|
|
2429
2430
|
" ",
|
|
2430
2431
|
n(i.was),
|
|
@@ -2470,15 +2471,15 @@ function zc({
|
|
|
2470
2471
|
for (const n of bt.changed) {
|
|
2471
2472
|
const t = Object.values(bi[n] ?? {});
|
|
2472
2473
|
if (t.length === 0) continue;
|
|
2473
|
-
const r = t.reduce((i,
|
|
2474
|
+
const r = t.reduce((i, o) => String(o.at) > String(i.at) ? o : i);
|
|
2474
2475
|
r.who && e.add(r.who);
|
|
2475
2476
|
}
|
|
2476
2477
|
return [...e];
|
|
2477
|
-
}, [bt, bi]), [Xe, on] = J(null), Ti = ae(/* @__PURE__ */ new Set()), xs = (e, n) => JSON.stringify([e, n]), [$n,
|
|
2478
|
-
}),
|
|
2478
|
+
}, [bt, bi]), [Xe, on] = J(null), Ti = ae(/* @__PURE__ */ new Set()), xs = (e, n) => JSON.stringify([e, n]), [$n, ia] = J(() => /* @__PURE__ */ new Map()), _s = ae(""), Ri = ae(() => {
|
|
2479
|
+
}), oa = (e) => {
|
|
2479
2480
|
const n = wr.current;
|
|
2480
2481
|
if (!n) return null;
|
|
2481
|
-
const t = `${
|
|
2482
|
+
const t = `${s}:${e}`;
|
|
2482
2483
|
for (const r of n.querySelectorAll("[data-o2m-row]")) {
|
|
2483
2484
|
if (r.getAttribute("data-o2m-row") !== t) continue;
|
|
2484
2485
|
const i = r.getAttribute("data-remote-editor");
|
|
@@ -2489,7 +2490,7 @@ function zc({
|
|
|
2489
2490
|
ge(() => {
|
|
2490
2491
|
const e = wr.current;
|
|
2491
2492
|
if (!e || !ks || typeof MutationObserver > "u") return;
|
|
2492
|
-
const n = `${
|
|
2493
|
+
const n = `${s}:`, t = () => {
|
|
2493
2494
|
const i = /* @__PURE__ */ new Map();
|
|
2494
2495
|
for (const a of e.querySelectorAll("[data-o2m-row][data-remote-editor]")) {
|
|
2495
2496
|
const c = a.getAttribute("data-o2m-row") ?? "", d = a.getAttribute("data-remote-editor");
|
|
@@ -2497,9 +2498,9 @@ function zc({
|
|
|
2497
2498
|
const m = c.slice(n.length);
|
|
2498
2499
|
m.startsWith("pending:") || i.set(m, d);
|
|
2499
2500
|
}
|
|
2500
|
-
const
|
|
2501
|
+
const o = [...i.entries()].map(([a, c]) => `${a}\0${c}`).sort().join(`
|
|
2501
2502
|
`);
|
|
2502
|
-
|
|
2503
|
+
o !== _s.current && (_s.current = o, ia(i));
|
|
2503
2504
|
};
|
|
2504
2505
|
Ri.current = t, t();
|
|
2505
2506
|
const r = new MutationObserver(t);
|
|
@@ -2512,7 +2513,7 @@ function zc({
|
|
|
2512
2513
|
r.disconnect(), Ri.current = () => {
|
|
2513
2514
|
};
|
|
2514
2515
|
};
|
|
2515
|
-
}, [ks,
|
|
2516
|
+
}, [ks, s]), ge(() => {
|
|
2516
2517
|
const e = Ti.current;
|
|
2517
2518
|
for (const n of [...e]) {
|
|
2518
2519
|
const [t, r] = JSON.parse(n);
|
|
@@ -2532,22 +2533,22 @@ function zc({
|
|
|
2532
2533
|
return O.forEach((n, t) => {
|
|
2533
2534
|
const r = $n.get(String(n.id));
|
|
2534
2535
|
if (!r) return;
|
|
2535
|
-
const i = n.line_number,
|
|
2536
|
-
e.push(`${r} is editing line ${String(
|
|
2536
|
+
const i = n.line_number, o = typeof i == "number" || typeof i == "string" && i.trim() !== "";
|
|
2537
|
+
e.push(`${r} is editing line ${String(o ? i : t + 1)}`);
|
|
2537
2538
|
}), e;
|
|
2538
2539
|
}, [$n, O]);
|
|
2539
2540
|
ge(() => {
|
|
2540
2541
|
if (!Kt || q) return;
|
|
2541
2542
|
let e = null;
|
|
2542
|
-
const n = Kt.subscribeCollections([
|
|
2543
|
+
const n = Kt.subscribeCollections([s], () => {
|
|
2543
2544
|
e && clearTimeout(e), e = setTimeout(() => {
|
|
2544
|
-
e = null, z.invalidateQueries({ queryKey: ["o2m-rows",
|
|
2545
|
+
e = null, z.invalidateQueries({ queryKey: ["o2m-rows", s, u, b] });
|
|
2545
2546
|
}, 1500);
|
|
2546
2547
|
});
|
|
2547
2548
|
return () => {
|
|
2548
2549
|
n(), e && clearTimeout(e);
|
|
2549
2550
|
};
|
|
2550
|
-
}, [Kt,
|
|
2551
|
+
}, [Kt, s, u, b, q, z]);
|
|
2551
2552
|
const Ns = ae(null);
|
|
2552
2553
|
ge(() => {
|
|
2553
2554
|
const e = {
|
|
@@ -2561,7 +2562,7 @@ function zc({
|
|
|
2561
2562
|
e.pending < n.pending && (Dt.current = Date.now());
|
|
2562
2563
|
}
|
|
2563
2564
|
}, [Ni]);
|
|
2564
|
-
const Ki = K(() =>
|
|
2565
|
+
const Ki = K(() => tc(ce), [ce]), Ss = K(
|
|
2565
2566
|
() => ce.filter(
|
|
2566
2567
|
(e) => e.group_key === "__create_with_defaults__" && !mo.has(e.type ?? "") && !fo.has(e.field)
|
|
2567
2568
|
),
|
|
@@ -2570,12 +2571,12 @@ function zc({
|
|
|
2570
2571
|
const e = /* @__PURE__ */ new Map();
|
|
2571
2572
|
for (const n of ke) {
|
|
2572
2573
|
const t = Me.find(
|
|
2573
|
-
(r) => r.many_collection ===
|
|
2574
|
+
(r) => r.many_collection === s && r.many_field === n.field && !r.junction_field
|
|
2574
2575
|
);
|
|
2575
2576
|
t != null && t.one_collection && e.set(n.field, t);
|
|
2576
2577
|
}
|
|
2577
2578
|
return e;
|
|
2578
|
-
}, [ke, Me,
|
|
2579
|
+
}, [ke, Me, s]), ir = K(() => {
|
|
2579
2580
|
var n;
|
|
2580
2581
|
const e = {};
|
|
2581
2582
|
for (const t of ke) {
|
|
@@ -2587,12 +2588,12 @@ function zc({
|
|
|
2587
2588
|
}
|
|
2588
2589
|
})() : null, i = r == null ? void 0 : r.option_filter;
|
|
2589
2590
|
if (!i || typeof i != "object") continue;
|
|
2590
|
-
const
|
|
2591
|
+
const o = bl(
|
|
2591
2592
|
i,
|
|
2592
2593
|
S == null ? void 0 : S.draft,
|
|
2593
2594
|
((n = S == null ? void 0 : S.draft) == null ? void 0 : n.id) != null ? String(S.draft.id) : ""
|
|
2594
2595
|
);
|
|
2595
|
-
|
|
2596
|
+
o && (e[t.field] = o);
|
|
2596
2597
|
}
|
|
2597
2598
|
return e;
|
|
2598
2599
|
}, [ke, S == null ? void 0 : S.draft]), Pi = K(() => {
|
|
@@ -2605,19 +2606,19 @@ function zc({
|
|
|
2605
2606
|
if (!(r != null && r.one_collection)) continue;
|
|
2606
2607
|
const i = [Ve[t], ir[t]].filter(
|
|
2607
2608
|
(c) => !!c
|
|
2608
|
-
),
|
|
2609
|
+
), o = i.length === 1 ? i[0] : { _and: i }, a = [
|
|
2609
2610
|
...new Set(
|
|
2610
2611
|
[...O, ...P].map((c) => c[t]).filter((c) => c != null && c !== "").map(String)
|
|
2611
2612
|
)
|
|
2612
2613
|
].sort();
|
|
2613
|
-
a.length && e.push({ field: t, target: r.one_collection, filter:
|
|
2614
|
+
a.length && e.push({ field: t, target: r.one_collection, filter: o, ids: a });
|
|
2614
2615
|
}
|
|
2615
2616
|
return e;
|
|
2616
2617
|
}, [Ve, ir, He, O, P]), $s = dn({
|
|
2617
2618
|
queries: Pi.map((e) => ({
|
|
2618
2619
|
queryKey: [
|
|
2619
2620
|
"cascade-stale-sweep",
|
|
2620
|
-
|
|
2621
|
+
s,
|
|
2621
2622
|
e.field,
|
|
2622
2623
|
JSON.stringify(e.filter),
|
|
2623
2624
|
e.ids.join(",")
|
|
@@ -2643,8 +2644,8 @@ function zc({
|
|
|
2643
2644
|
const d = wn(n.field, c);
|
|
2644
2645
|
(d == null ? void 0 : d.id) != null && i.add(String(d.id));
|
|
2645
2646
|
}
|
|
2646
|
-
const
|
|
2647
|
-
|
|
2647
|
+
const o = n.ids.filter((c) => !r.has(c) && !i.has(c));
|
|
2648
|
+
o.length && e.set(n.field, new Set(o));
|
|
2648
2649
|
}), e;
|
|
2649
2650
|
}, [
|
|
2650
2651
|
Pi,
|
|
@@ -2664,9 +2665,9 @@ function zc({
|
|
|
2664
2665
|
for (const r of Zt) {
|
|
2665
2666
|
const i = r.on_unavailable;
|
|
2666
2667
|
if (!(i != null && i.replace) || !e.has(r.parent_field)) continue;
|
|
2667
|
-
const
|
|
2668
|
-
if (!(
|
|
2669
|
-
const d = JSON.stringify(a), m = [...
|
|
2668
|
+
const o = Di.get(r.child_field), a = Ve[r.child_field], c = He.get(r.child_field);
|
|
2669
|
+
if (!(o != null && o.size) || !a || !(c != null && c.one_collection)) continue;
|
|
2670
|
+
const d = JSON.stringify(a), m = [...o].filter(
|
|
2670
2671
|
(h) => !Fr.current.has(`${r.child_field}|${h}|${d}`)
|
|
2671
2672
|
);
|
|
2672
2673
|
if (!m.length) continue;
|
|
@@ -2699,7 +2700,7 @@ function zc({
|
|
|
2699
2700
|
}
|
|
2700
2701
|
n.length && (Wi.current = !0, (async () => {
|
|
2701
2702
|
var m, g, p, h, v;
|
|
2702
|
-
let r = 0, i = 0,
|
|
2703
|
+
let r = 0, i = 0, o = 0, a = 0;
|
|
2703
2704
|
for (const N of n) {
|
|
2704
2705
|
for (const V of N.ids)
|
|
2705
2706
|
Fr.current.add(`${N.rule.child_field}|${V}|${N.filterKey}`);
|
|
@@ -2740,7 +2741,7 @@ function zc({
|
|
|
2740
2741
|
if (D && D.length > 0) {
|
|
2741
2742
|
const Z = await $.request(
|
|
2742
2743
|
Le("/field-rules/evaluate", {
|
|
2743
|
-
collection:
|
|
2744
|
+
collection: s,
|
|
2744
2745
|
data: V,
|
|
2745
2746
|
locks_only: !0,
|
|
2746
2747
|
probe: !0,
|
|
@@ -2751,7 +2752,7 @@ function zc({
|
|
|
2751
2752
|
for (const An of tt) ue[An] = null;
|
|
2752
2753
|
const nt = await $.request(
|
|
2753
2754
|
Le("/field-rules/evaluate", {
|
|
2754
|
-
collection:
|
|
2755
|
+
collection: s,
|
|
2755
2756
|
data: ue,
|
|
2756
2757
|
changed_field: y,
|
|
2757
2758
|
parent_context: T,
|
|
@@ -2765,7 +2766,7 @@ function zc({
|
|
|
2765
2766
|
}, X = P.map((V, ue) => ({ r: V, i: ue })).filter(({ r: V }) => V[y] != null && I.has(String(V[y])));
|
|
2766
2767
|
for (const { r: V, i: ue } of X) {
|
|
2767
2768
|
const ne = await E(V);
|
|
2768
|
-
x == null || x.updateRow(
|
|
2769
|
+
x == null || x.updateRow(s, u, ue, { ...V, ...ne }), r++;
|
|
2769
2770
|
}
|
|
2770
2771
|
const ie = O.filter((V) => {
|
|
2771
2772
|
var Z;
|
|
@@ -2777,15 +2778,15 @@ function zc({
|
|
|
2777
2778
|
for (const V of ie) {
|
|
2778
2779
|
const ue = String(V.id), ne = await E({ ...V, ...C.get(ue) ?? {} });
|
|
2779
2780
|
if ((W || q) && x)
|
|
2780
|
-
x.queueEdit(
|
|
2781
|
+
x.queueEdit(s, u, ue, { ...ne, ...pn(ue) });
|
|
2781
2782
|
else {
|
|
2782
|
-
const Z = await hn.current(`/items/${
|
|
2783
|
+
const Z = await hn.current(`/items/${s}/${ue}`, ue, ne).then((tt) => tt ? "ok" : "conflict").catch(() => "failed");
|
|
2783
2784
|
if (Z === "conflict") {
|
|
2784
2785
|
a++;
|
|
2785
2786
|
continue;
|
|
2786
2787
|
}
|
|
2787
2788
|
if (Z !== "ok") {
|
|
2788
|
-
|
|
2789
|
+
o++;
|
|
2789
2790
|
continue;
|
|
2790
2791
|
}
|
|
2791
2792
|
}
|
|
@@ -2794,14 +2795,14 @@ function zc({
|
|
|
2794
2795
|
);
|
|
2795
2796
|
}
|
|
2796
2797
|
ie.length && !((W || q) && x) && await z.invalidateQueries({
|
|
2797
|
-
queryKey: ["o2m-rows",
|
|
2798
|
+
queryKey: ["o2m-rows", s, u, b]
|
|
2798
2799
|
});
|
|
2799
2800
|
}
|
|
2800
2801
|
const c = ((g = n[0]) == null ? void 0 : g.cfg.label) ?? "Value", d = ((h = S == null ? void 0 : S.fieldLabels) == null ? void 0 : h[((p = n[0]) == null ? void 0 : p.rule.parent_field) ?? ""]) ?? ve(((v = n[0]) == null ? void 0 : v.rule.parent_field) ?? "parent");
|
|
2801
2802
|
r && be.message(
|
|
2802
2803
|
`${c} switched to the default on ${r} ${r === 1 ? "line" : "lines"} — the previous one is not available for this ${d}${(W || q) && x ? " (saved with the record)" : ""}`
|
|
2803
|
-
), (i ||
|
|
2804
|
-
`${i +
|
|
2804
|
+
), (i || o) && be.warning(
|
|
2805
|
+
`${i + o} ${i + o === 1 ? "line" : "lines"} could not be switched — no matching default option${o ? " / save failed" : ""}`
|
|
2805
2806
|
), a && Vn();
|
|
2806
2807
|
})().finally(() => {
|
|
2807
2808
|
Wi.current = !1;
|
|
@@ -2810,13 +2811,13 @@ function zc({
|
|
|
2810
2811
|
const or = K(() => {
|
|
2811
2812
|
const e = /* @__PURE__ */ new Map(), n = [...O, ...P], t = [...C.values()], r = dt.flatMap((i) => i.rows);
|
|
2812
2813
|
f != null && f.draft && r.push(f.draft);
|
|
2813
|
-
for (const [i,
|
|
2814
|
-
if (!
|
|
2814
|
+
for (const [i, o] of He) {
|
|
2815
|
+
if (!o.one_collection || nl(o.one_collection)) continue;
|
|
2815
2816
|
const a = n.map((g) => g[i]).filter((g) => g != null).map(String), c = t.map((g) => g[i]).filter((g) => g != null).map(String), d = r.map((g) => g[i]).filter((g) => g != null).map(String), m = [.../* @__PURE__ */ new Set([...a, ...c, ...d])].sort();
|
|
2816
|
-
m.length && e.set(
|
|
2817
|
+
m.length && e.set(o.one_collection, m);
|
|
2817
2818
|
}
|
|
2818
2819
|
return e;
|
|
2819
|
-
}, [O, P, C, He, dt, f == null ? void 0 : f.draft]),
|
|
2820
|
+
}, [O, P, C, He, dt, f == null ? void 0 : f.draft]), sa = K(() => {
|
|
2820
2821
|
const e = /* @__PURE__ */ new Map();
|
|
2821
2822
|
for (const n of ke) {
|
|
2822
2823
|
const t = He.get(n.field);
|
|
@@ -2829,11 +2830,11 @@ function zc({
|
|
|
2829
2830
|
}
|
|
2830
2831
|
}
|
|
2831
2832
|
return e;
|
|
2832
|
-
}, [ke, He]),
|
|
2833
|
-
() => ["m2o-display",
|
|
2834
|
-
[
|
|
2835
|
-
), { data: qn = {}, isFetching:
|
|
2836
|
-
queryKey:
|
|
2833
|
+
}, [ke, He]), la = K(
|
|
2834
|
+
() => ["m2o-display", s, ...Array.from(or.entries()).flat(2)],
|
|
2835
|
+
[s, or]
|
|
2836
|
+
), { data: qn = {}, isFetching: aa } = Ye({
|
|
2837
|
+
queryKey: la,
|
|
2837
2838
|
queryFn: async () => {
|
|
2838
2839
|
const e = {}, n = await Promise.all(
|
|
2839
2840
|
[...or.keys()].map(
|
|
@@ -2848,10 +2849,10 @@ function zc({
|
|
|
2848
2849
|
);
|
|
2849
2850
|
return await Promise.all(
|
|
2850
2851
|
n.map(async ({ collection: t, meta: r }) => {
|
|
2851
|
-
const i = or.get(t),
|
|
2852
|
+
const i = or.get(t), o = sa.get(t);
|
|
2852
2853
|
let a;
|
|
2853
|
-
if (
|
|
2854
|
-
a = `id,${
|
|
2854
|
+
if (o)
|
|
2855
|
+
a = `id,${o.groupField}.*,${o.optionField}.*`;
|
|
2855
2856
|
else {
|
|
2856
2857
|
const d = (r == null ? void 0 : r.display_template) ?? void 0, m = d ? [...d.matchAll(/\{\{([\w.]+)\}\}/g)].map((g) => g[1]) : [];
|
|
2857
2858
|
a = m.some((g) => g.includes(".")) ? ["id", ...m].join(",") : void 0;
|
|
@@ -2867,8 +2868,8 @@ function zc({
|
|
|
2867
2868
|
).then((d) => d.data ?? []);
|
|
2868
2869
|
e[t] = {};
|
|
2869
2870
|
for (const d of c)
|
|
2870
|
-
if (
|
|
2871
|
-
const m = d[
|
|
2871
|
+
if (o) {
|
|
2872
|
+
const m = d[o.groupField], g = d[o.optionField], p = m ? mr(null, m) : null, h = g ? mr(null, g) : null;
|
|
2872
2873
|
e[t][String(d.id)] = [p, h].filter(Boolean).join(" — ") || String(d.id);
|
|
2873
2874
|
} else {
|
|
2874
2875
|
const m = (r == null ? void 0 : r.display_template) ?? void 0;
|
|
@@ -2882,15 +2883,15 @@ function zc({
|
|
|
2882
2883
|
// already known on screen while the new one loads.
|
|
2883
2884
|
placeholderData: (e) => e,
|
|
2884
2885
|
staleTime: 6e4
|
|
2885
|
-
}),
|
|
2886
|
+
}), da = K(
|
|
2886
2887
|
() => le != null && le.unmatched_banner ? P.map((e) => he({ ...e })) : void 0,
|
|
2887
2888
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2888
2889
|
[le == null ? void 0 : le.unmatched_banner, P]
|
|
2889
|
-
), Wt =
|
|
2890
|
+
), Wt = Pd({
|
|
2890
2891
|
config: le,
|
|
2891
2892
|
rows: O,
|
|
2892
|
-
stagedRows:
|
|
2893
|
-
relatedCollection:
|
|
2893
|
+
stagedRows: da,
|
|
2894
|
+
relatedCollection: s,
|
|
2894
2895
|
childRelations: Me,
|
|
2895
2896
|
parentDraft: S == null ? void 0 : S.draft,
|
|
2896
2897
|
m2oRelMap: He,
|
|
@@ -2900,14 +2901,14 @@ function zc({
|
|
|
2900
2901
|
async function qs(e) {
|
|
2901
2902
|
if (!$ || !(D != null && D.length) || q && P.length === 0) return;
|
|
2902
2903
|
Ds(e ? "preview" : "apply");
|
|
2903
|
-
const n = W && !!x, t = P.map((i,
|
|
2904
|
+
const n = W && !!x, t = P.map((i, o) => ({ ...i, id: `pending:${o}` })), r = {};
|
|
2904
2905
|
if (x)
|
|
2905
|
-
for (const [i,
|
|
2906
|
-
r[String(i)] =
|
|
2906
|
+
for (const [i, o] of x.getPendingEdits(s, u))
|
|
2907
|
+
r[String(i)] = o;
|
|
2907
2908
|
try {
|
|
2908
|
-
const
|
|
2909
|
+
const o = (await $.request(
|
|
2909
2910
|
Le("/field-rules/apply", {
|
|
2910
|
-
collection:
|
|
2911
|
+
collection: s,
|
|
2911
2912
|
fk_field: u,
|
|
2912
2913
|
...q ? {} : { parent_id: b },
|
|
2913
2914
|
parent_context: Ut(),
|
|
@@ -2922,22 +2923,22 @@ function zc({
|
|
|
2922
2923
|
)).data;
|
|
2923
2924
|
if (e) {
|
|
2924
2925
|
On({
|
|
2925
|
-
rows:
|
|
2926
|
-
fields:
|
|
2927
|
-
changes:
|
|
2928
|
-
truncated:
|
|
2926
|
+
rows: o.rows,
|
|
2927
|
+
fields: o.fields,
|
|
2928
|
+
changes: o.changes,
|
|
2929
|
+
truncated: o.truncated
|
|
2929
2930
|
});
|
|
2930
2931
|
return;
|
|
2931
2932
|
}
|
|
2932
|
-
const a =
|
|
2933
|
+
const a = o.changes.filter((d) => String(d.id).startsWith("pending:")), c = o.changes.filter((d) => !String(d.id).startsWith("pending:"));
|
|
2933
2934
|
if (x)
|
|
2934
2935
|
for (const d of a) {
|
|
2935
2936
|
const m = Number(String(d.id).slice(8)), g = P[m];
|
|
2936
|
-
!Number.isFinite(m) || !g || x.updateRow(
|
|
2937
|
+
!Number.isFinite(m) || !g || x.updateRow(s, u, m, { ...g, ...d.patch });
|
|
2937
2938
|
}
|
|
2938
2939
|
if (n || q && x) {
|
|
2939
2940
|
for (const m of c)
|
|
2940
|
-
Qe.has(String(m.id)) || x.queueEdit(
|
|
2941
|
+
Qe.has(String(m.id)) || x.queueEdit(s, u, String(m.id), m.patch);
|
|
2941
2942
|
const d = a.length + c.length;
|
|
2942
2943
|
be.success(`Rules staged on ${d} ${d === 1 ? "line" : "lines"} — saved with the record`), On(null), Yr(!1);
|
|
2943
2944
|
return;
|
|
@@ -2951,7 +2952,7 @@ function zc({
|
|
|
2951
2952
|
if (a.length > 0) {
|
|
2952
2953
|
const d = await $.request(
|
|
2953
2954
|
Le("/field-rules/apply", {
|
|
2954
|
-
collection:
|
|
2955
|
+
collection: s,
|
|
2955
2956
|
fk_field: u,
|
|
2956
2957
|
parent_id: b,
|
|
2957
2958
|
parent_context: Ut(),
|
|
@@ -2962,14 +2963,14 @@ function zc({
|
|
|
2962
2963
|
saved_overrides: r
|
|
2963
2964
|
})
|
|
2964
2965
|
);
|
|
2965
|
-
|
|
2966
|
+
o.applied = d.data.applied + a.length, o.failed = d.data.failed;
|
|
2966
2967
|
}
|
|
2967
2968
|
for (const d of c) gt(String(d.id));
|
|
2968
|
-
z.invalidateQueries({ queryKey: ["o2m-rows",
|
|
2969
|
-
queryKey: ["o2m-field-snapshots",
|
|
2970
|
-
}),
|
|
2971
|
-
`Rules applied to ${
|
|
2972
|
-
) : be.success(`Rules applied to ${
|
|
2969
|
+
z.invalidateQueries({ queryKey: ["o2m-rows", s, u, b] }), z.invalidateQueries({
|
|
2970
|
+
queryKey: ["o2m-field-snapshots", s, u, b]
|
|
2971
|
+
}), o.failed.length ? be.error(
|
|
2972
|
+
`Rules applied to ${o.applied} ${o.applied === 1 ? "line" : "lines"} — ${o.failed.length} failed: ${o.failed.slice(0, 3).map((d) => `${ni(O, String(d.id), G)}: ${d.error}`).join("; ")}`
|
|
2973
|
+
) : be.success(`Rules applied to ${o.applied} ${o.applied === 1 ? "line" : "lines"}`), On(null), Yr(!1);
|
|
2973
2974
|
} catch (i) {
|
|
2974
2975
|
be.error(`Re-run rules failed: ${Tn(i, "unknown error")}`);
|
|
2975
2976
|
} finally {
|
|
@@ -2994,7 +2995,7 @@ function zc({
|
|
|
2994
2995
|
function Vr(e, n) {
|
|
2995
2996
|
!$ || !D || D.length === 0 || $.request(
|
|
2996
2997
|
Le("/field-rules/evaluate", {
|
|
2997
|
-
collection:
|
|
2998
|
+
collection: s,
|
|
2998
2999
|
data: n,
|
|
2999
3000
|
locks_only: !0,
|
|
3000
3001
|
probe: !0,
|
|
@@ -3033,29 +3034,29 @@ function zc({
|
|
|
3033
3034
|
const n = String(e.id);
|
|
3034
3035
|
if ((f == null ? void 0 : f.rowId) === n) return;
|
|
3035
3036
|
Ri.current();
|
|
3036
|
-
const t =
|
|
3037
|
+
const t = oa(n);
|
|
3037
3038
|
if (t && !Ti.current.has(xs(n, t))) {
|
|
3038
3039
|
on({ rowKey: n, editor: t });
|
|
3039
3040
|
return;
|
|
3040
3041
|
}
|
|
3041
3042
|
Xe && on(null);
|
|
3042
|
-
const r = he({ ...e }), i = Je.find((
|
|
3043
|
+
const r = he({ ...e }), i = Je.find((o) => String(o.id) === n) ?? e;
|
|
3043
3044
|
Nn.current = { rowId: n, snap: jt(i) }, Ui(n), Be({ rowId: n, draft: r, locksPending: Un.size > 0 }), Vr(n, r);
|
|
3044
3045
|
}
|
|
3045
3046
|
ge(() => {
|
|
3046
3047
|
const e = (n) => {
|
|
3047
3048
|
const t = n.detail;
|
|
3048
|
-
if (!t || t.collection !==
|
|
3049
|
+
if (!t || t.collection !== s || t.field !== u || !t.rowId) return;
|
|
3049
3050
|
const r = O.find((i) => String(i.id) === String(t.rowId));
|
|
3050
3051
|
r && (Hr(r), window.setTimeout(() => {
|
|
3051
3052
|
const i = document.querySelector(
|
|
3052
|
-
`[data-o2m-row="${
|
|
3053
|
+
`[data-o2m-row="${s}:${String(t.rowId)}"]`
|
|
3053
3054
|
);
|
|
3054
3055
|
i && (i.scrollIntoView({ block: "center", behavior: "smooth" }), i.classList.add("nvr-row-flash"), window.setTimeout(() => i.classList.remove("nvr-row-flash"), 2500));
|
|
3055
3056
|
}, 120));
|
|
3056
3057
|
};
|
|
3057
3058
|
return window.addEventListener("nvr:grid-open-row", e), () => window.removeEventListener("nvr:grid-open-row", e);
|
|
3058
|
-
}, [
|
|
3059
|
+
}, [s, u, O]);
|
|
3059
3060
|
function Es(e, n) {
|
|
3060
3061
|
if (L) return;
|
|
3061
3062
|
const t = `pending:${n}`;
|
|
@@ -3069,12 +3070,12 @@ function zc({
|
|
|
3069
3070
|
const n = (m = (d = Ce.current) == null ? void 0 : d.lockReasons) == null ? void 0 : m[e];
|
|
3070
3071
|
if (!n) return "Set automatically for this row";
|
|
3071
3072
|
if (n.reason) return `Locked — ${n.reason}`;
|
|
3072
|
-
const t = n.field ? ce.find((h) => h.field === n.field) : void 0, r = (t == null ? void 0 : t.label) || (n.field ? ve(n.field) : "a rule"), i = n.field ? (g = Ce.current) == null ? void 0 : g.draft[n.field] : void 0,
|
|
3073
|
+
const t = n.field ? ce.find((h) => h.field === n.field) : void 0, r = (t == null ? void 0 : t.label) || (n.field ? ve(n.field) : "a rule"), i = n.field ? (g = Ce.current) == null ? void 0 : g.draft[n.field] : void 0, o = n.field ? He.get(n.field) : void 0, a = i == null || i === "" ? null : o != null && o.one_collection ? ((p = qn[o.one_collection]) == null ? void 0 : p[String(i)]) ?? String(i) : String(i);
|
|
3073
3074
|
if (a) return `Locked — ${r} is ${a}`;
|
|
3074
3075
|
const c = n.op === "neq" ? "is not" : n.op === "null" ? "is empty" : n.op === "nnull" ? "is set" : n.op === "in" ? "is one of" : n.op === "contains" ? "contains" : "is";
|
|
3075
3076
|
return `Locked — ${r} ${c}${n.op === "null" || n.op === "nnull" ? "" : ` ${n.value ?? ""}`}`;
|
|
3076
3077
|
}
|
|
3077
|
-
function
|
|
3078
|
+
function ca(e) {
|
|
3078
3079
|
const n = f == null ? void 0 : f.expected;
|
|
3079
3080
|
if (!n || !(e in n)) return null;
|
|
3080
3081
|
const t = f == null ? void 0 : f.draft[e];
|
|
@@ -3082,7 +3083,7 @@ function zc({
|
|
|
3082
3083
|
const i = n[e];
|
|
3083
3084
|
return i == null || i === "" ? null : String(t) === String(i) ? "auto" : "overridden";
|
|
3084
3085
|
}
|
|
3085
|
-
function
|
|
3086
|
+
function ua(e) {
|
|
3086
3087
|
const n = Ce.current;
|
|
3087
3088
|
if (!n || !$ || !D || D.length === 0) return;
|
|
3088
3089
|
const t = n.rowId;
|
|
@@ -3090,7 +3091,7 @@ function zc({
|
|
|
3090
3091
|
const r = ++ui.current;
|
|
3091
3092
|
mt.current.seqs.set(e, r), $.request(
|
|
3092
3093
|
Le("/field-rules/evaluate", {
|
|
3093
|
-
collection:
|
|
3094
|
+
collection: s,
|
|
3094
3095
|
data: n.draft,
|
|
3095
3096
|
target_fields: [e],
|
|
3096
3097
|
probe: !0,
|
|
@@ -3114,22 +3115,22 @@ function zc({
|
|
|
3114
3115
|
}
|
|
3115
3116
|
return [...r].filter((i) => {
|
|
3116
3117
|
if (i === e || !(i in t)) return !1;
|
|
3117
|
-
const
|
|
3118
|
-
return
|
|
3118
|
+
const o = n[i], a = t[i];
|
|
3119
|
+
return o == null || o === "" || a == null || a === "" ? !1 : String(o) === String(a);
|
|
3119
3120
|
});
|
|
3120
3121
|
}
|
|
3121
3122
|
function Is(e, n, t, r = []) {
|
|
3122
3123
|
var c;
|
|
3123
3124
|
if (((c = Ce.current) == null ? void 0 : c.rowId) !== e || mt.current.rowId !== e) return;
|
|
3124
|
-
const i = mt.current.seqs,
|
|
3125
|
+
const i = mt.current.seqs, o = {};
|
|
3125
3126
|
for (const [d, m] of Object.entries(t.updates ?? {}))
|
|
3126
|
-
(i.get(d) ?? 0) > n || (
|
|
3127
|
+
(i.get(d) ?? 0) > n || (o[d] = m, i.set(d, n));
|
|
3127
3128
|
for (const d of r)
|
|
3128
|
-
d in
|
|
3129
|
-
const a = Object.keys(
|
|
3129
|
+
d in o || (i.get(d) ?? 0) > n || (o[d] = null, i.set(d, n));
|
|
3130
|
+
const a = Object.keys(o).length > 0;
|
|
3130
3131
|
Be((d) => !d || d.rowId !== e ? d : {
|
|
3131
3132
|
...d,
|
|
3132
|
-
draft: a ? he({ ...d.draft, ...
|
|
3133
|
+
draft: a ? he({ ...d.draft, ...o }) : d.draft,
|
|
3133
3134
|
locks: t.locks ?? d.locks,
|
|
3134
3135
|
lockReasons: t.lock_reasons ?? d.lockReasons,
|
|
3135
3136
|
locksPending: !1,
|
|
@@ -3142,7 +3143,7 @@ function zc({
|
|
|
3142
3143
|
const t = { ...e };
|
|
3143
3144
|
if (n.rowDeleted || !n.itemId) {
|
|
3144
3145
|
delete t.id;
|
|
3145
|
-
for (const r of Object.keys(t))
|
|
3146
|
+
for (const r of Object.keys(t)) ol.has(r) && delete t[r];
|
|
3146
3147
|
delete t[u], Be({
|
|
3147
3148
|
rowId: "new",
|
|
3148
3149
|
draft: Gn(t),
|
|
@@ -3169,10 +3170,10 @@ function zc({
|
|
|
3169
3170
|
const n = e.filter((i) => !document.getElementById(Bn(i.field, "cell")));
|
|
3170
3171
|
n.length && Et(n.map((i) => i.message).join(" · "));
|
|
3171
3172
|
const t = e.find((i) => !n.includes(i));
|
|
3172
|
-
t && ((r =
|
|
3173
|
+
t && ((r = gd(document.getElementById(Bn(t.field, "cell")))) == null || r.focus());
|
|
3173
3174
|
});
|
|
3174
3175
|
}
|
|
3175
|
-
function
|
|
3176
|
+
function fa() {
|
|
3176
3177
|
L || (Be({ rowId: "new", draft: { ...Xt }, locksPending: Un.size > 0 }), Vr("new", { ...Xt }));
|
|
3177
3178
|
}
|
|
3178
3179
|
function sr() {
|
|
@@ -3180,8 +3181,8 @@ function zc({
|
|
|
3180
3181
|
const e = (n = Ce.current) == null ? void 0 : n.rowId;
|
|
3181
3182
|
Be(null), Et(null), Rr((t) => {
|
|
3182
3183
|
const r = {};
|
|
3183
|
-
for (const [i,
|
|
3184
|
-
e && i.startsWith(`${e}|`) || i.startsWith("__new__|") || (r[i] =
|
|
3184
|
+
for (const [i, o] of Object.entries(t))
|
|
3185
|
+
e && i.startsWith(`${e}|`) || i.startsWith("__new__|") || (r[i] = o);
|
|
3185
3186
|
return r;
|
|
3186
3187
|
});
|
|
3187
3188
|
}
|
|
@@ -3190,9 +3191,9 @@ function zc({
|
|
|
3190
3191
|
(i = x == null ? void 0 : x.noteEditIntent) == null || i.call(x);
|
|
3191
3192
|
const n = Ce.current, t = (n == null ? void 0 : n.rowId) ?? null;
|
|
3192
3193
|
Jn.current = t, mt.current.rowId !== t && (mt.current = { rowId: t, seqs: /* @__PURE__ */ new Map() });
|
|
3193
|
-
for (const
|
|
3194
|
+
for (const o of Object.keys(e)) mt.current.seqs.set(o, ++ui.current);
|
|
3194
3195
|
const r = he({ ...(n == null ? void 0 : n.draft) ?? {}, ...e });
|
|
3195
|
-
Be((
|
|
3196
|
+
Be((o) => o && { ...o, draft: r });
|
|
3196
3197
|
}
|
|
3197
3198
|
function yt(e, n) {
|
|
3198
3199
|
var v, N, y, w;
|
|
@@ -3201,7 +3202,7 @@ function zc({
|
|
|
3201
3202
|
Jn.current = r, mt.current.rowId !== r && (mt.current = { rowId: r, seqs: /* @__PURE__ */ new Map() });
|
|
3202
3203
|
const i = ++ui.current;
|
|
3203
3204
|
mt.current.seqs.set(e, i);
|
|
3204
|
-
const
|
|
3205
|
+
const o = he(t ? { ...t.draft, [e]: n } : { [e]: n }), a = n != null && n !== "", c = !!((N = ke.find((_) => _.field === e)) != null && N.required), d = (a || !c) && !!((y = t == null ? void 0 : t.missing) != null && y.includes(e)), m = d ? ((t == null ? void 0 : t.missing) ?? []).filter((_) => _ !== e) : t == null ? void 0 : t.missing, g = ((t == null ? void 0 : t.invalid) ?? []).filter(
|
|
3205
3206
|
(_) => ce.some((I) => I.field === _ && I.computed_type === "write")
|
|
3206
3207
|
), p = !!((w = t == null ? void 0 : t.invalid) != null && w.includes(e)) || g.length > 0, h = p ? ((t == null ? void 0 : t.invalid) ?? []).filter((_) => _ !== e && !g.includes(_)) : t == null ? void 0 : t.invalid;
|
|
3207
3208
|
if ((d || p) && ((m == null ? void 0 : m.length) ?? 0) === 0 && ((h == null ? void 0 : h.length) ?? 0) === 0 && Et(null), Be(
|
|
@@ -3209,7 +3210,7 @@ function zc({
|
|
|
3209
3210
|
var I, T;
|
|
3210
3211
|
return _ && {
|
|
3211
3212
|
..._,
|
|
3212
|
-
draft:
|
|
3213
|
+
draft: o,
|
|
3213
3214
|
missing: (a || !c) && ((I = _.missing) != null && I.includes(e)) ? _.missing.filter((E) => E !== e) : _.missing,
|
|
3214
3215
|
invalid: (T = _.invalid) != null && T.length ? _.invalid.filter(
|
|
3215
3216
|
(E) => E !== e && !ce.some((X) => X.field === E && X.computed_type === "write")
|
|
@@ -3217,11 +3218,11 @@ function zc({
|
|
|
3217
3218
|
};
|
|
3218
3219
|
}
|
|
3219
3220
|
), D && D.length > 0 && $) {
|
|
3220
|
-
const _ = Ut(), I = Ji(e, (t == null ? void 0 : t.draft) ?? {}, t == null ? void 0 : t.expected), T = { ...
|
|
3221
|
+
const _ = Ut(), I = Ji(e, (t == null ? void 0 : t.draft) ?? {}, t == null ? void 0 : t.expected), T = { ...o };
|
|
3221
3222
|
for (const E of I) T[E] = null;
|
|
3222
3223
|
$.request(
|
|
3223
3224
|
Le("/field-rules/evaluate", {
|
|
3224
|
-
collection:
|
|
3225
|
+
collection: s,
|
|
3225
3226
|
data: T,
|
|
3226
3227
|
changed_field: e,
|
|
3227
3228
|
probe: !0,
|
|
@@ -3234,12 +3235,12 @@ function zc({
|
|
|
3234
3235
|
}
|
|
3235
3236
|
function Lt() {
|
|
3236
3237
|
if (Gt.current) return Gt.current;
|
|
3237
|
-
const e =
|
|
3238
|
+
const e = ma().finally(() => {
|
|
3238
3239
|
Gt.current === e && (Gt.current = null);
|
|
3239
3240
|
});
|
|
3240
3241
|
return Gt.current = e, e;
|
|
3241
3242
|
}
|
|
3242
|
-
async function
|
|
3243
|
+
async function ma() {
|
|
3243
3244
|
var g;
|
|
3244
3245
|
if (!f) return !1;
|
|
3245
3246
|
const e = f.rowId, n = () => {
|
|
@@ -3267,21 +3268,21 @@ function zc({
|
|
|
3267
3268
|
), Be(
|
|
3268
3269
|
(p) => p && { ...p, missing: r.map((h) => h.field), invalid: void 0 }
|
|
3269
3270
|
), !1;
|
|
3270
|
-
const i = Vo(f.rowId),
|
|
3271
|
+
const i = Vo(f.rowId), o = ke.flatMap((p) => {
|
|
3271
3272
|
var v;
|
|
3272
3273
|
if (fr(p) || (v = f.locks) != null && v.includes(p.field)) return [];
|
|
3273
|
-
if (!
|
|
3274
|
+
if (!Sd.has(p.type ?? "")) return [];
|
|
3274
3275
|
if (i && String(i[p.field] ?? "") === String(f.draft[p.field] ?? ""))
|
|
3275
3276
|
return [];
|
|
3276
|
-
const h =
|
|
3277
|
+
const h = $d(f.draft[p.field], {
|
|
3277
3278
|
type: p.type,
|
|
3278
3279
|
label: p.label || ve(p.field)
|
|
3279
3280
|
});
|
|
3280
3281
|
return h.ok ? [] : [{ field: p.field, message: h.message }];
|
|
3281
3282
|
});
|
|
3282
|
-
if (
|
|
3283
|
-
return Qi(
|
|
3284
|
-
const a = i ?
|
|
3283
|
+
if (o.length > 0)
|
|
3284
|
+
return Qi(o), !1;
|
|
3285
|
+
const a = i ? sl(f.draft, i, new Set(Object.keys(f.draft))) : f.draft, c = qd(
|
|
3285
3286
|
ce.map((p) => ({
|
|
3286
3287
|
field: p.field,
|
|
3287
3288
|
label: p.label || ve(p.field),
|
|
@@ -3293,7 +3294,7 @@ function zc({
|
|
|
3293
3294
|
);
|
|
3294
3295
|
if (c.length > 0)
|
|
3295
3296
|
return Qi(c), !1;
|
|
3296
|
-
const d =
|
|
3297
|
+
const d = Ed(
|
|
3297
3298
|
ce,
|
|
3298
3299
|
he({ ...f.draft }),
|
|
3299
3300
|
i,
|
|
@@ -3325,16 +3326,16 @@ function zc({
|
|
|
3325
3326
|
}
|
|
3326
3327
|
}
|
|
3327
3328
|
Et(null);
|
|
3328
|
-
const m =
|
|
3329
|
-
m && !(i &&
|
|
3329
|
+
const m = ll(ce, f.draft);
|
|
3330
|
+
m && !(i && ll(ce, i)) && be.warning(`${m} is 0 — this is a $0 line. Remove it if it is not needed.`), fn(!0);
|
|
3330
3331
|
try {
|
|
3331
3332
|
if (f.rowId.startsWith("pending:")) {
|
|
3332
3333
|
const p = parseInt(f.rowId.split(":")[1], 10), h = P[p];
|
|
3333
|
-
return x == null || x.updateRow(
|
|
3334
|
+
return x == null || x.updateRow(s, u, p, f.draft), h != null && h.__prefilled && (h == null ? void 0 : h.id) != null && ha((v) => /* @__PURE__ */ new Set([...v, h.id])), n(), fn(!1), !0;
|
|
3334
3335
|
}
|
|
3335
3336
|
if (f.rowId === "new") {
|
|
3336
3337
|
if ((q || W) && x)
|
|
3337
|
-
return x.queueRow(
|
|
3338
|
+
return x.queueRow(s, u, Gn({ ...f.draft })), n(), !0;
|
|
3338
3339
|
const p = Object.entries(f.draft).filter(([_]) => _.startsWith("__m2m_")), h = Object.entries(f.draft).filter(([_]) => _.startsWith("__o2m_")), v = Object.fromEntries(
|
|
3339
3340
|
Object.entries(f.draft).filter(
|
|
3340
3341
|
([_]) => !_.startsWith("__m2m_") && !_.startsWith("__o2m_")
|
|
@@ -3343,7 +3344,7 @@ function zc({
|
|
|
3343
3344
|
let y = null;
|
|
3344
3345
|
try {
|
|
3345
3346
|
y = await $.request(
|
|
3346
|
-
Le(`/items/${
|
|
3347
|
+
Le(`/items/${s}${ut}`, N)
|
|
3347
3348
|
);
|
|
3348
3349
|
} catch (_) {
|
|
3349
3350
|
const I = to(_);
|
|
@@ -3353,13 +3354,13 @@ function zc({
|
|
|
3353
3354
|
retry: async (T) => {
|
|
3354
3355
|
var X;
|
|
3355
3356
|
const E = await $.request(
|
|
3356
|
-
Le(`/items/${
|
|
3357
|
+
Le(`/items/${s}${ut}`, {
|
|
3357
3358
|
...N,
|
|
3358
3359
|
_change_reason: T
|
|
3359
3360
|
})
|
|
3360
3361
|
);
|
|
3361
3362
|
Dt.current = Date.now(), ((X = E == null ? void 0 : E.data) == null ? void 0 : X.id) != null && gt(String(E.data.id)), z.invalidateQueries({
|
|
3362
|
-
queryKey: ["o2m-rows",
|
|
3363
|
+
queryKey: ["o2m-rows", s, u, b]
|
|
3363
3364
|
}), n();
|
|
3364
3365
|
}
|
|
3365
3366
|
}), fn(!1), !1;
|
|
@@ -3388,7 +3389,7 @@ function zc({
|
|
|
3388
3389
|
if (ne.length === 0) continue;
|
|
3389
3390
|
T += ne.length;
|
|
3390
3391
|
const Z = Me.find(
|
|
3391
|
-
(nt) => nt.one_collection ===
|
|
3392
|
+
(nt) => nt.one_collection === s && nt.one_field === ue
|
|
3392
3393
|
);
|
|
3393
3394
|
if (w == null || !(Z != null && Z.many_collection) || !Z.many_field) {
|
|
3394
3395
|
E += ne.length;
|
|
@@ -3404,7 +3405,7 @@ function zc({
|
|
|
3404
3405
|
})
|
|
3405
3406
|
);
|
|
3406
3407
|
} catch (An) {
|
|
3407
|
-
tt.push(nt), I || (I =
|
|
3408
|
+
tt.push(nt), I || (I = ml(An));
|
|
3408
3409
|
}
|
|
3409
3410
|
tt.length && _.push({
|
|
3410
3411
|
label: ve(ue),
|
|
@@ -3423,7 +3424,7 @@ function zc({
|
|
|
3423
3424
|
groups: _
|
|
3424
3425
|
});
|
|
3425
3426
|
}
|
|
3426
|
-
z.invalidateQueries({ queryKey: ["o2m-rows",
|
|
3427
|
+
z.invalidateQueries({ queryKey: ["o2m-rows", s, u, b] });
|
|
3427
3428
|
} else {
|
|
3428
3429
|
const p = (D ?? []).filter((_) => _.target_type !== "lock").map((_) => _.target_field).filter((_) => typeof _ == "string" && _.length > 0 && _ !== "id"), h = /* @__PURE__ */ new Set([
|
|
3429
3430
|
...ke.map((_) => _.field).filter((_) => !_.startsWith("__m2m_")),
|
|
@@ -3431,25 +3432,25 @@ function zc({
|
|
|
3431
3432
|
// A reason an editor action prefilled (carry-forward) rides the row:
|
|
3432
3433
|
// the server stores it on the activity row, never in a column.
|
|
3433
3434
|
"_change_reason"
|
|
3434
|
-
]), v = O.find((_) => String(_.id) === f.rowId), N =
|
|
3435
|
+
]), v = O.find((_) => String(_.id) === f.rowId), N = sl(f.draft, v, h);
|
|
3435
3436
|
if (W && x) {
|
|
3436
3437
|
const _ = Object.entries(f.draft).filter(
|
|
3437
3438
|
([ie]) => ie.startsWith("__nested_ops_")
|
|
3438
|
-
), I = N, { rest: T, reverted: E } =
|
|
3439
|
+
), I = N, { rest: T, reverted: E } = Od(
|
|
3439
3440
|
C.get(f.rowId),
|
|
3440
3441
|
f.draft,
|
|
3441
3442
|
v
|
|
3442
3443
|
);
|
|
3443
3444
|
if (E.length > 0) {
|
|
3444
|
-
x.cancelPendingEdit(
|
|
3445
|
+
x.cancelPendingEdit(s, u, f.rowId);
|
|
3445
3446
|
const ie = {
|
|
3446
3447
|
...T,
|
|
3447
3448
|
...I,
|
|
3448
3449
|
...Object.fromEntries(_)
|
|
3449
3450
|
};
|
|
3450
|
-
if (
|
|
3451
|
+
if (Id(ie)) {
|
|
3451
3452
|
const V = await Bi(f.rowId);
|
|
3452
|
-
x.queueEdit(
|
|
3453
|
+
x.queueEdit(s, u, f.rowId, {
|
|
3453
3454
|
...ie,
|
|
3454
3455
|
...V != null ? { __base_revision: V } : {}
|
|
3455
3456
|
});
|
|
@@ -3459,7 +3460,7 @@ function zc({
|
|
|
3459
3460
|
if (Object.keys(I).length === 0 && _.length === 0)
|
|
3460
3461
|
return n(), !0;
|
|
3461
3462
|
const X = await Bi(f.rowId);
|
|
3462
|
-
return x.queueEdit(
|
|
3463
|
+
return x.queueEdit(s, u, f.rowId, {
|
|
3463
3464
|
...I,
|
|
3464
3465
|
...Object.fromEntries(_),
|
|
3465
3466
|
...X != null ? { __base_revision: X } : {}
|
|
@@ -3470,31 +3471,31 @@ function zc({
|
|
|
3470
3471
|
const y = await Bi(f.rowId), w = (_) => y != null ? { ..._, _base_revision: y } : _;
|
|
3471
3472
|
try {
|
|
3472
3473
|
await $.request(
|
|
3473
|
-
ii(`/items/${
|
|
3474
|
+
ii(`/items/${s}/${f.rowId}${ut}`, w(N))
|
|
3474
3475
|
);
|
|
3475
3476
|
} catch (_) {
|
|
3476
3477
|
const I = to(_);
|
|
3477
3478
|
if (I) {
|
|
3478
|
-
const E = `/items/${
|
|
3479
|
+
const E = `/items/${s}/${f.rowId}${ut}`;
|
|
3479
3480
|
return zn({
|
|
3480
3481
|
challenge: I,
|
|
3481
3482
|
retry: async (X) => {
|
|
3482
3483
|
await $.request(
|
|
3483
3484
|
ii(E, w({ ...N, _change_reason: X }))
|
|
3484
3485
|
), Bt.current.delete(e), kt.forget(e), gt(e), z.invalidateQueries({
|
|
3485
|
-
queryKey: ["o2m-rows",
|
|
3486
|
+
queryKey: ["o2m-rows", s, u, b]
|
|
3486
3487
|
}), n();
|
|
3487
3488
|
}
|
|
3488
3489
|
}), fn(!1), !1;
|
|
3489
3490
|
}
|
|
3490
|
-
const T =
|
|
3491
|
+
const T = Xa(_);
|
|
3491
3492
|
if (T)
|
|
3492
|
-
return Bt.current.set(e, Promise.resolve(T.latest || null)), T.latest > 0 && kt.set(e, T.latest), z.invalidateQueries({ queryKey: ["o2m-rows",
|
|
3493
|
+
return Bt.current.set(e, Promise.resolve(T.latest || null)), T.latest > 0 && kt.set(e, T.latest), z.invalidateQueries({ queryKey: ["o2m-rows", s, u, b] }), be.warning(
|
|
3493
3494
|
"Someone else changed this line while you edited it — take their values or keep yours, then save again"
|
|
3494
3495
|
), fn(!1), !1;
|
|
3495
3496
|
throw _;
|
|
3496
3497
|
}
|
|
3497
|
-
Bt.current.delete(e), kt.forget(e), gt(e), z.invalidateQueries({ queryKey: ["o2m-rows",
|
|
3498
|
+
Bt.current.delete(e), kt.forget(e), gt(e), z.invalidateQueries({ queryKey: ["o2m-rows", s, u, b] });
|
|
3498
3499
|
}
|
|
3499
3500
|
return n(), !0;
|
|
3500
3501
|
} catch {
|
|
@@ -3503,11 +3504,11 @@ function zc({
|
|
|
3503
3504
|
fn(!1);
|
|
3504
3505
|
}
|
|
3505
3506
|
}
|
|
3506
|
-
const [
|
|
3507
|
-
function
|
|
3508
|
-
|
|
3507
|
+
const [pa, ha] = J(/* @__PURE__ */ new Set()), [Nt, js] = J(null), [Jt, Ls] = J(null), [ga, Ts] = J(!1), [sn, ba] = J(1), [ln, En] = J(!1), [Rs, ya] = J(!1), [Fi, wa] = J({}), [Ms, Ks] = J(!1), [Ps, Yr] = J(!1), [Vi, va] = J("empty-only"), [Gr, Ds] = J(null), [Qt, On] = J(null), [an, Ws] = J({}), [Us, Bs] = J(!1);
|
|
3508
|
+
function xa(e, n) {
|
|
3509
|
+
wa((t) => ({ ...t, [e]: n }));
|
|
3509
3510
|
}
|
|
3510
|
-
async function
|
|
3511
|
+
async function _a() {
|
|
3511
3512
|
if (Object.keys(an).some(
|
|
3512
3513
|
(n) => an[n] !== null && an[n] !== void 0
|
|
3513
3514
|
)) {
|
|
@@ -3516,7 +3517,7 @@ function zc({
|
|
|
3516
3517
|
if (O.length)
|
|
3517
3518
|
if (W && x)
|
|
3518
3519
|
O.filter((n) => !Qe.has(String(n.id))).forEach(
|
|
3519
|
-
(n) => x.queueEdit(
|
|
3520
|
+
(n) => x.queueEdit(s, u, String(n.id), {
|
|
3520
3521
|
...an,
|
|
3521
3522
|
...pn(String(n.id))
|
|
3522
3523
|
})
|
|
@@ -3526,7 +3527,7 @@ function zc({
|
|
|
3526
3527
|
await Promise.all(
|
|
3527
3528
|
O.map(
|
|
3528
3529
|
(n) => hn.current(
|
|
3529
|
-
`/items/${
|
|
3530
|
+
`/items/${s}/${n.id}${ut}`,
|
|
3530
3531
|
String(n.id),
|
|
3531
3532
|
an
|
|
3532
3533
|
)
|
|
@@ -3534,11 +3535,11 @@ function zc({
|
|
|
3534
3535
|
);
|
|
3535
3536
|
} finally {
|
|
3536
3537
|
Vn(), z.invalidateQueries({
|
|
3537
|
-
queryKey: ["o2m-rows",
|
|
3538
|
+
queryKey: ["o2m-rows", s, u, b]
|
|
3538
3539
|
});
|
|
3539
3540
|
}
|
|
3540
3541
|
P.length && x && P.forEach(
|
|
3541
|
-
(n, t) => x.updateRow(
|
|
3542
|
+
(n, t) => x.updateRow(s, u, t, { ...n, ...an })
|
|
3542
3543
|
), Ks(!1), Ws({});
|
|
3543
3544
|
} catch {
|
|
3544
3545
|
} finally {
|
|
@@ -3546,45 +3547,45 @@ function zc({
|
|
|
3546
3547
|
}
|
|
3547
3548
|
}
|
|
3548
3549
|
}
|
|
3549
|
-
async function
|
|
3550
|
-
const n = Math.max(1, Math.min(24, sn)), t = /* @__PURE__ */ new Date(), r = Array.from({ length: n }, (i,
|
|
3551
|
-
const a = new Date(t.getFullYear(), t.getMonth() + 1 +
|
|
3550
|
+
async function ka(e) {
|
|
3551
|
+
const n = Math.max(1, Math.min(24, sn)), t = /* @__PURE__ */ new Date(), r = Array.from({ length: n }, (i, o) => {
|
|
3552
|
+
const a = new Date(t.getFullYear(), t.getMonth() + 1 + o, 1), c = `${a.getFullYear()}-${String(a.getMonth() + 1).padStart(2, "0")}-01`;
|
|
3552
3553
|
return { ...Xt, ...Fi, [e]: c };
|
|
3553
3554
|
});
|
|
3554
3555
|
if ((q || W) && x) {
|
|
3555
|
-
for (const i of en(r)) x.queueRow(
|
|
3556
|
+
for (const i of en(r)) x.queueRow(s, u, i);
|
|
3556
3557
|
return;
|
|
3557
3558
|
}
|
|
3558
3559
|
En(!0);
|
|
3559
3560
|
try {
|
|
3560
3561
|
for (const i of en(r))
|
|
3561
3562
|
await $.request(
|
|
3562
|
-
Le(`/items/${
|
|
3563
|
+
Le(`/items/${s}${ut}`, { ...i, [u]: b })
|
|
3563
3564
|
);
|
|
3564
|
-
Dt.current = Date.now(), z.invalidateQueries({ queryKey: ["o2m-rows",
|
|
3565
|
+
Dt.current = Date.now(), z.invalidateQueries({ queryKey: ["o2m-rows", s, u, b] });
|
|
3565
3566
|
} catch {
|
|
3566
3567
|
} finally {
|
|
3567
3568
|
En(!1);
|
|
3568
3569
|
}
|
|
3569
3570
|
}
|
|
3570
|
-
async function
|
|
3571
|
+
async function Na() {
|
|
3571
3572
|
const e = le == null ? void 0 : le.unmatched_banner;
|
|
3572
3573
|
if (!e || Wt.unmatchedCandidates.length === 0) return;
|
|
3573
3574
|
const n = Wt.unmatchedCandidates.map((t) => ({
|
|
3574
3575
|
...Xt,
|
|
3575
|
-
...
|
|
3576
|
+
...Dd(e, t)
|
|
3576
3577
|
}));
|
|
3577
3578
|
if ((q || W) && x) {
|
|
3578
|
-
for (const t of en(n)) x.queueRow(
|
|
3579
|
+
for (const t of en(n)) x.queueRow(s, u, t);
|
|
3579
3580
|
return;
|
|
3580
3581
|
}
|
|
3581
3582
|
En(!0);
|
|
3582
3583
|
try {
|
|
3583
3584
|
for (const t of en(n))
|
|
3584
3585
|
await $.request(
|
|
3585
|
-
Le(`/items/${
|
|
3586
|
+
Le(`/items/${s}${ut}`, { ...t, [u]: b })
|
|
3586
3587
|
);
|
|
3587
|
-
Dt.current = Date.now(), z.invalidateQueries({ queryKey: ["o2m-rows",
|
|
3588
|
+
Dt.current = Date.now(), z.invalidateQueries({ queryKey: ["o2m-rows", s, u, b] });
|
|
3588
3589
|
} catch (t) {
|
|
3589
3590
|
be.error(`Could not add rows: ${Tn(t, "unknown error")}`);
|
|
3590
3591
|
} finally {
|
|
@@ -3595,16 +3596,16 @@ function zc({
|
|
|
3595
3596
|
const n = Math.max(1, Math.min(100, sn)), t = e ? { ...Xt, ...Fi } : { ...Xt };
|
|
3596
3597
|
if ((q || W) && x) {
|
|
3597
3598
|
const r = en(Array.from({ length: n }, () => ({ ...t })));
|
|
3598
|
-
for (const i of r) x.queueRow(
|
|
3599
|
+
for (const i of r) x.queueRow(s, u, i);
|
|
3599
3600
|
return;
|
|
3600
3601
|
}
|
|
3601
3602
|
En(!0);
|
|
3602
3603
|
try {
|
|
3603
3604
|
for (const r of en(Array.from({ length: n }, () => ({ ...t }))))
|
|
3604
3605
|
await $.request(
|
|
3605
|
-
Le(`/items/${
|
|
3606
|
+
Le(`/items/${s}${ut}`, { ...r, [u]: b })
|
|
3606
3607
|
);
|
|
3607
|
-
Dt.current = Date.now(), z.invalidateQueries({ queryKey: ["o2m-rows",
|
|
3608
|
+
Dt.current = Date.now(), z.invalidateQueries({ queryKey: ["o2m-rows", s, u, b] });
|
|
3608
3609
|
} catch {
|
|
3609
3610
|
} finally {
|
|
3610
3611
|
En(!1);
|
|
@@ -3619,21 +3620,21 @@ function zc({
|
|
|
3619
3620
|
function In() {
|
|
3620
3621
|
js(null), Ls(null);
|
|
3621
3622
|
}
|
|
3622
|
-
async function
|
|
3623
|
+
async function Sa(e) {
|
|
3623
3624
|
if (e.preventDefault(), Nt === null || Jt === null || Nt === Jt) {
|
|
3624
3625
|
In();
|
|
3625
3626
|
return;
|
|
3626
3627
|
}
|
|
3627
3628
|
const n = [...O], [t] = n.splice(Nt, 1);
|
|
3628
3629
|
n.splice(Jt, 0, t);
|
|
3629
|
-
const r = n.map((i,
|
|
3630
|
+
const r = n.map((i, o) => ({ row: i, newOrder: o })).filter(({ row: i, newOrder: o }) => {
|
|
3630
3631
|
const a = W ? C.get(String(i.id)) : void 0, c = (a == null ? void 0 : a[G]) ?? i[G];
|
|
3631
|
-
return Number(c ?? -1) !==
|
|
3632
|
+
return Number(c ?? -1) !== o;
|
|
3632
3633
|
});
|
|
3633
3634
|
if (W && x) {
|
|
3634
3635
|
r.forEach(
|
|
3635
|
-
({ row: i, newOrder:
|
|
3636
|
-
[G]:
|
|
3636
|
+
({ row: i, newOrder: o }) => x.queueEdit(s, u, String(i.id), {
|
|
3637
|
+
[G]: o
|
|
3637
3638
|
})
|
|
3638
3639
|
), In();
|
|
3639
3640
|
return;
|
|
@@ -3642,11 +3643,11 @@ function zc({
|
|
|
3642
3643
|
try {
|
|
3643
3644
|
await Promise.all(
|
|
3644
3645
|
r.map(
|
|
3645
|
-
({ row: i, newOrder:
|
|
3646
|
-
ii(`/items/${
|
|
3646
|
+
({ row: i, newOrder: o }) => $.request(
|
|
3647
|
+
ii(`/items/${s}/${i.id}${ut}`, { [G]: o })
|
|
3647
3648
|
)
|
|
3648
3649
|
)
|
|
3649
|
-
), z.invalidateQueries({ queryKey: ["o2m-rows",
|
|
3650
|
+
), z.invalidateQueries({ queryKey: ["o2m-rows", s, u, b] });
|
|
3650
3651
|
} catch {
|
|
3651
3652
|
} finally {
|
|
3652
3653
|
Ts(!1), In();
|
|
@@ -3656,12 +3657,12 @@ function zc({
|
|
|
3656
3657
|
n.stopPropagation();
|
|
3657
3658
|
const t = e.id;
|
|
3658
3659
|
if (W && x) {
|
|
3659
|
-
x.queueDelete(
|
|
3660
|
+
x.queueDelete(s, u, String(t)), (f == null ? void 0 : f.rowId) === String(t) && Be(null);
|
|
3660
3661
|
return;
|
|
3661
3662
|
}
|
|
3662
3663
|
try {
|
|
3663
|
-
await $.request(
|
|
3664
|
-
queryKey: ["o2m-field-snapshots",
|
|
3664
|
+
await $.request(gl(`/items/${s}/${t}${ut}`)), gt(String(t)), z.invalidateQueries({ queryKey: ["o2m-rows", s, u, b] }), (f == null ? void 0 : f.rowId) === String(t) && Be(null), B && z.invalidateQueries({
|
|
3665
|
+
queryKey: ["o2m-field-snapshots", s, u, b]
|
|
3665
3666
|
});
|
|
3666
3667
|
} catch {
|
|
3667
3668
|
}
|
|
@@ -3699,7 +3700,7 @@ function zc({
|
|
|
3699
3700
|
return /* @__PURE__ */ l("span", { className: "tabular-nums", "data-tip": `${g} = ${y} = ${N}`, children: N });
|
|
3700
3701
|
}
|
|
3701
3702
|
if (e.interface === "match-agg-column") {
|
|
3702
|
-
const g =
|
|
3703
|
+
const g = Wl.get(e.field);
|
|
3703
3704
|
if (!g || !t) return /* @__PURE__ */ l("span", { className: "text-slate-300", children: "—" });
|
|
3704
3705
|
const p = O.find((w) => String(w.id) === t) ?? {}, h = (w, _) => _.split(".").reduce(
|
|
3705
3706
|
(I, T) => I && typeof I == "object" ? I[T] : void 0,
|
|
@@ -3763,10 +3764,10 @@ function zc({
|
|
|
3763
3764
|
}
|
|
3764
3765
|
);
|
|
3765
3766
|
}
|
|
3766
|
-
const
|
|
3767
|
-
if (
|
|
3768
|
-
const g = (d = qn[
|
|
3769
|
-
if (!g &&
|
|
3767
|
+
const o = He.get(e.field);
|
|
3768
|
+
if (o != null && o.one_collection) {
|
|
3769
|
+
const g = (d = qn[o.one_collection]) == null ? void 0 : d[String(n)];
|
|
3770
|
+
if (!g && aa)
|
|
3770
3771
|
return /* @__PURE__ */ l(Rn, { className: "h-3 w-3 animate-spin text-slate-300" });
|
|
3771
3772
|
const p = me ? tl(e) : null, h = n != null && ((m = Di.get(e.field)) == null ? void 0 : m.has(String(n))) === !0;
|
|
3772
3773
|
let v;
|
|
@@ -3776,7 +3777,7 @@ function zc({
|
|
|
3776
3777
|
type: "button",
|
|
3777
3778
|
onClick: (N) => {
|
|
3778
3779
|
N.stopPropagation(), me.open({
|
|
3779
|
-
collection:
|
|
3780
|
+
collection: o.one_collection,
|
|
3780
3781
|
itemId: String(n),
|
|
3781
3782
|
layoutId: p.layout_id,
|
|
3782
3783
|
width: p.width,
|
|
@@ -3786,13 +3787,13 @@ function zc({
|
|
|
3786
3787
|
className: "block max-w-full truncate text-left underline decoration-slate-300 decoration-dotted underline-offset-2 hover:text-[#172940] hover:decoration-nvr-cyan dark:hover:text-nvr-cyan",
|
|
3787
3788
|
children: g ?? String(n)
|
|
3788
3789
|
}
|
|
3789
|
-
) : v = /* @__PURE__ */ l("span", { className: "block truncate", children: g ?? String(n) }), h ? /* @__PURE__ */ l(
|
|
3790
|
+
) : v = /* @__PURE__ */ l("span", { className: "block truncate", children: g ?? String(n) }), h ? /* @__PURE__ */ l(Vd, { children: v }) : v;
|
|
3790
3791
|
}
|
|
3791
3792
|
if (e.type === "boolean")
|
|
3792
3793
|
return /* @__PURE__ */ l("span", { className: n ? "text-emerald-600" : "text-slate-400", children: n ? "Yes" : "No" });
|
|
3793
3794
|
if (e.type === "datetime" || e.type === "date")
|
|
3794
3795
|
try {
|
|
3795
|
-
return /* @__PURE__ */ l("span", { className: "block truncate", children:
|
|
3796
|
+
return /* @__PURE__ */ l("span", { className: "block truncate", children: ed(n) });
|
|
3796
3797
|
} catch {
|
|
3797
3798
|
}
|
|
3798
3799
|
if ([
|
|
@@ -3868,7 +3869,7 @@ function zc({
|
|
|
3868
3869
|
}), P.forEach((n, t) => {
|
|
3869
3870
|
e.push({ key: `pending:${t}`, kind: "pending", row: n, idx: t });
|
|
3870
3871
|
})), e;
|
|
3871
|
-
}, Gi = st ? dr().map((e) => e.key) : [],
|
|
3872
|
+
}, Gi = st ? dr().map((e) => e.key) : [], $a = Gi.length > 0 && Gi.every((e) => Pt.has(e)), cr = st ? dr().filter((e) => Pt.has(e.key)) : [], qa = () => {
|
|
3872
3873
|
var t;
|
|
3873
3874
|
const e = Ce.current;
|
|
3874
3875
|
if (!e) return !1;
|
|
@@ -3880,31 +3881,31 @@ function zc({
|
|
|
3880
3881
|
return !0;
|
|
3881
3882
|
continue;
|
|
3882
3883
|
}
|
|
3883
|
-
if (!yi.has(r) && ke.some((
|
|
3884
|
+
if (!yi.has(r) && ke.some((o) => o.field === r) && String(i ?? "") !== String(n[r] ?? ""))
|
|
3884
3885
|
return !0;
|
|
3885
3886
|
}
|
|
3886
3887
|
return !1;
|
|
3887
|
-
},
|
|
3888
|
+
}, Ea = async (e) => {
|
|
3888
3889
|
const n = Ce.current;
|
|
3889
3890
|
if (!n || n.rowId === "new") return;
|
|
3890
3891
|
const t = dr(), r = t.findIndex((a) => a.key === n.rowId);
|
|
3891
3892
|
if (r < 0) return;
|
|
3892
3893
|
const i = r + e;
|
|
3893
3894
|
if (i < 0 || i >= t.length) return;
|
|
3894
|
-
if (
|
|
3895
|
+
if (qa()) {
|
|
3895
3896
|
if (!await Lt()) return;
|
|
3896
3897
|
} else
|
|
3897
3898
|
sr();
|
|
3898
|
-
const
|
|
3899
|
-
|
|
3899
|
+
const o = t[i];
|
|
3900
|
+
o.kind === "pending" ? Es(o.row, o.idx) : Hr(o.row), window.setTimeout(() => {
|
|
3900
3901
|
const a = document.querySelector(
|
|
3901
|
-
`[data-o2m-row="${
|
|
3902
|
+
`[data-o2m-row="${s}:${o.key}"]`
|
|
3902
3903
|
);
|
|
3903
3904
|
a && (a.focus({ preventScroll: !0 }), a.scrollIntoView({ block: "nearest" }));
|
|
3904
3905
|
}, 0);
|
|
3905
3906
|
};
|
|
3906
|
-
go.current =
|
|
3907
|
-
async function
|
|
3907
|
+
go.current = Ea;
|
|
3908
|
+
async function Oa(e) {
|
|
3908
3909
|
const n = Yi.current;
|
|
3909
3910
|
await Ci(
|
|
3910
3911
|
e,
|
|
@@ -3912,8 +3913,8 @@ function zc({
|
|
|
3912
3913
|
{ clearSelection: !0, noun: "row", baseOf: (t) => n.get(t) }
|
|
3913
3914
|
), Yi.current = /* @__PURE__ */ new Map();
|
|
3914
3915
|
}
|
|
3915
|
-
function
|
|
3916
|
-
Yi.current = q || L ? /* @__PURE__ */ new Map() :
|
|
3916
|
+
function Ia() {
|
|
3917
|
+
Yi.current = q || L ? /* @__PURE__ */ new Map() : kd(
|
|
3917
3918
|
kt,
|
|
3918
3919
|
[...Pt].filter((e) => !e.startsWith("pending:"))
|
|
3919
3920
|
), yo(!0);
|
|
@@ -3936,7 +3937,7 @@ function zc({
|
|
|
3936
3937
|
var p;
|
|
3937
3938
|
const r = Object.keys(e);
|
|
3938
3939
|
if (r.length === 0 || n.length === 0) return;
|
|
3939
|
-
const i = (D ?? []).filter((h) => h.target_type !== "lock").map((h) => h.target_field).filter((h) => typeof h == "string" && h.length > 0 && h !== "id"),
|
|
3940
|
+
const i = (D ?? []).filter((h) => h.target_type !== "lock").map((h) => h.target_field).filter((h) => typeof h == "string" && h.length > 0 && h !== "id"), o = /* @__PURE__ */ new Set([
|
|
3940
3941
|
...ke.map((h) => h.field).filter((h) => !h.includes(".") && !h.startsWith("__")),
|
|
3941
3942
|
...i
|
|
3942
3943
|
]), a = [];
|
|
@@ -3946,7 +3947,7 @@ function zc({
|
|
|
3946
3947
|
try {
|
|
3947
3948
|
const _ = await $.request(
|
|
3948
3949
|
Le("/field-rules/evaluate", {
|
|
3949
|
-
collection:
|
|
3950
|
+
collection: s,
|
|
3950
3951
|
data: h.row,
|
|
3951
3952
|
locks_only: !0,
|
|
3952
3953
|
probe: !0,
|
|
@@ -3965,7 +3966,7 @@ function zc({
|
|
|
3965
3966
|
try {
|
|
3966
3967
|
const E = await $.request(
|
|
3967
3968
|
Le("/field-rules/evaluate", {
|
|
3968
|
-
collection:
|
|
3969
|
+
collection: s,
|
|
3969
3970
|
data: T,
|
|
3970
3971
|
changed_field: _,
|
|
3971
3972
|
probe: !0,
|
|
@@ -3985,7 +3986,7 @@ function zc({
|
|
|
3985
3986
|
const w = {};
|
|
3986
3987
|
for (const _ of r) N.includes(_) || (w[_] = e[_] ?? null);
|
|
3987
3988
|
for (const [_, I] of Object.entries(v))
|
|
3988
|
-
_ in w || _ === "id" || _ === u || yi.has(_) || !
|
|
3989
|
+
_ in w || _ === "id" || _ === u || yi.has(_) || !o.has(_) || String(I ?? "") !== String(h.row[_] ?? "") && (w[_] = I);
|
|
3989
3990
|
a.push({ t: h, changes: w });
|
|
3990
3991
|
}
|
|
3991
3992
|
const c = (h, v) => {
|
|
@@ -4000,13 +4001,13 @@ function zc({
|
|
|
4000
4001
|
for (const { t: v, changes: N } of a)
|
|
4001
4002
|
if (Object.keys(N).length !== 0) {
|
|
4002
4003
|
if (v.kind === "pending")
|
|
4003
|
-
x.updateRow(
|
|
4004
|
+
x.updateRow(s, u, v.idx, {
|
|
4004
4005
|
...P[v.idx] ?? v.row,
|
|
4005
4006
|
...N
|
|
4006
4007
|
});
|
|
4007
4008
|
else {
|
|
4008
4009
|
const y = await ((p = t.baseOf) == null ? void 0 : p.call(t, v.key)) ?? null;
|
|
4009
|
-
x.queueEdit(
|
|
4010
|
+
x.queueEdit(s, u, v.key, {
|
|
4010
4011
|
...N,
|
|
4011
4012
|
...y != null && y > 0 ? { __base_revision: y } : pn(v.key)
|
|
4012
4013
|
});
|
|
@@ -4023,7 +4024,7 @@ function zc({
|
|
|
4023
4024
|
const { t: w, changes: _ } = a[y];
|
|
4024
4025
|
if (Object.keys(_).length !== 0) {
|
|
4025
4026
|
if (w.kind === "pending") {
|
|
4026
|
-
x == null || x.updateRow(
|
|
4027
|
+
x == null || x.updateRow(s, u, w.idx, {
|
|
4027
4028
|
...P[w.idx] ?? w.row,
|
|
4028
4029
|
..._
|
|
4029
4030
|
}), d++;
|
|
@@ -4031,7 +4032,7 @@ function zc({
|
|
|
4031
4032
|
}
|
|
4032
4033
|
try {
|
|
4033
4034
|
await hn.current(
|
|
4034
|
-
`/items/${
|
|
4035
|
+
`/items/${s}/${w.key}${ut}`,
|
|
4035
4036
|
w.key,
|
|
4036
4037
|
v ? { ..._, _change_reason: v } : _,
|
|
4037
4038
|
(N = t.baseOf) == null ? void 0 : N.call(t, w.key)
|
|
@@ -4039,14 +4040,14 @@ function zc({
|
|
|
4039
4040
|
} catch (I) {
|
|
4040
4041
|
const T = v ? null : to(I);
|
|
4041
4042
|
if (T) {
|
|
4042
|
-
zn({ challenge: T, retry: (E) => g(y, E) }), z.invalidateQueries({ queryKey: ["o2m-rows",
|
|
4043
|
+
zn({ challenge: T, retry: (E) => g(y, E) }), z.invalidateQueries({ queryKey: ["o2m-rows", s, u, b] });
|
|
4043
4044
|
return;
|
|
4044
4045
|
}
|
|
4045
4046
|
m.push(`#${w.key} ${Tn(I, "failed")}`);
|
|
4046
4047
|
}
|
|
4047
4048
|
}
|
|
4048
4049
|
}
|
|
4049
|
-
Vn(), z.invalidateQueries({ queryKey: ["o2m-rows",
|
|
4050
|
+
Vn(), z.invalidateQueries({ queryKey: ["o2m-rows", s, u, b] }), c(d, m);
|
|
4050
4051
|
};
|
|
4051
4052
|
await g(0);
|
|
4052
4053
|
}
|
|
@@ -4075,15 +4076,15 @@ function zc({
|
|
|
4075
4076
|
const t = (n == null ? void 0 : n.rowKey) ?? "__new__", r = { ...e };
|
|
4076
4077
|
for (const i of Ke) {
|
|
4077
4078
|
if (i.computed_type !== "rollup" || !i.computed_formula) continue;
|
|
4078
|
-
let
|
|
4079
|
+
let o = null;
|
|
4079
4080
|
try {
|
|
4080
4081
|
const c = JSON.parse(String(i.computed_formula));
|
|
4081
|
-
|
|
4082
|
+
o = c != null && c.sources ? c : { sources: [c] };
|
|
4082
4083
|
} catch {
|
|
4083
4084
|
continue;
|
|
4084
4085
|
}
|
|
4085
4086
|
let a = null;
|
|
4086
|
-
for (const c of (
|
|
4087
|
+
for (const c of (o == null ? void 0 : o.sources) ?? []) {
|
|
4087
4088
|
const d = (te ?? []).map((v) => typeof v == "string" ? v : v.field), m = d.find((v) => v === c.related_collection) ?? (d.length === 1 ? d[0] : void 0), g = m ? e[`__o2m_${m}`] : void 0, p = (m ? Tr[`${t}|${m}`] : void 0) ?? g;
|
|
4088
4089
|
if (!p) continue;
|
|
4089
4090
|
const h = c.aggregate ?? "sum";
|
|
@@ -4097,16 +4098,16 @@ function zc({
|
|
|
4097
4098
|
}
|
|
4098
4099
|
for (const i of Ke)
|
|
4099
4100
|
if (i.computed_type === "write" && i.computed_formula) {
|
|
4100
|
-
const
|
|
4101
|
-
|
|
4101
|
+
const o = Ft(i.computed_formula, r);
|
|
4102
|
+
o != null && (r[i.field] = o);
|
|
4102
4103
|
}
|
|
4103
4104
|
return r;
|
|
4104
4105
|
}, Zr = (e, n) => !te || te.length === 0 ? null : /* @__PURE__ */ l("div", { className: "mt-3 space-y-2 border-t border-slate-100 pt-3 dark:border-border", children: te.map((t) => {
|
|
4105
|
-
const r = typeof t == "string" ? t : t.field, i = typeof t == "string" ? void 0 : t.hint,
|
|
4106
|
+
const r = typeof t == "string" ? t : t.field, i = typeof t == "string" ? void 0 : t.hint, o = typeof t == "string" ? void 0 : t.match, a = o ? oi(o, n, b, S == null ? void 0 : S.draft) : null;
|
|
4106
4107
|
return /* @__PURE__ */ l(
|
|
4107
4108
|
so,
|
|
4108
4109
|
{
|
|
4109
|
-
parentCollection:
|
|
4110
|
+
parentCollection: s,
|
|
4110
4111
|
relationField: r,
|
|
4111
4112
|
parentRowId: e ?? null,
|
|
4112
4113
|
parentDraft: n,
|
|
@@ -4115,9 +4116,9 @@ function zc({
|
|
|
4115
4116
|
...d,
|
|
4116
4117
|
[`${e ?? "__new__"}|${r}`]: c
|
|
4117
4118
|
})),
|
|
4118
|
-
outerGridInvalidateKey: ["o2m-rows",
|
|
4119
|
-
...
|
|
4120
|
-
matchCollection:
|
|
4119
|
+
outerGridInvalidateKey: ["o2m-rows", s, u, b],
|
|
4120
|
+
...o ? {
|
|
4121
|
+
matchCollection: o.collection,
|
|
4121
4122
|
matchQuery: (a == null ? void 0 : a.query) ?? null,
|
|
4122
4123
|
matchSeed: (a == null ? void 0 : a.seed) ?? {},
|
|
4123
4124
|
// #735 — a saved line in a pending grid stages its matched
|
|
@@ -4193,7 +4194,7 @@ function zc({
|
|
|
4193
4194
|
return t.length > 0 && (() => {
|
|
4194
4195
|
const r = ur(e.draft, { rowKey: e.rowId ?? "__new__" });
|
|
4195
4196
|
return /* @__PURE__ */ l("div", { className: "mb-3 flex flex-wrap items-stretch gap-x-6 gap-y-2 rounded-md bg-slate-50/80 px-3 py-2 dark:bg-muted/40", children: t.map((i) => {
|
|
4196
|
-
const
|
|
4197
|
+
const o = i.label || ve(i.field), a = i.computed_type === "write" && !!i.computed_formula, c = i.options ? typeof i.options == "string" ? (() => {
|
|
4197
4198
|
try {
|
|
4198
4199
|
return JSON.parse(i.options);
|
|
4199
4200
|
} catch {
|
|
@@ -4207,7 +4208,7 @@ function zc({
|
|
|
4207
4208
|
}
|
|
4208
4209
|
) : null;
|
|
4209
4210
|
return /* @__PURE__ */ k("div", { className: "flex min-w-0 flex-col justify-start", children: [
|
|
4210
|
-
/* @__PURE__ */ l("span", { className: "text-[10px] font-medium uppercase tracking-wide text-slate-400", children:
|
|
4211
|
+
/* @__PURE__ */ l("span", { className: "text-[10px] font-medium uppercase tracking-wide text-slate-400", children: o }),
|
|
4211
4212
|
/* @__PURE__ */ l("span", { className: "mt-0.5 truncate text-[12px] font-medium text-slate-700 dark:text-slate-200", children: a ? De(i, r[i.field] ?? e.draft[i.field]) : m != null ? /* @__PURE__ */ l("span", { className: "tabular-nums", children: m.toLocaleString(
|
|
4212
4213
|
"en-US",
|
|
4213
4214
|
St(c, c.format)
|
|
@@ -4224,7 +4225,7 @@ function zc({
|
|
|
4224
4225
|
style: { gridTemplateColumns: "repeat(auto-fit, minmax(240px, 1fr))" },
|
|
4225
4226
|
children: Ke.filter((t) => !fr(t)).map((t) => {
|
|
4226
4227
|
var h, v, N, y, w, _;
|
|
4227
|
-
const r = t.computed_type === "write" && !!t.computed_formula, i = t.label || ve(t.field),
|
|
4228
|
+
const r = t.computed_type === "write" && !!t.computed_formula, i = t.label || ve(t.field), o = t.interface === "formula-column" || t.interface === "match-agg-column" || t.interface === "relation-path";
|
|
4228
4229
|
if (ot(t))
|
|
4229
4230
|
return /* @__PURE__ */ k("div", { className: "flex min-w-0 flex-col gap-1", children: [
|
|
4230
4231
|
/* @__PURE__ */ l("span", { className: "text-[10px] font-medium uppercase tracking-wide text-slate-400", children: i }),
|
|
@@ -4240,7 +4241,7 @@ function zc({
|
|
|
4240
4241
|
"div",
|
|
4241
4242
|
{
|
|
4242
4243
|
id: Bn(t.field, "cell"),
|
|
4243
|
-
ref: (I) =>
|
|
4244
|
+
ref: (I) => bd(I, m, p),
|
|
4244
4245
|
"data-grid-cell": qo(e.rowId, t.field),
|
|
4245
4246
|
className: xe(
|
|
4246
4247
|
"flex min-w-0 flex-col gap-1",
|
|
@@ -4259,7 +4260,7 @@ function zc({
|
|
|
4259
4260
|
a && /* @__PURE__ */ l("span", { className: "ml-1 normal-case tracking-normal", children: "· required" }),
|
|
4260
4261
|
(() => {
|
|
4261
4262
|
var ie, V;
|
|
4262
|
-
const I =
|
|
4263
|
+
const I = ca(t.field);
|
|
4263
4264
|
if (!I) return null;
|
|
4264
4265
|
const T = He.get(t.field), E = (ue) => {
|
|
4265
4266
|
var ne;
|
|
@@ -4269,14 +4270,14 @@ function zc({
|
|
|
4269
4270
|
return ((ne = ke.find((Z) => Z.field === ue)) == null ? void 0 : ne.label) ?? ue.replace(/_/g, " ");
|
|
4270
4271
|
};
|
|
4271
4272
|
return /* @__PURE__ */ l(
|
|
4272
|
-
|
|
4273
|
+
Bd,
|
|
4273
4274
|
{
|
|
4274
4275
|
kind: I,
|
|
4275
4276
|
provenance: (ie = f == null ? void 0 : f.provenance) == null ? void 0 : ie[t.field],
|
|
4276
4277
|
labelOf: E,
|
|
4277
4278
|
fieldLabel: X,
|
|
4278
4279
|
relatedCollection: (T == null ? void 0 : T.one_collection) ?? null,
|
|
4279
|
-
onReset: I === "overridden" && !L && !((V = f == null ? void 0 : f.locks) != null && V.includes(t.field)) ? () =>
|
|
4280
|
+
onReset: I === "overridden" && !L && !((V = f == null ? void 0 : f.locks) != null && V.includes(t.field)) ? () => ua(t.field) : void 0
|
|
4280
4281
|
}
|
|
4281
4282
|
);
|
|
4282
4283
|
})()
|
|
@@ -4286,7 +4287,7 @@ function zc({
|
|
|
4286
4287
|
r ? /* @__PURE__ */ l("div", { className: "text-[12px] italic text-slate-500", children: De(
|
|
4287
4288
|
t,
|
|
4288
4289
|
Ft(t.computed_formula, e.draft) ?? e.draft[t.field]
|
|
4289
|
-
) }) :
|
|
4290
|
+
) }) : o || t.readonly || Pr(t) || (w = f == null ? void 0 : f.locks) != null && w.includes(t.field) || Ei(t.field, e.draft) ? /* @__PURE__ */ l(
|
|
4290
4291
|
"div",
|
|
4291
4292
|
{
|
|
4292
4293
|
className: "text-[12px] text-slate-500",
|
|
@@ -4313,7 +4314,7 @@ function zc({
|
|
|
4313
4314
|
value: e.draft[t.field] ?? null,
|
|
4314
4315
|
onChange: (I) => yt(t.field, I),
|
|
4315
4316
|
relations: Me,
|
|
4316
|
-
collection:
|
|
4317
|
+
collection: s,
|
|
4317
4318
|
itemId: e.rowId ?? "new",
|
|
4318
4319
|
cascadeFilter: Ve[t.field],
|
|
4319
4320
|
narrowedBy: Lr[t.field],
|
|
@@ -4340,13 +4341,13 @@ function zc({
|
|
|
4340
4341
|
className: "inline-flex items-center gap-0.5 text-[10px] uppercase tracking-wide text-slate-400",
|
|
4341
4342
|
"data-tip": j.closed_locked && bn ? `${j.closed_rule ?? ""} A change here needs a reason.`.trim() : j.closed_rule,
|
|
4342
4343
|
children: [
|
|
4343
|
-
/* @__PURE__ */ l(
|
|
4344
|
+
/* @__PURE__ */ l(Da, { className: "h-2.5 w-2.5", "aria-hidden": "true" }),
|
|
4344
4345
|
" closed"
|
|
4345
4346
|
]
|
|
4346
4347
|
}
|
|
4347
4348
|
),
|
|
4348
4349
|
E && !L && /* @__PURE__ */ l(
|
|
4349
|
-
|
|
4350
|
+
hd,
|
|
4350
4351
|
{
|
|
4351
4352
|
data: j,
|
|
4352
4353
|
rowKey: e.draft[j.key_field],
|
|
@@ -4380,7 +4381,7 @@ function zc({
|
|
|
4380
4381
|
}
|
|
4381
4382
|
),
|
|
4382
4383
|
_e && ((n = _e.fields) == null ? void 0 : n.length) > 0 && !L && /* @__PURE__ */ l(
|
|
4383
|
-
|
|
4384
|
+
nc,
|
|
4384
4385
|
{
|
|
4385
4386
|
config: _e,
|
|
4386
4387
|
draft: e.draft,
|
|
@@ -4398,16 +4399,16 @@ function zc({
|
|
|
4398
4399
|
const r = O.find((a) => Number(a[j.key_field]) === t - 1);
|
|
4399
4400
|
if (!r) return null;
|
|
4400
4401
|
const i = {};
|
|
4401
|
-
let
|
|
4402
|
+
let o = !1;
|
|
4402
4403
|
for (const a of _e.fields) {
|
|
4403
4404
|
const c = Number(r[a]) || 0;
|
|
4404
|
-
i[a] = c, c > 0 && (
|
|
4405
|
+
i[a] = c, c > 0 && (o = !0);
|
|
4405
4406
|
}
|
|
4406
|
-
return
|
|
4407
|
+
return o ? { label: `Like ${t - 1}`, values: i } : null;
|
|
4407
4408
|
})()
|
|
4408
4409
|
}
|
|
4409
4410
|
),
|
|
4410
|
-
le && e.rowId && !e.rowId.startsWith("pending:") && e.rowId !== "new" && /* @__PURE__ */ l(
|
|
4411
|
+
le && e.rowId && !e.rowId.startsWith("pending:") && e.rowId !== "new" && /* @__PURE__ */ l(Wd, { config: le, result: Wt.byRow.get(e.rowId) }),
|
|
4411
4412
|
e.drawer
|
|
4412
4413
|
]
|
|
4413
4414
|
}
|
|
@@ -4415,7 +4416,7 @@ function zc({
|
|
|
4415
4416
|
}, Xi = (e) => /* @__PURE__ */ l("td", { colSpan: Tt, className: "p-0", children: Vs(e) }), Hs = (e, n) => {
|
|
4416
4417
|
const t = e.editor.split(/\s+/).map((i) => i[0]).filter(Boolean).slice(0, 2).join("").toUpperCase(), r = () => {
|
|
4417
4418
|
Ti.current.add(xs(e.rowKey, e.editor)), on(null);
|
|
4418
|
-
const i = O.find((
|
|
4419
|
+
const i = O.find((o) => String(o.id) === e.rowKey);
|
|
4419
4420
|
i && Hr(C.has(e.rowKey) ? { ...i, ...C.get(e.rowKey) } : i);
|
|
4420
4421
|
};
|
|
4421
4422
|
return /* @__PURE__ */ k(
|
|
@@ -4454,7 +4455,7 @@ function zc({
|
|
|
4454
4455
|
]
|
|
4455
4456
|
}
|
|
4456
4457
|
);
|
|
4457
|
-
}, Ys = fi === pr,
|
|
4458
|
+
}, Ys = fi === pr, Aa = Ys ? null : (It == null ? void 0 : It.name) ?? ((Cs = re == null ? void 0 : re[0]) == null ? void 0 : Cs.name), Gs = re && re.length >= 2 && /* @__PURE__ */ k("div", { className: "flex items-center gap-1 text-[11px]", children: [
|
|
4458
4459
|
/* @__PURE__ */ l(
|
|
4459
4460
|
"button",
|
|
4460
4461
|
{
|
|
@@ -4474,7 +4475,7 @@ function zc({
|
|
|
4474
4475
|
onClick: () => Ro(e.name),
|
|
4475
4476
|
className: xe(
|
|
4476
4477
|
"h-6 px-2.5 rounded border transition-colors",
|
|
4477
|
-
|
|
4478
|
+
Aa === e.name ? "border-nvr-cyan bg-nvr-cyan/10 text-nvr-cyan" : "border-slate-200 text-slate-600 hover:border-slate-400 hover:text-slate-800"
|
|
4478
4479
|
),
|
|
4479
4480
|
children: e.name
|
|
4480
4481
|
},
|
|
@@ -4489,12 +4490,12 @@ function zc({
|
|
|
4489
4490
|
"div",
|
|
4490
4491
|
{
|
|
4491
4492
|
className: "space-y-1.5",
|
|
4492
|
-
"data-o2m-collection":
|
|
4493
|
-
onFocusCapture:
|
|
4494
|
-
onBlurCapture:
|
|
4493
|
+
"data-o2m-collection": s,
|
|
4494
|
+
onFocusCapture: Ll,
|
|
4495
|
+
onBlurCapture: Tl,
|
|
4495
4496
|
children: [
|
|
4496
4497
|
/* @__PURE__ */ l(
|
|
4497
|
-
|
|
4498
|
+
Ba,
|
|
4498
4499
|
{
|
|
4499
4500
|
challenge: (qr == null ? void 0 : qr.challenge) ?? null,
|
|
4500
4501
|
onCancel: () => zn(null),
|
|
@@ -4505,7 +4506,7 @@ function zc({
|
|
|
4505
4506
|
}
|
|
4506
4507
|
),
|
|
4507
4508
|
Ar && Ar.length > 0 && /* @__PURE__ */ l(
|
|
4508
|
-
|
|
4509
|
+
Ad,
|
|
4509
4510
|
{
|
|
4510
4511
|
lines: Ar.map((e) => ({
|
|
4511
4512
|
...e,
|
|
@@ -4518,7 +4519,7 @@ function zc({
|
|
|
4518
4519
|
hideField: (e, n) => {
|
|
4519
4520
|
var t;
|
|
4520
4521
|
return Me.some(
|
|
4521
|
-
(r) => r.many_collection ===
|
|
4522
|
+
(r) => r.many_collection === s && r.many_field === n
|
|
4522
4523
|
) || !!((t = ce.find((r) => r.field === n)) != null && t.hidden);
|
|
4523
4524
|
},
|
|
4524
4525
|
intro: "Someone else saved these line values after this table loaded, so your change was not written. Pick which value wins for each.",
|
|
@@ -4529,10 +4530,10 @@ function zc({
|
|
|
4529
4530
|
},
|
|
4530
4531
|
onCancel: () => {
|
|
4531
4532
|
hi(null), z.invalidateQueries({
|
|
4532
|
-
queryKey: ["o2m-rows",
|
|
4533
|
+
queryKey: ["o2m-rows", s, u, b]
|
|
4533
4534
|
});
|
|
4534
4535
|
},
|
|
4535
|
-
onResolve: (e) => void
|
|
4536
|
+
onResolve: (e) => void ta(e)
|
|
4536
4537
|
}
|
|
4537
4538
|
),
|
|
4538
4539
|
!L && /* @__PURE__ */ k("div", { className: "flex items-center gap-2 text-[11px]", children: [
|
|
@@ -4544,7 +4545,7 @@ function zc({
|
|
|
4544
4545
|
min: 1,
|
|
4545
4546
|
max: 100,
|
|
4546
4547
|
value: sn,
|
|
4547
|
-
onChange: (e) =>
|
|
4548
|
+
onChange: (e) => ba(Math.max(1, Math.min(100, parseInt(e.target.value, 10) || 1))),
|
|
4548
4549
|
className: "w-14 h-6 rounded border border-slate-200 px-2 text-[11px] text-slate-700 text-center focus:outline-none focus:ring-1 focus:ring-nvr-cyan"
|
|
4549
4550
|
}
|
|
4550
4551
|
),
|
|
@@ -4570,7 +4571,7 @@ function zc({
|
|
|
4570
4571
|
{
|
|
4571
4572
|
type: "button",
|
|
4572
4573
|
disabled: ln,
|
|
4573
|
-
onClick: () =>
|
|
4574
|
+
onClick: () => ka(e[0].field),
|
|
4574
4575
|
"data-tip": `Generate ${sn} rows with ${e[0].field} advancing one month per row (starting next month)`,
|
|
4575
4576
|
className: "h-6 px-2.5 rounded border border-dashed border-slate-300 text-slate-500 hover:border-nvr-cyan/60 hover:text-slate-700 disabled:opacity-40 transition-colors",
|
|
4576
4577
|
children: [
|
|
@@ -4581,17 +4582,17 @@ function zc({
|
|
|
4581
4582
|
);
|
|
4582
4583
|
})(),
|
|
4583
4584
|
Te && (!q || x) && /* @__PURE__ */ l(
|
|
4584
|
-
|
|
4585
|
+
Xd,
|
|
4585
4586
|
{
|
|
4586
4587
|
config: Te,
|
|
4587
|
-
relatedCollection:
|
|
4588
|
+
relatedCollection: s,
|
|
4588
4589
|
manyField: u,
|
|
4589
4590
|
parentId: b,
|
|
4590
4591
|
rows: q ? [] : O,
|
|
4591
4592
|
rowDefaults: Xt,
|
|
4592
4593
|
parentDraft: S == null ? void 0 : S.draft,
|
|
4593
4594
|
invalidate: () => z.invalidateQueries({
|
|
4594
|
-
queryKey: ["o2m-rows",
|
|
4595
|
+
queryKey: ["o2m-rows", s, u, b]
|
|
4595
4596
|
}),
|
|
4596
4597
|
onLocalWrite: (e) => {
|
|
4597
4598
|
e ? gt(e) : Dt.current = Date.now();
|
|
@@ -4601,7 +4602,7 @@ function zc({
|
|
|
4601
4602
|
pendingRows: P,
|
|
4602
4603
|
pendingEdits: C,
|
|
4603
4604
|
pendingDeletes: Qe,
|
|
4604
|
-
writeRow: (e, n) => Li(`/items/${
|
|
4605
|
+
writeRow: (e, n) => Li(`/items/${s}/${e}`, e, n),
|
|
4605
4606
|
stagedBase: pn
|
|
4606
4607
|
}
|
|
4607
4608
|
),
|
|
@@ -4610,48 +4611,48 @@ function zc({
|
|
|
4610
4611
|
(n) => typeof n == "object" && n.field === qe.relation && !!n.match
|
|
4611
4612
|
);
|
|
4612
4613
|
return e != null && e.match ? /* @__PURE__ */ l(
|
|
4613
|
-
|
|
4614
|
+
ec,
|
|
4614
4615
|
{
|
|
4615
4616
|
config: qe,
|
|
4616
4617
|
matchCfg: e.match,
|
|
4617
4618
|
rows: O,
|
|
4618
4619
|
parentId: b,
|
|
4619
4620
|
parentDraft: S == null ? void 0 : S.draft,
|
|
4620
|
-
relatedCollection:
|
|
4621
|
+
relatedCollection: s,
|
|
4621
4622
|
manyField: u
|
|
4622
4623
|
}
|
|
4623
4624
|
) : null;
|
|
4624
4625
|
})(),
|
|
4625
4626
|
(Ze ?? []).map((e) => /* @__PURE__ */ l(
|
|
4626
|
-
|
|
4627
|
+
Zd,
|
|
4627
4628
|
{
|
|
4628
4629
|
config: e,
|
|
4629
4630
|
rows: [...O, ...P.map((n, t) => ({ ...n, __pendingIndex: t }))],
|
|
4630
|
-
relatedCollection:
|
|
4631
|
+
relatedCollection: s,
|
|
4631
4632
|
computedWriteFields: yi,
|
|
4632
4633
|
applyRow: async (n, t) => {
|
|
4633
4634
|
const r = n.__pendingIndex;
|
|
4634
4635
|
if (typeof r == "number" && x) {
|
|
4635
|
-
x.updateRow(
|
|
4636
|
+
x.updateRow(s, u, r, t);
|
|
4636
4637
|
return;
|
|
4637
4638
|
}
|
|
4638
4639
|
const i = String(n.id);
|
|
4639
4640
|
if (W && x) {
|
|
4640
|
-
x.queueEdit(
|
|
4641
|
+
x.queueEdit(s, u, i, {
|
|
4641
4642
|
...t,
|
|
4642
4643
|
...pn(i)
|
|
4643
4644
|
});
|
|
4644
4645
|
return;
|
|
4645
4646
|
}
|
|
4646
|
-
await Li(`/items/${
|
|
4647
|
-
queryKey: ["o2m-rows",
|
|
4647
|
+
await Li(`/items/${s}/${i}`, i, t), await z.invalidateQueries({
|
|
4648
|
+
queryKey: ["o2m-rows", s, u, b]
|
|
4648
4649
|
});
|
|
4649
4650
|
}
|
|
4650
4651
|
},
|
|
4651
4652
|
e.label
|
|
4652
4653
|
)),
|
|
4653
4654
|
$t && !q && !L && rt && A && /* @__PURE__ */ l(
|
|
4654
|
-
|
|
4655
|
+
nd,
|
|
4655
4656
|
{
|
|
4656
4657
|
collection: A,
|
|
4657
4658
|
templateFilter: (e) => {
|
|
@@ -4677,13 +4678,13 @@ function zc({
|
|
|
4677
4678
|
children: "Copy from…"
|
|
4678
4679
|
}
|
|
4679
4680
|
),
|
|
4680
|
-
|
|
4681
|
+
_l && /* @__PURE__ */ l("span", { className: "absolute left-0 top-full z-[70] mt-1 w-[300px] rounded-lg border border-slate-200 bg-white p-2 shadow-xl dark:border-border dark:bg-card", children: /* @__PURE__ */ l(
|
|
4681
4682
|
lo,
|
|
4682
4683
|
{
|
|
4683
4684
|
collection: A,
|
|
4684
4685
|
value: null,
|
|
4685
4686
|
onChange: (e) => {
|
|
4686
|
-
e != null &&
|
|
4687
|
+
e != null && Sl(String(e));
|
|
4687
4688
|
},
|
|
4688
4689
|
placeholder: "Pick the record to copy from…"
|
|
4689
4690
|
}
|
|
@@ -4693,7 +4694,7 @@ function zc({
|
|
|
4693
4694
|
"button",
|
|
4694
4695
|
{
|
|
4695
4696
|
type: "button",
|
|
4696
|
-
onClick: () =>
|
|
4697
|
+
onClick: () => ya((e) => !e),
|
|
4697
4698
|
className: xe(
|
|
4698
4699
|
"h-6 px-2.5 rounded border transition-colors",
|
|
4699
4700
|
Rs ? "border-nvr-cyan bg-nvr-cyan/10 text-nvr-cyan" : "border-slate-200 text-slate-600 hover:border-slate-400 hover:text-slate-800"
|
|
@@ -4714,12 +4715,12 @@ function zc({
|
|
|
4714
4715
|
}
|
|
4715
4716
|
),
|
|
4716
4717
|
_e && ((Xs = _e.fields) == null ? void 0 : Xs.length) > 0 && _e.across_rows !== !1 && O.length + P.length > 1 && /* @__PURE__ */ l(
|
|
4717
|
-
|
|
4718
|
+
rc,
|
|
4718
4719
|
{
|
|
4719
4720
|
config: _e,
|
|
4720
4721
|
remaining: wt(_e.remaining, tn),
|
|
4721
4722
|
rowNoun: j ? ve(j.key_field).toLowerCase() : "row",
|
|
4722
|
-
onApply:
|
|
4723
|
+
onApply: Hl
|
|
4723
4724
|
}
|
|
4724
4725
|
),
|
|
4725
4726
|
!!(D != null && D.length) && O.length + P.length > 0 && /* @__PURE__ */ l(
|
|
@@ -4737,15 +4738,15 @@ function zc({
|
|
|
4737
4738
|
children: "re-run rules…"
|
|
4738
4739
|
}
|
|
4739
4740
|
),
|
|
4740
|
-
!L && Ie === "original" && O.length + P.length > 0 &&
|
|
4741
|
-
const n = cr.length > 0 ? cr : Fs(), t = ce.find((a) => a.field === e.field), r = e.label ?? (t ? Xn(t) : ve(e.field)), i = new Set(n.map((a) => String(a.row[e.field] ?? ""))),
|
|
4741
|
+
!L && Ie === "original" && O.length + P.length > 0 && Jd(Mn).filter((e) => !e.admin_only || bn).map((e) => {
|
|
4742
|
+
const n = cr.length > 0 ? cr : Fs(), t = ce.find((a) => a.field === e.field), r = e.label ?? (t ? Xn(t) : ve(e.field)), i = new Set(n.map((a) => String(a.row[e.field] ?? ""))), o = i.size === 1 && [...i][0] || null;
|
|
4742
4743
|
return /* @__PURE__ */ l(
|
|
4743
|
-
|
|
4744
|
+
Qd,
|
|
4744
4745
|
{
|
|
4745
4746
|
label: r,
|
|
4746
4747
|
count: n.length,
|
|
4747
4748
|
scope: cr.length > 0 ? "selected" : "all",
|
|
4748
|
-
commonValue:
|
|
4749
|
+
commonValue: o,
|
|
4749
4750
|
onApply: (a) => Ci({ [e.field]: a }, n, {
|
|
4750
4751
|
clearSelection: cr.length > 0,
|
|
4751
4752
|
noun: "line"
|
|
@@ -4762,14 +4763,14 @@ function zc({
|
|
|
4762
4763
|
"aria-pressed": cn,
|
|
4763
4764
|
"data-tip": cn ? "Hide the selection checkboxes" : "Tick rows to edit several lines at once",
|
|
4764
4765
|
onClick: () => {
|
|
4765
|
-
|
|
4766
|
+
vl((e) => !e), xr(/* @__PURE__ */ new Set());
|
|
4766
4767
|
},
|
|
4767
4768
|
className: xe(
|
|
4768
4769
|
"inline-flex h-6 items-center gap-1 rounded border px-2 transition-colors",
|
|
4769
4770
|
cn ? "border-nvr-cyan bg-nvr-cyan/10 text-nvr-cyan" : "border-slate-200 text-slate-600 hover:border-slate-400 hover:text-slate-800 dark:border-border dark:text-slate-300"
|
|
4770
4771
|
),
|
|
4771
4772
|
children: [
|
|
4772
|
-
/* @__PURE__ */ l(
|
|
4773
|
+
/* @__PURE__ */ l(ja, { className: "h-3 w-3", "aria-hidden": "true" }),
|
|
4773
4774
|
cn ? "Selecting" : "Select rows"
|
|
4774
4775
|
]
|
|
4775
4776
|
}
|
|
@@ -4778,11 +4779,11 @@ function zc({
|
|
|
4778
4779
|
"button",
|
|
4779
4780
|
{
|
|
4780
4781
|
type: "button",
|
|
4781
|
-
onClick:
|
|
4782
|
+
onClick: Ia,
|
|
4782
4783
|
"data-tip": "Set the same values on every selected line",
|
|
4783
4784
|
className: "inline-flex h-6 items-center gap-1 rounded border border-amber-400 bg-amber-50 px-2 font-medium text-amber-700 transition-colors hover:border-amber-500 dark:border-amber-600 dark:bg-amber-950/30 dark:text-amber-300",
|
|
4784
4785
|
children: [
|
|
4785
|
-
/* @__PURE__ */ l(
|
|
4786
|
+
/* @__PURE__ */ l(La, { className: "h-3 w-3", "aria-hidden": "true" }),
|
|
4786
4787
|
"Edit ",
|
|
4787
4788
|
Pt.size,
|
|
4788
4789
|
" selected…"
|
|
@@ -4801,7 +4802,7 @@ function zc({
|
|
|
4801
4802
|
"inline-flex h-6 w-6 items-center justify-center rounded border transition-colors",
|
|
4802
4803
|
$e ? "border-nvr-cyan bg-nvr-cyan/10 text-nvr-cyan" : "border-slate-200 text-slate-500 hover:border-slate-400 hover:text-slate-800 dark:border-border dark:text-slate-300"
|
|
4803
4804
|
),
|
|
4804
|
-
children: $e ? /* @__PURE__ */ l(
|
|
4805
|
+
children: $e ? /* @__PURE__ */ l(Ta, { className: "h-3 w-3", "aria-hidden": "true" }) : /* @__PURE__ */ l(Ra, { className: "h-3 w-3", "aria-hidden": "true" })
|
|
4805
4806
|
}
|
|
4806
4807
|
),
|
|
4807
4808
|
ln && /* @__PURE__ */ l(Rn, { className: "h-3 w-3 animate-spin text-slate-400" }),
|
|
@@ -4814,7 +4815,7 @@ function zc({
|
|
|
4814
4815
|
"data-grid-save-mode": "live",
|
|
4815
4816
|
"data-tip": "Every change to a line here is saved the moment you make it — no Save needed",
|
|
4816
4817
|
children: [
|
|
4817
|
-
/* @__PURE__ */ l(
|
|
4818
|
+
/* @__PURE__ */ l(Ma, { className: "h-3 w-3", "aria-hidden": "true" }),
|
|
4818
4819
|
"Saves as you go"
|
|
4819
4820
|
]
|
|
4820
4821
|
}
|
|
@@ -4865,7 +4866,7 @@ function zc({
|
|
|
4865
4866
|
value: an[e.field] ?? null,
|
|
4866
4867
|
onChange: (n) => Ws((t) => ({ ...t, [e.field]: n })),
|
|
4867
4868
|
relations: Me,
|
|
4868
|
-
collection:
|
|
4869
|
+
collection: s,
|
|
4869
4870
|
itemId: "new"
|
|
4870
4871
|
}
|
|
4871
4872
|
)
|
|
@@ -4875,7 +4876,7 @@ function zc({
|
|
|
4875
4876
|
{
|
|
4876
4877
|
type: "button",
|
|
4877
4878
|
disabled: Us || !(O.length + P.length),
|
|
4878
|
-
onClick:
|
|
4879
|
+
onClick: _a,
|
|
4879
4880
|
className: "h-9 rounded px-3 bg-amber-500 text-white text-[11px] font-medium hover:brightness-110 disabled:opacity-50 whitespace-nowrap",
|
|
4880
4881
|
children: Us ? "Applying…" : `Apply to all ${O.length + P.length} rows`
|
|
4881
4882
|
}
|
|
@@ -4927,7 +4928,7 @@ function zc({
|
|
|
4927
4928
|
name: `rerun-mode-${u}`,
|
|
4928
4929
|
checked: Vi === e,
|
|
4929
4930
|
onChange: () => {
|
|
4930
|
-
|
|
4931
|
+
va(e), On(null);
|
|
4931
4932
|
},
|
|
4932
4933
|
className: "accent-nvr-cyan"
|
|
4933
4934
|
}
|
|
@@ -4977,7 +4978,7 @@ function zc({
|
|
|
4977
4978
|
var a, c, d, m, g, p, h, v;
|
|
4978
4979
|
const e = Wt.unmatchedCandidates.length, n = ((a = le.unmatched_banner) == null ? void 0 : a.label) ?? "related line", t = e === 1 ? n : `${n}s`, r = ((c = le.candidates) == null ? void 0 : c.primary) ?? ((g = (m = (d = le.candidates) == null ? void 0 : d.keys) == null ? void 0 : m[0]) == null ? void 0 : g.row), i = (v = (h = (p = le.candidates) == null ? void 0 : p.keys) == null ? void 0 : h.find(
|
|
4979
4980
|
(N) => N.row === r
|
|
4980
|
-
)) == null ? void 0 : v.candidate,
|
|
4981
|
+
)) == null ? void 0 : v.candidate, o = i ? Wt.unmatchedCandidates.map((N) => String(N[i] ?? "")).filter(Boolean).slice(0, 8) : [];
|
|
4981
4982
|
return /* @__PURE__ */ k("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg border border-amber-200 bg-amber-50/60 px-3 py-2 text-[11px] text-amber-800 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-200", children: [
|
|
4982
4983
|
/* @__PURE__ */ l(hr, { className: "h-3.5 w-3.5 shrink-0", "aria-hidden": "true" }),
|
|
4983
4984
|
/* @__PURE__ */ k("span", { children: [
|
|
@@ -4989,13 +4990,13 @@ function zc({
|
|
|
4989
4990
|
e === 1 ? "has" : "have",
|
|
4990
4991
|
" no matching row here"
|
|
4991
4992
|
] }),
|
|
4992
|
-
|
|
4993
|
+
o.length > 0 && /* @__PURE__ */ k("span", { className: "text-amber-700/80 dark:text-amber-300/80", children: [
|
|
4993
4994
|
" ",
|
|
4994
4995
|
"· line",
|
|
4995
|
-
|
|
4996
|
+
o.length === 1 ? "" : "s",
|
|
4996
4997
|
" ",
|
|
4997
|
-
|
|
4998
|
-
e >
|
|
4998
|
+
o.join(", "),
|
|
4999
|
+
e > o.length ? ` +${e - o.length}` : ""
|
|
4999
5000
|
] })
|
|
5000
5001
|
] }),
|
|
5001
5002
|
/* @__PURE__ */ l(
|
|
@@ -5003,7 +5004,7 @@ function zc({
|
|
|
5003
5004
|
{
|
|
5004
5005
|
type: "button",
|
|
5005
5006
|
disabled: ln,
|
|
5006
|
-
onClick: () => void
|
|
5007
|
+
onClick: () => void Na(),
|
|
5007
5008
|
className: "ml-auto h-6 rounded border border-amber-300 bg-white px-2.5 text-[11px] font-medium text-amber-800 hover:border-amber-400 disabled:opacity-50 dark:border-amber-500/50 dark:bg-transparent dark:text-amber-200",
|
|
5008
5009
|
"data-tip": q || W ? "Stages one row per missing line — saved with the record" : "Adds one row per missing line now",
|
|
5009
5010
|
children: ln ? "Adding…" : `Add ${e === 1 ? "it" : `all ${e}`} as ${e === 1 ? "a row" : "rows"}`
|
|
@@ -5015,8 +5016,8 @@ function zc({
|
|
|
5015
5016
|
const e = bt, n = (e == null ? void 0 : e.total) ?? 0, t = [];
|
|
5016
5017
|
e != null && e.added.size && t.push(`${e.added.size} added`), e != null && e.changed.size && t.push(`${e.changed.size} changed`), e != null && e.removed.length && t.push(`${e.removed.length} removed`);
|
|
5017
5018
|
const r = ((e == null ? void 0 : e.removed) ?? []).slice(0, 5).map((i) => {
|
|
5018
|
-
var
|
|
5019
|
-
return Xr(((
|
|
5019
|
+
var o;
|
|
5020
|
+
return Xr(((o = kn.current) == null ? void 0 : o.get(i)) ?? { id: i });
|
|
5020
5021
|
});
|
|
5021
5022
|
return /* @__PURE__ */ k(
|
|
5022
5023
|
"div",
|
|
@@ -5044,7 +5045,7 @@ function zc({
|
|
|
5044
5045
|
"button",
|
|
5045
5046
|
{
|
|
5046
5047
|
type: "button",
|
|
5047
|
-
onClick:
|
|
5048
|
+
onClick: ra,
|
|
5048
5049
|
className: "ml-auto h-6 rounded border border-amber-300 bg-white px-2.5 text-[11px] font-medium text-amber-800 hover:border-amber-400 dark:border-amber-500/50 dark:bg-transparent dark:text-amber-200",
|
|
5049
5050
|
"data-tip": "Take the current rows as the new baseline",
|
|
5050
5051
|
children: "Dismiss"
|
|
@@ -5069,17 +5070,17 @@ function zc({
|
|
|
5069
5070
|
/* @__PURE__ */ l("div", { className: "h-8 rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))] animate-pulse" })
|
|
5070
5071
|
] }),
|
|
5071
5072
|
!L && Xo.length > 0 && /* @__PURE__ */ l(
|
|
5072
|
-
|
|
5073
|
+
ud,
|
|
5073
5074
|
{
|
|
5074
5075
|
proposals: Xo,
|
|
5075
|
-
onApply:
|
|
5076
|
+
onApply: Vl,
|
|
5076
5077
|
onDismiss: (e) => Oi(e, !0)
|
|
5077
5078
|
}
|
|
5078
5079
|
),
|
|
5079
5080
|
($i && $i.length > 0 || Pe && !q && (j || Yo || Go)) && /* @__PURE__ */ k("div", { "data-o2m-stats": !0, className: "mb-2 flex flex-wrap items-stretch gap-1.5", children: [
|
|
5080
|
-
/* @__PURE__ */ l(
|
|
5081
|
+
/* @__PURE__ */ l(fd, { data: j, loading: Yo, error: Go }),
|
|
5081
5082
|
($i ?? []).map((e) => /* @__PURE__ */ l(
|
|
5082
|
-
|
|
5083
|
+
md,
|
|
5083
5084
|
{
|
|
5084
5085
|
label: e.label,
|
|
5085
5086
|
value: e.result,
|
|
@@ -5096,7 +5097,7 @@ function zc({
|
|
|
5096
5097
|
ref: wr,
|
|
5097
5098
|
className: _o ? "hidden" : `relative rounded-lg border border-slate-200 text-[12px]${Y ? " overflow-x-auto" : ""}`,
|
|
5098
5099
|
children: [
|
|
5099
|
-
|
|
5100
|
+
ga && /* @__PURE__ */ l("div", { className: "absolute inset-0 z-10 flex items-center justify-center rounded-lg bg-white/60 backdrop-blur-[1px] dark:bg-black/40", children: /* @__PURE__ */ k("div", { className: "flex items-center gap-2 rounded-md border border-slate-200 bg-white px-3 py-1.5 shadow-sm text-[12px] text-slate-500", children: [
|
|
5100
5101
|
/* @__PURE__ */ l(Rn, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
5101
5102
|
"Saving order…"
|
|
5102
5103
|
] }) }),
|
|
@@ -5113,7 +5114,7 @@ function zc({
|
|
|
5113
5114
|
type: "checkbox",
|
|
5114
5115
|
"aria-label": "Select all rows",
|
|
5115
5116
|
className: "accent-nvr-cyan",
|
|
5116
|
-
checked:
|
|
5117
|
+
checked: $a,
|
|
5117
5118
|
onChange: (e) => xr(e.target.checked ? new Set(Gi) : /* @__PURE__ */ new Set())
|
|
5118
5119
|
}
|
|
5119
5120
|
) }),
|
|
@@ -5145,9 +5146,9 @@ function zc({
|
|
|
5145
5146
|
{
|
|
5146
5147
|
field: e,
|
|
5147
5148
|
value: Fi[e.field] ?? null,
|
|
5148
|
-
onChange: (n) =>
|
|
5149
|
+
onChange: (n) => xa(e.field, n),
|
|
5149
5150
|
relations: Me,
|
|
5150
|
-
collection:
|
|
5151
|
+
collection: s,
|
|
5151
5152
|
itemId: "new"
|
|
5152
5153
|
}
|
|
5153
5154
|
)
|
|
@@ -5166,28 +5167,28 @@ function zc({
|
|
|
5166
5167
|
) })
|
|
5167
5168
|
] }),
|
|
5168
5169
|
!q && Ie === "original" && O.slice(0, _n).map((e, n) => {
|
|
5169
|
-
const t = String(e.id), r = zo ? Hn(e) : null, i = r !== null && (n === 0 || Hn(O[n - 1]) !== r),
|
|
5170
|
+
const t = String(e.id), r = zo ? Hn(e) : null, i = r !== null && (n === 0 || Hn(O[n - 1]) !== r), o = r !== null && Fo.has(r), a = i && r !== null ? /* @__PURE__ */ l("tr", { className: "border-b border-slate-200 bg-slate-100/80 dark:border-border dark:bg-muted", children: /* @__PURE__ */ l("td", { colSpan: Tt, className: "px-2 py-1", children: /* @__PURE__ */ k(
|
|
5170
5171
|
"button",
|
|
5171
5172
|
{
|
|
5172
5173
|
type: "button",
|
|
5173
5174
|
onClick: (y) => {
|
|
5174
|
-
y.stopPropagation(),
|
|
5175
|
+
y.stopPropagation(), Jl(r);
|
|
5175
5176
|
},
|
|
5176
5177
|
className: "flex w-full items-center gap-1.5 text-left",
|
|
5177
5178
|
children: [
|
|
5178
5179
|
/* @__PURE__ */ l(
|
|
5179
|
-
|
|
5180
|
+
hl,
|
|
5180
5181
|
{
|
|
5181
5182
|
className: xe(
|
|
5182
5183
|
"h-3 w-3 shrink-0 text-slate-400 transition-transform",
|
|
5183
|
-
!
|
|
5184
|
+
!o && "rotate-90"
|
|
5184
5185
|
)
|
|
5185
5186
|
}
|
|
5186
5187
|
),
|
|
5187
5188
|
/* @__PURE__ */ l("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: r }),
|
|
5188
5189
|
/* @__PURE__ */ l("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: O.reduce((y, w) => y + (Hn(w) === r ? 1 : 0), 0) }),
|
|
5189
5190
|
(() => {
|
|
5190
|
-
const y =
|
|
5191
|
+
const y = Ql(
|
|
5191
5192
|
O.filter(
|
|
5192
5193
|
(w) => Hn(w) === r && !Qe.has(String(w.id))
|
|
5193
5194
|
)
|
|
@@ -5208,20 +5209,20 @@ function zc({
|
|
|
5208
5209
|
]
|
|
5209
5210
|
}
|
|
5210
5211
|
) }) }) : null;
|
|
5211
|
-
if (
|
|
5212
|
-
const c = (f == null ? void 0 : f.rowId) === t, d = c && !$e, m = Nt === n, g = Jt === n && Nt !== n, p = C.has(t), h = Qe.has(t), v = p ? { ...e, ...C.get(t) } : e, N = vo && !h ?
|
|
5212
|
+
if (o) return /* @__PURE__ */ l(eo, { children: a }, t);
|
|
5213
|
+
const c = (f == null ? void 0 : f.rowId) === t, d = c && !$e, m = Nt === n, g = Jt === n && Nt !== n, p = C.has(t), h = Qe.has(t), v = p ? { ...e, ...C.get(t) } : e, N = vo && !h ? xl.get(String(v[vo] ?? "")) ?? null : null;
|
|
5213
5214
|
return /* @__PURE__ */ k(eo, { children: [
|
|
5214
5215
|
a,
|
|
5215
5216
|
/* @__PURE__ */ k(
|
|
5216
5217
|
"tr",
|
|
5217
5218
|
{
|
|
5218
|
-
"data-o2m-row": `${
|
|
5219
|
+
"data-o2m-row": `${s}:${t}`,
|
|
5219
5220
|
"data-o2m-editing": c ? "" : void 0,
|
|
5220
5221
|
tabIndex: $e ? -1 : void 0,
|
|
5221
5222
|
draggable: se && !!G && !c && !h,
|
|
5222
5223
|
onDragStart: () => Qs(n),
|
|
5223
5224
|
onDragOver: (y) => zs(y, n),
|
|
5224
|
-
onDrop:
|
|
5225
|
+
onDrop: Sa,
|
|
5225
5226
|
onDragEnd: In,
|
|
5226
5227
|
onClick: () => !c && !h && Hr(v),
|
|
5227
5228
|
onBlur: (y) => {
|
|
@@ -5280,7 +5281,7 @@ function zc({
|
|
|
5280
5281
|
/* @__PURE__ */ k("span", { className: "inline-flex items-center gap-1", children: [
|
|
5281
5282
|
n + 1,
|
|
5282
5283
|
le && /* @__PURE__ */ l(
|
|
5283
|
-
|
|
5284
|
+
dl,
|
|
5284
5285
|
{
|
|
5285
5286
|
result: Wt.byRow.get(t),
|
|
5286
5287
|
title: le.title
|
|
@@ -5318,7 +5319,7 @@ function zc({
|
|
|
5318
5319
|
W && /* @__PURE__ */ k("td", { className: "relative px-3 py-1 align-middle w-20", children: [
|
|
5319
5320
|
lr === "status" && ar(t),
|
|
5320
5321
|
!R && le && /* @__PURE__ */ l(
|
|
5321
|
-
|
|
5322
|
+
dl,
|
|
5322
5323
|
{
|
|
5323
5324
|
result: Wt.byRow.get(t),
|
|
5324
5325
|
title: le.title
|
|
@@ -5378,7 +5379,7 @@ function zc({
|
|
|
5378
5379
|
const I = w.computed_type === "write" && !!w.computed_formula, T = I ? Ft(
|
|
5379
5380
|
w.computed_formula,
|
|
5380
5381
|
c ? (f == null ? void 0 : f.draft) ?? v : v
|
|
5381
|
-
) ?? v[w.field] : null, E = B && !c && !h ? (ie = bi[t]) == null ? void 0 : ie[w.field] : void 0, X = E ? `${w.label || ve(w.field)} · changed ${
|
|
5382
|
+
) ?? v[w.field] : null, E = B && !c && !h ? (ie = bi[t]) == null ? void 0 : ie[w.field] : void 0, X = E ? `${w.label || ve(w.field)} · changed ${rl(E.at)} by ${E.who}${E.reason ? `
|
|
5382
5383
|
Reason: “${E.reason}”` : ""}` : void 0;
|
|
5383
5384
|
return /* @__PURE__ */ k(
|
|
5384
5385
|
"td",
|
|
@@ -5439,7 +5440,7 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
5439
5440
|
value: (f == null ? void 0 : f.draft[w.field]) ?? null,
|
|
5440
5441
|
onChange: (ne) => yt(w.field, ne),
|
|
5441
5442
|
relations: Me,
|
|
5442
|
-
collection:
|
|
5443
|
+
collection: s,
|
|
5443
5444
|
itemId: t,
|
|
5444
5445
|
cascadeFilter: Ve[w.field],
|
|
5445
5446
|
narrowedBy: Lr[w.field],
|
|
@@ -5518,7 +5519,7 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
5518
5519
|
type: "button",
|
|
5519
5520
|
title: "Undo delete",
|
|
5520
5521
|
onClick: (y) => {
|
|
5521
|
-
y.stopPropagation(), x == null || x.cancelPendingDelete(
|
|
5522
|
+
y.stopPropagation(), x == null || x.cancelPendingDelete(s, u, t);
|
|
5522
5523
|
},
|
|
5523
5524
|
className: "rounded px-1.5 py-0.5 text-[10px] text-red-500 hover:text-red-700 border border-red-200 hover:border-red-400",
|
|
5524
5525
|
children: "Undo"
|
|
@@ -5530,7 +5531,7 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
5530
5531
|
type: "button",
|
|
5531
5532
|
title: "Undo edit",
|
|
5532
5533
|
onClick: (y) => {
|
|
5533
|
-
y.stopPropagation(), x == null || x.cancelPendingEdit(
|
|
5534
|
+
y.stopPropagation(), x == null || x.cancelPendingEdit(s, u, t), Rr((w) => {
|
|
5534
5535
|
const _ = {};
|
|
5535
5536
|
for (const [I, T] of Object.entries(w))
|
|
5536
5537
|
I.startsWith(`${t}|`) || (_[I] = T);
|
|
@@ -5542,11 +5543,11 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
5542
5543
|
}
|
|
5543
5544
|
),
|
|
5544
5545
|
ee && t != null && /* @__PURE__ */ l(
|
|
5545
|
-
|
|
5546
|
+
Md,
|
|
5546
5547
|
{
|
|
5547
|
-
collection:
|
|
5548
|
+
collection: s,
|
|
5548
5549
|
rowId: String(t),
|
|
5549
|
-
count:
|
|
5550
|
+
count: Zl[String(t)] ?? 0
|
|
5550
5551
|
}
|
|
5551
5552
|
),
|
|
5552
5553
|
B && /* @__PURE__ */ l(
|
|
@@ -5562,15 +5563,15 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
5562
5563
|
}
|
|
5563
5564
|
),
|
|
5564
5565
|
t != null && !String(t).startsWith("pending") && /* @__PURE__ */ l(
|
|
5565
|
-
|
|
5566
|
+
Ud,
|
|
5566
5567
|
{
|
|
5567
|
-
collection:
|
|
5568
|
+
collection: s,
|
|
5568
5569
|
rowId: String(t),
|
|
5569
|
-
rowLabel:
|
|
5570
|
+
rowLabel: Gd(e)
|
|
5570
5571
|
}
|
|
5571
5572
|
),
|
|
5572
5573
|
!L && /* @__PURE__ */ l(
|
|
5573
|
-
|
|
5574
|
+
ul,
|
|
5574
5575
|
{
|
|
5575
5576
|
saved: t != null && !String(t).startsWith("pending"),
|
|
5576
5577
|
onDelete: (y) => Hi(e, y)
|
|
@@ -5608,14 +5609,14 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
5608
5609
|
return /* @__PURE__ */ l(
|
|
5609
5610
|
so,
|
|
5610
5611
|
{
|
|
5611
|
-
parentCollection:
|
|
5612
|
+
parentCollection: s,
|
|
5612
5613
|
relationField: w,
|
|
5613
5614
|
parentRowId: t,
|
|
5614
5615
|
parentDraft: (f == null ? void 0 : f.draft) ?? v,
|
|
5615
5616
|
hint: _,
|
|
5616
5617
|
outerGridInvalidateKey: [
|
|
5617
5618
|
"o2m-rows",
|
|
5618
|
-
|
|
5619
|
+
s,
|
|
5619
5620
|
u,
|
|
5620
5621
|
b
|
|
5621
5622
|
],
|
|
@@ -5679,22 +5680,22 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
5679
5680
|
return /* @__PURE__ */ l("td", { className: "px-2 py-1 align-top", children: n ? /* @__PURE__ */ l("div", { className: "py-0.5 overflow-hidden text-slate-500 italic", children: De(
|
|
5680
5681
|
e,
|
|
5681
5682
|
Ft(e.computed_formula, f.draft) ?? null
|
|
5682
|
-
) }) : t && i ? /* @__PURE__ */ l("div", { onClick: (
|
|
5683
|
+
) }) : t && i ? /* @__PURE__ */ l("div", { onClick: (o) => o.stopPropagation(), children: /* @__PURE__ */ l(
|
|
5683
5684
|
lo,
|
|
5684
5685
|
{
|
|
5685
5686
|
collection: i.targetCollection,
|
|
5686
5687
|
value: f.draft[r] ?? null,
|
|
5687
|
-
onChange: (
|
|
5688
|
+
onChange: (o) => yt(r, o),
|
|
5688
5689
|
extraFilter: Ve[e.field]
|
|
5689
5690
|
}
|
|
5690
|
-
) }) : /* @__PURE__ */ l("div", { onClick: (
|
|
5691
|
+
) }) : /* @__PURE__ */ l("div", { onClick: (o) => o.stopPropagation(), children: /* @__PURE__ */ l(
|
|
5691
5692
|
jn,
|
|
5692
5693
|
{
|
|
5693
5694
|
field: { ...e, sort: e.sort ?? 0 },
|
|
5694
5695
|
value: f.draft[e.field] ?? null,
|
|
5695
|
-
onChange: (
|
|
5696
|
+
onChange: (o) => yt(e.field, o),
|
|
5696
5697
|
relations: Me,
|
|
5697
|
-
collection:
|
|
5698
|
+
collection: s,
|
|
5698
5699
|
itemId: "new",
|
|
5699
5700
|
cascadeFilter: Ve[e.field],
|
|
5700
5701
|
narrowedBy: Lr[e.field],
|
|
@@ -5762,7 +5763,7 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
5762
5763
|
children: "No proposed rows in this addendum"
|
|
5763
5764
|
}
|
|
5764
5765
|
) });
|
|
5765
|
-
const
|
|
5766
|
+
const o = i.map((c, d) => {
|
|
5766
5767
|
const m = he(
|
|
5767
5768
|
{ ...c },
|
|
5768
5769
|
c
|
|
@@ -5840,7 +5841,7 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
5840
5841
|
},
|
|
5841
5842
|
d
|
|
5842
5843
|
);
|
|
5843
|
-
}), ...
|
|
5844
|
+
}), ...o];
|
|
5844
5845
|
})(),
|
|
5845
5846
|
!q && Ie === "original" && O.length > _n && /* @__PURE__ */ l("tr", { ref: cs, children: /* @__PURE__ */ k("td", { colSpan: 99, className: "px-3 py-2 text-center text-[11px] text-slate-400", children: [
|
|
5846
5847
|
"Showing ",
|
|
@@ -5913,19 +5914,19 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
5913
5914
|
));
|
|
5914
5915
|
})(),
|
|
5915
5916
|
P.length > 0 && P.map((e, n) => {
|
|
5916
|
-
const t = `pending:${n}`, r = (f == null ? void 0 : f.rowId) === t, i = r && !$e,
|
|
5917
|
+
const t = `pending:${n}`, r = (f == null ? void 0 : f.rowId) === t, i = r && !$e, o = Nt === n, a = Jt === n && Nt !== n, c = !!e.__prefilled;
|
|
5917
5918
|
return /* @__PURE__ */ k(eo, { children: [
|
|
5918
5919
|
/* @__PURE__ */ k(
|
|
5919
5920
|
"tr",
|
|
5920
5921
|
{
|
|
5921
5922
|
"data-o2m-editing": r ? "" : void 0,
|
|
5922
|
-
"data-o2m-row": `${
|
|
5923
|
+
"data-o2m-row": `${s}:${t}`,
|
|
5923
5924
|
tabIndex: $e ? -1 : void 0,
|
|
5924
5925
|
draggable: se && !r,
|
|
5925
5926
|
onDragStart: () => Qs(n),
|
|
5926
5927
|
onDragOver: (d) => zs(d, n),
|
|
5927
5928
|
onDrop: (d) => {
|
|
5928
|
-
d.preventDefault(), Nt !== null && Jt !== null && Nt !== Jt && (x == null || x.reorderRows(
|
|
5929
|
+
d.preventDefault(), Nt !== null && Jt !== null && Nt !== Jt && (x == null || x.reorderRows(s, u, Nt, Jt)), In();
|
|
5929
5930
|
},
|
|
5930
5931
|
onDragEnd: In,
|
|
5931
5932
|
onClick: () => !r && Es(e, n),
|
|
@@ -5939,7 +5940,7 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
5939
5940
|
},
|
|
5940
5941
|
className: xe(
|
|
5941
5942
|
"nvr-rise-in border-b border-slate-100 transition-colors",
|
|
5942
|
-
|
|
5943
|
+
o ? "opacity-40" : "",
|
|
5943
5944
|
a ? "border-t-2 border-t-nvr-cyan" : "",
|
|
5944
5945
|
r ? $e ? "bg-[#e6f8ff] outline-none dark:bg-nvr-cyan/15 cursor-default" : "bg-[#f0fbff] dark:bg-nvr-cyan/5 cursor-default" : c ? "hover:bg-slate-50 dark:hover:bg-muted cursor-pointer" : "bg-amber-50/40 hover:bg-amber-50/70 dark:bg-amber-400/10 dark:hover:bg-amber-400/15 cursor-pointer"
|
|
5945
5946
|
),
|
|
@@ -5990,7 +5991,7 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
5990
5991
|
] }) }),
|
|
5991
5992
|
/* @__PURE__ */ k("td", { className: "px-3 py-1 align-middle w-16", children: [
|
|
5992
5993
|
!r && !c && /* @__PURE__ */ l("span", { className: "nvr-pop inline-flex text-[10px] font-medium text-amber-600 bg-amber-50 border border-amber-200 dark:text-amber-400 dark:bg-amber-500/10 dark:border-amber-500/40 rounded px-1.5 py-0.5", children: "Pending" }),
|
|
5993
|
-
!r && c && e.id != null &&
|
|
5994
|
+
!r && c && e.id != null && pa.has(e.id) && /* @__PURE__ */ l("span", { className: "inline-flex text-[10px] font-medium text-blue-600 bg-blue-50 border border-blue-200 rounded px-1.5 py-0.5", children: "Edited" })
|
|
5994
5995
|
] })
|
|
5995
5996
|
] }),
|
|
5996
5997
|
r && lt === "panel" ? Xi({
|
|
@@ -5999,7 +6000,7 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
5999
6000
|
rowId: t,
|
|
6000
6001
|
saveLabel: "Save",
|
|
6001
6002
|
onDelete: (d) => {
|
|
6002
|
-
d.stopPropagation(), x == null || x.removeRow(
|
|
6003
|
+
d.stopPropagation(), x == null || x.removeRow(s, u, n);
|
|
6003
6004
|
},
|
|
6004
6005
|
// Grandchild rows for an unsaved row stage against the
|
|
6005
6006
|
// draft, so there is no row id to pass yet.
|
|
@@ -6045,7 +6046,7 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
6045
6046
|
value: f.draft[m.field] ?? null,
|
|
6046
6047
|
onChange: (T) => yt(m.field, T),
|
|
6047
6048
|
relations: Me,
|
|
6048
|
-
collection:
|
|
6049
|
+
collection: s,
|
|
6049
6050
|
itemId: "new",
|
|
6050
6051
|
cascadeFilter: Ve[m.field],
|
|
6051
6052
|
narrowedBy: Lr[m.field],
|
|
@@ -6125,11 +6126,11 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
6125
6126
|
}
|
|
6126
6127
|
),
|
|
6127
6128
|
/* @__PURE__ */ l(
|
|
6128
|
-
|
|
6129
|
+
ul,
|
|
6129
6130
|
{
|
|
6130
6131
|
saved: !1,
|
|
6131
6132
|
onDelete: (d) => {
|
|
6132
|
-
d.stopPropagation(), x == null || x.removeRow(
|
|
6133
|
+
d.stopPropagation(), x == null || x.removeRow(s, u, n);
|
|
6133
6134
|
}
|
|
6134
6135
|
}
|
|
6135
6136
|
)
|
|
@@ -6147,7 +6148,7 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
6147
6148
|
return /* @__PURE__ */ l(
|
|
6148
6149
|
so,
|
|
6149
6150
|
{
|
|
6150
|
-
parentCollection:
|
|
6151
|
+
parentCollection: s,
|
|
6151
6152
|
relationField: m,
|
|
6152
6153
|
parentRowId: null,
|
|
6153
6154
|
stagedMembers: f.draft[`__o2m_${m}`] ?? [],
|
|
@@ -6199,14 +6200,14 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
6199
6200
|
} catch {
|
|
6200
6201
|
return {};
|
|
6201
6202
|
}
|
|
6202
|
-
})() : t.options : {}, i = r.aggregate,
|
|
6203
|
+
})() : t.options : {}, i = r.aggregate, o = pd(j, t.field), a = o != null ? /* @__PURE__ */ k(
|
|
6203
6204
|
"div",
|
|
6204
6205
|
{
|
|
6205
6206
|
"data-compare-footer": t.field,
|
|
6206
6207
|
className: "mt-0.5 flex min-w-0 flex-wrap items-baseline gap-x-1 text-[11px] font-normal leading-4 text-slate-500 dark:text-slate-400",
|
|
6207
6208
|
children: [
|
|
6208
6209
|
/* @__PURE__ */ l("span", { className: "font-mono text-[9px] uppercase tracking-wide text-slate-500 dark:text-slate-400", children: j == null ? void 0 : j.label }),
|
|
6209
|
-
/* @__PURE__ */ l("span", { className: "tabular-nums", children: no(
|
|
6210
|
+
/* @__PURE__ */ l("span", { className: "tabular-nums", children: no(o) })
|
|
6210
6211
|
]
|
|
6211
6212
|
}
|
|
6212
6213
|
) : null;
|
|
@@ -6276,7 +6277,7 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
6276
6277
|
type: "button",
|
|
6277
6278
|
"data-grid-nested-retry": "",
|
|
6278
6279
|
disabled: Lo,
|
|
6279
|
-
onClick: () => void
|
|
6280
|
+
onClick: () => void Rl(),
|
|
6280
6281
|
className: "font-semibold underline-offset-2 hover:underline disabled:opacity-50",
|
|
6281
6282
|
children: Lo ? "Retrying…" : "Retry"
|
|
6282
6283
|
}
|
|
@@ -6297,7 +6298,7 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
6297
6298
|
"button",
|
|
6298
6299
|
{
|
|
6299
6300
|
type: "button",
|
|
6300
|
-
onClick:
|
|
6301
|
+
onClick: fa,
|
|
6301
6302
|
className: "text-[11px] font-medium text-nvr-cyan hover:underline",
|
|
6302
6303
|
children: "+ Add row"
|
|
6303
6304
|
}
|
|
@@ -6307,7 +6308,7 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
6307
6308
|
),
|
|
6308
6309
|
$e && Xe && Ie === "original" && /* @__PURE__ */ l("div", { "data-grid-split-editor-lock": "", children: Hs(Xe, "docked") }),
|
|
6309
6310
|
$e && f && Ie === "original" && (() => {
|
|
6310
|
-
const e = f.rowId, n = e.startsWith("pending:"), t = n ? parseInt(e.split(":")[1], 10) : -1, r = !n && e !== "new" ? O.findIndex((d) => String(d.id) === e) : -1, i = r >= 0 ? O[r] : void 0,
|
|
6311
|
+
const e = f.rowId, n = e.startsWith("pending:"), t = n ? parseInt(e.split(":")[1], 10) : -1, r = !n && e !== "new" ? O.findIndex((d) => String(d.id) === e) : -1, i = r >= 0 ? O[r] : void 0, o = e === "new" ? O.length + P.length + 1 : n ? O.length + t + 1 : r + 1, a = R ? `Line ${o} · ` : "", c = e === "new" ? `${a}New line` : `${a}${Xr(f.draft)}`;
|
|
6311
6312
|
return /* @__PURE__ */ k(
|
|
6312
6313
|
"div",
|
|
6313
6314
|
{
|
|
@@ -6341,7 +6342,7 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
6341
6342
|
(m) => Math.max(160, Math.min(900, m + (d.key === "ArrowDown" ? 24 : -24)))
|
|
6342
6343
|
));
|
|
6343
6344
|
},
|
|
6344
|
-
children: /* @__PURE__ */ l(
|
|
6345
|
+
children: /* @__PURE__ */ l(Ka, { className: "h-3 w-3", "aria-hidden": "true" })
|
|
6345
6346
|
}
|
|
6346
6347
|
),
|
|
6347
6348
|
/* @__PURE__ */ l("div", { className: "min-h-0 flex-1 overflow-y-auto", children: Vs({
|
|
@@ -6351,7 +6352,7 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
6351
6352
|
saveLabel: e === "new" ? "Add" : "Save",
|
|
6352
6353
|
bare: !0,
|
|
6353
6354
|
onDelete: i ? (d) => Hi(i, d) : n ? (d) => {
|
|
6354
|
-
d.stopPropagation(), x == null || x.removeRow(
|
|
6355
|
+
d.stopPropagation(), x == null || x.removeRow(s, u, t);
|
|
6355
6356
|
} : void 0,
|
|
6356
6357
|
// Grandchild rows of an unsaved row stage against the draft.
|
|
6357
6358
|
drawer: Zr(i ? e : void 0, f.draft)
|
|
@@ -6361,18 +6362,18 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
6361
6362
|
);
|
|
6362
6363
|
})(),
|
|
6363
6364
|
/* @__PURE__ */ l(
|
|
6364
|
-
|
|
6365
|
+
yd,
|
|
6365
6366
|
{
|
|
6366
6367
|
open: Dn,
|
|
6367
6368
|
onOpenChange: yo,
|
|
6368
6369
|
columns: ke.filter(
|
|
6369
|
-
(e) => !fr(e) && !e.field.includes(".") && !Yn(e.interface) && !
|
|
6370
|
+
(e) => !fr(e) && !e.field.includes(".") && !Yn(e.interface) && !ol.has(e.field)
|
|
6370
6371
|
),
|
|
6371
6372
|
rows: cr.map((e) => e.row),
|
|
6372
6373
|
relations: Me,
|
|
6373
|
-
collection:
|
|
6374
|
+
collection: s,
|
|
6374
6375
|
cascadeFilters: Ve,
|
|
6375
|
-
onApply:
|
|
6376
|
+
onApply: Oa,
|
|
6376
6377
|
onEditIntent: () => {
|
|
6377
6378
|
var e;
|
|
6378
6379
|
(e = x == null ? void 0 : x.noteEditIntent) == null || e.call(x), Ao(!0);
|
|
@@ -6380,37 +6381,37 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
6380
6381
|
}
|
|
6381
6382
|
),
|
|
6382
6383
|
/* @__PURE__ */ l(
|
|
6383
|
-
|
|
6384
|
+
al,
|
|
6384
6385
|
{
|
|
6385
6386
|
mode: "timeline",
|
|
6386
6387
|
open: So,
|
|
6387
6388
|
onOpenChange: kr,
|
|
6388
6389
|
rowTitle: `${O.length} ${O.length === 1 ? "line" : "lines"} on this record`,
|
|
6389
|
-
revisions:
|
|
6390
|
-
loading:
|
|
6390
|
+
revisions: Al,
|
|
6391
|
+
loading: Il,
|
|
6391
6392
|
truncated: !!(Yt != null && Yt.truncated),
|
|
6392
6393
|
fields: ce,
|
|
6393
6394
|
displayCols: ke,
|
|
6394
6395
|
parentField: u,
|
|
6395
6396
|
m2oRelMap: He,
|
|
6396
6397
|
relations: Me,
|
|
6397
|
-
collection:
|
|
6398
|
+
collection: s,
|
|
6398
6399
|
m2oDisplays: qn,
|
|
6399
6400
|
client: $,
|
|
6400
6401
|
allowRestore: !!oe && !L,
|
|
6401
6402
|
rowLabel: (e, n) => {
|
|
6402
|
-
const t = G ? n[G] : n.line_number, r = O.findIndex((c) => String(c.id) === String(e)) + 1, i = t != null && t !== "" ? `Line ${String(t)}` : r > 0 ? `Line ${r}` : "A removed line",
|
|
6403
|
+
const t = G ? n[G] : n.line_number, r = O.findIndex((c) => String(c.id) === String(e)) + 1, i = t != null && t !== "" ? `Line ${String(t)}` : r > 0 ? `Line ${r}` : "A removed line", o = ke.find(
|
|
6403
6404
|
(c) => c.field !== "id" && !He.get(c.field) && /^(string|text)$/i.test(c.type ?? "") && typeof n[c.field] == "string" && n[c.field].trim() !== ""
|
|
6404
|
-
), a =
|
|
6405
|
+
), a = o ? String(n[o.field]) : null;
|
|
6405
6406
|
return { title: i, subtitle: a && a.length > 48 ? `${a.slice(0, 48)}…` : a };
|
|
6406
6407
|
},
|
|
6407
6408
|
onRestore: (e, n) => As(e, n),
|
|
6408
|
-
onRestoreAllTo:
|
|
6409
|
-
restoringAll:
|
|
6409
|
+
onRestoreAllTo: jl,
|
|
6410
|
+
restoringAll: ql
|
|
6410
6411
|
}
|
|
6411
6412
|
),
|
|
6412
6413
|
/* @__PURE__ */ l(
|
|
6413
|
-
|
|
6414
|
+
al,
|
|
6414
6415
|
{
|
|
6415
6416
|
open: !!Oe,
|
|
6416
6417
|
onOpenChange: (e) => {
|
|
@@ -6427,18 +6428,18 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
6427
6428
|
);
|
|
6428
6429
|
return e ? String(Oe[e.field]) : null;
|
|
6429
6430
|
})(),
|
|
6430
|
-
revisions:
|
|
6431
|
-
loading:
|
|
6431
|
+
revisions: El,
|
|
6432
|
+
loading: Ol,
|
|
6432
6433
|
fields: ce,
|
|
6433
6434
|
displayCols: ke,
|
|
6434
6435
|
parentField: u,
|
|
6435
6436
|
m2oRelMap: He,
|
|
6436
6437
|
relations: Me,
|
|
6437
|
-
collection:
|
|
6438
|
+
collection: s,
|
|
6438
6439
|
m2oDisplays: qn,
|
|
6439
6440
|
client: $,
|
|
6440
6441
|
allowRestore: !!oe && !L,
|
|
6441
|
-
focusRevisionId:
|
|
6442
|
+
focusRevisionId: $l,
|
|
6442
6443
|
onRestore: (e, n) => As(e, { ...n, itemId: n.itemId ?? String(Oe.id) })
|
|
6443
6444
|
}
|
|
6444
6445
|
)
|
|
@@ -6447,42 +6448,42 @@ Reason: “${E.reason}”` : ""}` : void 0;
|
|
|
6447
6448
|
)
|
|
6448
6449
|
);
|
|
6449
6450
|
}
|
|
6450
|
-
const
|
|
6451
|
+
const fl = {
|
|
6451
6452
|
even: "Evenly",
|
|
6452
6453
|
front: "Front-loaded",
|
|
6453
6454
|
back: "Back-loaded",
|
|
6454
6455
|
shape: "Like previous"
|
|
6455
6456
|
};
|
|
6456
|
-
function
|
|
6457
|
-
return
|
|
6457
|
+
function wl(s) {
|
|
6458
|
+
return s.presets.length < 2 ? null : /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-0.5", "data-o2m-spread-presets": !0, children: s.presets.map((u) => /* @__PURE__ */ l(
|
|
6458
6459
|
"button",
|
|
6459
6460
|
{
|
|
6460
6461
|
type: "button",
|
|
6461
6462
|
"data-o2m-spread-preset": u,
|
|
6462
|
-
"aria-pressed":
|
|
6463
|
-
onClick: () =>
|
|
6463
|
+
"aria-pressed": s.value === u,
|
|
6464
|
+
onClick: () => s.onChange(u),
|
|
6464
6465
|
className: xe(
|
|
6465
6466
|
"rounded-full border px-2 py-px text-[10.5px]",
|
|
6466
|
-
|
|
6467
|
+
s.value === u ? "border-nvr-cyan bg-nvr-cyan/10 font-semibold text-slate-800 dark:text-slate-100" : "border-slate-200 text-slate-500 hover:bg-muted dark:border-border dark:text-slate-400"
|
|
6467
6468
|
),
|
|
6468
|
-
children: u === "shape" ?
|
|
6469
|
+
children: u === "shape" ? s.shapeLabel ?? fl.shape : fl[u]
|
|
6469
6470
|
},
|
|
6470
6471
|
u
|
|
6471
6472
|
)) });
|
|
6472
6473
|
}
|
|
6473
|
-
function
|
|
6474
|
-
config:
|
|
6474
|
+
function nc({
|
|
6475
|
+
config: s,
|
|
6475
6476
|
draft: u,
|
|
6476
6477
|
remaining: b,
|
|
6477
6478
|
onApply: A,
|
|
6478
6479
|
closedFields: U,
|
|
6479
6480
|
shapeSource: B
|
|
6480
6481
|
}) {
|
|
6481
|
-
const ee =
|
|
6482
|
+
const ee = s.only_empty !== !1, oe = (fe) => fe == null || fe === "" || Number(fe) === 0, Q = s.fields.filter(
|
|
6482
6483
|
(fe) => (U == null ? void 0 : U.has(fe)) && (!ee || oe(u[fe]))
|
|
6483
|
-
).length, R =
|
|
6484
|
+
).length, R = s.fields.filter(
|
|
6484
6485
|
(fe) => !(U != null && U.has(fe)) && (!ee || oe(u[fe]))
|
|
6485
|
-
), se = K(() => (
|
|
6486
|
+
), se = K(() => (s.presets ?? ["even", "front", "back", "shape"]).filter((ze) => ze !== "shape" || !!B), [s.presets, B]), [je, D] = J("even"), re = se.includes(je) ? je : se[0] ?? "even", Ne = b == null || !Number.isFinite(b) ? 0 : Math.round(b * 100) / 100, te = (fe) => s.format === "number" ? fe.toLocaleString(void 0, { maximumFractionDigits: 2 }) : fe.toLocaleString(void 0, { style: "currency", currency: "USD" }), Se = Ne <= 0 ? Ne < 0 ? `${te(-Ne)} over — nothing to spread` : "Nothing left to spread" : R.length === 0 ? Q > 0 ? "Every open target field already holds a value" : "Every target field already holds a value" : null;
|
|
6486
6487
|
return /* @__PURE__ */ k("div", { className: "mt-2 flex flex-wrap items-center gap-2", "data-o2m-spread": !0, children: [
|
|
6487
6488
|
/* @__PURE__ */ k(
|
|
6488
6489
|
"button",
|
|
@@ -6490,7 +6491,7 @@ function tc({
|
|
|
6490
6491
|
type: "button",
|
|
6491
6492
|
onClick: () => {
|
|
6492
6493
|
if (Se) return;
|
|
6493
|
-
const fe = B ? R.map((Y) => B.values[Y] ?? 0) : void 0, ze =
|
|
6494
|
+
const fe = B ? R.map((Y) => B.values[Y] ?? 0) : void 0, ze = yl(Ne, R.length, re, fe), we = {};
|
|
6494
6495
|
R.forEach((Y, ye) => {
|
|
6495
6496
|
we[Y] = ze[ye];
|
|
6496
6497
|
}), A(we);
|
|
@@ -6499,13 +6500,13 @@ function tc({
|
|
|
6499
6500
|
title: Se ?? `${te(Ne)} across ${R.length} ${R.length === 1 ? "field" : "fields"}`,
|
|
6500
6501
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 bg-white px-2.5 text-[11.5px] font-medium text-slate-700 hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50 dark:border-border dark:bg-background dark:text-slate-200 dark:hover:bg-white/5",
|
|
6501
6502
|
children: [
|
|
6502
|
-
|
|
6503
|
+
s.label ?? "Spread remaining",
|
|
6503
6504
|
/* @__PURE__ */ l("span", { className: "tabular-nums text-slate-500 dark:text-slate-400", children: te(Ne) })
|
|
6504
6505
|
]
|
|
6505
6506
|
}
|
|
6506
6507
|
),
|
|
6507
6508
|
!Se && /* @__PURE__ */ l(
|
|
6508
|
-
|
|
6509
|
+
wl,
|
|
6509
6510
|
{
|
|
6510
6511
|
presets: se,
|
|
6511
6512
|
value: re,
|
|
@@ -6530,10 +6531,10 @@ function tc({
|
|
|
6530
6531
|
Se && /* @__PURE__ */ l("span", { className: "text-[11px] text-slate-400 dark:text-slate-500", children: Se })
|
|
6531
6532
|
] });
|
|
6532
6533
|
}
|
|
6533
|
-
function
|
|
6534
|
-
const [u, b] = J(!1), [A, U] = J("even"), B =
|
|
6534
|
+
function rc(s) {
|
|
6535
|
+
const [u, b] = J(!1), [A, U] = J("even"), B = s.remaining == null || !Number.isFinite(s.remaining) ? 0 : Math.round(s.remaining * 100) / 100, ee = (Q) => s.config.format === "number" ? Q.toLocaleString(void 0, { maximumFractionDigits: 2 }) : Q.toLocaleString(void 0, { style: "currency", currency: "USD" });
|
|
6535
6536
|
if (B <= 0) return null;
|
|
6536
|
-
const oe = (
|
|
6537
|
+
const oe = (s.config.presets ?? ["even", "front", "back"]).filter(
|
|
6537
6538
|
(Q) => Q !== "shape"
|
|
6538
6539
|
);
|
|
6539
6540
|
return /* @__PURE__ */ k("span", { className: "relative inline-flex items-center", "data-o2m-spread-rows": !0, children: [
|
|
@@ -6546,10 +6547,10 @@ function nc(o) {
|
|
|
6546
6547
|
"h-6 px-2.5 rounded border transition-colors",
|
|
6547
6548
|
u ? "border-nvr-cyan bg-nvr-cyan/10 text-nvr-cyan" : "border-slate-200 text-slate-600 hover:border-slate-400 hover:text-slate-800"
|
|
6548
6549
|
),
|
|
6549
|
-
"data-tip": `Put the remaining ${ee(B)} onto every empty open month across all ${
|
|
6550
|
+
"data-tip": `Put the remaining ${ee(B)} onto every empty open month across all ${s.rowNoun}s at once`,
|
|
6550
6551
|
children: [
|
|
6551
6552
|
"spread across ",
|
|
6552
|
-
|
|
6553
|
+
s.rowNoun,
|
|
6553
6554
|
"s…"
|
|
6554
6555
|
]
|
|
6555
6556
|
}
|
|
@@ -6565,11 +6566,11 @@ function nc(o) {
|
|
|
6565
6566
|
/* @__PURE__ */ l("b", { className: "tabular-nums", children: ee(B) }),
|
|
6566
6567
|
" over every empty open month, oldest",
|
|
6567
6568
|
" ",
|
|
6568
|
-
|
|
6569
|
+
s.rowNoun,
|
|
6569
6570
|
" first."
|
|
6570
6571
|
] }),
|
|
6571
6572
|
/* @__PURE__ */ l("div", { className: "mt-2", children: /* @__PURE__ */ l(
|
|
6572
|
-
|
|
6573
|
+
wl,
|
|
6573
6574
|
{
|
|
6574
6575
|
presets: oe,
|
|
6575
6576
|
value: oe.includes(A) ? A : oe[0],
|
|
@@ -6592,7 +6593,7 @@ function nc(o) {
|
|
|
6592
6593
|
type: "button",
|
|
6593
6594
|
"data-o2m-spread-rows-apply": !0,
|
|
6594
6595
|
onClick: () => {
|
|
6595
|
-
|
|
6596
|
+
s.onApply(oe.includes(A) ? A : oe[0]), b(!1);
|
|
6596
6597
|
},
|
|
6597
6598
|
className: "h-7 rounded-md bg-nvr-cyan px-3 text-[12px] font-semibold text-white hover:opacity-90",
|
|
6598
6599
|
children: "Stage the spread"
|
|
@@ -6604,17 +6605,17 @@ function nc(o) {
|
|
|
6604
6605
|
)
|
|
6605
6606
|
] });
|
|
6606
6607
|
}
|
|
6607
|
-
function
|
|
6608
|
+
function ml(s) {
|
|
6608
6609
|
var b, A;
|
|
6609
|
-
const u =
|
|
6610
|
+
const u = s;
|
|
6610
6611
|
return ((b = u == null ? void 0 : u.response) == null ? void 0 : b.error) ?? ((A = u == null ? void 0 : u.response) == null ? void 0 : A.message) ?? (u == null ? void 0 : u.message) ?? "the server refused it";
|
|
6611
6612
|
}
|
|
6612
6613
|
export {
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6614
|
+
ul as DeleteLineButton,
|
|
6615
|
+
Vc as InlineTableField,
|
|
6616
|
+
tc as applyValueColumns,
|
|
6617
|
+
Fd as dropUnavailableValues,
|
|
6617
6618
|
Ft as evalClientFormula,
|
|
6618
6619
|
ao as failingLints,
|
|
6619
|
-
|
|
6620
|
+
yl as spreadAmounts
|
|
6620
6621
|
};
|