@nivaro/react 0.3.51 → 0.3.53
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 -3
- package/dist/shared/components/ItemEditForm.js +3885 -3847
- package/dist/shared/components/NotificationBell.js +163 -150
- package/dist/shared/components/PageRenderer.js +600 -549
- package/dist/shared/components/ProfileView.js +36 -34
- package/dist/shared/components/QueryStatStrip.js +96 -89
- package/dist/shared/components/QueryTable.js +214 -215
- package/dist/shared/components/ReportView.js +548 -529
- package/dist/shared/components/alerts/AlertManagerView.js +346 -320
- package/dist/shared/components/item-edit/CatalogPickerField.js +1300 -1219
- package/dist/shared/components/item-edit/FieldAffordances.js +145 -136
- package/dist/shared/components/item-edit/FieldRenderer.js +366 -326
- package/dist/shared/components/item-edit/InlineTableField.js +3047 -2932
- package/dist/shared/components/item-edit/NestedRelationEditor.js +149 -143
- package/dist/shared/components/item-edit/PlanGrid.js +718 -705
- package/dist/shared/components/item-edit/SummaryPanel.js +351 -337
- package/dist/shared/components/item-edit/line-qty.js +115 -53
- package/dist/shared/components/item-edit/save-refusal.js +18 -18
- package/dist/shared/components/item-edit/usePersonalDefaults.js +210 -207
- package/dist/shared/components/panels/CommentPanel.js +204 -197
- package/dist/shared/components/panels/ItemLockBanner.js +318 -291
- package/dist/shared/components/panels/PipelinePanel.js +1388 -1218
- package/dist/shared/components/panels/RecordIntegrityBanner.js +201 -172
- package/dist/shared/components/panels/RevisionsPanel.js +101 -106
- package/dist/shared/components/panels/TransitionRequirementsDialog.js +564 -534
- package/dist/shared/components/panels/requirement-side-effects.js +46 -29
- package/dist/shared/components/queue/QueueItemSheet.js +219 -146
- package/dist/shared/components/queue/QueueWorklist.js +738 -730
- package/dist/shared/components/widgets/ReviewListWidget.js +236 -201
- package/dist/shared/lib/activity-sentence.js +236 -227
- package/dist/shared/lib/record-ref.js +43 -34
- package/package.json +1 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { AlertCircle as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { createPortal as
|
|
6
|
-
import { useNivaroClient as
|
|
7
|
-
import { patch as
|
|
8
|
-
import { cn as
|
|
9
|
-
import { buildCascadeFilter as
|
|
10
|
-
import { extractTemplateFields as
|
|
11
|
-
import { Button as
|
|
12
|
-
import { Dialog as
|
|
13
|
-
import { Input as
|
|
14
|
-
import { keepValuesPatch as
|
|
15
|
-
const
|
|
16
|
-
function R(
|
|
17
|
-
return `${
|
|
1
|
+
import { jsx as s, jsxs as k, Fragment as Le } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as Oe, useQuery as ce } from "@tanstack/react-query";
|
|
3
|
+
import { AlertCircle as I, CopyPlus as Fe, Loader2 as ee, ChevronDown as ye, Check as ke, Paperclip as de, X as Re } from "lucide-react";
|
|
4
|
+
import { useState as L, useRef as z, Fragment as De, useEffect as ve, useLayoutEffect as Pe } from "react";
|
|
5
|
+
import { createPortal as Te } from "react-dom";
|
|
6
|
+
import { useNivaroClient as ie } from "../../context.js";
|
|
7
|
+
import { patch as ue, get as Q, del as fe, post as me } from "../../lib/commands.js";
|
|
8
|
+
import { cn as K, titleCase as te } from "../../lib/utils.js";
|
|
9
|
+
import { buildCascadeFilter as Ke } from "../item-edit/helpers.js";
|
|
10
|
+
import { extractTemplateFields as ze, renderDisplayTemplate as pe } from "../pipeline/relations.js";
|
|
11
|
+
import { Button as B } from "../ui/button.js";
|
|
12
|
+
import { Dialog as Ue, DialogContent as Ve, DialogHeader as Ie, DialogTitle as Me, DialogBody as Be, DialogFooter as He } from "../ui/dialog.js";
|
|
13
|
+
import { Input as V } from "../ui/input.js";
|
|
14
|
+
import { keepValuesPatch as Qe, runPooled as he, overwrittenBySideEffect as Je } from "./requirement-side-effects.js";
|
|
15
|
+
const We = "x-nivaro-requirements-for";
|
|
16
|
+
function R(n, i) {
|
|
17
|
+
return `${n}::${String(i)}`;
|
|
18
18
|
}
|
|
19
|
-
const
|
|
19
|
+
const Ye = [
|
|
20
20
|
"integer",
|
|
21
21
|
"bigInteger",
|
|
22
22
|
"float",
|
|
@@ -32,714 +32,741 @@ const Je = [
|
|
|
32
32
|
"double",
|
|
33
33
|
"number"
|
|
34
34
|
];
|
|
35
|
-
function
|
|
36
|
-
if (
|
|
37
|
-
const
|
|
38
|
-
if (!Number.isNaN(
|
|
35
|
+
function X(n, i) {
|
|
36
|
+
if (i && Ye.includes(i)) {
|
|
37
|
+
const a = Number(n.trim());
|
|
38
|
+
if (!Number.isNaN(a)) return a;
|
|
39
39
|
}
|
|
40
|
-
return
|
|
40
|
+
return n;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
return
|
|
42
|
+
function ne(n) {
|
|
43
|
+
return n == null ? "" : String(n);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
const
|
|
47
|
-
if (!
|
|
48
|
-
const
|
|
49
|
-
return Number.isNaN(
|
|
45
|
+
function M(n, i) {
|
|
46
|
+
const a = ne(n);
|
|
47
|
+
if (!i || a === "") return a;
|
|
48
|
+
const b = Number(a);
|
|
49
|
+
return Number.isNaN(b) ? a : i === "currency" ? b.toLocaleString("en-US", {
|
|
50
|
+
style: "currency",
|
|
51
|
+
currency: "USD",
|
|
52
|
+
minimumFractionDigits: 2,
|
|
53
|
+
maximumFractionDigits: 4
|
|
54
|
+
}) : b.toLocaleString("en-US");
|
|
50
55
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return
|
|
56
|
+
function G(n) {
|
|
57
|
+
const i = (n.label ?? "").trim();
|
|
58
|
+
return i ? /^[a-z0-9]+(_[a-z0-9]+)+$/.test(i) || i === n.field ? te(i) : i : te(n.field);
|
|
54
59
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
const re = (n) => n.kind === "m2m" || n.kind === "files";
|
|
61
|
+
function H(n) {
|
|
62
|
+
return R(n.collection, `record:${n.item}`);
|
|
63
|
+
}
|
|
64
|
+
function be(n, i = !1) {
|
|
65
|
+
var b;
|
|
66
|
+
const a = {};
|
|
67
|
+
for (const c of n) {
|
|
68
|
+
if (c.type === "record_fields") {
|
|
69
|
+
const y = {};
|
|
70
|
+
for (const m of c.fields) {
|
|
71
|
+
const p = c.values[m.field];
|
|
72
|
+
y[m.field] = re(m) ? Array.isArray(p) ? p.map(String) : [] : ne(p);
|
|
64
73
|
}
|
|
65
|
-
|
|
74
|
+
a[H(c)] = y;
|
|
66
75
|
continue;
|
|
67
76
|
}
|
|
68
|
-
for (const
|
|
69
|
-
const
|
|
70
|
-
for (const
|
|
71
|
-
let
|
|
72
|
-
if (
|
|
73
|
-
const
|
|
74
|
-
|
|
77
|
+
for (const y of c.rows) {
|
|
78
|
+
const m = {};
|
|
79
|
+
for (const p of c.fields) {
|
|
80
|
+
let h = p.kind === "m2m" ? Array.isArray(y.values[p.field]) ? y.values[p.field].map(String) : [] : ne(y.values[p.field]);
|
|
81
|
+
if (i && ((b = c.prefill_values) == null ? void 0 : b[p.field]) != null) {
|
|
82
|
+
const S = c.prefill_values[p.field];
|
|
83
|
+
p.kind === "m2m" && Array.isArray(h) && h.length === 0 ? h = [String(S)] : p.kind !== "m2m" && h === "" && (h = String(S));
|
|
75
84
|
}
|
|
76
|
-
p
|
|
85
|
+
m[p.field] = h;
|
|
77
86
|
}
|
|
78
|
-
|
|
87
|
+
a[R(c.collection, y.id)] = m;
|
|
79
88
|
}
|
|
80
89
|
}
|
|
81
|
-
return
|
|
90
|
+
return a;
|
|
82
91
|
}
|
|
83
|
-
function
|
|
84
|
-
if (Array.isArray(
|
|
85
|
-
const
|
|
86
|
-
for (const
|
|
87
|
-
(
|
|
88
|
-
return
|
|
92
|
+
function Ze(n) {
|
|
93
|
+
if (Array.isArray(n)) {
|
|
94
|
+
const i = {};
|
|
95
|
+
for (const a of n)
|
|
96
|
+
(a == null ? void 0 : a.id) != null && (i[String(a.id)] = String(a.name ?? a.id));
|
|
97
|
+
return i;
|
|
89
98
|
}
|
|
90
|
-
return typeof
|
|
99
|
+
return typeof n == "string" ? { __single__: n } : {};
|
|
91
100
|
}
|
|
92
|
-
function
|
|
93
|
-
multiple:
|
|
94
|
-
ids:
|
|
95
|
-
initialNames:
|
|
96
|
-
onChange:
|
|
101
|
+
function Xe({
|
|
102
|
+
multiple: n,
|
|
103
|
+
ids: i,
|
|
104
|
+
initialNames: a,
|
|
105
|
+
onChange: b
|
|
97
106
|
}) {
|
|
98
|
-
const
|
|
99
|
-
async function
|
|
100
|
-
if (!(
|
|
101
|
-
|
|
102
|
-
const
|
|
107
|
+
const c = ie(), y = z(null), [m, p] = L({}), [h, S] = L(!1), [q, $] = L(null), _ = (x) => m[x] ?? a[x] ?? (n ? void 0 : a.__single__) ?? x;
|
|
108
|
+
async function w(x) {
|
|
109
|
+
if (!(x != null && x.length)) return;
|
|
110
|
+
S(!0), $(null);
|
|
111
|
+
const j = [];
|
|
103
112
|
try {
|
|
104
|
-
for (const
|
|
105
|
-
const
|
|
106
|
-
|
|
113
|
+
for (const O of Array.from(x).slice(0, n ? 20 : 1)) {
|
|
114
|
+
const P = await c.upload(O), F = String(P.id);
|
|
115
|
+
j.push(F), p((J) => ({ ...J, [F]: O.name }));
|
|
107
116
|
}
|
|
108
117
|
} catch {
|
|
109
|
-
|
|
118
|
+
$("A file could not be uploaded");
|
|
110
119
|
} finally {
|
|
111
|
-
|
|
120
|
+
S(!1), y.current && (y.current.value = "");
|
|
112
121
|
}
|
|
113
|
-
|
|
122
|
+
j.length && b(n ? [...i, ...j] : j.slice(0, 1));
|
|
114
123
|
}
|
|
115
|
-
return /* @__PURE__ */
|
|
116
|
-
|
|
124
|
+
return /* @__PURE__ */ k("div", { className: "space-y-1.5", "data-requirement-file": n ? "files" : "file", children: [
|
|
125
|
+
i.length > 0 && /* @__PURE__ */ s("ul", { className: "space-y-1", children: i.map((x) => /* @__PURE__ */ k(
|
|
117
126
|
"li",
|
|
118
127
|
{
|
|
119
128
|
className: "flex items-center gap-1.5 rounded border border-slate-200 px-2 py-1 text-[12px] text-slate-700 dark:border-border dark:text-slate-200",
|
|
120
129
|
children: [
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
-
/* @__PURE__ */
|
|
123
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ s(de, { className: "h-3 w-3 shrink-0 text-slate-400" }),
|
|
131
|
+
/* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate", children: _(x) }),
|
|
132
|
+
/* @__PURE__ */ s(
|
|
124
133
|
"button",
|
|
125
134
|
{
|
|
126
135
|
type: "button",
|
|
127
|
-
"aria-label": `Remove ${
|
|
128
|
-
onClick: () =>
|
|
136
|
+
"aria-label": `Remove ${_(x)}`,
|
|
137
|
+
onClick: () => b(i.filter((j) => j !== x)),
|
|
129
138
|
className: "rounded p-0.5 text-slate-400 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted",
|
|
130
|
-
children: /* @__PURE__ */
|
|
139
|
+
children: /* @__PURE__ */ s(Re, { className: "h-3 w-3" })
|
|
131
140
|
}
|
|
132
141
|
)
|
|
133
142
|
]
|
|
134
143
|
},
|
|
135
|
-
|
|
144
|
+
x
|
|
136
145
|
)) }),
|
|
137
|
-
(
|
|
138
|
-
/* @__PURE__ */
|
|
146
|
+
(n || i.length === 0) && /* @__PURE__ */ k(Le, { children: [
|
|
147
|
+
/* @__PURE__ */ s(
|
|
139
148
|
"input",
|
|
140
149
|
{
|
|
141
|
-
ref:
|
|
150
|
+
ref: y,
|
|
142
151
|
type: "file",
|
|
143
|
-
multiple:
|
|
152
|
+
multiple: n,
|
|
144
153
|
className: "hidden",
|
|
145
|
-
onChange: (
|
|
154
|
+
onChange: (x) => void w(x.target.files)
|
|
146
155
|
}
|
|
147
156
|
),
|
|
148
|
-
/* @__PURE__ */
|
|
149
|
-
|
|
157
|
+
/* @__PURE__ */ k(
|
|
158
|
+
B,
|
|
150
159
|
{
|
|
151
160
|
type: "button",
|
|
152
161
|
variant: "outline",
|
|
153
162
|
size: "sm",
|
|
154
|
-
disabled:
|
|
163
|
+
disabled: h,
|
|
155
164
|
onClick: () => {
|
|
156
|
-
var
|
|
157
|
-
return (
|
|
165
|
+
var x;
|
|
166
|
+
return (x = y.current) == null ? void 0 : x.click();
|
|
158
167
|
},
|
|
159
168
|
className: "h-8 gap-1.5 text-[12px]",
|
|
160
169
|
"data-requirement-upload": !0,
|
|
161
170
|
children: [
|
|
162
|
-
|
|
163
|
-
|
|
171
|
+
h ? /* @__PURE__ */ s(ee, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ s(de, { className: "h-3.5 w-3.5" }),
|
|
172
|
+
h ? "Uploading…" : n ? "Add files" : "Upload a file"
|
|
164
173
|
]
|
|
165
174
|
}
|
|
166
175
|
)
|
|
167
176
|
] }),
|
|
168
|
-
|
|
177
|
+
q && /* @__PURE__ */ s("p", { className: "text-[11px] text-red-600", children: q })
|
|
169
178
|
] });
|
|
170
179
|
}
|
|
171
|
-
function
|
|
172
|
-
anchor:
|
|
173
|
-
panelRef:
|
|
174
|
-
children:
|
|
180
|
+
function we({
|
|
181
|
+
anchor: n,
|
|
182
|
+
panelRef: i,
|
|
183
|
+
children: a
|
|
175
184
|
}) {
|
|
176
|
-
const
|
|
177
|
-
return
|
|
178
|
-
if (!
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
185
|
+
const b = n.closest('[role="dialog"]'), [c, y] = L(null);
|
|
186
|
+
return Pe(() => {
|
|
187
|
+
if (!b) return;
|
|
188
|
+
const m = () => {
|
|
189
|
+
const p = n.getBoundingClientRect(), h = b.getBoundingClientRect(), S = p.bottom + 208 > window.innerHeight && p.top > 216;
|
|
190
|
+
y(
|
|
191
|
+
S ? { bottom: h.bottom - p.top + 4, left: p.left - h.left, width: p.width } : { top: p.bottom - h.top + 4, left: p.left - h.left, width: p.width }
|
|
183
192
|
);
|
|
184
193
|
};
|
|
185
|
-
return
|
|
186
|
-
window.removeEventListener("scroll",
|
|
194
|
+
return m(), window.addEventListener("scroll", m, !0), window.addEventListener("resize", m), () => {
|
|
195
|
+
window.removeEventListener("scroll", m, !0), window.removeEventListener("resize", m);
|
|
187
196
|
};
|
|
188
|
-
}, [
|
|
189
|
-
/* @__PURE__ */
|
|
197
|
+
}, [n, b]), !c || !b ? null : Te(
|
|
198
|
+
/* @__PURE__ */ s(
|
|
190
199
|
"div",
|
|
191
200
|
{
|
|
192
|
-
ref:
|
|
201
|
+
ref: i,
|
|
193
202
|
role: "listbox",
|
|
194
203
|
className: "absolute z-[120] max-h-48 w-56 overflow-y-auto rounded-md border border-slate-200 bg-white py-1 shadow-lg dark:border-border dark:bg-card",
|
|
195
|
-
style: { top:
|
|
196
|
-
children:
|
|
204
|
+
style: { top: c.top, bottom: c.bottom, left: c.left, minWidth: c.width },
|
|
205
|
+
children: a
|
|
197
206
|
}
|
|
198
207
|
),
|
|
199
|
-
|
|
208
|
+
b
|
|
200
209
|
);
|
|
201
210
|
}
|
|
202
|
-
function
|
|
203
|
-
const
|
|
204
|
-
if (
|
|
205
|
-
const
|
|
206
|
-
if (/[\p{L}\p{N}]/u.test(
|
|
211
|
+
function Ge(n, i) {
|
|
212
|
+
const a = String(i.id ?? "");
|
|
213
|
+
if (n) {
|
|
214
|
+
const c = pe(n, i).trim();
|
|
215
|
+
if (/[\p{L}\p{N}]/u.test(c)) return c;
|
|
207
216
|
}
|
|
208
|
-
const
|
|
209
|
-
...
|
|
217
|
+
const b = pe(null, {
|
|
218
|
+
...i,
|
|
210
219
|
short_name: void 0
|
|
211
220
|
}).trim();
|
|
212
|
-
return
|
|
221
|
+
return b && b !== a ? b : i.short_name != null && i.short_name !== "" ? String(i.short_name) : a ? `#${a}` : "";
|
|
213
222
|
}
|
|
214
|
-
function
|
|
215
|
-
var
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
218
|
-
const { filter:
|
|
219
|
-
rules:
|
|
220
|
-
parentValue: (
|
|
223
|
+
function Ne(n, i) {
|
|
224
|
+
var b;
|
|
225
|
+
const a = [];
|
|
226
|
+
if (n.option_filter && Object.keys(n.option_filter).length > 0 && a.push(n.option_filter), (b = n.cascade_filters) != null && b.length) {
|
|
227
|
+
const { filter: c } = Ke({
|
|
228
|
+
rules: n.cascade_filters,
|
|
229
|
+
parentValue: (y) => i == null ? void 0 : i[y]
|
|
221
230
|
});
|
|
222
|
-
|
|
231
|
+
c && Object.keys(c).length > 0 && a.push(c);
|
|
223
232
|
}
|
|
224
|
-
if (
|
|
225
|
-
return
|
|
233
|
+
if (a.length !== 0)
|
|
234
|
+
return a.length === 1 ? a[0] : { _and: a };
|
|
226
235
|
}
|
|
227
|
-
function
|
|
228
|
-
const
|
|
229
|
-
queryKey: ["col-meta",
|
|
230
|
-
queryFn: () =>
|
|
231
|
-
enabled: !!
|
|
236
|
+
function _e(n, i) {
|
|
237
|
+
const a = ie(), { data: b, isPending: c } = ce({
|
|
238
|
+
queryKey: ["col-meta", n],
|
|
239
|
+
queryFn: () => a.request(Q(`/collections/${n}`)).then((q) => q.data ?? {}),
|
|
240
|
+
enabled: !!n,
|
|
232
241
|
staleTime: 3e5,
|
|
233
242
|
retry: !1
|
|
234
|
-
}),
|
|
235
|
-
queryKey: ["req-related-options",
|
|
236
|
-
queryFn: () =>
|
|
237
|
-
|
|
243
|
+
}), y = (b == null ? void 0 : b.display_template) ?? null, m = y ? ze(y).join(",") : void 0, p = i ? JSON.stringify(i) : "", { data: h = [], isSuccess: S } = ce({
|
|
244
|
+
queryKey: ["req-related-options", n, y ?? "", p],
|
|
245
|
+
queryFn: () => a.request(
|
|
246
|
+
Q(`/items/${n}`, {
|
|
238
247
|
limit: 500,
|
|
239
248
|
picker: "1",
|
|
240
|
-
...
|
|
241
|
-
...
|
|
249
|
+
...m ? { fields: m } : {},
|
|
250
|
+
...p ? { filter: p } : {}
|
|
242
251
|
})
|
|
243
252
|
).then(
|
|
244
|
-
(
|
|
253
|
+
(q) => (q.data ?? []).map(($) => ({ id: String($.id), label: Ge(y, $) })).sort(($, _) => $.label.localeCompare(_.label, void 0, { numeric: !0 }))
|
|
245
254
|
).catch(() => []),
|
|
246
255
|
// The template decides `fields`: wait for it (a miss just means none).
|
|
247
|
-
enabled: !!
|
|
256
|
+
enabled: !!n && !c,
|
|
248
257
|
staleTime: 3e5
|
|
249
258
|
});
|
|
250
|
-
return
|
|
259
|
+
return { options: h, loaded: S };
|
|
260
|
+
}
|
|
261
|
+
const et = /^[A-Za-z][A-Za-z0-9_]*$/;
|
|
262
|
+
function tt(n) {
|
|
263
|
+
let i = n, a = null;
|
|
264
|
+
for (let b = 0; b < 6 && i && typeof i == "object"; b++) {
|
|
265
|
+
if (Array.isArray(i)) {
|
|
266
|
+
i = i[0];
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
const c = Object.entries(i), y = c.find(([p]) => p === "_and" || p === "_or"), m = c.find(([p]) => et.test(p));
|
|
270
|
+
if (m)
|
|
271
|
+
m[0] !== "id" && (a = m[0]), i = m[1];
|
|
272
|
+
else if (y) i = y[1];
|
|
273
|
+
else break;
|
|
274
|
+
}
|
|
275
|
+
return a ? a.replace(/_id$/, "").replace(/_/g, " ").toLowerCase() : null;
|
|
251
276
|
}
|
|
252
|
-
function
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
277
|
+
function nt(n) {
|
|
278
|
+
const i = n.trim().toLowerCase();
|
|
279
|
+
return i ? /[^aeiou]y$/.test(i) ? `${i.slice(0, -1)}ies` : /(s|x|z|ch|sh)$/.test(i) ? `${i}es` : `${i}s` : "options";
|
|
280
|
+
}
|
|
281
|
+
function Ae(n, i) {
|
|
282
|
+
const a = nt(n.label), b = tt(i);
|
|
283
|
+
return b ? `This ${b} has no ${a} set up. Ask an administrator, or pick another ${b}.` : `No ${a} are set up yet. Ask an administrator.`;
|
|
284
|
+
}
|
|
285
|
+
function ge({
|
|
286
|
+
meta: n,
|
|
287
|
+
selected: i,
|
|
288
|
+
onChange: a,
|
|
289
|
+
rowValues: b
|
|
257
290
|
}) {
|
|
258
|
-
const [
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
var $, _;
|
|
266
|
-
const A = v.target;
|
|
267
|
-
($ = p.current) != null && $.contains(A) || (_ = h.current) != null && _.contains(A) || k(!1);
|
|
291
|
+
const [c, y] = L(!1), m = z(null), p = z(null), h = Ne(n, b), { options: S, loaded: q } = _e(n.related_collection, h);
|
|
292
|
+
ve(() => {
|
|
293
|
+
if (!c) return;
|
|
294
|
+
const _ = (w) => {
|
|
295
|
+
var j, O;
|
|
296
|
+
const x = w.target;
|
|
297
|
+
(j = m.current) != null && j.contains(x) || (O = p.current) != null && O.contains(x) || y(!1);
|
|
268
298
|
};
|
|
269
|
-
return window.addEventListener("mousedown",
|
|
270
|
-
}, [
|
|
271
|
-
const
|
|
272
|
-
var
|
|
273
|
-
return ((
|
|
299
|
+
return window.addEventListener("mousedown", _), () => window.removeEventListener("mousedown", _);
|
|
300
|
+
}, [c]);
|
|
301
|
+
const $ = i.length === 0 ? `Select ${n.label.toLowerCase()}…` : i.map((_) => {
|
|
302
|
+
var w;
|
|
303
|
+
return ((w = S.find((x) => x.id === _)) == null ? void 0 : w.label) ?? _;
|
|
274
304
|
}).join(", ");
|
|
275
|
-
return /* @__PURE__ */
|
|
276
|
-
/* @__PURE__ */
|
|
305
|
+
return /* @__PURE__ */ k("div", { ref: m, className: "relative", children: [
|
|
306
|
+
/* @__PURE__ */ k(
|
|
277
307
|
"button",
|
|
278
308
|
{
|
|
279
309
|
type: "button",
|
|
280
|
-
onClick: () =>
|
|
310
|
+
onClick: () => y((_) => !_),
|
|
281
311
|
"aria-haspopup": "listbox",
|
|
282
|
-
"aria-expanded":
|
|
283
|
-
className:
|
|
312
|
+
"aria-expanded": c,
|
|
313
|
+
className: K(
|
|
284
314
|
"flex h-8 w-full min-w-[10rem] items-center justify-between gap-1 rounded-md border border-slate-200 bg-white px-2 text-left text-[12px] dark:border-border dark:bg-card",
|
|
285
|
-
|
|
315
|
+
i.length === 0 && "text-slate-400"
|
|
286
316
|
),
|
|
287
317
|
children: [
|
|
288
|
-
/* @__PURE__ */
|
|
289
|
-
/* @__PURE__ */
|
|
318
|
+
/* @__PURE__ */ s("span", { className: "truncate", children: $ }),
|
|
319
|
+
/* @__PURE__ */ s(ye, { className: "h-3 w-3 shrink-0 text-slate-400" })
|
|
290
320
|
]
|
|
291
321
|
}
|
|
292
322
|
),
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
const
|
|
296
|
-
return /* @__PURE__ */
|
|
323
|
+
c && m.current && /* @__PURE__ */ k(we, { anchor: m.current, panelRef: p, children: [
|
|
324
|
+
S.map((_) => {
|
|
325
|
+
const w = i.includes(_.id), x = n.max_values === 1;
|
|
326
|
+
return /* @__PURE__ */ k(
|
|
297
327
|
"button",
|
|
298
328
|
{
|
|
299
329
|
type: "button",
|
|
300
330
|
role: "option",
|
|
301
|
-
"aria-selected":
|
|
331
|
+
"aria-selected": w,
|
|
302
332
|
onClick: () => {
|
|
303
|
-
if (
|
|
304
|
-
|
|
333
|
+
if (x) {
|
|
334
|
+
a([_.id]), y(!1);
|
|
305
335
|
return;
|
|
306
336
|
}
|
|
307
|
-
|
|
337
|
+
a(w ? i.filter((j) => j !== _.id) : [...i, _.id]);
|
|
308
338
|
},
|
|
309
|
-
className:
|
|
339
|
+
className: K(
|
|
310
340
|
"flex w-full items-center justify-between px-2.5 py-1.5 text-left text-[12px] hover:bg-slate-50 dark:hover:bg-muted/50",
|
|
311
|
-
|
|
341
|
+
w ? "font-semibold text-nvr-navy dark:text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
|
|
312
342
|
),
|
|
313
343
|
children: [
|
|
314
|
-
/* @__PURE__ */
|
|
315
|
-
|
|
344
|
+
/* @__PURE__ */ s("span", { className: "truncate", children: _.label }),
|
|
345
|
+
w && /* @__PURE__ */ s(ke, { className: "h-3 w-3 shrink-0" })
|
|
316
346
|
]
|
|
317
347
|
},
|
|
318
|
-
|
|
348
|
+
_.id
|
|
319
349
|
);
|
|
320
350
|
}),
|
|
321
|
-
|
|
351
|
+
S.length === 0 && /* @__PURE__ */ s("p", { className: "max-w-[18rem] px-2.5 py-2 text-[11px] text-slate-500 dark:text-muted-foreground", children: q ? Ae(n, h) : "Loading…" })
|
|
322
352
|
] })
|
|
323
353
|
] });
|
|
324
354
|
}
|
|
325
|
-
function
|
|
326
|
-
meta:
|
|
327
|
-
selected:
|
|
328
|
-
onChange:
|
|
329
|
-
rowValues:
|
|
355
|
+
function xe({
|
|
356
|
+
meta: n,
|
|
357
|
+
selected: i,
|
|
358
|
+
onChange: a,
|
|
359
|
+
rowValues: b
|
|
330
360
|
}) {
|
|
331
|
-
var
|
|
332
|
-
const [
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
var _, O;
|
|
340
|
-
const $ = A.target;
|
|
341
|
-
(_ = p.current) != null && _.contains($) || (O = h.current) != null && O.contains($) || k(!1);
|
|
361
|
+
var _;
|
|
362
|
+
const [c, y] = L(!1), m = z(null), p = z(null), h = Ne(n, b), { options: S, loaded: q } = _e(n.related_collection, h);
|
|
363
|
+
ve(() => {
|
|
364
|
+
if (!c) return;
|
|
365
|
+
const w = (x) => {
|
|
366
|
+
var O, P;
|
|
367
|
+
const j = x.target;
|
|
368
|
+
(O = m.current) != null && O.contains(j) || (P = p.current) != null && P.contains(j) || y(!1);
|
|
342
369
|
};
|
|
343
|
-
return window.addEventListener("mousedown",
|
|
344
|
-
}, [
|
|
345
|
-
const
|
|
346
|
-
return /* @__PURE__ */
|
|
347
|
-
/* @__PURE__ */
|
|
370
|
+
return window.addEventListener("mousedown", w), () => window.removeEventListener("mousedown", w);
|
|
371
|
+
}, [c]);
|
|
372
|
+
const $ = i ? ((_ = S.find((w) => w.id === i)) == null ? void 0 : _.label) ?? i : `Select ${n.label.toLowerCase()}…`;
|
|
373
|
+
return /* @__PURE__ */ k("div", { ref: m, className: "relative", children: [
|
|
374
|
+
/* @__PURE__ */ k(
|
|
348
375
|
"button",
|
|
349
376
|
{
|
|
350
377
|
type: "button",
|
|
351
|
-
onClick: () =>
|
|
378
|
+
onClick: () => y((w) => !w),
|
|
352
379
|
"aria-haspopup": "listbox",
|
|
353
|
-
"aria-expanded":
|
|
354
|
-
className:
|
|
380
|
+
"aria-expanded": c,
|
|
381
|
+
className: K(
|
|
355
382
|
"flex h-8 w-full min-w-[10rem] items-center justify-between gap-1 rounded-md border border-slate-200 bg-white px-2 text-left text-[12px] dark:border-border dark:bg-card",
|
|
356
|
-
!
|
|
383
|
+
!i && "text-slate-400"
|
|
357
384
|
),
|
|
358
385
|
children: [
|
|
359
|
-
/* @__PURE__ */
|
|
360
|
-
/* @__PURE__ */
|
|
386
|
+
/* @__PURE__ */ s("span", { className: "truncate", children: $ }),
|
|
387
|
+
/* @__PURE__ */ s(ye, { className: "h-3 w-3 shrink-0 text-slate-400" })
|
|
361
388
|
]
|
|
362
389
|
}
|
|
363
390
|
),
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
const
|
|
367
|
-
return /* @__PURE__ */
|
|
391
|
+
c && m.current && /* @__PURE__ */ k(we, { anchor: m.current, panelRef: p, children: [
|
|
392
|
+
S.map((w) => {
|
|
393
|
+
const x = i === w.id;
|
|
394
|
+
return /* @__PURE__ */ k(
|
|
368
395
|
"button",
|
|
369
396
|
{
|
|
370
397
|
type: "button",
|
|
371
398
|
role: "option",
|
|
372
|
-
"aria-selected":
|
|
399
|
+
"aria-selected": x,
|
|
373
400
|
onClick: () => {
|
|
374
|
-
|
|
401
|
+
a(w.id), y(!1);
|
|
375
402
|
},
|
|
376
|
-
className:
|
|
403
|
+
className: K(
|
|
377
404
|
"flex w-full items-center justify-between px-2.5 py-1.5 text-left text-[12px] hover:bg-slate-50 dark:hover:bg-muted/50",
|
|
378
|
-
|
|
405
|
+
x ? "font-semibold text-nvr-navy dark:text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
|
|
379
406
|
),
|
|
380
407
|
children: [
|
|
381
|
-
/* @__PURE__ */
|
|
382
|
-
|
|
408
|
+
/* @__PURE__ */ s("span", { className: "truncate", children: w.label }),
|
|
409
|
+
x && /* @__PURE__ */ s(ke, { className: "h-3 w-3 shrink-0" })
|
|
383
410
|
]
|
|
384
411
|
},
|
|
385
|
-
|
|
412
|
+
w.id
|
|
386
413
|
);
|
|
387
414
|
}),
|
|
388
|
-
|
|
415
|
+
S.length === 0 && /* @__PURE__ */ s("p", { className: "max-w-[18rem] px-2.5 py-2 text-[11px] text-slate-500 dark:text-muted-foreground", children: q ? Ae(n, h) : "Loading…" })
|
|
389
416
|
] })
|
|
390
417
|
] });
|
|
391
418
|
}
|
|
392
|
-
function
|
|
393
|
-
payload:
|
|
394
|
-
transitionId:
|
|
395
|
-
isRetry:
|
|
396
|
-
onSubmitted:
|
|
397
|
-
executing:
|
|
398
|
-
onClose:
|
|
419
|
+
function gt({
|
|
420
|
+
payload: n,
|
|
421
|
+
transitionId: i,
|
|
422
|
+
isRetry: a,
|
|
423
|
+
onSubmitted: b,
|
|
424
|
+
executing: c = !1,
|
|
425
|
+
onClose: y
|
|
399
426
|
}) {
|
|
400
|
-
var
|
|
401
|
-
const
|
|
402
|
-
() =>
|
|
403
|
-
),
|
|
404
|
-
|
|
405
|
-
if (!(
|
|
427
|
+
var oe;
|
|
428
|
+
const m = ie(), p = Oe(), [h, S] = L(
|
|
429
|
+
() => be(n, !0)
|
|
430
|
+
), q = z(be(n)), [$, _] = L({}), [w, x] = L(!1), [j, O] = L("save"), P = (l) => i ? { ...l, _headers: { [We]: i } } : l, F = (l, u, v) => {
|
|
431
|
+
S((e) => ({ ...e, [l]: { ...e[l], [u]: v } })), _((e) => {
|
|
432
|
+
if (!(l in e)) return e;
|
|
406
433
|
const t = { ...e };
|
|
407
|
-
return delete t[
|
|
434
|
+
return delete t[l], t;
|
|
408
435
|
});
|
|
409
|
-
}, J = (
|
|
410
|
-
const
|
|
436
|
+
}, J = (l, u) => {
|
|
437
|
+
const v = l.rows.map((e) => {
|
|
411
438
|
var t;
|
|
412
|
-
return (t =
|
|
439
|
+
return (t = h[R(l.collection, e.id)]) == null ? void 0 : t[u.field];
|
|
413
440
|
}).find(
|
|
414
441
|
(e) => u.kind === "m2m" ? Array.isArray(e) && e.length > 0 : typeof e == "string" && e.trim()
|
|
415
442
|
);
|
|
416
|
-
|
|
443
|
+
v != null && (S((e) => {
|
|
417
444
|
const t = { ...e };
|
|
418
|
-
for (const
|
|
419
|
-
const f = R(
|
|
420
|
-
t[f] = { ...t[f], [u.field]: Array.isArray(
|
|
445
|
+
for (const r of l.rows) {
|
|
446
|
+
const f = R(l.collection, r.id);
|
|
447
|
+
t[f] = { ...t[f], [u.field]: Array.isArray(v) ? [...v] : v };
|
|
421
448
|
}
|
|
422
449
|
return t;
|
|
423
|
-
}),
|
|
424
|
-
},
|
|
450
|
+
}), _({}));
|
|
451
|
+
}, U = (l, u) => {
|
|
425
452
|
var f;
|
|
426
|
-
const
|
|
427
|
-
if (!
|
|
428
|
-
const e = (f =
|
|
429
|
-
return (Array.isArray(e) ? e : [e]).some((
|
|
430
|
-
}, [
|
|
431
|
-
|
|
453
|
+
const v = u.optional_when;
|
|
454
|
+
if (!v) return !1;
|
|
455
|
+
const e = (f = h[l]) == null ? void 0 : f[v.field], t = new Set(v.in.map(String));
|
|
456
|
+
return (Array.isArray(e) ? e : [e]).some((N) => N != null && N !== "" && t.has(String(N)));
|
|
457
|
+
}, [Se, Ce] = L({}), le = (l, u) => {
|
|
458
|
+
l.trim() && (S((v) => {
|
|
432
459
|
var t;
|
|
433
|
-
const e = { ...
|
|
434
|
-
for (const
|
|
435
|
-
if (
|
|
436
|
-
const f =
|
|
460
|
+
const e = { ...v };
|
|
461
|
+
for (const r of n) {
|
|
462
|
+
if (r.type !== "child_fields") continue;
|
|
463
|
+
const f = r.fields.find((N) => N.field === u);
|
|
437
464
|
if (!(!f || f.kind === "m2m"))
|
|
438
|
-
for (const
|
|
439
|
-
const
|
|
440
|
-
if (
|
|
441
|
-
const
|
|
442
|
-
if ((Array.isArray(
|
|
465
|
+
for (const N of r.rows) {
|
|
466
|
+
const g = R(r.collection, N.id), d = f.optional_when;
|
|
467
|
+
if (d) {
|
|
468
|
+
const o = (t = e[g]) == null ? void 0 : t[d.field], C = new Set(d.in.map(String));
|
|
469
|
+
if ((Array.isArray(o) ? o : [o]).some((A) => A != null && A !== "" && C.has(String(A)))) continue;
|
|
443
470
|
}
|
|
444
|
-
e[
|
|
471
|
+
e[g] = { ...e[g], [u]: l };
|
|
445
472
|
}
|
|
446
473
|
}
|
|
447
474
|
return e;
|
|
448
|
-
}),
|
|
449
|
-
},
|
|
450
|
-
if (
|
|
451
|
-
if (
|
|
452
|
-
const u =
|
|
453
|
-
return
|
|
475
|
+
}), _({}));
|
|
476
|
+
}, $e = n.some((l) => {
|
|
477
|
+
if (l.type === "record_fields") {
|
|
478
|
+
if (l.optional) return !1;
|
|
479
|
+
const u = H(l);
|
|
480
|
+
return l.fields.some((v) => {
|
|
454
481
|
var t;
|
|
455
|
-
if (
|
|
456
|
-
const e = (t =
|
|
457
|
-
return
|
|
482
|
+
if (U(u, v)) return !1;
|
|
483
|
+
const e = (t = h[u]) == null ? void 0 : t[v.field];
|
|
484
|
+
return re(v) ? !Array.isArray(e) || e.length === 0 : !(typeof e == "string" ? e : "").trim();
|
|
458
485
|
});
|
|
459
486
|
}
|
|
460
|
-
return
|
|
461
|
-
const
|
|
462
|
-
return
|
|
463
|
-
var
|
|
464
|
-
if (
|
|
465
|
-
const t = (
|
|
487
|
+
return l.rows.some((u) => {
|
|
488
|
+
const v = R(l.collection, u.id);
|
|
489
|
+
return l.fields.some((e) => {
|
|
490
|
+
var r;
|
|
491
|
+
if (U(v, e)) return !1;
|
|
492
|
+
const t = (r = h[v]) == null ? void 0 : r[e.field];
|
|
466
493
|
return e.kind === "m2m" ? !Array.isArray(t) || t.length === 0 : !(typeof t == "string" ? t : "").trim();
|
|
467
494
|
});
|
|
468
495
|
});
|
|
469
|
-
}),
|
|
470
|
-
const
|
|
471
|
-
for (const f of
|
|
472
|
-
f.kind === "m2m" ||
|
|
473
|
-
return
|
|
474
|
-
},
|
|
475
|
-
const
|
|
476
|
-
for (const u of
|
|
496
|
+
}), se = ((oe = n.find((l) => l.type === "child_fields" && !!l.review)) == null ? void 0 : oe.review_message) ?? null, [T, W] = L(null), Y = z({}), je = (l, u) => {
|
|
497
|
+
const v = R(l.collection, u.id), e = h[v] ?? {}, t = q.current[v] ?? {}, r = {};
|
|
498
|
+
for (const f of l.fields)
|
|
499
|
+
f.kind === "m2m" || U(v, f) || e[f.field] !== t[f.field] && (r[f.field] = f.kind === "m2o" ? String(e[f.field] ?? "") || null : X(String(e[f.field] ?? ""), f.type));
|
|
500
|
+
return r;
|
|
501
|
+
}, Ee = async () => {
|
|
502
|
+
const l = [];
|
|
503
|
+
for (const u of n) {
|
|
477
504
|
if (u.type !== "child_fields") continue;
|
|
478
|
-
const
|
|
505
|
+
const v = (e) => u.display_fields.find((t) => t.field === e) ?? u.fields.find((t) => t.field === e);
|
|
479
506
|
for (const e of u.rows) {
|
|
480
|
-
const t =
|
|
507
|
+
const t = je(u, e);
|
|
481
508
|
if (Object.keys(t).length === 0) continue;
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
() =>
|
|
485
|
-
|
|
509
|
+
const r = R(u.collection, e.id);
|
|
510
|
+
l.push(
|
|
511
|
+
() => m.request(
|
|
512
|
+
P({
|
|
486
513
|
_method: "PATCH",
|
|
487
514
|
_path: `/items/${u.collection}/${e.id}`,
|
|
488
515
|
_params: { dry_run: "1" },
|
|
489
516
|
_body: t
|
|
490
517
|
})
|
|
491
518
|
).then((f) => {
|
|
492
|
-
const
|
|
493
|
-
return
|
|
494
|
-
rk:
|
|
519
|
+
const N = Je(f, t, (g) => !!v(g));
|
|
520
|
+
return N.length === 0 ? null : {
|
|
521
|
+
rk: r,
|
|
495
522
|
rowLabel: e.label,
|
|
496
|
-
changes:
|
|
497
|
-
const
|
|
498
|
-
return { ...
|
|
523
|
+
changes: N.map((g) => {
|
|
524
|
+
const d = v(g.field);
|
|
525
|
+
return { ...g, label: d ? G(d) : te(g.field), format: d == null ? void 0 : d.format };
|
|
499
526
|
})
|
|
500
527
|
};
|
|
501
528
|
}).catch(() => null)
|
|
502
529
|
);
|
|
503
530
|
}
|
|
504
531
|
}
|
|
505
|
-
return (await
|
|
506
|
-
},
|
|
507
|
-
if (
|
|
508
|
-
Y.current =
|
|
532
|
+
return (await he(l)).filter((u) => u != null);
|
|
533
|
+
}, ae = async (l) => {
|
|
534
|
+
if (x(!0), l)
|
|
535
|
+
Y.current = l === "keep" ? Object.fromEntries((T ?? []).map((e) => [e.rk, Qe(e.changes)])) : {}, W(null);
|
|
509
536
|
else {
|
|
510
537
|
Y.current = {};
|
|
511
|
-
const e = await
|
|
538
|
+
const e = await Ee();
|
|
512
539
|
if (e.length > 0) {
|
|
513
|
-
W(e),
|
|
540
|
+
W(e), x(!1);
|
|
514
541
|
return;
|
|
515
542
|
}
|
|
516
543
|
}
|
|
517
|
-
const u = await
|
|
518
|
-
|
|
544
|
+
const u = await he(
|
|
545
|
+
n.flatMap((e) => {
|
|
519
546
|
if (e.type === "record_fields") {
|
|
520
|
-
const t =
|
|
547
|
+
const t = H(e);
|
|
521
548
|
return [
|
|
522
549
|
async () => {
|
|
523
|
-
const
|
|
524
|
-
for (const
|
|
525
|
-
if (
|
|
526
|
-
const
|
|
527
|
-
(E.length > 0 ||
|
|
550
|
+
const r = h[t] ?? {}, f = q.current[t] ?? {}, N = {}, g = [];
|
|
551
|
+
for (const d of e.fields) {
|
|
552
|
+
if (re(d)) {
|
|
553
|
+
const o = Array.isArray(r[d.field]) ? r[d.field] : [], C = Array.isArray(f[d.field]) ? f[d.field] : [], E = o.filter((D) => !C.includes(D)), A = C.filter((D) => !o.includes(D));
|
|
554
|
+
(E.length > 0 || A.length > 0) && g.push({ meta: d, add: E, remove: A });
|
|
528
555
|
continue;
|
|
529
556
|
}
|
|
530
|
-
|
|
557
|
+
r[d.field] !== f[d.field] && (N[d.field] = d.kind === "m2o" || d.kind === "file" ? String(r[d.field] ?? "") || null : X(String(r[d.field] ?? ""), d.type));
|
|
531
558
|
}
|
|
532
|
-
if (Object.keys(
|
|
559
|
+
if (Object.keys(N).length === 0 && g.length === 0)
|
|
533
560
|
return { rk: t, ok: !0 };
|
|
534
561
|
try {
|
|
535
|
-
Object.keys(
|
|
536
|
-
|
|
562
|
+
Object.keys(N).length > 0 && await m.request(
|
|
563
|
+
P(ue(`/items/${e.collection}/${e.item}`, N))
|
|
537
564
|
);
|
|
538
|
-
for (const { meta:
|
|
539
|
-
if (!(!
|
|
565
|
+
for (const { meta: d, add: o, remove: C } of g)
|
|
566
|
+
if (!(!d.junction || !d.fk_to_child || !d.junction_field)) {
|
|
540
567
|
if (C.length > 0) {
|
|
541
|
-
const E = await
|
|
542
|
-
|
|
568
|
+
const E = await m.request(
|
|
569
|
+
Q(`/items/${d.junction}`, {
|
|
543
570
|
limit: 500,
|
|
544
|
-
filter: JSON.stringify({ [
|
|
571
|
+
filter: JSON.stringify({ [d.fk_to_child]: { _eq: e.item } })
|
|
545
572
|
})
|
|
546
573
|
);
|
|
547
|
-
for (const
|
|
548
|
-
C.includes(String(
|
|
574
|
+
for (const A of E.data ?? [])
|
|
575
|
+
C.includes(String(A[d.junction_field])) && await m.request(fe(`/items/${d.junction}/${A.id}`));
|
|
549
576
|
}
|
|
550
|
-
for (const E of
|
|
551
|
-
await
|
|
552
|
-
|
|
553
|
-
[
|
|
554
|
-
[
|
|
577
|
+
for (const E of o)
|
|
578
|
+
await m.request(
|
|
579
|
+
me(`/items/${d.junction}`, {
|
|
580
|
+
[d.fk_to_child]: e.item,
|
|
581
|
+
[d.junction_field]: E
|
|
555
582
|
})
|
|
556
583
|
);
|
|
557
584
|
}
|
|
558
|
-
return
|
|
585
|
+
return p.invalidateQueries({
|
|
559
586
|
queryKey: ["item", e.collection, String(e.item)]
|
|
560
|
-
}), { rk: t, ok: !0, saved: { ...f, ...
|
|
561
|
-
} catch (
|
|
562
|
-
const
|
|
563
|
-
return { rk: t, ok: !1, error: (
|
|
587
|
+
}), { rk: t, ok: !0, saved: { ...f, ...r } };
|
|
588
|
+
} catch (d) {
|
|
589
|
+
const o = d == null ? void 0 : d.response;
|
|
590
|
+
return { rk: t, ok: !1, error: (o == null ? void 0 : o.error) ?? "Failed to save" };
|
|
564
591
|
}
|
|
565
592
|
}
|
|
566
593
|
];
|
|
567
594
|
}
|
|
568
595
|
return e.rows.map((t) => async () => {
|
|
569
|
-
const
|
|
570
|
-
for (const
|
|
571
|
-
if (
|
|
572
|
-
const C = Array.isArray(f[
|
|
573
|
-
(
|
|
596
|
+
const r = R(e.collection, t.id), f = h[r] ?? {}, N = q.current[r] ?? {}, g = {}, d = [];
|
|
597
|
+
for (const o of e.fields) {
|
|
598
|
+
if (o.kind === "m2m") {
|
|
599
|
+
const C = Array.isArray(f[o.field]) ? f[o.field] : [], E = Array.isArray(N[o.field]) ? N[o.field] : [], A = C.filter((Z) => !E.includes(Z)), D = E.filter((Z) => !C.includes(Z));
|
|
600
|
+
(A.length > 0 || D.length > 0) && d.push({ meta: o, add: A, remove: D });
|
|
574
601
|
continue;
|
|
575
602
|
}
|
|
576
|
-
|
|
603
|
+
U(r, o) || f[o.field] !== N[o.field] && (g[o.field] = o.kind === "m2o" ? String(f[o.field] ?? "") || null : X(String(f[o.field] ?? ""), o.type));
|
|
577
604
|
}
|
|
578
|
-
if (Object.keys(
|
|
579
|
-
return { rk:
|
|
580
|
-
if (Object.keys(
|
|
581
|
-
for (const [
|
|
582
|
-
|
|
605
|
+
if (Object.keys(g).length === 0 && d.length === 0)
|
|
606
|
+
return { rk: r, ok: !0 };
|
|
607
|
+
if (Object.keys(g).length > 0)
|
|
608
|
+
for (const [o, C] of Object.entries(Y.current[r] ?? {}))
|
|
609
|
+
o in g || (g[o] = C);
|
|
583
610
|
try {
|
|
584
|
-
Object.keys(
|
|
585
|
-
for (const { meta:
|
|
586
|
-
if (!(!
|
|
611
|
+
Object.keys(g).length > 0 && await m.request(P(ue(`/items/${e.collection}/${t.id}`, g)));
|
|
612
|
+
for (const { meta: o, add: C, remove: E } of d)
|
|
613
|
+
if (!(!o.junction || !o.fk_to_child || !o.junction_field)) {
|
|
587
614
|
if (E.length > 0) {
|
|
588
|
-
const
|
|
589
|
-
|
|
615
|
+
const A = await m.request(
|
|
616
|
+
Q(`/items/${o.junction}`, {
|
|
590
617
|
limit: 500,
|
|
591
|
-
filter: JSON.stringify({ [
|
|
618
|
+
filter: JSON.stringify({ [o.fk_to_child]: { _eq: t.id } })
|
|
592
619
|
})
|
|
593
620
|
);
|
|
594
|
-
for (const
|
|
595
|
-
E.includes(String(
|
|
621
|
+
for (const D of A.data ?? [])
|
|
622
|
+
E.includes(String(D[o.junction_field])) && await m.request(fe(`/items/${o.junction}/${D.id}`));
|
|
596
623
|
}
|
|
597
|
-
for (const
|
|
598
|
-
await
|
|
599
|
-
|
|
600
|
-
[
|
|
601
|
-
[
|
|
624
|
+
for (const A of C)
|
|
625
|
+
await m.request(
|
|
626
|
+
me(`/items/${o.junction}`, {
|
|
627
|
+
[o.fk_to_child]: t.id,
|
|
628
|
+
[o.junction_field]: A
|
|
602
629
|
})
|
|
603
630
|
);
|
|
604
631
|
}
|
|
605
|
-
return
|
|
606
|
-
} catch (
|
|
607
|
-
const C =
|
|
608
|
-
return { rk:
|
|
632
|
+
return p.invalidateQueries({ queryKey: ["item", e.collection, String(t.id)] }), { rk: r, ok: !0, saved: { ...N, ...f } };
|
|
633
|
+
} catch (o) {
|
|
634
|
+
const C = o == null ? void 0 : o.response;
|
|
635
|
+
return { rk: r, ok: !1, error: (C == null ? void 0 : C.error) ?? "Failed to save" };
|
|
609
636
|
}
|
|
610
637
|
});
|
|
611
638
|
})
|
|
612
|
-
),
|
|
639
|
+
), v = u.filter((e) => !e.ok);
|
|
613
640
|
for (const e of u)
|
|
614
|
-
e.ok && e.saved && (
|
|
615
|
-
if (
|
|
616
|
-
|
|
641
|
+
e.ok && e.saved && (q.current[e.rk] = e.saved);
|
|
642
|
+
if (v.length > 0) {
|
|
643
|
+
x(!1), _(Object.fromEntries(v.map((e) => [e.rk, e.ok ? "" : e.error])));
|
|
617
644
|
return;
|
|
618
645
|
}
|
|
619
|
-
|
|
646
|
+
_({}), O("transition");
|
|
620
647
|
try {
|
|
621
|
-
await
|
|
648
|
+
await b();
|
|
622
649
|
} catch {
|
|
623
650
|
} finally {
|
|
624
|
-
|
|
651
|
+
x(!1), O("save");
|
|
625
652
|
}
|
|
626
|
-
},
|
|
627
|
-
return /* @__PURE__ */
|
|
628
|
-
|
|
653
|
+
}, qe = n.length === 1 && n[0].title ? n[0].title : "Required before continuing";
|
|
654
|
+
return /* @__PURE__ */ s(Ue, { open: !0, onOpenChange: (l) => !l && !w && !c && y(), children: /* @__PURE__ */ k(
|
|
655
|
+
Ve,
|
|
629
656
|
{
|
|
630
|
-
className:
|
|
657
|
+
className: K(
|
|
631
658
|
"max-w-2xl",
|
|
632
|
-
|
|
633
|
-
(
|
|
659
|
+
n.some(
|
|
660
|
+
(l) => l.type === "child_fields" && (l.display_fields ?? []).length + l.fields.length > 3
|
|
634
661
|
) && "max-w-5xl"
|
|
635
662
|
),
|
|
636
663
|
style: (() => {
|
|
637
664
|
var u;
|
|
638
|
-
const
|
|
639
|
-
(
|
|
665
|
+
const l = (u = n.find(
|
|
666
|
+
(v) => v.type === "child_fields" && !!v.width
|
|
640
667
|
)) == null ? void 0 : u.width;
|
|
641
|
-
return
|
|
668
|
+
return l ? { width: l, maxWidth: l } : void 0;
|
|
642
669
|
})(),
|
|
643
670
|
children: [
|
|
644
|
-
/* @__PURE__ */
|
|
645
|
-
/* @__PURE__ */
|
|
671
|
+
/* @__PURE__ */ s(Ie, { children: /* @__PURE__ */ s(Me, { className: "text-[15px]", children: qe }) }),
|
|
672
|
+
/* @__PURE__ */ k(
|
|
646
673
|
Be,
|
|
647
674
|
{
|
|
648
|
-
className:
|
|
675
|
+
className: K(
|
|
649
676
|
"max-h-[60vh] space-y-5 overflow-y-auto",
|
|
650
|
-
(
|
|
677
|
+
(w || c) && "pointer-events-none opacity-60 transition-opacity"
|
|
651
678
|
),
|
|
652
679
|
children: [
|
|
653
|
-
|
|
654
|
-
/* @__PURE__ */
|
|
680
|
+
a && /* @__PURE__ */ k("p", { className: "flex items-center gap-2 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] text-amber-700 dark:border-amber-500/20 dark:bg-amber-500/10 dark:text-amber-400", children: [
|
|
681
|
+
/* @__PURE__ */ s("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full bg-amber-400" }),
|
|
655
682
|
"Values changed since your last attempt — review the highlighted rows."
|
|
656
683
|
] }),
|
|
657
|
-
|
|
684
|
+
T && /* @__PURE__ */ k(
|
|
658
685
|
"div",
|
|
659
686
|
{
|
|
660
687
|
"data-req-side-effects": !0,
|
|
661
688
|
className: "rounded-md border border-amber-200 bg-amber-50 px-3 py-2.5 text-[12px] text-amber-800 dark:border-amber-500/20 dark:bg-amber-500/10 dark:text-amber-300",
|
|
662
689
|
children: [
|
|
663
|
-
/* @__PURE__ */
|
|
664
|
-
/* @__PURE__ */
|
|
690
|
+
/* @__PURE__ */ k("p", { className: "flex items-center gap-2 font-medium", children: [
|
|
691
|
+
/* @__PURE__ */ s(I, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
665
692
|
"Your choices also change values these lines already have"
|
|
666
693
|
] }),
|
|
667
|
-
/* @__PURE__ */
|
|
668
|
-
(
|
|
669
|
-
|
|
694
|
+
/* @__PURE__ */ s("ul", { className: "mt-1.5 space-y-0.5 pl-5", children: T.flatMap(
|
|
695
|
+
(l) => l.changes.map((u) => /* @__PURE__ */ k("li", { children: [
|
|
696
|
+
l.rowLabel,
|
|
670
697
|
" · ",
|
|
671
698
|
u.label,
|
|
672
699
|
": ",
|
|
673
|
-
|
|
700
|
+
M(u.from, u.format) || "—",
|
|
674
701
|
" →",
|
|
675
702
|
" ",
|
|
676
|
-
/* @__PURE__ */
|
|
677
|
-
] }, `${
|
|
703
|
+
/* @__PURE__ */ s("span", { className: "font-medium", children: M(u.to, u.format) || "—" })
|
|
704
|
+
] }, `${l.rk}:${u.field}`))
|
|
678
705
|
) }),
|
|
679
|
-
/* @__PURE__ */
|
|
706
|
+
/* @__PURE__ */ s("p", { className: "mt-1.5 text-[11.5px] text-amber-700/90 dark:text-amber-300/80", children: "Keep the current values, or apply every change." })
|
|
680
707
|
]
|
|
681
708
|
}
|
|
682
709
|
),
|
|
683
|
-
|
|
684
|
-
/* @__PURE__ */
|
|
685
|
-
|
|
710
|
+
se && !a && /* @__PURE__ */ k("p", { className: "flex items-center gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[12px] text-red-700 dark:border-red-500/20 dark:bg-red-500/10 dark:text-red-400", children: [
|
|
711
|
+
/* @__PURE__ */ s(I, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
712
|
+
se
|
|
686
713
|
] }),
|
|
687
|
-
|
|
688
|
-
if (
|
|
689
|
-
const e =
|
|
690
|
-
return /* @__PURE__ */
|
|
691
|
-
|
|
692
|
-
/* @__PURE__ */
|
|
693
|
-
var f,
|
|
694
|
-
const
|
|
695
|
-
return /* @__PURE__ */
|
|
696
|
-
/* @__PURE__ */
|
|
697
|
-
t.kind === "m2o" ? /* @__PURE__ */
|
|
698
|
-
|
|
714
|
+
n.map((l) => {
|
|
715
|
+
if (l.type === "record_fields") {
|
|
716
|
+
const e = H(l);
|
|
717
|
+
return /* @__PURE__ */ k("div", { className: "space-y-2", children: [
|
|
718
|
+
n.length > 1 && /* @__PURE__ */ s("h4", { className: "text-[12px] font-semibold text-slate-500", children: l.title }),
|
|
719
|
+
/* @__PURE__ */ s("div", { className: "grid grid-cols-1 gap-3 rounded-md border border-slate-200 p-3 sm:grid-cols-2 dark:border-border", children: l.fields.map((t) => {
|
|
720
|
+
var f, N;
|
|
721
|
+
const r = (f = h[e]) == null ? void 0 : f[t.field];
|
|
722
|
+
return /* @__PURE__ */ k("div", { className: "space-y-1", children: [
|
|
723
|
+
/* @__PURE__ */ s("label", { className: "text-[11px] font-medium text-slate-500", children: t.label }),
|
|
724
|
+
t.kind === "m2o" ? /* @__PURE__ */ s(
|
|
725
|
+
xe,
|
|
699
726
|
{
|
|
700
727
|
meta: t,
|
|
701
|
-
selected: typeof
|
|
702
|
-
onChange: (
|
|
728
|
+
selected: typeof r == "string" ? r : "",
|
|
729
|
+
onChange: (g) => F(e, t.field, g)
|
|
703
730
|
}
|
|
704
|
-
) : t.kind === "m2m" ? /* @__PURE__ */
|
|
705
|
-
|
|
731
|
+
) : t.kind === "m2m" ? /* @__PURE__ */ s(
|
|
732
|
+
ge,
|
|
706
733
|
{
|
|
707
734
|
meta: t,
|
|
708
|
-
selected: Array.isArray(
|
|
709
|
-
onChange: (
|
|
735
|
+
selected: Array.isArray(r) ? r : [],
|
|
736
|
+
onChange: (g) => F(e, t.field, g)
|
|
710
737
|
}
|
|
711
|
-
) : t.kind === "file" || t.kind === "files" ? /* @__PURE__ */
|
|
712
|
-
|
|
738
|
+
) : t.kind === "file" || t.kind === "files" ? /* @__PURE__ */ s(
|
|
739
|
+
Xe,
|
|
713
740
|
{
|
|
714
741
|
multiple: t.kind === "files",
|
|
715
|
-
ids: Array.isArray(
|
|
716
|
-
initialNames:
|
|
717
|
-
onChange: (
|
|
742
|
+
ids: Array.isArray(r) ? r : typeof r == "string" && r ? [r] : [],
|
|
743
|
+
initialNames: Ze(l.display[t.field]),
|
|
744
|
+
onChange: (g) => F(
|
|
718
745
|
e,
|
|
719
746
|
t.field,
|
|
720
|
-
t.kind === "files" ?
|
|
747
|
+
t.kind === "files" ? g : g[0] ?? ""
|
|
721
748
|
)
|
|
722
749
|
}
|
|
723
|
-
) : (
|
|
724
|
-
/* @__PURE__ */
|
|
725
|
-
|
|
750
|
+
) : (N = l.copy_to_lines) != null && N[t.field] ? /* @__PURE__ */ k("div", { className: "flex items-center gap-1.5", children: [
|
|
751
|
+
/* @__PURE__ */ s(
|
|
752
|
+
V,
|
|
726
753
|
{
|
|
727
|
-
value: typeof
|
|
728
|
-
onChange: (
|
|
754
|
+
value: typeof r == "string" ? r : "",
|
|
755
|
+
onChange: (g) => F(e, t.field, g.target.value),
|
|
729
756
|
placeholder: t.label,
|
|
730
757
|
className: "h-8 w-full text-[12px]"
|
|
731
758
|
}
|
|
732
759
|
),
|
|
733
|
-
/* @__PURE__ */
|
|
760
|
+
/* @__PURE__ */ s(
|
|
734
761
|
"button",
|
|
735
762
|
{
|
|
736
763
|
type: "button",
|
|
737
|
-
disabled: !(typeof
|
|
764
|
+
disabled: !(typeof r == "string" && r.trim()),
|
|
738
765
|
onClick: () => {
|
|
739
|
-
var
|
|
740
|
-
return
|
|
741
|
-
typeof
|
|
742
|
-
(
|
|
766
|
+
var g;
|
|
767
|
+
return le(
|
|
768
|
+
typeof r == "string" ? r : "",
|
|
769
|
+
(g = l.copy_to_lines) == null ? void 0 : g[t.field]
|
|
743
770
|
);
|
|
744
771
|
},
|
|
745
772
|
title: "Copy this value to every available line",
|
|
@@ -747,53 +774,53 @@ function ft({
|
|
|
747
774
|
children: "Apply to lines ↓"
|
|
748
775
|
}
|
|
749
776
|
)
|
|
750
|
-
] }) : /* @__PURE__ */
|
|
751
|
-
|
|
777
|
+
] }) : /* @__PURE__ */ s(
|
|
778
|
+
V,
|
|
752
779
|
{
|
|
753
|
-
value: typeof
|
|
754
|
-
onChange: (
|
|
780
|
+
value: typeof r == "string" ? r : "",
|
|
781
|
+
onChange: (g) => F(e, t.field, g.target.value),
|
|
755
782
|
placeholder: t.label,
|
|
756
783
|
className: "h-8 w-full text-[12px]"
|
|
757
784
|
}
|
|
758
785
|
)
|
|
759
786
|
] }, t.field);
|
|
760
787
|
}) }),
|
|
761
|
-
|
|
762
|
-
/* @__PURE__ */
|
|
763
|
-
|
|
788
|
+
$[e] && /* @__PURE__ */ k("p", { className: "flex items-center gap-1 text-[11px] text-red-600", children: [
|
|
789
|
+
/* @__PURE__ */ s(I, { className: "h-3 w-3 shrink-0" }),
|
|
790
|
+
$[e]
|
|
764
791
|
] })
|
|
765
792
|
] }, e);
|
|
766
793
|
}
|
|
767
|
-
const u =
|
|
768
|
-
return /* @__PURE__ */
|
|
794
|
+
const u = l.display_fields ?? [], v = 1 + u.length + l.fields.length;
|
|
795
|
+
return /* @__PURE__ */ k(
|
|
769
796
|
"div",
|
|
770
797
|
{
|
|
771
798
|
className: "space-y-2",
|
|
772
799
|
children: [
|
|
773
|
-
|
|
774
|
-
(
|
|
775
|
-
const t = `__bulk__:${
|
|
776
|
-
return /* @__PURE__ */
|
|
800
|
+
n.length > 1 && /* @__PURE__ */ s("h4", { className: "text-[12px] font-semibold text-slate-500", children: l.title }),
|
|
801
|
+
(l.apply_all ?? []).map((e) => l.fields.find((t) => t.field === e)).filter((e) => !!e && e.kind !== "m2m").map((e) => {
|
|
802
|
+
const t = `__bulk__:${l.collection}:${e.field}`, r = Se[t] ?? "";
|
|
803
|
+
return /* @__PURE__ */ k(
|
|
777
804
|
"div",
|
|
778
805
|
{
|
|
779
806
|
className: "flex items-center gap-2 rounded-md border border-slate-200 bg-slate-50/60 px-3 py-2 dark:border-border dark:bg-white/[0.03]",
|
|
780
807
|
children: [
|
|
781
|
-
/* @__PURE__ */
|
|
782
|
-
/* @__PURE__ */
|
|
783
|
-
|
|
808
|
+
/* @__PURE__ */ s("label", { className: "shrink-0 text-[11px] font-medium text-slate-500", children: e.label }),
|
|
809
|
+
/* @__PURE__ */ s(
|
|
810
|
+
V,
|
|
784
811
|
{
|
|
785
|
-
value:
|
|
786
|
-
onChange: (f) =>
|
|
812
|
+
value: r,
|
|
813
|
+
onChange: (f) => Ce((N) => ({ ...N, [t]: f.target.value })),
|
|
787
814
|
placeholder: `${e.label} for every line…`,
|
|
788
815
|
className: "h-8 w-full max-w-xs text-[12px]"
|
|
789
816
|
}
|
|
790
817
|
),
|
|
791
|
-
/* @__PURE__ */
|
|
818
|
+
/* @__PURE__ */ s(
|
|
792
819
|
"button",
|
|
793
820
|
{
|
|
794
821
|
type: "button",
|
|
795
|
-
disabled: !
|
|
796
|
-
onClick: () =>
|
|
822
|
+
disabled: !r.trim(),
|
|
823
|
+
onClick: () => le(r, e.field),
|
|
797
824
|
className: "h-8 shrink-0 whitespace-nowrap rounded-md bg-nvr-cyan px-3 text-[11px] font-medium text-white transition-colors hover:opacity-90 disabled:opacity-40",
|
|
798
825
|
children: "Apply to all lines"
|
|
799
826
|
}
|
|
@@ -803,34 +830,34 @@ function ft({
|
|
|
803
830
|
t
|
|
804
831
|
);
|
|
805
832
|
}),
|
|
806
|
-
/* @__PURE__ */
|
|
807
|
-
/* @__PURE__ */
|
|
808
|
-
/* @__PURE__ */
|
|
809
|
-
u.map((e) => /* @__PURE__ */
|
|
810
|
-
|
|
811
|
-
e
|
|
812
|
-
|
|
833
|
+
/* @__PURE__ */ s("div", { className: "overflow-x-auto rounded-md border border-slate-200 dark:border-border", children: /* @__PURE__ */ k("table", { className: "w-full border-collapse text-[12px]", children: [
|
|
834
|
+
/* @__PURE__ */ s("thead", { children: /* @__PURE__ */ k("tr", { className: "border-b border-slate-200 bg-slate-50/60 text-left text-[11px] font-medium text-slate-400 dark:border-border dark:bg-white/[0.02]", children: [
|
|
835
|
+
/* @__PURE__ */ s("th", { className: "px-2.5 py-1.5 font-medium", children: "Row" }),
|
|
836
|
+
u.map((e) => /* @__PURE__ */ s("th", { className: "px-2.5 py-1.5 font-medium", children: G(e) }, e.field)),
|
|
837
|
+
l.fields.map((e) => /* @__PURE__ */ s("th", { className: "w-40 px-2.5 py-1.5 font-medium", children: /* @__PURE__ */ k("span", { className: "flex items-center gap-1.5", children: [
|
|
838
|
+
G(e),
|
|
839
|
+
l.rows.length > 1 && /* @__PURE__ */ s(
|
|
813
840
|
"button",
|
|
814
841
|
{
|
|
815
842
|
type: "button",
|
|
816
|
-
onClick: () => J(
|
|
843
|
+
onClick: () => J(l, e),
|
|
817
844
|
title: `Apply the first ${e.label} to all lines`,
|
|
818
845
|
className: "rounded p-0.5 text-slate-300 transition-colors hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-muted/50",
|
|
819
|
-
children: /* @__PURE__ */
|
|
846
|
+
children: /* @__PURE__ */ s(Fe, { className: "h-3 w-3" })
|
|
820
847
|
}
|
|
821
848
|
)
|
|
822
849
|
] }) }, e.field))
|
|
823
850
|
] }) }),
|
|
824
|
-
/* @__PURE__ */
|
|
825
|
-
const t = R(
|
|
826
|
-
return /* @__PURE__ */
|
|
827
|
-
/* @__PURE__ */
|
|
828
|
-
/* @__PURE__ */
|
|
829
|
-
!e.complete && /* @__PURE__ */
|
|
830
|
-
/* @__PURE__ */
|
|
851
|
+
/* @__PURE__ */ s("tbody", { children: l.rows.map((e) => {
|
|
852
|
+
const t = R(l.collection, e.id);
|
|
853
|
+
return /* @__PURE__ */ k(De, { children: [
|
|
854
|
+
/* @__PURE__ */ k("tr", { className: "border-b border-slate-100 last:border-b-0 dark:border-border/50", children: [
|
|
855
|
+
/* @__PURE__ */ s("td", { className: "max-w-[220px] px-2.5 py-1.5", children: /* @__PURE__ */ k("span", { className: "flex items-center gap-1.5", children: [
|
|
856
|
+
!e.complete && /* @__PURE__ */ s("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full bg-amber-400 animate-pulse" }),
|
|
857
|
+
/* @__PURE__ */ s(
|
|
831
858
|
"span",
|
|
832
859
|
{
|
|
833
|
-
className:
|
|
860
|
+
className: K(
|
|
834
861
|
"truncate",
|
|
835
862
|
e.complete ? "text-slate-400" : "font-medium text-slate-700"
|
|
836
863
|
),
|
|
@@ -839,110 +866,110 @@ function ft({
|
|
|
839
866
|
}
|
|
840
867
|
)
|
|
841
868
|
] }) }),
|
|
842
|
-
u.map((
|
|
843
|
-
var f,
|
|
844
|
-
return /* @__PURE__ */
|
|
869
|
+
u.map((r) => {
|
|
870
|
+
var f, N;
|
|
871
|
+
return /* @__PURE__ */ s(
|
|
845
872
|
"td",
|
|
846
873
|
{
|
|
847
|
-
className:
|
|
874
|
+
className: K(
|
|
848
875
|
"max-w-[200px] truncate px-2.5 py-1.5 text-slate-500",
|
|
849
|
-
|
|
876
|
+
r.format && "text-right tabular-nums"
|
|
850
877
|
),
|
|
851
|
-
title:
|
|
852
|
-
children:
|
|
878
|
+
title: M((f = e.display) == null ? void 0 : f[r.field], r.format),
|
|
879
|
+
children: M((N = e.display) == null ? void 0 : N[r.field], r.format) || "—"
|
|
853
880
|
},
|
|
854
|
-
|
|
881
|
+
r.field
|
|
855
882
|
);
|
|
856
883
|
}),
|
|
857
|
-
|
|
858
|
-
var f,
|
|
859
|
-
return /* @__PURE__ */
|
|
860
|
-
|
|
884
|
+
l.fields.map((r) => {
|
|
885
|
+
var f, N, g, d, o, C, E;
|
|
886
|
+
return /* @__PURE__ */ s("td", { className: "px-2 py-1", children: r.kind === "m2m" ? /* @__PURE__ */ s(
|
|
887
|
+
ge,
|
|
861
888
|
{
|
|
862
|
-
meta:
|
|
863
|
-
selected: Array.isArray((f =
|
|
864
|
-
onChange: (
|
|
865
|
-
rowValues: { ...e.cascade_values, ...
|
|
889
|
+
meta: r,
|
|
890
|
+
selected: Array.isArray((f = h[t]) == null ? void 0 : f[r.field]) ? (N = h[t]) == null ? void 0 : N[r.field] : [],
|
|
891
|
+
onChange: (A) => F(t, r.field, A),
|
|
892
|
+
rowValues: { ...e.cascade_values, ...h[t] }
|
|
866
893
|
}
|
|
867
|
-
) :
|
|
868
|
-
|
|
894
|
+
) : U(t, r) ? /* @__PURE__ */ s(
|
|
895
|
+
V,
|
|
869
896
|
{
|
|
870
897
|
value: "",
|
|
871
898
|
disabled: !0,
|
|
872
899
|
readOnly: !0,
|
|
873
|
-
placeholder: ((
|
|
900
|
+
placeholder: ((g = r.optional_when) == null ? void 0 : g.placeholder) ?? "Auto-assigned",
|
|
874
901
|
title: "Assigned automatically after submission",
|
|
875
902
|
className: "h-8 w-full min-w-[9rem] bg-slate-50 text-[12px] italic dark:bg-muted/50"
|
|
876
903
|
}
|
|
877
|
-
) :
|
|
878
|
-
|
|
904
|
+
) : r.kind === "m2o" ? /* @__PURE__ */ s(
|
|
905
|
+
xe,
|
|
879
906
|
{
|
|
880
|
-
meta:
|
|
881
|
-
selected: typeof ((
|
|
882
|
-
onChange: (
|
|
883
|
-
rowValues: { ...e.cascade_values, ...
|
|
907
|
+
meta: r,
|
|
908
|
+
selected: typeof ((d = h[t]) == null ? void 0 : d[r.field]) == "string" ? (o = h[t]) == null ? void 0 : o[r.field] : "",
|
|
909
|
+
onChange: (A) => F(t, r.field, A),
|
|
910
|
+
rowValues: { ...e.cascade_values, ...h[t] }
|
|
884
911
|
}
|
|
885
|
-
) : /* @__PURE__ */
|
|
886
|
-
|
|
912
|
+
) : /* @__PURE__ */ s(
|
|
913
|
+
V,
|
|
887
914
|
{
|
|
888
|
-
value: typeof ((C =
|
|
889
|
-
onChange: (
|
|
890
|
-
placeholder:
|
|
915
|
+
value: typeof ((C = h[t]) == null ? void 0 : C[r.field]) == "string" ? (E = h[t]) == null ? void 0 : E[r.field] : "",
|
|
916
|
+
onChange: (A) => F(t, r.field, A.target.value),
|
|
917
|
+
placeholder: r.label,
|
|
891
918
|
className: "h-8 w-full min-w-[9rem] text-[12px]"
|
|
892
919
|
}
|
|
893
|
-
) },
|
|
920
|
+
) }, r.field);
|
|
894
921
|
})
|
|
895
922
|
] }),
|
|
896
|
-
|
|
897
|
-
/* @__PURE__ */
|
|
898
|
-
|
|
923
|
+
$[t] && /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s("td", { colSpan: v, className: "px-2.5 pb-1.5", children: /* @__PURE__ */ k("p", { className: "flex items-center gap-1 text-[11px] text-red-600", children: [
|
|
924
|
+
/* @__PURE__ */ s(I, { className: "h-3 w-3 shrink-0" }),
|
|
925
|
+
$[t]
|
|
899
926
|
] }) }) })
|
|
900
927
|
] }, t);
|
|
901
928
|
}) })
|
|
902
929
|
] }) })
|
|
903
930
|
]
|
|
904
931
|
},
|
|
905
|
-
`${
|
|
932
|
+
`${l.collection}-${l.fk_field}-${l.title}`
|
|
906
933
|
);
|
|
907
934
|
})
|
|
908
935
|
]
|
|
909
936
|
}
|
|
910
937
|
),
|
|
911
|
-
/* @__PURE__ */
|
|
912
|
-
(
|
|
913
|
-
/* @__PURE__ */
|
|
914
|
-
|
|
938
|
+
/* @__PURE__ */ k(He, { className: "items-center", children: [
|
|
939
|
+
(w || c) && /* @__PURE__ */ k("span", { className: "mr-auto flex items-center gap-2 text-[12px] text-slate-500 dark:text-slate-400", children: [
|
|
940
|
+
/* @__PURE__ */ s(ee, { className: "h-3.5 w-3.5 animate-spin text-nvr-cyan" }),
|
|
941
|
+
w ? "Saving line values…" : "Submitting — contacting external systems, this can take a few seconds…"
|
|
915
942
|
] }),
|
|
916
|
-
/* @__PURE__ */
|
|
917
|
-
|
|
943
|
+
/* @__PURE__ */ s(
|
|
944
|
+
B,
|
|
918
945
|
{
|
|
919
946
|
type: "button",
|
|
920
947
|
variant: "outline",
|
|
921
|
-
onClick:
|
|
922
|
-
disabled:
|
|
923
|
-
children:
|
|
948
|
+
onClick: T ? () => W(null) : y,
|
|
949
|
+
disabled: w || c,
|
|
950
|
+
children: T ? "Back" : "Cancel"
|
|
924
951
|
}
|
|
925
952
|
),
|
|
926
|
-
|
|
927
|
-
|
|
953
|
+
T && /* @__PURE__ */ s(
|
|
954
|
+
B,
|
|
928
955
|
{
|
|
929
956
|
type: "button",
|
|
930
957
|
variant: "outline",
|
|
931
|
-
onClick: () => void
|
|
932
|
-
disabled:
|
|
958
|
+
onClick: () => void ae("keep"),
|
|
959
|
+
disabled: w || c,
|
|
933
960
|
children: "Keep current values"
|
|
934
961
|
}
|
|
935
962
|
),
|
|
936
|
-
/* @__PURE__ */
|
|
937
|
-
|
|
963
|
+
/* @__PURE__ */ s(
|
|
964
|
+
B,
|
|
938
965
|
{
|
|
939
966
|
type: "button",
|
|
940
|
-
onClick: () => void
|
|
941
|
-
disabled:
|
|
942
|
-
children:
|
|
943
|
-
/* @__PURE__ */
|
|
944
|
-
|
|
945
|
-
] }) :
|
|
967
|
+
onClick: () => void ae(T ? "apply" : void 0),
|
|
968
|
+
disabled: w || c || $e,
|
|
969
|
+
children: w || c ? /* @__PURE__ */ k("span", { className: "flex items-center gap-1.5", children: [
|
|
970
|
+
/* @__PURE__ */ s(ee, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
971
|
+
w && j === "save" ? "Saving…" : "Submitting…"
|
|
972
|
+
] }) : T ? "Apply all changes" : "Submit"
|
|
946
973
|
}
|
|
947
974
|
)
|
|
948
975
|
] })
|
|
@@ -951,7 +978,10 @@ function ft({
|
|
|
951
978
|
) });
|
|
952
979
|
}
|
|
953
980
|
export {
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
981
|
+
gt as TransitionRequirementsDialog,
|
|
982
|
+
G as columnLabel,
|
|
983
|
+
Ae as emptyOptionsText,
|
|
984
|
+
M as fmtDisplay,
|
|
985
|
+
Ge as relatedOptionLabel,
|
|
986
|
+
Ne as requirementOptionFilter
|
|
957
987
|
};
|