@nivaro/react 0.3.105 → 0.3.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +47 -0
- package/dist/index.js +713 -708
- package/dist/shared/components/CollectionBrowserView.js +908 -892
- package/dist/shared/components/EnvironmentNotice.js +127 -0
- package/dist/shared/components/WidgetSlot.js +51 -50
- package/dist/shared/components/item-edit/GroupSection.js +116 -112
- package/dist/shared/components/panels/AddendumPanel.js +548 -547
- package/dist/shared/components/panels/CommentPanel.js +253 -256
- package/dist/shared/components/panels/OwnersSlot.js +35 -39
- package/dist/shared/components/panels/PipelinePanel.js +1048 -1051
- package/dist/shared/components/panels/ReferencedByPanel.js +16 -16
- package/dist/shared/components/panels/RelatedRecordsPanel.js +33 -32
- package/dist/shared/components/panels/TaskPanel.js +259 -262
- package/dist/shared/lib/use-starts-open.js +10 -0
- package/package.json +1 -1
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import { jsxs as i, Fragment as Ne, jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { useQueryClient as Be, useQuery as
|
|
2
|
+
import { useQueryClient as Be, useQuery as W, useQueries as Le, useMutation as pe } from "@tanstack/react-query";
|
|
3
3
|
import { FileDiff as tt, ChevronDown as rt, Paperclip as Ie, Loader2 as nt, Upload as at } from "lucide-react";
|
|
4
|
-
import { useState as
|
|
4
|
+
import { useState as O, useRef as Pe, useEffect as Je, useMemo as oe, Fragment as Se, useCallback as Ke, memo as lt } from "react";
|
|
5
5
|
import { toast as E } from "sonner";
|
|
6
6
|
import { useNivaroClient as xe, useItemEditAuth as st } from "../../context.js";
|
|
7
7
|
import { get as L, post as ve, del as it } from "../../lib/commands.js";
|
|
8
8
|
import { sanitizeHtml as ot } from "../../lib/sanitize-html.js";
|
|
9
|
+
import { useStartsOpen as dt } from "../../lib/use-starts-open.js";
|
|
9
10
|
import { titleCase as fe } from "../../lib/utils.js";
|
|
10
|
-
import { DocumentAutofillButton as
|
|
11
|
-
import { FieldRenderer as
|
|
12
|
-
import { useFileDownload as
|
|
13
|
-
import { evalClientFormula as
|
|
14
|
-
import { parseRollupParentFilter as ze, matchesRollupFilter as
|
|
15
|
-
import { useLocalLiveRows as
|
|
11
|
+
import { DocumentAutofillButton as ct } from "../import/DocumentAutofillButton.js";
|
|
12
|
+
import { FieldRenderer as mt } from "../item-edit/FieldRenderer.js";
|
|
13
|
+
import { useFileDownload as ut } from "../item-edit/file-download.js";
|
|
14
|
+
import { evalClientFormula as pt } from "../item-edit/InlineTableField.js";
|
|
15
|
+
import { parseRollupParentFilter as ze, matchesRollupFilter as ft, computeLiveRollup as We, parseRollupSources as He } from "../item-edit/live-rollups.js";
|
|
16
|
+
import { useLocalLiveRows as ht, LiveRowsContext as xt, O2MStagingContext as bt, useLiveRows as gt } from "../item-edit/O2MStagingContext.js";
|
|
16
17
|
import { Button as Q } from "../ui/button.js";
|
|
17
18
|
import { Input as je } from "../ui/input.js";
|
|
18
19
|
import { Label as he } from "../ui/label.js";
|
|
19
|
-
import { Sheet as
|
|
20
|
+
import { Sheet as vt, SheetContent as yt, SheetHeader as Nt, SheetTitle as kt } from "../ui/sheet.js";
|
|
20
21
|
import { Skeleton as re } from "../ui/skeleton.js";
|
|
21
|
-
import { Textarea as
|
|
22
|
-
import { AddendumCompare as
|
|
22
|
+
import { Textarea as _t } from "../ui/textarea.js";
|
|
23
|
+
import { AddendumCompare as wt } from "./AddendumCompare.js";
|
|
23
24
|
import { AddendumLinesDiff as Ue } from "./AddendumLinesDiff.js";
|
|
24
|
-
import { resolveAddendumAmounts as
|
|
25
|
-
const ye = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }),
|
|
25
|
+
import { resolveAddendumAmounts as Ct } from "./addendum-summary.js";
|
|
26
|
+
const ye = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }), St = (t) => t.replace(/<[^>]+>/g, " ").replace(/ /g, " ").replace(/\s+/g, " ").trim();
|
|
26
27
|
function Qe(t) {
|
|
27
28
|
const m = Number(t);
|
|
28
29
|
return !t || Number.isNaN(m) || m === 0 ? null : /* @__PURE__ */ i(
|
|
@@ -39,8 +40,8 @@ function Qe(t) {
|
|
|
39
40
|
}
|
|
40
41
|
);
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
-
const { previous: m, next:
|
|
43
|
+
function $t({ amounts: t }) {
|
|
44
|
+
const { previous: m, next: y, change: x } = t, k = x != null && x !== 0, p = [
|
|
44
45
|
{
|
|
45
46
|
label: "Previous",
|
|
46
47
|
value: m == null ? "—" : ye.format(m),
|
|
@@ -48,21 +49,21 @@ function St({ amounts: t }) {
|
|
|
48
49
|
},
|
|
49
50
|
{
|
|
50
51
|
label: "New",
|
|
51
|
-
value:
|
|
52
|
+
value: y == null ? "—" : ye.format(y),
|
|
52
53
|
className: "font-semibold text-foreground"
|
|
53
54
|
},
|
|
54
55
|
{
|
|
55
56
|
label: "Change",
|
|
56
|
-
value:
|
|
57
|
-
className:
|
|
57
|
+
value: x == null ? "—" : k ? `${x > 0 ? "+" : "−"}${ye.format(Math.abs(x))}` : "No change",
|
|
58
|
+
className: k ? x > 0 ? "font-semibold text-emerald-600 dark:text-emerald-400" : "font-semibold text-red-600 dark:text-red-400" : "text-slate-500 dark:text-slate-400"
|
|
58
59
|
}
|
|
59
60
|
];
|
|
60
|
-
return /* @__PURE__ */ r("div", { className: "flex flex-wrap items-start gap-x-8 gap-y-2", children: p.map((
|
|
61
|
-
/* @__PURE__ */ r("p", { className: D("text-[13px] leading-5 tabular-nums",
|
|
62
|
-
/* @__PURE__ */ r("p", { className: "text-[11px] leading-4 text-slate-400 dark:text-slate-500", children:
|
|
63
|
-
] },
|
|
61
|
+
return /* @__PURE__ */ r("div", { className: "flex flex-wrap items-start gap-x-8 gap-y-2", children: p.map((b) => /* @__PURE__ */ i("div", { className: "min-w-0", children: [
|
|
62
|
+
/* @__PURE__ */ r("p", { className: D("text-[13px] leading-5 tabular-nums", b.className), children: b.value }),
|
|
63
|
+
/* @__PURE__ */ r("p", { className: "text-[11px] leading-4 text-slate-400 dark:text-slate-500", children: b.label })
|
|
64
|
+
] }, b.label)) });
|
|
64
65
|
}
|
|
65
|
-
const Ve = "grid grid-cols-1 items-baseline text-[12.5px] sm:grid-cols-[140px_minmax(0,1fr)] sm:gap-x-6 sm:gap-y-2.5",
|
|
66
|
+
const Ve = "grid grid-cols-1 items-baseline text-[12.5px] sm:grid-cols-[140px_minmax(0,1fr)] sm:gap-x-6 sm:gap-y-2.5", de = "text-[12px] text-slate-500 dark:text-slate-400", ce = "mb-2.5 min-w-0 text-slate-700 sm:mb-0 dark:text-slate-200";
|
|
66
67
|
function D(...t) {
|
|
67
68
|
return t.filter(Boolean).join(" ");
|
|
68
69
|
}
|
|
@@ -87,29 +88,29 @@ const Me = {
|
|
|
87
88
|
badge: "bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-400",
|
|
88
89
|
dot: "bg-amber-500"
|
|
89
90
|
}
|
|
90
|
-
},
|
|
91
|
-
function
|
|
92
|
-
if (!
|
|
93
|
-
const
|
|
94
|
-
return
|
|
91
|
+
}, qt = (t, m) => Math.round(Number(t) * 100) === Math.round(Number(m) * 100);
|
|
92
|
+
function Ft(t, m, y) {
|
|
93
|
+
if (!y || t.computed_type !== "rollup" || !t.computed_formula) return t;
|
|
94
|
+
const x = We(He(t.computed_formula), y.rows);
|
|
95
|
+
return x === null || m != null && qt(m, x) ? t : {
|
|
95
96
|
...t,
|
|
96
97
|
options: {
|
|
97
98
|
...t.options ?? {},
|
|
98
|
-
__live_delta: { original: m, live:
|
|
99
|
+
__live_delta: { original: m, live: x }
|
|
99
100
|
}
|
|
100
101
|
};
|
|
101
102
|
}
|
|
102
|
-
function
|
|
103
|
+
function At({
|
|
103
104
|
current: t,
|
|
104
105
|
value: m,
|
|
105
|
-
onChange:
|
|
106
|
-
currentLabel:
|
|
107
|
-
newLabel:
|
|
106
|
+
onChange: y,
|
|
107
|
+
currentLabel: x,
|
|
108
|
+
newLabel: k
|
|
108
109
|
}) {
|
|
109
|
-
const [p,
|
|
110
|
-
const
|
|
111
|
-
return !Number.isFinite(
|
|
112
|
-
}),
|
|
110
|
+
const [p, b] = O(() => {
|
|
111
|
+
const v = Number(m);
|
|
112
|
+
return !Number.isFinite(v) || Math.round(v * 100) === Math.round(t * 100) ? "" : String(Math.round((v - t) * 100) / 100);
|
|
113
|
+
}), _ = p.trim() === "" ? 0 : Number(p), f = Number.isFinite(_), C = f ? Math.round((t + _) * 100) / 100 : t, u = (v) => v.toLocaleString("en-US", { style: "currency", currency: "USD" });
|
|
113
114
|
return /* @__PURE__ */ i("div", { className: "space-y-1.5", children: [
|
|
114
115
|
/* @__PURE__ */ i("div", { className: "flex items-center gap-0", children: [
|
|
115
116
|
/* @__PURE__ */ r("span", { className: "flex h-9 items-center rounded-l-md border border-r-0 border-slate-200 bg-slate-50 px-2.5 text-[13px] text-slate-500 dark:border-border dark:bg-muted", children: "$" }),
|
|
@@ -117,11 +118,11 @@ function Ft({
|
|
|
117
118
|
je,
|
|
118
119
|
{
|
|
119
120
|
value: p,
|
|
120
|
-
onChange: (
|
|
121
|
-
const S =
|
|
122
|
-
|
|
121
|
+
onChange: (v) => {
|
|
122
|
+
const S = v.target.value;
|
|
123
|
+
b(S);
|
|
123
124
|
const B = S.trim() === "" ? 0 : Number(S);
|
|
124
|
-
Number.isFinite(B) &&
|
|
125
|
+
Number.isFinite(B) && y(Math.round((t + B) * 100) / 100);
|
|
125
126
|
},
|
|
126
127
|
placeholder: "Negative numbers to decrease",
|
|
127
128
|
className: "h-9 rounded-l-none text-[13px]"
|
|
@@ -130,74 +131,74 @@ function Ft({
|
|
|
130
131
|
] }),
|
|
131
132
|
/* @__PURE__ */ i("p", { className: "text-[12px]", children: [
|
|
132
133
|
/* @__PURE__ */ i("span", { className: "font-medium text-slate-600 dark:text-slate-300", children: [
|
|
133
|
-
|
|
134
|
+
x ?? "Current REQ Amount",
|
|
134
135
|
":"
|
|
135
136
|
] }),
|
|
136
137
|
" ",
|
|
137
138
|
/* @__PURE__ */ r("span", { className: "tabular-nums text-slate-700 dark:text-slate-200", children: u(t) }),
|
|
138
139
|
/* @__PURE__ */ r("span", { className: "mx-2 text-slate-300", children: "·" }),
|
|
139
140
|
/* @__PURE__ */ i("span", { className: "font-medium text-slate-600 dark:text-slate-300", children: [
|
|
140
|
-
|
|
141
|
+
k ?? "New REQ Total",
|
|
141
142
|
":"
|
|
142
143
|
] }),
|
|
143
144
|
" ",
|
|
144
145
|
/* @__PURE__ */ r(
|
|
145
146
|
"span",
|
|
146
147
|
{
|
|
147
|
-
className: "tabular-nums font-semibold " + (
|
|
148
|
-
children: u(
|
|
148
|
+
className: "tabular-nums font-semibold " + (C > t ? "text-emerald-600 dark:text-emerald-400" : C < t ? "text-red-600 dark:text-red-400" : "text-slate-700 dark:text-slate-200"),
|
|
149
|
+
children: u(C)
|
|
149
150
|
}
|
|
150
151
|
),
|
|
151
|
-
!
|
|
152
|
+
!f && /* @__PURE__ */ r("span", { className: "ml-2 text-[11px] text-red-500", children: "Enter a number" })
|
|
152
153
|
] })
|
|
153
154
|
] });
|
|
154
155
|
}
|
|
155
|
-
const
|
|
156
|
+
const Mt = lt(function({
|
|
156
157
|
configuredFields: m,
|
|
157
|
-
fieldMap:
|
|
158
|
-
formData:
|
|
159
|
-
onFieldChange:
|
|
158
|
+
fieldMap: y,
|
|
159
|
+
formData: x,
|
|
160
|
+
onFieldChange: k,
|
|
160
161
|
relations: p,
|
|
161
|
-
collection:
|
|
162
|
-
prefillParentId:
|
|
163
|
-
parentData:
|
|
162
|
+
collection: b,
|
|
163
|
+
prefillParentId: _,
|
|
164
|
+
parentData: f
|
|
164
165
|
}) {
|
|
165
|
-
const
|
|
166
|
+
const C = gt();
|
|
166
167
|
return m.length === 0 ? /* @__PURE__ */ r("div", { className: "rounded-lg border border-dashed border-slate-200 bg-slate-50 px-4 py-6 text-center dark:border-border dark:bg-muted/30", children: /* @__PURE__ */ r("p", { className: "text-[12px] text-slate-400 dark:text-slate-500", children: "No fields configured for addendum. Set up the field list in Data Model → Layouts → Addendum Form." }) }) : /* @__PURE__ */ i("div", { className: "border-t border-slate-100 dark:border-border pt-3", children: [
|
|
167
168
|
/* @__PURE__ */ r("p", { className: "mb-3 text-[11px] font-semibold uppercase tracking-wide text-slate-400 dark:text-slate-500", children: "Proposed changes" }),
|
|
168
169
|
/* @__PURE__ */ r("div", { className: "space-y-3", children: m.map((u) => {
|
|
169
|
-
const
|
|
170
|
-
if (!
|
|
170
|
+
const v = y[u.field], S = u.label_override ?? fe((v == null ? void 0 : v.field) ?? u.field);
|
|
171
|
+
if (!v)
|
|
171
172
|
return /* @__PURE__ */ i("div", { children: [
|
|
172
173
|
/* @__PURE__ */ r(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children: S }),
|
|
173
174
|
/* @__PURE__ */ r(
|
|
174
175
|
je,
|
|
175
176
|
{
|
|
176
|
-
value: String(
|
|
177
|
-
onChange: (I) =>
|
|
177
|
+
value: String(x[u.field] ?? ""),
|
|
178
|
+
onChange: (I) => k(u.field, I.target.value),
|
|
178
179
|
className: "h-8 text-[12px]"
|
|
179
180
|
}
|
|
180
181
|
)
|
|
181
182
|
] }, u.field);
|
|
182
|
-
const
|
|
183
|
+
const N = (typeof u.overrides == "string" ? (() => {
|
|
183
184
|
try {
|
|
184
185
|
return JSON.parse(u.overrides);
|
|
185
186
|
} catch {
|
|
186
187
|
return {};
|
|
187
188
|
}
|
|
188
189
|
})() : u.overrides ?? {}).options ?? {};
|
|
189
|
-
if (
|
|
190
|
-
const I = Number((
|
|
190
|
+
if (N.entry_mode === "delta") {
|
|
191
|
+
const I = Number((f == null ? void 0 : f[u.field]) ?? 0);
|
|
191
192
|
return /* @__PURE__ */ i("div", { children: [
|
|
192
193
|
/* @__PURE__ */ r(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children: S }),
|
|
193
194
|
/* @__PURE__ */ r(
|
|
194
|
-
|
|
195
|
+
At,
|
|
195
196
|
{
|
|
196
197
|
current: Number.isFinite(I) ? I : 0,
|
|
197
|
-
value:
|
|
198
|
-
onChange: (
|
|
199
|
-
currentLabel: typeof
|
|
200
|
-
newLabel: typeof
|
|
198
|
+
value: x[u.field],
|
|
199
|
+
onChange: (j) => k(u.field, j),
|
|
200
|
+
currentLabel: typeof N.current_label == "string" ? N.current_label : void 0,
|
|
201
|
+
newLabel: typeof N.new_label == "string" ? N.new_label : void 0
|
|
201
202
|
}
|
|
202
203
|
)
|
|
203
204
|
] }, u.field);
|
|
@@ -205,31 +206,31 @@ const At = lt(function({
|
|
|
205
206
|
return /* @__PURE__ */ i("div", { children: [
|
|
206
207
|
/* @__PURE__ */ r(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children: S }),
|
|
207
208
|
/* @__PURE__ */ r(
|
|
208
|
-
|
|
209
|
+
mt,
|
|
209
210
|
{
|
|
210
|
-
field:
|
|
211
|
-
value:
|
|
212
|
-
onChange: (I) =>
|
|
211
|
+
field: Ft(v, x[u.field], C),
|
|
212
|
+
value: x[u.field],
|
|
213
|
+
onChange: (I) => k(u.field, I),
|
|
213
214
|
relations: p,
|
|
214
|
-
collection:
|
|
215
|
+
collection: b,
|
|
215
216
|
itemId: "new",
|
|
216
|
-
prefillParentId:
|
|
217
|
+
prefillParentId: _
|
|
217
218
|
}
|
|
218
219
|
)
|
|
219
220
|
] }, u.field);
|
|
220
221
|
}) })
|
|
221
222
|
] });
|
|
222
223
|
});
|
|
223
|
-
function
|
|
224
|
-
const m = xe(), { data:
|
|
224
|
+
function Pt({ addendumId: t }) {
|
|
225
|
+
const m = xe(), { data: y, isLoading: x } = W({
|
|
225
226
|
queryKey: ["pipeline-instance", "nivaro_addendums", t],
|
|
226
|
-
queryFn: () => m.request(L(`/pipelines/instance/nivaro_addendums/${t}`)).then((
|
|
227
|
+
queryFn: () => m.request(L(`/pipelines/instance/nivaro_addendums/${t}`)).then((b) => b.data),
|
|
227
228
|
staleTime: 1e4
|
|
228
229
|
});
|
|
229
|
-
if (
|
|
230
|
-
if (!(
|
|
230
|
+
if (x) return /* @__PURE__ */ r(re, { className: "h-8 w-full" });
|
|
231
|
+
if (!(y != null && y.instance))
|
|
231
232
|
return /* @__PURE__ */ r("p", { className: "text-[12px] text-slate-400 italic", children: "No workflow instance found." });
|
|
232
|
-
const { instance:
|
|
233
|
+
const { instance: k } = y, p = k.current_state_obj;
|
|
233
234
|
return /* @__PURE__ */ i("div", { className: "space-y-3", children: [
|
|
234
235
|
p && /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
|
|
235
236
|
/* @__PURE__ */ r("span", { className: "text-[11px] text-slate-500", children: "Current state:" }),
|
|
@@ -246,134 +247,134 @@ function Mt({ addendumId: t }) {
|
|
|
246
247
|
}
|
|
247
248
|
)
|
|
248
249
|
] }),
|
|
249
|
-
|
|
250
|
+
k.completed_at && /* @__PURE__ */ r("p", { className: "text-[11px] text-slate-400 italic", children: "Workflow complete." })
|
|
250
251
|
] });
|
|
251
252
|
}
|
|
252
|
-
function
|
|
253
|
+
function jt({
|
|
253
254
|
collection: t,
|
|
254
255
|
itemId: m,
|
|
255
|
-
assignments:
|
|
256
|
-
workflowTemplateId:
|
|
257
|
-
resolvedLayoutId:
|
|
256
|
+
assignments: y,
|
|
257
|
+
workflowTemplateId: x,
|
|
258
|
+
resolvedLayoutId: k,
|
|
258
259
|
fields: p,
|
|
259
|
-
relations:
|
|
260
|
-
parentData:
|
|
261
|
-
onClose:
|
|
262
|
-
onCreated:
|
|
260
|
+
relations: b,
|
|
261
|
+
parentData: _,
|
|
262
|
+
onClose: f,
|
|
263
|
+
onCreated: C
|
|
263
264
|
}) {
|
|
264
|
-
const u = xe(),
|
|
265
|
-
(
|
|
266
|
-
), [S, B] =
|
|
267
|
-
if (
|
|
268
|
-
|
|
269
|
-
for (const
|
|
265
|
+
const u = xe(), v = y.filter(
|
|
266
|
+
(l) => !String(l.field).startsWith("__") && (l.is_visible || l.is_visible === 1)
|
|
267
|
+
), [S, B] = O(""), [N, I] = O(""), [j, G] = O([]), [F, ne] = O(0), V = Pe(null), A = async (l) => {
|
|
268
|
+
if (l.length !== 0) {
|
|
269
|
+
ne((n) => n + l.length);
|
|
270
|
+
for (const n of l)
|
|
270
271
|
try {
|
|
271
|
-
const
|
|
272
|
-
|
|
272
|
+
const o = await u.upload(n);
|
|
273
|
+
G((d) => [...d, { id: String(o.id), name: n.name }]);
|
|
273
274
|
} catch {
|
|
274
|
-
E.error(`Failed to upload ${
|
|
275
|
+
E.error(`Failed to upload ${n.name}`);
|
|
275
276
|
} finally {
|
|
276
|
-
|
|
277
|
+
ne((o) => o - 1);
|
|
277
278
|
}
|
|
278
279
|
}
|
|
279
|
-
}, [K,
|
|
280
|
-
const
|
|
281
|
-
for (const
|
|
282
|
-
const
|
|
280
|
+
}, [K, R] = O(() => {
|
|
281
|
+
const l = {};
|
|
282
|
+
for (const n of v) {
|
|
283
|
+
const o = typeof n.overrides == "string" ? (() => {
|
|
283
284
|
try {
|
|
284
|
-
return JSON.parse(
|
|
285
|
+
return JSON.parse(n.overrides);
|
|
285
286
|
} catch {
|
|
286
287
|
return {};
|
|
287
288
|
}
|
|
288
|
-
})() :
|
|
289
|
-
|
|
289
|
+
})() : n.overrides ?? {}, d = (o == null ? void 0 : o.prefill_from_parent) !== !1;
|
|
290
|
+
l[n.field] = d ? _[n.field] ?? null : null;
|
|
290
291
|
}
|
|
291
|
-
return
|
|
292
|
-
}),
|
|
293
|
-
const
|
|
294
|
-
for (const
|
|
295
|
-
return
|
|
296
|
-
}, [p]),
|
|
297
|
-
|
|
298
|
-
}, []),
|
|
299
|
-
(
|
|
300
|
-
|
|
301
|
-
for (const [
|
|
302
|
-
const d =
|
|
303
|
-
(
|
|
292
|
+
return l;
|
|
293
|
+
}), z = oe(() => {
|
|
294
|
+
const l = {};
|
|
295
|
+
for (const n of p) l[n.field] = n;
|
|
296
|
+
return l;
|
|
297
|
+
}, [p]), ae = Ke((l, n) => {
|
|
298
|
+
R((o) => ({ ...o, [l]: n }));
|
|
299
|
+
}, []), le = Ke(
|
|
300
|
+
(l) => {
|
|
301
|
+
R((n) => ({ ...n, ...l.values })), !S.trim() && l.summary && B(l.summary.slice(0, 120));
|
|
302
|
+
for (const [n, o] of Object.entries(l.lines_by_alias)) {
|
|
303
|
+
const d = b.find(
|
|
304
|
+
(w) => w.one_collection === t && !w.junction_field && (w.one_field === n || w.many_collection === n)
|
|
304
305
|
);
|
|
305
306
|
if (!(d != null && d.many_collection) || !d.many_field) continue;
|
|
306
|
-
const c = d.many_field,
|
|
307
|
-
|
|
308
|
-
const
|
|
309
|
-
return
|
|
310
|
-
...
|
|
311
|
-
...
|
|
312
|
-
]),
|
|
307
|
+
const c = d.many_field, h = `${d.many_collection}.${c}`;
|
|
308
|
+
H((w) => {
|
|
309
|
+
const P = new Map(w);
|
|
310
|
+
return P.set(h, [
|
|
311
|
+
...P.get(h) ?? [],
|
|
312
|
+
...o.map((ie) => ({ ...ie.values, [c]: m }))
|
|
313
|
+
]), P;
|
|
313
314
|
});
|
|
314
315
|
}
|
|
315
|
-
|
|
316
|
+
l.file_id && G((n) => [...n, { id: l.file_id, name: l.document_name }]);
|
|
316
317
|
},
|
|
317
|
-
[t, m,
|
|
318
|
-
), [
|
|
318
|
+
[t, m, b, S]
|
|
319
|
+
), [M, H] = O(
|
|
319
320
|
/* @__PURE__ */ new Map()
|
|
320
|
-
), [
|
|
321
|
+
), [X, Y] = O(/* @__PURE__ */ new Map()), [Z, ee] = O(/* @__PURE__ */ new Map()), se = Pe(M);
|
|
321
322
|
Je(() => {
|
|
322
|
-
|
|
323
|
-
}, [
|
|
324
|
-
const
|
|
323
|
+
se.current = M;
|
|
324
|
+
}, [M]);
|
|
325
|
+
const te = ht(), me = oe(
|
|
325
326
|
() => ({
|
|
326
|
-
getPendingRows: (
|
|
327
|
-
queueRow: (
|
|
328
|
-
const c = new Map(d),
|
|
329
|
-
return c.set(
|
|
327
|
+
getPendingRows: (l, n) => M.get(`${l}.${n}`) ?? [],
|
|
328
|
+
queueRow: (l, n, o) => H((d) => {
|
|
329
|
+
const c = new Map(d), h = `${l}.${n}`;
|
|
330
|
+
return c.set(h, [...c.get(h) ?? [], o]), c;
|
|
330
331
|
}),
|
|
331
|
-
removeRow: (
|
|
332
|
-
const c = new Map(d),
|
|
333
|
-
return
|
|
332
|
+
removeRow: (l, n, o) => H((d) => {
|
|
333
|
+
const c = new Map(d), h = `${l}.${n}`, w = [...c.get(h) ?? []];
|
|
334
|
+
return w.splice(o, 1), c.set(h, w), c;
|
|
334
335
|
}),
|
|
335
|
-
updateRow: (
|
|
336
|
-
const
|
|
337
|
-
return
|
|
336
|
+
updateRow: (l, n, o, d) => H((c) => {
|
|
337
|
+
const h = new Map(c), w = `${l}.${n}`, P = [...h.get(w) ?? []];
|
|
338
|
+
return P[o] = { ...P[o], ...d }, h.set(w, P), h;
|
|
338
339
|
}),
|
|
339
|
-
reorderRows: (
|
|
340
|
-
const
|
|
341
|
-
return
|
|
340
|
+
reorderRows: (l, n, o, d) => H((c) => {
|
|
341
|
+
const h = new Map(c), w = `${l}.${n}`, P = [...h.get(w) ?? []], [ie] = P.splice(o, 1);
|
|
342
|
+
return P.splice(d, 0, ie), h.set(w, P), h;
|
|
342
343
|
}),
|
|
343
|
-
getPendingEdits: (
|
|
344
|
-
getPendingDeletes: (
|
|
345
|
-
queueEdit: (
|
|
346
|
-
const
|
|
347
|
-
return
|
|
344
|
+
getPendingEdits: (l, n) => X.get(`${l}.${n}`) ?? /* @__PURE__ */ new Map(),
|
|
345
|
+
getPendingDeletes: (l, n) => Z.get(`${l}.${n}`) ?? /* @__PURE__ */ new Set(),
|
|
346
|
+
queueEdit: (l, n, o, d) => Y((c) => {
|
|
347
|
+
const h = new Map(c), w = `${l}.${n}`, P = new Map(h.get(w) ?? []);
|
|
348
|
+
return P.set(o, { ...P.get(o) ?? {}, ...d }), h.set(w, P), h;
|
|
348
349
|
}),
|
|
349
|
-
queueDelete: (
|
|
350
|
-
const c = new Map(d),
|
|
351
|
-
return c.set(
|
|
350
|
+
queueDelete: (l, n, o) => ee((d) => {
|
|
351
|
+
const c = new Map(d), h = `${l}.${n}`;
|
|
352
|
+
return c.set(h, /* @__PURE__ */ new Set([...c.get(h) ?? [], o])), c;
|
|
352
353
|
}),
|
|
353
|
-
cancelPendingEdit: (
|
|
354
|
-
const c = new Map(d),
|
|
355
|
-
return
|
|
354
|
+
cancelPendingEdit: (l, n, o) => Y((d) => {
|
|
355
|
+
const c = new Map(d), h = `${l}.${n}`, w = new Map(c.get(h) ?? []);
|
|
356
|
+
return w.delete(o), c.set(h, w), c;
|
|
356
357
|
}),
|
|
357
|
-
cancelPendingDelete: (
|
|
358
|
-
const c = new Map(d),
|
|
359
|
-
return
|
|
358
|
+
cancelPendingDelete: (l, n, o) => ee((d) => {
|
|
359
|
+
const c = new Map(d), h = `${l}.${n}`, w = new Set(c.get(h) ?? []);
|
|
360
|
+
return w.delete(o), c.set(h, w), c;
|
|
360
361
|
})
|
|
361
362
|
}),
|
|
362
|
-
[
|
|
363
|
-
),
|
|
363
|
+
[M, X, Z]
|
|
364
|
+
), $ = pe({
|
|
364
365
|
mutationFn: () => {
|
|
365
|
-
const
|
|
366
|
-
for (const [
|
|
367
|
-
const d =
|
|
368
|
-
(d == null ? void 0 : d.computed_type) === "rollup" || (d == null ? void 0 : d.computed_type) === "write" ||
|
|
366
|
+
const l = {};
|
|
367
|
+
for (const [n, o] of Object.entries(K)) {
|
|
368
|
+
const d = z[n];
|
|
369
|
+
(d == null ? void 0 : d.computed_type) === "rollup" || (d == null ? void 0 : d.computed_type) === "write" || o !== void 0 && String(o ?? "") !== String(_[n] ?? "") && (l[n] = o);
|
|
369
370
|
}
|
|
370
|
-
for (const
|
|
371
|
-
const
|
|
372
|
-
(d) => d.one_collection === t && !d.junction_field && (d.one_field ===
|
|
371
|
+
for (const n of v) {
|
|
372
|
+
const o = b.find(
|
|
373
|
+
(d) => d.one_collection === t && !d.junction_field && (d.one_field === n.field || d.many_collection === n.field)
|
|
373
374
|
);
|
|
374
|
-
if (
|
|
375
|
-
const d = (
|
|
376
|
-
d.length > 0 && (
|
|
375
|
+
if (o != null && o.many_collection && o.many_field) {
|
|
376
|
+
const d = (se.current.get(`${o.many_collection}.${o.many_field}`) ?? []).map(({ __prefilled: c, ...h }) => h);
|
|
377
|
+
d.length > 0 && (l[n.field] = d);
|
|
377
378
|
}
|
|
378
379
|
}
|
|
379
380
|
return u.request(
|
|
@@ -381,24 +382,24 @@ function Pt({
|
|
|
381
382
|
parent_collection: t,
|
|
382
383
|
parent_id: m,
|
|
383
384
|
title: S.trim(),
|
|
384
|
-
description:
|
|
385
|
-
workflow_template_id:
|
|
386
|
-
addendum_layout_id:
|
|
387
|
-
data:
|
|
388
|
-
fields_schema:
|
|
389
|
-
attachments:
|
|
385
|
+
description: N.trim() || void 0,
|
|
386
|
+
workflow_template_id: x ?? void 0,
|
|
387
|
+
addendum_layout_id: k,
|
|
388
|
+
data: l,
|
|
389
|
+
fields_schema: v.map((n) => n.field),
|
|
390
|
+
attachments: j.length > 0 ? j.map((n) => n.id) : void 0
|
|
390
391
|
})
|
|
391
392
|
);
|
|
392
393
|
},
|
|
393
|
-
onSuccess: (
|
|
394
|
-
var
|
|
395
|
-
E.success("Addendum created"),
|
|
394
|
+
onSuccess: (l) => {
|
|
395
|
+
var n;
|
|
396
|
+
E.success("Addendum created"), C(((n = l == null ? void 0 : l.data) == null ? void 0 : n.id) != null ? String(l.data.id) : null), f();
|
|
396
397
|
},
|
|
397
398
|
onError: () => E.error("Failed to create addendum")
|
|
398
399
|
});
|
|
399
|
-
return /* @__PURE__ */ r(
|
|
400
|
-
/* @__PURE__ */ i(
|
|
401
|
-
/* @__PURE__ */ r(
|
|
400
|
+
return /* @__PURE__ */ r(xt.Provider, { value: te, children: /* @__PURE__ */ r(bt.Provider, { value: me, children: /* @__PURE__ */ i("div", { className: "flex h-full flex-col", children: [
|
|
401
|
+
/* @__PURE__ */ i(Nt, { className: "shrink-0 border-b border-slate-200 px-5 py-4 dark:border-border", children: [
|
|
402
|
+
/* @__PURE__ */ r(kt, { className: "text-[14px] font-semibold text-slate-900 dark:text-slate-100", children: "New Addendum" }),
|
|
402
403
|
/* @__PURE__ */ r("p", { className: "mt-0.5 text-[12px] text-slate-500 dark:text-slate-400", children: "Propose changes to this record. Fields are pre-filled with current values — edit what's changing." })
|
|
403
404
|
] }),
|
|
404
405
|
/* @__PURE__ */ i("div", { className: "flex-1 overflow-y-auto px-5 py-4 space-y-4", children: [
|
|
@@ -412,7 +413,7 @@ function Pt({
|
|
|
412
413
|
je,
|
|
413
414
|
{
|
|
414
415
|
value: S,
|
|
415
|
-
onChange: (
|
|
416
|
+
onChange: (l) => B(l.target.value),
|
|
416
417
|
className: "h-8 text-[12px]",
|
|
417
418
|
placeholder: "Brief description of this addendum",
|
|
418
419
|
autoFocus: !0
|
|
@@ -422,10 +423,10 @@ function Pt({
|
|
|
422
423
|
/* @__PURE__ */ i("div", { children: [
|
|
423
424
|
/* @__PURE__ */ r(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children: "Notes" }),
|
|
424
425
|
/* @__PURE__ */ r(
|
|
425
|
-
|
|
426
|
+
_t,
|
|
426
427
|
{
|
|
427
|
-
value:
|
|
428
|
-
onChange: (
|
|
428
|
+
value: N,
|
|
429
|
+
onChange: (l) => I(l.target.value),
|
|
429
430
|
rows: 2,
|
|
430
431
|
className: "text-[12px]",
|
|
431
432
|
placeholder: "Why is this change needed?"
|
|
@@ -437,59 +438,59 @@ function Pt({
|
|
|
437
438
|
/* @__PURE__ */ r(
|
|
438
439
|
"input",
|
|
439
440
|
{
|
|
440
|
-
ref:
|
|
441
|
+
ref: V,
|
|
441
442
|
type: "file",
|
|
442
443
|
multiple: !0,
|
|
443
444
|
className: "hidden",
|
|
444
|
-
onChange: (
|
|
445
|
-
|
|
445
|
+
onChange: (l) => {
|
|
446
|
+
A(Array.from(l.target.files ?? [])), l.target.value = "";
|
|
446
447
|
}
|
|
447
448
|
}
|
|
448
449
|
),
|
|
449
450
|
/* @__PURE__ */ i("div", { className: "flex flex-wrap items-center gap-1.5", children: [
|
|
450
|
-
|
|
451
|
+
j.map((l) => /* @__PURE__ */ i(
|
|
451
452
|
"span",
|
|
452
453
|
{
|
|
453
454
|
className: "inline-flex max-w-[240px] items-center gap-1 rounded border border-slate-200 bg-slate-50 px-2 py-1 text-[11px] text-slate-700 dark:border-border dark:bg-muted dark:text-slate-200",
|
|
454
455
|
children: [
|
|
455
456
|
/* @__PURE__ */ r(Ie, { className: "h-3 w-3 shrink-0 text-slate-400" }),
|
|
456
|
-
/* @__PURE__ */ r("span", { className: "truncate", children:
|
|
457
|
+
/* @__PURE__ */ r("span", { className: "truncate", children: l.name }),
|
|
457
458
|
/* @__PURE__ */ r(
|
|
458
459
|
"button",
|
|
459
460
|
{
|
|
460
461
|
type: "button",
|
|
461
|
-
onClick: () =>
|
|
462
|
+
onClick: () => G((n) => n.filter((o) => o.id !== l.id)),
|
|
462
463
|
className: "shrink-0 text-slate-400 hover:text-red-500",
|
|
463
464
|
children: "×"
|
|
464
465
|
}
|
|
465
466
|
)
|
|
466
467
|
]
|
|
467
468
|
},
|
|
468
|
-
|
|
469
|
+
l.id
|
|
469
470
|
)),
|
|
470
471
|
/* @__PURE__ */ i(
|
|
471
472
|
"button",
|
|
472
473
|
{
|
|
473
474
|
type: "button",
|
|
474
475
|
onClick: () => {
|
|
475
|
-
var
|
|
476
|
-
return (
|
|
476
|
+
var l;
|
|
477
|
+
return (l = V.current) == null ? void 0 : l.click();
|
|
477
478
|
},
|
|
478
|
-
disabled:
|
|
479
|
+
disabled: F > 0,
|
|
479
480
|
className: "inline-flex items-center gap-1.5 rounded-md border border-slate-200 px-2.5 py-1 text-[11px] font-medium text-slate-600 hover:border-slate-300 hover:text-slate-800 disabled:opacity-50 dark:border-border dark:text-slate-300 dark:hover:text-slate-100",
|
|
480
481
|
children: [
|
|
481
|
-
|
|
482
|
-
|
|
482
|
+
F > 0 ? /* @__PURE__ */ r(nt, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ r(at, { className: "h-3 w-3" }),
|
|
483
|
+
F > 0 ? "Uploading…" : "Upload"
|
|
483
484
|
]
|
|
484
485
|
}
|
|
485
486
|
),
|
|
486
487
|
/* @__PURE__ */ r(
|
|
487
|
-
|
|
488
|
+
ct,
|
|
488
489
|
{
|
|
489
490
|
collection: t,
|
|
490
|
-
layoutId:
|
|
491
|
+
layoutId: k,
|
|
491
492
|
label: "Fill from document",
|
|
492
|
-
onApply:
|
|
493
|
+
onApply: le,
|
|
493
494
|
className: "h-7 px-2.5 text-[11px]"
|
|
494
495
|
}
|
|
495
496
|
)
|
|
@@ -497,72 +498,72 @@ function Pt({
|
|
|
497
498
|
] })
|
|
498
499
|
] }),
|
|
499
500
|
/* @__PURE__ */ r(
|
|
500
|
-
|
|
501
|
+
Mt,
|
|
501
502
|
{
|
|
502
|
-
parentData:
|
|
503
|
-
configuredFields:
|
|
504
|
-
fieldMap:
|
|
503
|
+
parentData: _,
|
|
504
|
+
configuredFields: v,
|
|
505
|
+
fieldMap: z,
|
|
505
506
|
formData: K,
|
|
506
|
-
onFieldChange:
|
|
507
|
-
relations:
|
|
507
|
+
onFieldChange: ae,
|
|
508
|
+
relations: b,
|
|
508
509
|
collection: t,
|
|
509
510
|
prefillParentId: m
|
|
510
511
|
}
|
|
511
512
|
)
|
|
512
513
|
] }),
|
|
513
514
|
/* @__PURE__ */ i("div", { className: "shrink-0 flex items-center justify-end gap-2 border-t border-slate-200 px-5 py-3 dark:border-border", children: [
|
|
514
|
-
/* @__PURE__ */ r(Q, { variant: "outline", size: "sm", className: "h-8 text-[12px]", onClick:
|
|
515
|
+
/* @__PURE__ */ r(Q, { variant: "outline", size: "sm", className: "h-8 text-[12px]", onClick: f, children: "Cancel" }),
|
|
515
516
|
/* @__PURE__ */ r(
|
|
516
517
|
Q,
|
|
517
518
|
{
|
|
518
519
|
size: "sm",
|
|
519
520
|
className: "h-8 bg-nvr-cyan text-[12px] font-medium text-white hover:bg-nvr-cyan/90",
|
|
520
|
-
disabled: !S.trim() ||
|
|
521
|
-
onClick: () =>
|
|
522
|
-
children:
|
|
521
|
+
disabled: !S.trim() || $.isPending,
|
|
522
|
+
onClick: () => $.mutate(),
|
|
523
|
+
children: $.isPending ? "Creating…" : "Create Addendum"
|
|
523
524
|
}
|
|
524
525
|
)
|
|
525
526
|
] })
|
|
526
527
|
] }) }) });
|
|
527
528
|
}
|
|
528
|
-
function
|
|
529
|
-
var
|
|
530
|
-
const m = xe(),
|
|
531
|
-
queryKey: ["addendum-users", ...
|
|
529
|
+
function Rt({ addendum: t }) {
|
|
530
|
+
var C;
|
|
531
|
+
const m = xe(), y = [t.created_by, t.approved_by].filter(Boolean), { data: x = {} } = W({
|
|
532
|
+
queryKey: ["addendum-users", ...y.sort()],
|
|
532
533
|
queryFn: async () => {
|
|
533
534
|
const u = await m.request(
|
|
534
535
|
L("/items/nivaro_users", {
|
|
535
|
-
filter: JSON.stringify({ id: { _in:
|
|
536
|
+
filter: JSON.stringify({ id: { _in: y } }),
|
|
536
537
|
fields: "id,first_name,last_name"
|
|
537
538
|
})
|
|
538
|
-
).then((
|
|
539
|
+
).then((v) => v.data ?? []);
|
|
539
540
|
return Object.fromEntries(
|
|
540
|
-
u.map((
|
|
541
|
-
String(
|
|
542
|
-
[
|
|
541
|
+
u.map((v) => [
|
|
542
|
+
String(v.id).toUpperCase(),
|
|
543
|
+
[v.first_name, v.last_name].filter(Boolean).join(" ")
|
|
543
544
|
])
|
|
544
545
|
);
|
|
545
546
|
},
|
|
546
|
-
enabled:
|
|
547
|
+
enabled: y.length > 0,
|
|
547
548
|
staleTime: 3e5
|
|
548
|
-
}),
|
|
549
|
-
return t.timeline_impact_days != null && Number(t.timeline_impact_days) !== 0 &&
|
|
549
|
+
}), k = (u) => u && x[String(u).toUpperCase()] || null, p = (u) => u ? new Date(u).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" }) : null, b = k(t.created_by), _ = k(t.approved_by), f = [];
|
|
550
|
+
return t.timeline_impact_days != null && Number(t.timeline_impact_days) !== 0 && f.push({
|
|
550
551
|
label: "Timeline impact",
|
|
551
552
|
value: `${t.timeline_impact_days > 0 ? "+" : ""}${t.timeline_impact_days} days`
|
|
552
|
-
}), t.created_at &&
|
|
553
|
+
}), t.created_at && f.push({
|
|
553
554
|
label: "Created",
|
|
554
|
-
value: [p(t.created_at),
|
|
555
|
-
}), t.status === "approved" && (t.approved_at ||
|
|
555
|
+
value: [p(t.created_at), b].filter(Boolean).join(" · ")
|
|
556
|
+
}), t.status === "approved" && (t.approved_at || _) && f.push({
|
|
556
557
|
label: "Approved",
|
|
557
|
-
value: [p(t.approved_at),
|
|
558
|
-
}),
|
|
559
|
-
|
|
560
|
-
/* @__PURE__ */ r("dt", { className:
|
|
561
|
-
/* @__PURE__ */ r("dd", { className:
|
|
558
|
+
value: [p(t.approved_at), _].filter(Boolean).join(" · ")
|
|
559
|
+
}), f.length === 0 && !t.description && !((C = t.attachments) != null && C.length) ? null : /* @__PURE__ */ i("dl", { className: D(Ve, "px-4 py-3.5"), children: [
|
|
560
|
+
f.map((u) => /* @__PURE__ */ i(Se, { children: [
|
|
561
|
+
/* @__PURE__ */ r("dt", { className: de, children: u.label }),
|
|
562
|
+
/* @__PURE__ */ r("dd", { className: ce, children: u.value })
|
|
562
563
|
] }, u.label)),
|
|
563
564
|
t.description && /* @__PURE__ */ i(Ne, { children: [
|
|
564
|
-
/* @__PURE__ */ r("dt", { className:
|
|
565
|
-
/* @__PURE__ */ r("dd", { className:
|
|
565
|
+
/* @__PURE__ */ r("dt", { className: de, children: "Justification" }),
|
|
566
|
+
/* @__PURE__ */ r("dd", { className: ce, children: /^\s*</.test(t.description) ? /* @__PURE__ */ r(
|
|
566
567
|
"div",
|
|
567
568
|
{
|
|
568
569
|
className: "nvr-addendum-reason max-w-[75ch] leading-relaxed [&_a]:text-nvr-cyan [&_a]:underline [&_li]:ml-4 [&_ol]:list-decimal [&_p]:mb-1 [&_ul]:list-disc",
|
|
@@ -570,46 +571,46 @@ function jt({ addendum: t }) {
|
|
|
570
571
|
}
|
|
571
572
|
) : /* @__PURE__ */ r("p", { className: "max-w-[75ch] whitespace-pre-wrap leading-relaxed", children: t.description }) })
|
|
572
573
|
] }),
|
|
573
|
-
/* @__PURE__ */ r(
|
|
574
|
+
/* @__PURE__ */ r(Ot, { ids: t.attachments })
|
|
574
575
|
] });
|
|
575
576
|
}
|
|
576
|
-
function
|
|
577
|
-
const m = xe(),
|
|
578
|
-
queryKey: ["addendum-files", ...
|
|
577
|
+
function Ot({ ids: t }) {
|
|
578
|
+
const m = xe(), y = ut(), x = Array.isArray(t) ? t.filter(Boolean) : [], { data: k = [] } = W({
|
|
579
|
+
queryKey: ["addendum-files", ...x],
|
|
579
580
|
queryFn: () => Promise.all(
|
|
580
|
-
|
|
581
|
-
(p) => m.request(L(`/files/${p}/meta`)).then((
|
|
582
|
-
var
|
|
581
|
+
x.map(
|
|
582
|
+
(p) => m.request(L(`/files/${p}/meta`)).then((b) => {
|
|
583
|
+
var _, f, C, u, v, S;
|
|
583
584
|
return {
|
|
584
585
|
id: p,
|
|
585
|
-
filename: ((
|
|
586
|
-
size: ((u =
|
|
587
|
-
type: ((
|
|
588
|
-
missing: !!((S =
|
|
586
|
+
filename: ((_ = b.data) == null ? void 0 : _.filename_download) ?? ((f = b.data) == null ? void 0 : f.filename) ?? ((C = b.data) == null ? void 0 : C.title) ?? null,
|
|
587
|
+
size: ((u = b.data) == null ? void 0 : u.filesize) ?? null,
|
|
588
|
+
type: ((v = b.data) == null ? void 0 : v.type) ?? null,
|
|
589
|
+
missing: !!((S = b.data) != null && S.missing_at)
|
|
589
590
|
};
|
|
590
591
|
}).catch(() => ({ id: p, filename: null, size: null, type: null, missing: !1 }))
|
|
591
592
|
)
|
|
592
593
|
),
|
|
593
|
-
enabled:
|
|
594
|
+
enabled: x.length > 0,
|
|
594
595
|
staleTime: 3e5
|
|
595
596
|
});
|
|
596
|
-
return
|
|
597
|
-
/* @__PURE__ */ r("dt", { className:
|
|
598
|
-
/* @__PURE__ */ i("dd", { className: D(
|
|
599
|
-
|
|
600
|
-
|
|
597
|
+
return x.length === 0 ? null : /* @__PURE__ */ i(Ne, { children: [
|
|
598
|
+
/* @__PURE__ */ r("dt", { className: de, children: "Attachments" }),
|
|
599
|
+
/* @__PURE__ */ i("dd", { className: D(ce, "flex flex-wrap gap-x-4 gap-y-1"), children: [
|
|
600
|
+
k.length === 0 && /* @__PURE__ */ i("span", { className: "text-slate-400 dark:text-slate-500", children: [
|
|
601
|
+
x.length,
|
|
601
602
|
" ",
|
|
602
|
-
|
|
603
|
+
x.length === 1 ? "file" : "files",
|
|
603
604
|
"…"
|
|
604
605
|
] }),
|
|
605
|
-
|
|
606
|
+
k.map((p) => (
|
|
606
607
|
// Every file click downloads (2026-11-08): no in-app preview.
|
|
607
608
|
/* @__PURE__ */ i(
|
|
608
609
|
"a",
|
|
609
610
|
{
|
|
610
611
|
href: `${m.fileUrl(p.id)}?download=1`,
|
|
611
612
|
download: p.filename || !0,
|
|
612
|
-
onClick:
|
|
613
|
+
onClick: y(`${m.fileUrl(p.id)}?download=1`, p.filename),
|
|
613
614
|
title: "Download",
|
|
614
615
|
className: "inline-flex min-w-0 items-center gap-1.5 rounded text-slate-700 underline-offset-2 transition-colors hover:text-nvr-cyan hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40 dark:text-slate-200",
|
|
615
616
|
children: [
|
|
@@ -631,141 +632,141 @@ function Rt({ ids: t }) {
|
|
|
631
632
|
] })
|
|
632
633
|
] });
|
|
633
634
|
}
|
|
634
|
-
function
|
|
635
|
+
function Dt({
|
|
635
636
|
addendum: t,
|
|
636
637
|
configuredFields: m,
|
|
637
|
-
onRefresh:
|
|
638
|
-
isActive:
|
|
639
|
-
relations:
|
|
638
|
+
onRefresh: y,
|
|
639
|
+
isActive: x,
|
|
640
|
+
relations: k = [],
|
|
640
641
|
parentCollection: p,
|
|
641
|
-
parentId:
|
|
642
|
-
fieldMap:
|
|
642
|
+
parentId: b,
|
|
643
|
+
fieldMap: _ = {}
|
|
643
644
|
}) {
|
|
644
645
|
var Re, Oe, De;
|
|
645
|
-
const
|
|
646
|
-
const
|
|
647
|
-
(
|
|
646
|
+
const f = xe(), [C, u] = O(!1), v = !!t.workflow_template_id && ["draft", "review"].includes(t.status), S = v ? ((Re = t.workflow_state) == null ? void 0 : Re.label) ?? "in approvals" : t.status, B = v ? Me.review : Me[t.status] ?? Me.draft, N = t.data ?? {}, j = Object.keys(N).filter((e) => Array.isArray(N[e])).map((e) => m.find((a) => a.field === e) ?? { field: e }).map((e) => {
|
|
647
|
+
const a = k.find(
|
|
648
|
+
(s) => s.one_collection === p && !s.junction_field && (s.one_field === e.field || s.many_collection === e.field)
|
|
648
649
|
);
|
|
649
|
-
return { field: e.field, rel:
|
|
650
|
+
return { field: e.field, rel: a };
|
|
650
651
|
}).filter((e) => {
|
|
651
|
-
var
|
|
652
|
-
return ((
|
|
653
|
-
}),
|
|
654
|
-
queries:
|
|
655
|
-
queryKey: ["o2m-rows", e.many_collection, e.many_field,
|
|
656
|
-
queryFn: () =>
|
|
652
|
+
var a, s;
|
|
653
|
+
return ((a = e.rel) == null ? void 0 : a.many_collection) && ((s = e.rel) == null ? void 0 : s.many_field);
|
|
654
|
+
}), G = Le({
|
|
655
|
+
queries: j.map(({ rel: e }) => ({
|
|
656
|
+
queryKey: ["o2m-rows", e.many_collection, e.many_field, b],
|
|
657
|
+
queryFn: () => f.request(
|
|
657
658
|
L(`/items/${e.many_collection}`, {
|
|
658
|
-
filter: JSON.stringify({ [e.many_field]: { _eq:
|
|
659
|
+
filter: JSON.stringify({ [e.many_field]: { _eq: b } }),
|
|
659
660
|
limit: 200
|
|
660
661
|
})
|
|
661
|
-
).then((
|
|
662
|
+
).then((a) => a.data ?? []),
|
|
662
663
|
staleTime: 3e4,
|
|
663
|
-
enabled: !!
|
|
664
|
+
enabled: !!b
|
|
664
665
|
}))
|
|
665
|
-
}),
|
|
666
|
+
}), F = ["approved", "reverted"].includes(t.status), { data: ne } = W({
|
|
666
667
|
queryKey: ["addendum-lines", t.id],
|
|
667
|
-
queryFn: () =>
|
|
668
|
-
enabled:
|
|
668
|
+
queryFn: () => f.request(L(`/addendums/${t.id}/lines`)).then((e) => e.data ?? {}),
|
|
669
|
+
enabled: C && F,
|
|
669
670
|
staleTime: 6e4
|
|
670
|
-
}),
|
|
671
|
-
|
|
672
|
-
|
|
671
|
+
}), V = Object.fromEntries(
|
|
672
|
+
G.map((e, a) => [
|
|
673
|
+
j[a].field,
|
|
673
674
|
e.data ?? null
|
|
674
675
|
])
|
|
675
|
-
),
|
|
676
|
-
mutationFn: () =>
|
|
676
|
+
), A = pe({
|
|
677
|
+
mutationFn: () => f.request(ve(`/addendums/${t.id}/approve`)),
|
|
677
678
|
onSuccess: () => {
|
|
678
|
-
|
|
679
|
+
y(), E.success("Addendum approved — changes applied to record");
|
|
679
680
|
},
|
|
680
681
|
onError: (e) => {
|
|
681
|
-
var
|
|
682
|
-
const
|
|
683
|
-
E.error(
|
|
682
|
+
var s, g;
|
|
683
|
+
const a = (g = (s = e == null ? void 0 : e.response) == null ? void 0 : s.data) == null ? void 0 : g.error;
|
|
684
|
+
E.error(a ?? "Failed to approve");
|
|
684
685
|
}
|
|
685
686
|
}), K = pe({
|
|
686
|
-
mutationFn: () =>
|
|
687
|
+
mutationFn: () => f.request(ve(`/addendums/${t.id}/revert`)),
|
|
687
688
|
onSuccess: () => {
|
|
688
|
-
|
|
689
|
+
H(), E.success("Addendum reverted — the record is back to its pre-approval values");
|
|
689
690
|
},
|
|
690
691
|
onError: (e) => {
|
|
691
|
-
var
|
|
692
|
-
const
|
|
693
|
-
E.error(
|
|
692
|
+
var s, g;
|
|
693
|
+
const a = (g = (s = e == null ? void 0 : e.response) == null ? void 0 : s.data) == null ? void 0 : g.error;
|
|
694
|
+
E.error(a ?? "Failed to revert", { duration: 1e4 });
|
|
694
695
|
}
|
|
695
|
-
}), [
|
|
696
|
-
|
|
697
|
-
},
|
|
698
|
-
mutationFn: () =>
|
|
696
|
+
}), [R, z] = O(!1), [ae, le] = O(!1), M = Be(), H = () => {
|
|
697
|
+
y(), M.invalidateQueries({ queryKey: ["addendums"] }), M.invalidateQueries({ queryKey: ["item-actions"] }), M.invalidateQueries({ queryKey: ["ext-item-actions"] }), M.invalidateQueries({ queryKey: ["pipeline-all-owners"] }), M.invalidateQueries({ queryKey: ["item"] }), M.invalidateQueries({ queryKey: ["o2m-rows"] }), M.invalidateQueries({ queryKey: ["pipeline-instance"] });
|
|
698
|
+
}, X = pe({
|
|
699
|
+
mutationFn: () => f.request(it(`/addendums/${t.id}`)),
|
|
699
700
|
onSuccess: () => {
|
|
700
|
-
|
|
701
|
+
H(), E.success("Addendum deleted");
|
|
701
702
|
},
|
|
702
703
|
onError: (e) => {
|
|
703
|
-
var
|
|
704
|
-
const
|
|
705
|
-
E.error(
|
|
704
|
+
var s, g;
|
|
705
|
+
const a = (g = (s = e == null ? void 0 : e.response) == null ? void 0 : s.data) == null ? void 0 : g.error;
|
|
706
|
+
E.error(a ?? "Failed to delete", { duration: 1e4 });
|
|
706
707
|
}
|
|
707
|
-
}), { isAdmin:
|
|
708
|
-
mutationFn: () =>
|
|
708
|
+
}), { isAdmin: Y } = st(), Z = pe({
|
|
709
|
+
mutationFn: () => f.request(ve(`/addendums/${t.id}/reject`)),
|
|
709
710
|
onSuccess: () => {
|
|
710
|
-
|
|
711
|
+
y(), E.success("Addendum rejected");
|
|
711
712
|
},
|
|
712
713
|
onError: () => E.error("Failed to reject")
|
|
713
|
-
}),
|
|
714
|
-
mutationFn: () =>
|
|
714
|
+
}), ee = pe({
|
|
715
|
+
mutationFn: () => f.request(ve(`/addendums/${t.id}/submit`)),
|
|
715
716
|
onSuccess: () => {
|
|
716
|
-
|
|
717
|
+
y(), E.success("Submitted for review");
|
|
717
718
|
},
|
|
718
719
|
onError: () => E.error("Failed to submit")
|
|
719
|
-
}),
|
|
720
|
-
const
|
|
721
|
-
(
|
|
720
|
+
}), se = m.filter((e) => N[e.field] !== void 0), te = (e) => e.computed_type === "rollup" ? He(e.computed_formula) : [], me = (e) => {
|
|
721
|
+
const a = k.find(
|
|
722
|
+
(s) => s.one_collection === p && s.many_collection === e.related_collection && s.many_field === e.fk_field && !s.junction_field
|
|
722
723
|
);
|
|
723
|
-
return
|
|
724
|
-
},
|
|
725
|
-
() => Object.values(
|
|
726
|
-
const
|
|
727
|
-
return
|
|
728
|
-
const
|
|
729
|
-
return !!
|
|
724
|
+
return a ? a.one_field ?? a.many_collection : null;
|
|
725
|
+
}, $ = oe(
|
|
726
|
+
() => Object.values(_).filter((e) => {
|
|
727
|
+
const a = te(e);
|
|
728
|
+
return a.length > 0 && !a.some((s) => s.recursive) && a.every((s) => {
|
|
729
|
+
const g = me(s);
|
|
730
|
+
return !!g && Array.isArray(N[g]);
|
|
730
731
|
});
|
|
731
732
|
}),
|
|
732
733
|
// biome-ignore lint/correctness/useExhaustiveDependencies: helpers close over relations/parentCollection
|
|
733
|
-
[
|
|
734
|
-
),
|
|
734
|
+
[_, N, k, p]
|
|
735
|
+
), l = oe(
|
|
735
736
|
() => [
|
|
736
737
|
...new Set(
|
|
737
|
-
|
|
738
|
+
$.flatMap((e) => te(e).map((a) => a.related_collection))
|
|
738
739
|
)
|
|
739
740
|
],
|
|
740
|
-
[
|
|
741
|
-
),
|
|
742
|
-
queries:
|
|
741
|
+
[$]
|
|
742
|
+
), n = Le({
|
|
743
|
+
queries: l.map((e) => ({
|
|
743
744
|
queryKey: ["field-config", e, null],
|
|
744
|
-
queryFn: () =>
|
|
745
|
+
queryFn: () => f.request(L(`/field-config/${e}`)).then((a) => a.data ?? []),
|
|
745
746
|
staleTime: 6e4
|
|
746
747
|
}))
|
|
747
|
-
}),
|
|
748
|
-
const
|
|
749
|
-
return
|
|
750
|
-
(
|
|
748
|
+
}), o = n.map((e) => e.dataUpdatedAt).join(","), d = se.filter((e) => {
|
|
749
|
+
const a = N[e.field];
|
|
750
|
+
return a != null && typeof a == "object" || a == null ? !1 : !k.some(
|
|
751
|
+
(s) => s.one_collection === p && (s.one_field === e.field || s.many_collection === e.field)
|
|
751
752
|
);
|
|
752
|
-
}), { data: c } =
|
|
753
|
+
}), { data: c } = W({
|
|
753
754
|
queryKey: [
|
|
754
755
|
"addendum-current",
|
|
755
756
|
p,
|
|
756
|
-
|
|
757
|
+
b,
|
|
757
758
|
d.map((e) => e.field).join(","),
|
|
758
|
-
|
|
759
|
+
$.map((e) => e.field).join(",")
|
|
759
760
|
],
|
|
760
|
-
queryFn: () =>
|
|
761
|
-
L(`/items/${p}/${
|
|
761
|
+
queryFn: () => f.request(
|
|
762
|
+
L(`/items/${p}/${b}`, {
|
|
762
763
|
fields: [
|
|
763
764
|
.../* @__PURE__ */ new Set([
|
|
764
765
|
"id",
|
|
765
766
|
...d.map((e) => e.field),
|
|
766
767
|
// The rollups themselves (current figure) plus any parent_filter
|
|
767
768
|
// columns that decide whether the rollup applies to this record.
|
|
768
|
-
|
|
769
|
+
...$.flatMap((e) => [
|
|
769
770
|
e.field,
|
|
770
771
|
...Object.keys(ze(e.computed_formula) ?? {})
|
|
771
772
|
])
|
|
@@ -773,104 +774,104 @@ function Ot({
|
|
|
773
774
|
].join(",")
|
|
774
775
|
})
|
|
775
776
|
).then((e) => e.data ?? null).catch(() => null),
|
|
776
|
-
enabled: !!p && !!
|
|
777
|
+
enabled: !!p && !!b && (d.length > 0 || $.length > 0),
|
|
777
778
|
staleTime: 15e3
|
|
778
|
-
}),
|
|
779
|
-
const e = /* @__PURE__ */ new Map(),
|
|
780
|
-
|
|
781
|
-
var
|
|
779
|
+
}), h = oe(() => {
|
|
780
|
+
const e = /* @__PURE__ */ new Map(), a = new Map(
|
|
781
|
+
l.map((s, g) => {
|
|
782
|
+
var q;
|
|
782
783
|
return [
|
|
783
|
-
|
|
784
|
-
(
|
|
784
|
+
s,
|
|
785
|
+
(q = n[g]) == null ? void 0 : q.data
|
|
785
786
|
];
|
|
786
787
|
})
|
|
787
788
|
);
|
|
788
|
-
for (const
|
|
789
|
-
const
|
|
790
|
-
if (
|
|
791
|
-
const
|
|
792
|
-
let
|
|
793
|
-
for (const U of
|
|
794
|
-
const ge =
|
|
789
|
+
for (const s of $) {
|
|
790
|
+
const g = ze(s.computed_formula);
|
|
791
|
+
if (g && c && !ft(c, g)) continue;
|
|
792
|
+
const q = /* @__PURE__ */ new Map();
|
|
793
|
+
let J = !0;
|
|
794
|
+
for (const U of te(s)) {
|
|
795
|
+
const ge = me(U), ue = a.get(U.related_collection);
|
|
795
796
|
if (!ge || !ue) {
|
|
796
|
-
|
|
797
|
+
J = !1;
|
|
797
798
|
break;
|
|
798
799
|
}
|
|
799
|
-
const Ze = ue.filter((Ce) => Ce.computed_type === "write" && !!Ce.computed_formula), et =
|
|
800
|
+
const Ze = ue.filter((Ce) => Ce.computed_type === "write" && !!Ce.computed_formula), et = N[ge].map((Ce) => {
|
|
800
801
|
const Ae = { ...Ce };
|
|
801
802
|
for (const Te of Ze) {
|
|
802
|
-
const Ee =
|
|
803
|
+
const Ee = pt(String(Te.computed_formula), Ae);
|
|
803
804
|
Ee !== null && (Ae[Te.field] = Ee);
|
|
804
805
|
}
|
|
805
806
|
return Ae;
|
|
806
807
|
});
|
|
807
|
-
|
|
808
|
+
q.set(`${U.related_collection}.${U.fk_field}`, et);
|
|
808
809
|
}
|
|
809
|
-
if (!
|
|
810
|
-
const T = We(
|
|
811
|
-
T !== null && e.set(
|
|
810
|
+
if (!J) continue;
|
|
811
|
+
const T = We(te(s), q);
|
|
812
|
+
T !== null && e.set(s.field, Math.round(T * 100) / 100);
|
|
812
813
|
}
|
|
813
814
|
return e;
|
|
814
|
-
}, [
|
|
815
|
-
const
|
|
816
|
-
return
|
|
817
|
-
(
|
|
815
|
+
}, [$, l, o, N, c]), w = (e, a) => a ? e.filter((s) => {
|
|
816
|
+
const g = a.find((q) => String(q.id) === String(s.id));
|
|
817
|
+
return g ? Object.keys(s).some(
|
|
818
|
+
(q) => q !== "id" && String(s[q] ?? "") !== String(g[q] ?? "")
|
|
818
819
|
) : !0;
|
|
819
|
-
}).length : e.length,
|
|
820
|
-
...
|
|
821
|
-
const
|
|
822
|
-
if (
|
|
823
|
-
if (Array.isArray(
|
|
824
|
-
return
|
|
825
|
-
const
|
|
826
|
-
return !((
|
|
820
|
+
}).length : e.length, ie = [
|
|
821
|
+
...se.filter((e) => {
|
|
822
|
+
const a = N[e.field];
|
|
823
|
+
if (a == null || a === "") return !1;
|
|
824
|
+
if (Array.isArray(a))
|
|
825
|
+
return w(a, V[e.field]) > 0;
|
|
826
|
+
const s = _[e.field];
|
|
827
|
+
return !((s == null ? void 0 : s.computed_type) === "rollup" || (s == null ? void 0 : s.computed_type) === "write" || c && e.field in c && String(c[e.field] ?? "") === String(a));
|
|
827
828
|
}).map((e) => ({
|
|
828
829
|
field: e.field,
|
|
829
830
|
label_override: e.label_override ?? null,
|
|
830
|
-
value:
|
|
831
|
+
value: N[e.field]
|
|
831
832
|
})),
|
|
832
|
-
|
|
833
|
-
(e) =>
|
|
833
|
+
...$.flatMap(
|
|
834
|
+
(e) => h.has(e.field) && !(c && c[e.field] != null && Number(c[e.field]) === h.get(e.field)) ? [
|
|
834
835
|
{
|
|
835
836
|
field: e.field,
|
|
836
837
|
label_override: e.label ?? null,
|
|
837
|
-
value:
|
|
838
|
+
value: h.get(e.field)
|
|
838
839
|
}
|
|
839
840
|
] : []
|
|
840
841
|
)
|
|
841
|
-
], ke =
|
|
842
|
-
var
|
|
843
|
-
const
|
|
844
|
-
return
|
|
842
|
+
], ke = ie.length, Ye = (e, a) => {
|
|
843
|
+
var g;
|
|
844
|
+
const s = (g = _[e]) == null ? void 0 : g.type;
|
|
845
|
+
return s && ["integer", "bigInteger", "decimal", "float", "number"].includes(s) ? !0 : a != null && a !== "" && !Array.isArray(a) && !Number.isNaN(Number(a));
|
|
845
846
|
}, $e = (e) => {
|
|
846
|
-
var
|
|
847
|
-
const
|
|
848
|
-
return
|
|
849
|
-
}, qe = (e,
|
|
847
|
+
var s;
|
|
848
|
+
const a = (s = _[e]) == null ? void 0 : s.options;
|
|
849
|
+
return a && typeof a == "object" && a.format === "currency" ? !0 : /amount|cost|price|total|budget|spend/i.test(e);
|
|
850
|
+
}, qe = (e, a) => $e(e) ? ye.format(Number(a)) : new Intl.NumberFormat("en-US").format(Number(a)), Ge = oe(() => {
|
|
850
851
|
if (t.cost_impact != null && Number(t.cost_impact) !== 0 || !c) return null;
|
|
851
852
|
for (const e of d) {
|
|
852
853
|
if (!$e(e.field)) continue;
|
|
853
|
-
const
|
|
854
|
-
if (!Number.isNaN(
|
|
854
|
+
const a = Number(N[e.field]), s = Number(c[e.field]);
|
|
855
|
+
if (!Number.isNaN(a) && !Number.isNaN(s) && a !== s) return a - s;
|
|
855
856
|
}
|
|
856
857
|
return null;
|
|
857
|
-
}, [t.cost_impact, c, d,
|
|
858
|
+
}, [t.cost_impact, c, d, N]), _e = oe(() => {
|
|
858
859
|
if (!c) return null;
|
|
859
860
|
const e = [
|
|
860
|
-
...d.map((
|
|
861
|
-
...
|
|
862
|
-
].flatMap(([
|
|
863
|
-
const
|
|
864
|
-
return !$e(
|
|
861
|
+
...d.map((a) => [a.field, Number(N[a.field])]),
|
|
862
|
+
...h.entries()
|
|
863
|
+
].flatMap(([a, s]) => {
|
|
864
|
+
const g = c[a];
|
|
865
|
+
return !$e(a) || g == null || g === "" ? [] : Number.isNaN(Number(g)) || Number.isNaN(s) ? [] : [{ field: a, previous: Number(g), next: s }];
|
|
865
866
|
});
|
|
866
|
-
return e.find((
|
|
867
|
-
}, [c, d,
|
|
867
|
+
return e.find((a) => a.previous !== a.next) ?? e[0] ?? null;
|
|
868
|
+
}, [c, d, N, h]), we = Ct(t, _e), Fe = we.previous != null || we.next != null || we.change != null, be = Fe ? (_e == null ? void 0 : _e.field) ?? null : null, Xe = be ? ((Oe = ie.find((e) => e.field === be)) == null ? void 0 : Oe.label_override) ?? ((De = _[be]) == null ? void 0 : De.label) ?? fe(be) : "Amount";
|
|
868
869
|
return /* @__PURE__ */ i(
|
|
869
870
|
"div",
|
|
870
871
|
{
|
|
871
872
|
className: D(
|
|
872
873
|
"overflow-hidden rounded-lg border bg-white transition-shadow hover:shadow-sm dark:bg-card",
|
|
873
|
-
|
|
874
|
+
x ? "border-amber-300 dark:border-amber-500/40" : "border-slate-200 dark:border-border"
|
|
874
875
|
),
|
|
875
876
|
children: [
|
|
876
877
|
/* @__PURE__ */ i(
|
|
@@ -902,14 +903,14 @@ function Ot({
|
|
|
902
903
|
] }),
|
|
903
904
|
Qe(t.cost_impact) ?? Qe(Ge)
|
|
904
905
|
] }),
|
|
905
|
-
t.description &&
|
|
906
|
+
t.description && !C && /* @__PURE__ */ r("p", { className: "mt-0.5 text-[12px] text-slate-500 dark:text-slate-400 line-clamp-1", children: St(t.description) })
|
|
906
907
|
] }),
|
|
907
908
|
/* @__PURE__ */ r(
|
|
908
909
|
"span",
|
|
909
910
|
{
|
|
910
911
|
className: D(
|
|
911
912
|
"shrink-0 text-[10px] text-slate-400 transition-transform",
|
|
912
|
-
|
|
913
|
+
C && "rotate-180"
|
|
913
914
|
),
|
|
914
915
|
children: "▾"
|
|
915
916
|
}
|
|
@@ -917,33 +918,33 @@ function Ot({
|
|
|
917
918
|
]
|
|
918
919
|
}
|
|
919
920
|
),
|
|
920
|
-
|
|
921
|
-
/* @__PURE__ */ r(
|
|
921
|
+
C && /* @__PURE__ */ i("div", { className: "border-t border-slate-100 dark:border-border", children: [
|
|
922
|
+
/* @__PURE__ */ r(Rt, { addendum: t }),
|
|
922
923
|
(ke > 0 || Fe) && /* @__PURE__ */ i("section", { className: "border-t border-slate-100 px-4 py-3.5 dark:border-border", children: [
|
|
923
|
-
/* @__PURE__ */ r("h4", { className: "mb-3 text-[12.5px] font-semibold text-slate-800 dark:text-slate-100", children:
|
|
924
|
+
/* @__PURE__ */ r("h4", { className: "mb-3 text-[12.5px] font-semibold text-slate-800 dark:text-slate-100", children: F ? "Changes" : "Proposed changes" }),
|
|
924
925
|
/* @__PURE__ */ i("dl", { className: Ve, children: [
|
|
925
926
|
Fe && /* @__PURE__ */ i(Ne, { children: [
|
|
926
|
-
/* @__PURE__ */ r("dt", { className:
|
|
927
|
-
/* @__PURE__ */ r("dd", { className:
|
|
927
|
+
/* @__PURE__ */ r("dt", { className: de, children: Xe }),
|
|
928
|
+
/* @__PURE__ */ r("dd", { className: ce, children: /* @__PURE__ */ r($t, { amounts: we }) })
|
|
928
929
|
] }),
|
|
929
|
-
|
|
930
|
-
var
|
|
931
|
-
const
|
|
932
|
-
if (e.field === be || Array.isArray(
|
|
933
|
-
let
|
|
934
|
-
if (
|
|
935
|
-
|
|
936
|
-
else if (Array.isArray(
|
|
937
|
-
|
|
938
|
-
else if (typeof
|
|
939
|
-
|
|
940
|
-
else if (Ye(e.field,
|
|
941
|
-
const
|
|
942
|
-
|
|
943
|
-
T != null && T !==
|
|
930
|
+
ie.map((e) => {
|
|
931
|
+
var g;
|
|
932
|
+
const a = e.value;
|
|
933
|
+
if (e.field === be || Array.isArray(a) && V[e.field]) return null;
|
|
934
|
+
let s;
|
|
935
|
+
if (a == null)
|
|
936
|
+
s = "—";
|
|
937
|
+
else if (Array.isArray(a))
|
|
938
|
+
s = `${a.length} row${a.length === 1 ? "" : "s"}`;
|
|
939
|
+
else if (typeof a == "object")
|
|
940
|
+
s = JSON.stringify(a).slice(0, 60);
|
|
941
|
+
else if (Ye(e.field, a)) {
|
|
942
|
+
const q = Number(a), J = c == null ? void 0 : c[e.field], T = J != null && J !== "" && !Number.isNaN(Number(J)) ? Number(J) : null, U = T != null ? q - T : 0;
|
|
943
|
+
s = /* @__PURE__ */ i("span", { className: "inline-flex flex-wrap items-baseline gap-x-1.5 tabular-nums", children: [
|
|
944
|
+
T != null && T !== q && /* @__PURE__ */ r("span", { className: "text-slate-400 line-through decoration-slate-300 dark:text-slate-500 dark:decoration-slate-600", children: qe(e.field, T) }),
|
|
944
945
|
/* @__PURE__ */ i("span", { className: "font-medium text-foreground", children: [
|
|
945
|
-
T != null && T !==
|
|
946
|
-
qe(e.field,
|
|
946
|
+
T != null && T !== q && /* @__PURE__ */ r("span", { className: "mr-1 font-normal text-slate-400", "aria-hidden": "true", children: "→" }),
|
|
947
|
+
qe(e.field, q)
|
|
947
948
|
] }),
|
|
948
949
|
U !== 0 && /* @__PURE__ */ i(
|
|
949
950
|
"span",
|
|
@@ -960,46 +961,46 @@ function Ot({
|
|
|
960
961
|
)
|
|
961
962
|
] });
|
|
962
963
|
} else
|
|
963
|
-
|
|
964
|
+
s = String(a);
|
|
964
965
|
return /* @__PURE__ */ i(Se, { children: [
|
|
965
|
-
/* @__PURE__ */ r("dt", { className:
|
|
966
|
-
/* @__PURE__ */ r("dd", { className: D(
|
|
966
|
+
/* @__PURE__ */ r("dt", { className: de, children: e.label_override ?? ((g = _[e.field]) == null ? void 0 : g.label) ?? fe(e.field) }),
|
|
967
|
+
/* @__PURE__ */ r("dd", { className: D(ce, "break-words"), children: s })
|
|
967
968
|
] }, e.field);
|
|
968
969
|
}),
|
|
969
|
-
|
|
970
|
-
var
|
|
970
|
+
F && Object.entries(ne ?? {}).map(([e, a]) => {
|
|
971
|
+
var s, g;
|
|
971
972
|
return /* @__PURE__ */ i(Se, { children: [
|
|
972
|
-
/* @__PURE__ */ r("dt", { className:
|
|
973
|
-
/* @__PURE__ */ r("dd", { className:
|
|
973
|
+
/* @__PURE__ */ r("dt", { className: de, children: ((s = _[e]) == null ? void 0 : s.label) ?? fe(e) }),
|
|
974
|
+
/* @__PURE__ */ r("dd", { className: ce, children: /* @__PURE__ */ r(
|
|
974
975
|
Ue,
|
|
975
976
|
{
|
|
976
|
-
client:
|
|
977
|
-
childCollection:
|
|
978
|
-
fkField:
|
|
979
|
-
proposed:
|
|
980
|
-
original:
|
|
977
|
+
client: f,
|
|
978
|
+
childCollection: a.collection,
|
|
979
|
+
fkField: a.fk,
|
|
980
|
+
proposed: a.after,
|
|
981
|
+
original: a.before,
|
|
981
982
|
ignoreMissing: !0,
|
|
982
|
-
label: ((
|
|
983
|
+
label: ((g = _[e]) == null ? void 0 : g.label) ?? fe(e)
|
|
983
984
|
}
|
|
984
985
|
) })
|
|
985
986
|
] }, `applied-${e}`);
|
|
986
987
|
}),
|
|
987
|
-
|
|
988
|
+
j.map(({ field: e, rel: a }) => {
|
|
988
989
|
var U, ge;
|
|
989
|
-
const
|
|
990
|
-
if (
|
|
990
|
+
const s = N[e], g = j.findIndex((ue) => ue.field === e), q = V[e] ?? ((U = G[g]) != null && U.isLoading ? null : []);
|
|
991
|
+
if (F || !Array.isArray(s) || !q || !(a != null && a.many_collection) || !a.many_field)
|
|
991
992
|
return null;
|
|
992
|
-
const
|
|
993
|
+
const J = m.find((ue) => ue.field === e), T = (J == null ? void 0 : J.label_override) ?? ((ge = _[e]) == null ? void 0 : ge.label) ?? fe(e);
|
|
993
994
|
return /* @__PURE__ */ i(Se, { children: [
|
|
994
|
-
/* @__PURE__ */ r("dt", { className:
|
|
995
|
-
/* @__PURE__ */ r("dd", { className:
|
|
995
|
+
/* @__PURE__ */ r("dt", { className: de, children: T }),
|
|
996
|
+
/* @__PURE__ */ r("dd", { className: ce, children: /* @__PURE__ */ r(
|
|
996
997
|
Ue,
|
|
997
998
|
{
|
|
998
|
-
client:
|
|
999
|
-
childCollection:
|
|
1000
|
-
fkField:
|
|
1001
|
-
proposed:
|
|
1002
|
-
original:
|
|
999
|
+
client: f,
|
|
1000
|
+
childCollection: a.many_collection,
|
|
1001
|
+
fkField: a.many_field,
|
|
1002
|
+
proposed: s,
|
|
1003
|
+
original: q,
|
|
1003
1004
|
label: T
|
|
1004
1005
|
}
|
|
1005
1006
|
) })
|
|
@@ -1009,8 +1010,8 @@ function Ot({
|
|
|
1009
1010
|
] }),
|
|
1010
1011
|
t.workflow_template_id && /* @__PURE__ */ i("div", { className: "border-t border-slate-100 dark:border-border px-4 py-3.5", children: [
|
|
1011
1012
|
/* @__PURE__ */ r("h4", { className: "mb-3 text-[12.5px] font-semibold text-slate-800 dark:text-slate-100", children: "Workflow" }),
|
|
1012
|
-
/* @__PURE__ */ r(
|
|
1013
|
-
|
|
1013
|
+
/* @__PURE__ */ r(Pt, { addendumId: t.id }),
|
|
1014
|
+
Y && /* @__PURE__ */ r("div", { className: "mt-2 flex items-center justify-end gap-2", children: t.status === "approved" ? t.legacy_id != null ? null : R ? /* @__PURE__ */ i("span", { className: "flex items-center gap-1.5", children: [
|
|
1014
1015
|
/* @__PURE__ */ r("span", { className: "text-[11px] text-amber-600 dark:text-amber-400", children: "Roll every applied change back?" }),
|
|
1015
1016
|
/* @__PURE__ */ r(
|
|
1016
1017
|
Q,
|
|
@@ -1019,7 +1020,7 @@ function Ot({
|
|
|
1019
1020
|
className: "h-6 bg-amber-600 px-2 text-[11px] text-white hover:bg-amber-700",
|
|
1020
1021
|
disabled: K.isPending,
|
|
1021
1022
|
onClick: () => {
|
|
1022
|
-
K.mutate(),
|
|
1023
|
+
K.mutate(), z(!1);
|
|
1023
1024
|
},
|
|
1024
1025
|
children: K.isPending ? "Reverting…" : "Revert"
|
|
1025
1026
|
}
|
|
@@ -1030,7 +1031,7 @@ function Ot({
|
|
|
1030
1031
|
size: "sm",
|
|
1031
1032
|
variant: "ghost",
|
|
1032
1033
|
className: "h-6 px-2 text-[11px]",
|
|
1033
|
-
onClick: () =>
|
|
1034
|
+
onClick: () => z(!1),
|
|
1034
1035
|
children: "Cancel"
|
|
1035
1036
|
}
|
|
1036
1037
|
)
|
|
@@ -1039,22 +1040,22 @@ function Ot({
|
|
|
1039
1040
|
{
|
|
1040
1041
|
type: "button",
|
|
1041
1042
|
"data-tip": "Admin only — restores the record to its pre-approval values through the normal revision trail; the addendum stays as a reverted record of what happened",
|
|
1042
|
-
onClick: () =>
|
|
1043
|
+
onClick: () => z(!0),
|
|
1043
1044
|
className: "text-[11px] text-slate-400 underline decoration-dotted underline-offset-2 hover:text-amber-600",
|
|
1044
1045
|
children: "Revert…"
|
|
1045
1046
|
}
|
|
1046
|
-
) :
|
|
1047
|
+
) : ae ? /* @__PURE__ */ i("span", { className: "flex items-center gap-1.5", children: [
|
|
1047
1048
|
/* @__PURE__ */ r("span", { className: "text-[11px] text-red-600 dark:text-red-400", children: "Delete this addendum and its approval workflow?" }),
|
|
1048
1049
|
/* @__PURE__ */ r(
|
|
1049
1050
|
Q,
|
|
1050
1051
|
{
|
|
1051
1052
|
size: "sm",
|
|
1052
1053
|
className: "h-6 bg-red-600 px-2 text-[11px] text-white hover:bg-red-700",
|
|
1053
|
-
disabled:
|
|
1054
|
+
disabled: X.isPending,
|
|
1054
1055
|
onClick: () => {
|
|
1055
|
-
|
|
1056
|
+
X.mutate(), le(!1);
|
|
1056
1057
|
},
|
|
1057
|
-
children:
|
|
1058
|
+
children: X.isPending ? "Deleting…" : "Delete"
|
|
1058
1059
|
}
|
|
1059
1060
|
),
|
|
1060
1061
|
/* @__PURE__ */ r(
|
|
@@ -1063,7 +1064,7 @@ function Ot({
|
|
|
1063
1064
|
size: "sm",
|
|
1064
1065
|
variant: "ghost",
|
|
1065
1066
|
className: "h-6 px-2 text-[11px]",
|
|
1066
|
-
onClick: () =>
|
|
1067
|
+
onClick: () => le(!1),
|
|
1067
1068
|
children: "Cancel"
|
|
1068
1069
|
}
|
|
1069
1070
|
)
|
|
@@ -1072,7 +1073,7 @@ function Ot({
|
|
|
1072
1073
|
{
|
|
1073
1074
|
type: "button",
|
|
1074
1075
|
"data-tip": "Admin only — removes the addendum and its approval workflow; nothing has applied to the record yet",
|
|
1075
|
-
onClick: () =>
|
|
1076
|
+
onClick: () => le(!0),
|
|
1076
1077
|
className: "text-[11px] text-slate-400 underline decoration-dotted underline-offset-2 hover:text-red-600",
|
|
1077
1078
|
children: "Delete addendum…"
|
|
1078
1079
|
}
|
|
@@ -1085,9 +1086,9 @@ function Ot({
|
|
|
1085
1086
|
size: "sm",
|
|
1086
1087
|
variant: "outline",
|
|
1087
1088
|
className: "h-7 text-[11px]",
|
|
1088
|
-
onClick: () =>
|
|
1089
|
-
disabled:
|
|
1090
|
-
children:
|
|
1089
|
+
onClick: () => ee.mutate(),
|
|
1090
|
+
disabled: ee.isPending,
|
|
1091
|
+
children: ee.isPending ? "Submitting…" : "Submit for Review"
|
|
1091
1092
|
}
|
|
1092
1093
|
),
|
|
1093
1094
|
t.status === "review" && !t.workflow_template_id && /* @__PURE__ */ i(Ne, { children: [
|
|
@@ -1097,8 +1098,8 @@ function Ot({
|
|
|
1097
1098
|
size: "sm",
|
|
1098
1099
|
variant: "outline",
|
|
1099
1100
|
className: "h-7 border-red-200 text-[11px] text-red-600 hover:bg-red-50 dark:border-red-800 dark:text-red-400 dark:hover:bg-red-900/20",
|
|
1100
|
-
onClick: () =>
|
|
1101
|
-
disabled:
|
|
1101
|
+
onClick: () => Z.mutate(),
|
|
1102
|
+
disabled: Z.isPending,
|
|
1102
1103
|
children: "Reject"
|
|
1103
1104
|
}
|
|
1104
1105
|
),
|
|
@@ -1107,15 +1108,15 @@ function Ot({
|
|
|
1107
1108
|
{
|
|
1108
1109
|
size: "sm",
|
|
1109
1110
|
className: "h-7 bg-emerald-600 text-[11px] text-white hover:bg-emerald-700",
|
|
1110
|
-
onClick: () =>
|
|
1111
|
-
disabled:
|
|
1112
|
-
children:
|
|
1111
|
+
onClick: () => A.mutate(),
|
|
1112
|
+
disabled: A.isPending,
|
|
1113
|
+
children: A.isPending ? "Approving…" : "Approve"
|
|
1113
1114
|
}
|
|
1114
1115
|
)
|
|
1115
1116
|
] }),
|
|
1116
1117
|
!t.workflow_template_id && (t.status === "approved" || t.status === "rejected") && /* @__PURE__ */ r("span", { className: "text-[11px] text-slate-400 dark:text-slate-500 italic", children: t.status === "approved" ? "Changes applied to record" : "No changes applied" }),
|
|
1117
1118
|
t.status === "reverted" && /* @__PURE__ */ r("span", { className: "text-[11px] italic text-amber-600 dark:text-amber-400", children: "Reverted — the applied changes were rolled back" }),
|
|
1118
|
-
|
|
1119
|
+
Y && t.status === "approved" && t.legacy_id == null && (R ? /* @__PURE__ */ i("span", { className: "ml-auto flex items-center gap-1.5", children: [
|
|
1119
1120
|
/* @__PURE__ */ r("span", { className: "text-[11px] text-amber-600 dark:text-amber-400", children: "Roll every applied change back?" }),
|
|
1120
1121
|
/* @__PURE__ */ r(
|
|
1121
1122
|
Q,
|
|
@@ -1124,7 +1125,7 @@ function Ot({
|
|
|
1124
1125
|
className: "h-7 bg-amber-600 text-[11px] text-white hover:bg-amber-700",
|
|
1125
1126
|
disabled: K.isPending,
|
|
1126
1127
|
onClick: () => {
|
|
1127
|
-
K.mutate(),
|
|
1128
|
+
K.mutate(), z(!1);
|
|
1128
1129
|
},
|
|
1129
1130
|
children: K.isPending ? "Reverting…" : "Revert"
|
|
1130
1131
|
}
|
|
@@ -1135,7 +1136,7 @@ function Ot({
|
|
|
1135
1136
|
size: "sm",
|
|
1136
1137
|
variant: "ghost",
|
|
1137
1138
|
className: "h-7 text-[11px]",
|
|
1138
|
-
onClick: () =>
|
|
1139
|
+
onClick: () => z(!1),
|
|
1139
1140
|
children: "Cancel"
|
|
1140
1141
|
}
|
|
1141
1142
|
)
|
|
@@ -1144,7 +1145,7 @@ function Ot({
|
|
|
1144
1145
|
{
|
|
1145
1146
|
type: "button",
|
|
1146
1147
|
"data-tip": "Admin only — restores the record to its pre-approval values through the normal revision trail; the addendum stays as a reverted record of what happened",
|
|
1147
|
-
onClick: () =>
|
|
1148
|
+
onClick: () => z(!0),
|
|
1148
1149
|
className: "ml-auto text-[11px] text-slate-400 underline decoration-dotted underline-offset-2 hover:text-amber-600",
|
|
1149
1150
|
children: "Revert…"
|
|
1150
1151
|
}
|
|
@@ -1155,88 +1156,88 @@ function Ot({
|
|
|
1155
1156
|
}
|
|
1156
1157
|
);
|
|
1157
1158
|
}
|
|
1158
|
-
function
|
|
1159
|
+
function or({
|
|
1159
1160
|
collection: t,
|
|
1160
1161
|
item: m,
|
|
1161
|
-
addendumLayoutId:
|
|
1162
|
-
canCreate:
|
|
1163
|
-
onActiveCountChange:
|
|
1162
|
+
addendumLayoutId: y,
|
|
1163
|
+
canCreate: x = !0,
|
|
1164
|
+
onActiveCountChange: k,
|
|
1164
1165
|
onApplied: p,
|
|
1165
|
-
onCreated:
|
|
1166
|
-
defaultExpanded:
|
|
1166
|
+
onCreated: b,
|
|
1167
|
+
defaultExpanded: _ = !0
|
|
1167
1168
|
}) {
|
|
1168
|
-
const
|
|
1169
|
-
data:
|
|
1170
|
-
isLoading:
|
|
1171
|
-
refetch:
|
|
1172
|
-
} =
|
|
1169
|
+
const f = xe(), C = Be(), [u, v] = O(!1), [S, B] = dt(_, !0), N = !S, I = (n) => B((o) => !(typeof n == "function" ? n(!o) : n)), [j, G] = O(!1), {
|
|
1170
|
+
data: F = [],
|
|
1171
|
+
isLoading: ne,
|
|
1172
|
+
refetch: V
|
|
1173
|
+
} = W({
|
|
1173
1174
|
queryKey: ["addendums", t, m],
|
|
1174
|
-
queryFn: () =>
|
|
1175
|
+
queryFn: () => f.request(L(`/addendums/${t}/${m}`)).then((n) => n.data ?? []),
|
|
1175
1176
|
// The form reads this key first (staleTime 30 s); with none here the panel,
|
|
1176
1177
|
// mounting just after, counted that answer stale and fetched it again.
|
|
1177
1178
|
// Live sync and the panel's own writes invalidate it.
|
|
1178
1179
|
staleTime: 3e4
|
|
1179
|
-
}), { data: A, isLoading:
|
|
1180
|
-
queryKey: ["addendum-layout", t,
|
|
1180
|
+
}), { data: A, isLoading: K } = W({
|
|
1181
|
+
queryKey: ["addendum-layout", t, y ?? "default"],
|
|
1181
1182
|
queryFn: async () => {
|
|
1182
|
-
const
|
|
1183
|
-
return
|
|
1183
|
+
const n = await f.request(L("/collection-layouts", { collection: t })).then((o) => (o.data ?? []).filter((d) => d.layout_type === "addendum"));
|
|
1184
|
+
return y != null ? n.find((o) => o.id === y) ?? null : n[0] ?? null;
|
|
1184
1185
|
},
|
|
1185
1186
|
staleTime: 300 * 1e3
|
|
1186
|
-
}),
|
|
1187
|
-
queryKey: ["addendum-layout-assignments",
|
|
1188
|
-
queryFn: () =>
|
|
1189
|
-
L(`/collection-layouts/${
|
|
1190
|
-
).then((
|
|
1191
|
-
enabled:
|
|
1187
|
+
}), R = y ?? (A == null ? void 0 : A.id) ?? null, z = !!R && (u || F.length > 0), { data: ae = [], isPending: le } = W({
|
|
1188
|
+
queryKey: ["addendum-layout-assignments", R],
|
|
1189
|
+
queryFn: () => R ? f.request(
|
|
1190
|
+
L(`/collection-layouts/${R}/assignments`)
|
|
1191
|
+
).then((n) => n.data ?? []) : Promise.resolve([]),
|
|
1192
|
+
enabled: z,
|
|
1192
1193
|
staleTime: 300 * 1e3
|
|
1193
|
-
}), { data:
|
|
1194
|
-
queryKey: ["collection-fields", t,
|
|
1195
|
-
queryFn: () =>
|
|
1194
|
+
}), { data: M = [], isPending: H } = W({
|
|
1195
|
+
queryKey: ["collection-fields", t, R],
|
|
1196
|
+
queryFn: () => f.request(
|
|
1196
1197
|
L(
|
|
1197
1198
|
`/field-config/${t}`,
|
|
1198
|
-
|
|
1199
|
+
R ? { layout_id: String(R) } : void 0
|
|
1199
1200
|
)
|
|
1200
|
-
).then((
|
|
1201
|
-
enabled:
|
|
1201
|
+
).then((n) => n.data ?? []),
|
|
1202
|
+
enabled: z,
|
|
1202
1203
|
staleTime: 300 * 1e3
|
|
1203
|
-
}),
|
|
1204
|
+
}), X = u && R != null && (le || H), { data: Y = [] } = W({
|
|
1204
1205
|
queryKey: ["relations", t],
|
|
1205
|
-
queryFn: () =>
|
|
1206
|
+
queryFn: () => f.request(L(`/data-model/relations/for/${t}`)).then((n) => n.data ?? []),
|
|
1206
1207
|
staleTime: 300 * 1e3
|
|
1207
|
-
}), { data: Z, isLoading:
|
|
1208
|
+
}), { data: Z, isLoading: ee } = W({
|
|
1208
1209
|
queryKey: ["item", t, m],
|
|
1209
|
-
queryFn: () =>
|
|
1210
|
+
queryFn: () => f.request(L(`/items/${t}/${m}`)).then((n) => n.data ?? {}),
|
|
1210
1211
|
enabled: u,
|
|
1211
1212
|
staleTime: 0
|
|
1212
1213
|
}), se = () => {
|
|
1213
|
-
|
|
1214
|
-
}, te = (
|
|
1215
|
-
|
|
1216
|
-
const
|
|
1217
|
-
let
|
|
1218
|
-
if (
|
|
1214
|
+
C.invalidateQueries({ queryKey: ["addendums", t, m] }), V(), p == null || p();
|
|
1215
|
+
}, te = (n) => {
|
|
1216
|
+
C.invalidateQueries({ queryKey: ["addendums", t, m] }), V();
|
|
1217
|
+
const o = ae.find((c) => String(c.field) === "__pdf__");
|
|
1218
|
+
let d = null;
|
|
1219
|
+
if (o != null && o.overrides)
|
|
1219
1220
|
try {
|
|
1220
|
-
|
|
1221
|
+
d = typeof o.overrides == "string" ? JSON.parse(o.overrides) : o.overrides;
|
|
1221
1222
|
} catch {
|
|
1222
|
-
|
|
1223
|
+
d = null;
|
|
1223
1224
|
}
|
|
1224
|
-
|
|
1225
|
-
},
|
|
1226
|
-
(
|
|
1227
|
-
),
|
|
1228
|
-
(
|
|
1229
|
-
).length,
|
|
1230
|
-
return
|
|
1231
|
-
var
|
|
1232
|
-
(
|
|
1233
|
-
}, [
|
|
1225
|
+
b == null || b({ id: n, pdfSlot: d });
|
|
1226
|
+
}, me = ae.filter(
|
|
1227
|
+
(n) => !String(n.field).startsWith("__") && (n.is_visible || n.is_visible === 1)
|
|
1228
|
+
), $ = F.filter(
|
|
1229
|
+
(n) => !["approved", "rejected", "reverted"].includes(n.status)
|
|
1230
|
+
).length, l = Pe(k);
|
|
1231
|
+
return l.current = k, Je(() => {
|
|
1232
|
+
var n;
|
|
1233
|
+
(n = l.current) == null || n.call(l, $);
|
|
1234
|
+
}, [$]), !x && (ne || F.length === 0) ? null : /* @__PURE__ */ i(Ne, { children: [
|
|
1234
1235
|
/* @__PURE__ */ i(
|
|
1235
1236
|
"div",
|
|
1236
1237
|
{
|
|
1237
1238
|
className: D(
|
|
1238
1239
|
"overflow-hidden rounded-xl border bg-white dark:bg-card",
|
|
1239
|
-
|
|
1240
|
+
$ > 0 ? "border-amber-300 dark:border-amber-500/40" : "border-slate-200 dark:border-border"
|
|
1240
1241
|
),
|
|
1241
1242
|
children: [
|
|
1242
1243
|
/* @__PURE__ */ i(
|
|
@@ -1244,44 +1245,44 @@ function sr({
|
|
|
1244
1245
|
{
|
|
1245
1246
|
className: D(
|
|
1246
1247
|
"flex items-center justify-between px-4 py-3 cursor-pointer select-none",
|
|
1247
|
-
!
|
|
1248
|
+
!N && ($ > 0 ? "border-b border-amber-200 dark:border-amber-500/30" : "border-b border-slate-200 dark:border-border")
|
|
1248
1249
|
),
|
|
1249
|
-
onClick: () =>
|
|
1250
|
+
onClick: () => I((n) => !n),
|
|
1250
1251
|
children: [
|
|
1251
1252
|
/* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
|
|
1252
1253
|
/* @__PURE__ */ r(tt, { className: "h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500" }),
|
|
1253
1254
|
/* @__PURE__ */ r("h3", { className: "text-[13px] font-medium text-slate-800 dark:text-slate-200", children: "Addendums" }),
|
|
1254
|
-
|
|
1255
|
+
$ > 0 && /* @__PURE__ */ i("span", { className: "inline-flex items-center gap-1 rounded-full bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20", children: [
|
|
1255
1256
|
/* @__PURE__ */ r("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 animate-pulse" }),
|
|
1256
|
-
|
|
1257
|
+
$,
|
|
1257
1258
|
" in review"
|
|
1258
1259
|
] }),
|
|
1259
|
-
|
|
1260
|
+
F.length >= 2 && !N && /* @__PURE__ */ r(
|
|
1260
1261
|
"button",
|
|
1261
1262
|
{
|
|
1262
1263
|
type: "button",
|
|
1263
|
-
onClick: (
|
|
1264
|
-
|
|
1264
|
+
onClick: (n) => {
|
|
1265
|
+
n.stopPropagation(), G((o) => !o);
|
|
1265
1266
|
},
|
|
1266
1267
|
className: D(
|
|
1267
1268
|
"ml-1 rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors",
|
|
1268
|
-
|
|
1269
|
+
j ? "border-nvr-cyan bg-nvr-cyan/10 text-[#0b7ea6] dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:border-slate-400 hover:text-slate-700 dark:border-border dark:text-slate-400"
|
|
1269
1270
|
),
|
|
1270
1271
|
"data-tip": "Every addendum side by side — amount moved, fields touched, lines changed, running total",
|
|
1271
|
-
"aria-pressed":
|
|
1272
|
-
children:
|
|
1272
|
+
"aria-pressed": j,
|
|
1273
|
+
children: j ? "Cards" : "Compare"
|
|
1273
1274
|
}
|
|
1274
1275
|
)
|
|
1275
1276
|
] }),
|
|
1276
1277
|
/* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
|
|
1277
|
-
|
|
1278
|
+
x && (!(A != null && A.single_active_addendum) || $ === 0) && /* @__PURE__ */ r(
|
|
1278
1279
|
Q,
|
|
1279
1280
|
{
|
|
1280
1281
|
size: "sm",
|
|
1281
1282
|
variant: "outline",
|
|
1282
1283
|
className: "h-7 text-[12px]",
|
|
1283
|
-
onClick: (
|
|
1284
|
-
|
|
1284
|
+
onClick: (n) => {
|
|
1285
|
+
n.stopPropagation(), v(!0);
|
|
1285
1286
|
},
|
|
1286
1287
|
children: "+ New Addendum"
|
|
1287
1288
|
}
|
|
@@ -1291,7 +1292,7 @@ function sr({
|
|
|
1291
1292
|
{
|
|
1292
1293
|
className: D(
|
|
1293
1294
|
"h-3.5 w-3.5 shrink-0 text-slate-400 transition-transform duration-150",
|
|
1294
|
-
|
|
1295
|
+
N && "-rotate-90"
|
|
1295
1296
|
)
|
|
1296
1297
|
}
|
|
1297
1298
|
)
|
|
@@ -1299,66 +1300,66 @@ function sr({
|
|
|
1299
1300
|
]
|
|
1300
1301
|
}
|
|
1301
1302
|
),
|
|
1302
|
-
!
|
|
1303
|
+
!N && !A && !K && /* @__PURE__ */ i("div", { className: "px-4 py-4 text-center", children: [
|
|
1303
1304
|
/* @__PURE__ */ r("p", { className: "text-[12px] text-slate-400", children: "No addendum form configured." }),
|
|
1304
1305
|
/* @__PURE__ */ r("p", { className: "text-[11px] text-slate-300 dark:text-slate-600", children: 'Create an "Addendum Form" layout in Data Model → Layouts to enable addendum creation.' })
|
|
1305
1306
|
] }),
|
|
1306
|
-
!
|
|
1307
|
+
!N && (A || K) && (ne ? /* @__PURE__ */ i("div", { className: "p-4 space-y-2", children: [
|
|
1307
1308
|
/* @__PURE__ */ r(re, { className: "h-12 w-full" }),
|
|
1308
1309
|
/* @__PURE__ */ r(re, { className: "h-12 w-full" })
|
|
1309
|
-
] }) :
|
|
1310
|
+
] }) : F.length === 0 ? /* @__PURE__ */ i("div", { className: "px-4 py-8 text-center", children: [
|
|
1310
1311
|
/* @__PURE__ */ r("p", { className: "text-[12px] text-slate-400 dark:text-slate-500", children: "No addendum attached to this record" }),
|
|
1311
1312
|
/* @__PURE__ */ r("p", { className: "mt-0.5 text-[11px] text-slate-300 dark:text-slate-600", children: "Addendums propose changes that go through a review process before being applied." })
|
|
1312
|
-
] }) :
|
|
1313
|
-
|
|
1313
|
+
] }) : j && F.length >= 2 ? /* @__PURE__ */ r("div", { className: "p-3", children: /* @__PURE__ */ r(
|
|
1314
|
+
wt,
|
|
1314
1315
|
{
|
|
1315
|
-
client:
|
|
1316
|
-
addendums:
|
|
1316
|
+
client: f,
|
|
1317
|
+
addendums: F,
|
|
1317
1318
|
parentCollection: t,
|
|
1318
1319
|
parentId: m,
|
|
1319
|
-
relations:
|
|
1320
|
-
fieldMap: Object.fromEntries(
|
|
1320
|
+
relations: Y,
|
|
1321
|
+
fieldMap: Object.fromEntries(M.map((n) => [n.field, n]))
|
|
1321
1322
|
}
|
|
1322
|
-
) }) : /* @__PURE__ */ r("div", { className: "p-3 space-y-2", children:
|
|
1323
|
-
|
|
1323
|
+
) }) : /* @__PURE__ */ r("div", { className: "p-3 space-y-2", children: F.map((n) => /* @__PURE__ */ r(
|
|
1324
|
+
Dt,
|
|
1324
1325
|
{
|
|
1325
|
-
addendum:
|
|
1326
|
-
configuredFields:
|
|
1326
|
+
addendum: n,
|
|
1327
|
+
configuredFields: me,
|
|
1327
1328
|
onRefresh: se,
|
|
1328
|
-
isActive: !["approved", "rejected", "reverted"].includes(
|
|
1329
|
-
relations:
|
|
1329
|
+
isActive: !["approved", "rejected", "reverted"].includes(n.status),
|
|
1330
|
+
relations: Y,
|
|
1330
1331
|
parentCollection: t,
|
|
1331
1332
|
parentId: m,
|
|
1332
|
-
fieldMap: Object.fromEntries(
|
|
1333
|
+
fieldMap: Object.fromEntries(M.map((o) => [o.field, o]))
|
|
1333
1334
|
},
|
|
1334
|
-
|
|
1335
|
+
n.id
|
|
1335
1336
|
)) }))
|
|
1336
1337
|
]
|
|
1337
1338
|
}
|
|
1338
1339
|
),
|
|
1339
|
-
/* @__PURE__ */ r(
|
|
1340
|
+
/* @__PURE__ */ r(vt, { open: u, onOpenChange: v, children: /* @__PURE__ */ r(yt, { side: "right", className: "w-[80vw] sm:max-w-[80vw] p-0 flex flex-col", children: u && (ee || X) ? /* @__PURE__ */ i("div", { className: "flex flex-col gap-3 p-6", children: [
|
|
1340
1341
|
/* @__PURE__ */ r(re, { className: "h-6 w-48" }),
|
|
1341
1342
|
/* @__PURE__ */ r(re, { className: "h-9 w-full" }),
|
|
1342
1343
|
/* @__PURE__ */ r(re, { className: "h-9 w-full" }),
|
|
1343
1344
|
/* @__PURE__ */ r(re, { className: "h-9 w-full" }),
|
|
1344
1345
|
/* @__PURE__ */ r(re, { className: "h-9 w-3/4" })
|
|
1345
1346
|
] }) : u && Z ? /* @__PURE__ */ r(
|
|
1346
|
-
|
|
1347
|
+
jt,
|
|
1347
1348
|
{
|
|
1348
1349
|
collection: t,
|
|
1349
1350
|
itemId: m,
|
|
1350
|
-
assignments:
|
|
1351
|
+
assignments: ae,
|
|
1351
1352
|
workflowTemplateId: (A == null ? void 0 : A.workflow_template_id) ?? null,
|
|
1352
|
-
resolvedLayoutId:
|
|
1353
|
-
fields:
|
|
1354
|
-
relations:
|
|
1353
|
+
resolvedLayoutId: R,
|
|
1354
|
+
fields: M,
|
|
1355
|
+
relations: Y,
|
|
1355
1356
|
parentData: Z,
|
|
1356
|
-
onClose: () =>
|
|
1357
|
+
onClose: () => v(!1),
|
|
1357
1358
|
onCreated: te
|
|
1358
1359
|
}
|
|
1359
1360
|
) : null }) })
|
|
1360
1361
|
] });
|
|
1361
1362
|
}
|
|
1362
1363
|
export {
|
|
1363
|
-
|
|
1364
|
+
or as AddendumPanel
|
|
1364
1365
|
};
|