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