@nivaro/react 0.3.111 → 0.3.113
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 +207 -3
- package/dist/index.js +745 -728
- package/dist/shared/components/CollectionBrowserView.js +3133 -2954
- package/dist/shared/components/CollectionImportBanner.js +135 -0
- package/dist/shared/components/ItemEditForm.js +2235 -2218
- package/dist/shared/components/JobsTray.js +54 -47
- package/dist/shared/components/ViewAsPersonButton.js +109 -0
- package/dist/shared/components/bulk/BulkFieldUpdate.js +228 -150
- package/dist/shared/components/bulk/BulkFieldUpdateButton.js +35 -41
- package/dist/shared/components/bulk/BulkLinksValue.js +91 -0
- package/dist/shared/components/bulk/bulk-field-options.js +20 -19
- package/dist/shared/components/bulk/bulk-update-preview.js +39 -0
- package/dist/shared/components/cbv/ColumnHeaderMenu.js +130 -0
- package/dist/shared/components/cbv/column-totals.js +163 -0
- package/dist/shared/components/collections-directory/CollectionHoverCard.js +108 -81
- package/dist/shared/components/collections-directory/CollectionRow.js +164 -148
- package/dist/shared/components/collections-directory/CollectionsDirectory.js +167 -166
- package/dist/shared/components/collections-directory/directory-data.js +70 -58
- package/dist/shared/components/imports/CollectionImportPanel.js +120 -118
- package/dist/shared/components/imports/DefinitionsPanel.js +24 -24
- package/dist/shared/components/imports/ImportDuplicatesNotice.js +65 -0
- package/dist/shared/components/item-edit/CatalogPickerField.js +631 -639
- package/dist/shared/components/item-edit/DuplicateNotice.js +168 -0
- package/dist/shared/components/item-edit/FieldRow.js +248 -246
- package/dist/shared/components/item-edit/InlineGridField.js +34 -33
- package/dist/shared/components/item-edit/InlineTableField.js +3002 -2825
- package/dist/shared/components/item-edit/MembershipSetField.js +165 -169
- package/dist/shared/components/item-edit/NestedRelationEditor.js +184 -189
- package/dist/shared/components/item-edit/PlanGrid.js +2 -1
- package/dist/shared/components/item-edit/QuickPickerDialog.js +35 -34
- package/dist/shared/components/item-edit/RecordLiveSync.js +32 -30
- package/dist/shared/components/item-edit/RelationCombobox.js +101 -100
- package/dist/shared/components/item-edit/RowHistorySheet.js +28 -27
- package/dist/shared/components/item-edit/SummaryPanel.js +133 -135
- package/dist/shared/components/item-edit/UserChip.js +262 -239
- package/dist/shared/components/item-edit/ViewAsRole.js +129 -52
- package/dist/shared/components/item-edit/grid-search.js +375 -0
- package/dist/shared/components/item-edit/render-stability.js +61 -54
- package/dist/shared/components/notifications/NotificationRulesEditor.js +25 -20
- package/dist/shared/components/ops-report/DigestSections.js +163 -144
- package/dist/shared/components/ops-report/drill.js +97 -97
- package/dist/shared/components/panels/AddendumLinesDiff.js +52 -51
- package/dist/shared/components/panels/AddendumPanel.js +92 -91
- package/dist/shared/components/panels/AsyncUserPicker.js +108 -0
- package/dist/shared/components/panels/CommentPanel.js +265 -252
- package/dist/shared/components/panels/OwnersSlot.js +47 -35
- package/dist/shared/components/panels/PipelineInsight.js +186 -0
- package/dist/shared/components/panels/PipelinePanel.js +1440 -1397
- package/dist/shared/components/panels/RecordIntegrityBanner.js +39 -38
- package/dist/shared/components/panels/RevisionsPanel.js +261 -260
- package/dist/shared/components/panels/StandInReason.js +69 -0
- package/dist/shared/components/pipeline/FieldPicker.js +41 -40
- package/dist/shared/components/pipeline/OwnerMatrix.js +829 -700
- package/dist/shared/components/pipeline/OwnerRecordTrial.js +362 -0
- package/dist/shared/components/pipeline/PipelineEditorView.js +483 -467
- package/dist/shared/components/pipeline/PipelineStateOwners.js +65 -64
- package/dist/shared/components/pipeline/owner-matrix-draft.js +178 -0
- package/dist/shared/components/profile/MyDefaultsCard.js +36 -35
- package/dist/shared/components/profile/PersonHeader.js +29 -29
- package/dist/shared/components/profile/PersonProfile.js +30 -28
- package/dist/shared/components/profile/SlowScreensCard.js +286 -0
- package/dist/shared/components/queue/QueueWorklist.js +1090 -1071
- package/dist/shared/components/quick-filters/useQuickFilterEditing.js +45 -44
- package/dist/shared/components/support/TicketDetailSheet.js +25 -16
- package/dist/shared/components/support/TicketSlowScreens.js +32 -0
- package/dist/shared/lib/activity-sentence.js +224 -178
- package/dist/shared/lib/collection-import-banner.js +27 -0
- package/dist/shared/lib/crash-report.js +112 -0
- package/dist/shared/lib/export-runs.js +99 -0
- package/dist/shared/lib/jobs-tray.js +89 -67
- package/dist/shared/lib/list-link.js +76 -69
- package/dist/shared/lib/nav-trail.js +180 -76
- package/dist/shared/lib/query-keys.js +26 -0
- package/dist/shared/lib/view-as.js +16 -11
- package/package.json +1 -1
|
@@ -1,64 +1,72 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQuery as
|
|
3
|
-
import { ArrowLeft as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useNivaroClient as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { jsxs as a, jsx as t, Fragment as ee } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as A } from "@tanstack/react-query";
|
|
3
|
+
import { ArrowLeft as te, Lock as re } from "lucide-react";
|
|
4
|
+
import { useState as g, useRef as W, useEffect as X, useMemo as j } from "react";
|
|
5
|
+
import { useNivaroClient as ae } from "../../context.js";
|
|
6
|
+
import { useDebounced as le } from "../../hooks/useDebounced.js";
|
|
7
|
+
import { post as Y, get as z } from "../../lib/commands.js";
|
|
8
|
+
import { cn as H } from "../../lib/utils.js";
|
|
9
|
+
import { FieldRenderer as ne } from "../item-edit/FieldRenderer.js";
|
|
10
|
+
import { Command as oe, CommandInput as de, CommandList as se, CommandEmpty as ie, CommandGroup as ue, CommandItem as ce } from "../ui/command.js";
|
|
11
|
+
import { Popover as me, PopoverTrigger as pe, PopoverContent as fe } from "../ui/popover.js";
|
|
12
|
+
import { Skeleton as x } from "../ui/skeleton.js";
|
|
13
|
+
import { BulkLinksValue as be } from "./BulkLinksValue.js";
|
|
14
|
+
import { bulkFieldSections as he, bulkFieldNote as R } from "./bulk-field-options.js";
|
|
15
|
+
import { bulkLinksValue as xe, bulkPreviewSentence as ge } from "./bulk-update-preview.js";
|
|
16
|
+
function Ee({
|
|
17
|
+
collection: d,
|
|
18
|
+
selectedIds: b,
|
|
19
|
+
disabled: i,
|
|
20
|
+
className: P,
|
|
21
|
+
onApply: T,
|
|
22
|
+
onSaveRecipe: w,
|
|
23
|
+
pointAt: u
|
|
20
24
|
}) {
|
|
21
|
-
const [
|
|
22
|
-
return
|
|
23
|
-
|
|
25
|
+
const [C, l] = g(!1), [y, L] = g(null), v = W(null);
|
|
26
|
+
return X(() => {
|
|
27
|
+
!u || i || u.nonce === v.current || (v.current = u.nonce, L(u.field), l(!0));
|
|
28
|
+
}, [u, i]), /* @__PURE__ */ a(
|
|
29
|
+
me,
|
|
24
30
|
{
|
|
25
|
-
open:
|
|
26
|
-
onOpenChange: (
|
|
27
|
-
(!
|
|
31
|
+
open: C,
|
|
32
|
+
onOpenChange: (o) => {
|
|
33
|
+
(!i || !o) && l(o), o || L(null);
|
|
28
34
|
},
|
|
29
35
|
children: [
|
|
30
|
-
/* @__PURE__ */
|
|
36
|
+
/* @__PURE__ */ t(pe, { asChild: !0, children: /* @__PURE__ */ t(
|
|
31
37
|
"button",
|
|
32
38
|
{
|
|
33
39
|
type: "button",
|
|
34
|
-
disabled:
|
|
40
|
+
disabled: i,
|
|
35
41
|
"data-bulk-update-field": !0,
|
|
36
|
-
className:
|
|
42
|
+
className: P,
|
|
37
43
|
"aria-haspopup": "dialog",
|
|
38
44
|
children: "Update Field"
|
|
39
45
|
}
|
|
40
46
|
) }),
|
|
41
|
-
/* @__PURE__ */
|
|
42
|
-
|
|
47
|
+
/* @__PURE__ */ t(
|
|
48
|
+
fe,
|
|
43
49
|
{
|
|
44
50
|
side: "top",
|
|
45
51
|
align: "end",
|
|
46
52
|
sideOffset: 8,
|
|
47
53
|
className: "w-[380px] max-w-[calc(100vw-24px)] p-0",
|
|
48
|
-
onOpenAutoFocus: (
|
|
49
|
-
children:
|
|
50
|
-
|
|
54
|
+
onOpenAutoFocus: (o) => o.preventDefault(),
|
|
55
|
+
children: C && /* @__PURE__ */ t(
|
|
56
|
+
ye,
|
|
51
57
|
{
|
|
52
|
-
collection:
|
|
53
|
-
selectedIds:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
collection: d,
|
|
59
|
+
selectedIds: b,
|
|
60
|
+
initialField: y,
|
|
61
|
+
onCancel: () => l(!1),
|
|
62
|
+
onApply: (o, e) => {
|
|
63
|
+
l(!1), T(o, e);
|
|
57
64
|
},
|
|
58
|
-
onSaveRecipe:
|
|
59
|
-
|
|
65
|
+
onSaveRecipe: w ? (o, e) => {
|
|
66
|
+
l(!1), w(o, e);
|
|
60
67
|
} : void 0
|
|
61
|
-
}
|
|
68
|
+
},
|
|
69
|
+
y ?? ""
|
|
62
70
|
)
|
|
63
71
|
}
|
|
64
72
|
)
|
|
@@ -66,128 +74,187 @@ function ce({
|
|
|
66
74
|
}
|
|
67
75
|
);
|
|
68
76
|
}
|
|
69
|
-
function
|
|
70
|
-
collection:
|
|
71
|
-
selectedIds:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
function ye({
|
|
78
|
+
collection: d,
|
|
79
|
+
selectedIds: b,
|
|
80
|
+
initialField: i,
|
|
81
|
+
onCancel: P,
|
|
82
|
+
onApply: T,
|
|
83
|
+
onSaveRecipe: w
|
|
75
84
|
}) {
|
|
76
|
-
var
|
|
77
|
-
const
|
|
78
|
-
queryKey: ["bulk-fields",
|
|
79
|
-
queryFn: () =>
|
|
80
|
-
|
|
85
|
+
var J, D, G, Q;
|
|
86
|
+
const u = ae(), C = j(() => b.map(String).join(","), [b]), l = A({
|
|
87
|
+
queryKey: ["bulk-fields", d, C],
|
|
88
|
+
queryFn: () => u.request(
|
|
89
|
+
Y(`/items/${d}/bulk-fields`, { ids: b })
|
|
81
90
|
).then((r) => r.data),
|
|
82
91
|
staleTime: 15e3,
|
|
83
92
|
retry: !1
|
|
84
|
-
}),
|
|
85
|
-
queryKey: ["bulk-fields-config",
|
|
86
|
-
queryFn: () =>
|
|
93
|
+
}), y = A({
|
|
94
|
+
queryKey: ["bulk-fields-config", d],
|
|
95
|
+
queryFn: () => u.request(z(`/field-config/${d}`)).then((r) => Array.isArray(r.data) ? r.data : []),
|
|
87
96
|
staleTime: 6e4
|
|
88
|
-
}),
|
|
89
|
-
queryKey: ["bulk-fields-relations",
|
|
90
|
-
queryFn: () =>
|
|
97
|
+
}), L = A({
|
|
98
|
+
queryKey: ["bulk-fields-relations", d],
|
|
99
|
+
queryFn: () => u.request(z(`/data-model/relations/for/${d}`)).then((r) => Array.isArray(r.data) ? r.data : []),
|
|
91
100
|
staleTime: 6e4
|
|
92
|
-
}),
|
|
101
|
+
}), v = j(() => {
|
|
93
102
|
const r = {};
|
|
94
|
-
for (const
|
|
103
|
+
for (const n of y.data ?? []) r[n.field] = n.label;
|
|
95
104
|
return r;
|
|
96
|
-
}, [
|
|
97
|
-
() =>
|
|
98
|
-
[
|
|
99
|
-
), [
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
}, [y.data]), o = j(
|
|
106
|
+
() => l.data ? he(l.data, v) : [],
|
|
107
|
+
[l.data, v]
|
|
108
|
+
), [e, M] = g(null), [c, $] = g(null), [m, E] = g("append"), [F, V] = g([]), [S, Z] = g(null), _ = W(!1);
|
|
109
|
+
X(() => {
|
|
110
|
+
if (!i || _.current || !l.data) return;
|
|
111
|
+
_.current = !0;
|
|
112
|
+
const r = o.flatMap((n) => n.options).find((n) => n.field === i);
|
|
113
|
+
r && r.writable > 0 ? (M(r), $(null)) : Z(r ? R(r, l.data.readable) ?? null : "");
|
|
114
|
+
}, [i, l.data, o]);
|
|
115
|
+
const p = !!(e != null && e.m2m), K = p ? xe(m, F) : c, U = le(JSON.stringify(K ?? null), 300), B = !!e && (!p || m === "replace" || F.length > 0), k = A({
|
|
116
|
+
queryKey: ["bulk-update-preview", d, C, (e == null ? void 0 : e.field) ?? "", U],
|
|
117
|
+
queryFn: () => u.request(
|
|
118
|
+
Y(`/items/${d}/bulk-update?dry_run=1`, {
|
|
119
|
+
ids: b,
|
|
120
|
+
data: { [e == null ? void 0 : e.field]: JSON.parse(U) },
|
|
121
|
+
by_form: !0
|
|
122
|
+
})
|
|
123
|
+
).then((r) => r.data),
|
|
124
|
+
enabled: B && U === JSON.stringify(K ?? null),
|
|
125
|
+
staleTime: 1e4,
|
|
126
|
+
retry: !1
|
|
127
|
+
}), h = ((J = l.data) == null ? void 0 : J.readable) ?? b.length, q = ((D = l.data) == null ? void 0 : D.forms) ?? [], I = l.data ? q.length === 0 ? "These records have no form, so every field you may change is listed." : q.length === 1 ? `Fields on their form, ${q[0].name}.` : `Fields on their ${q.length} forms, ${q[0].name} first.` : null;
|
|
128
|
+
if (e) {
|
|
129
|
+
const r = (y.data ?? []).find((N) => N.field === e.field), n = R(e, h), s = p ? F.length === 0 : c == null || typeof c == "string" && c.trim() === "" || Array.isArray(c) && c.length === 0, f = p ? s && (m !== "replace" || e.required) : e.required && s, O = k.data ? ge(k.data, { mode: p ? m : null }) : null;
|
|
130
|
+
return /* @__PURE__ */ a("div", { className: "flex flex-col", "data-bulk-field-value": !0, children: [
|
|
131
|
+
/* @__PURE__ */ a("div", { className: "flex items-center gap-2 border-b border-border px-3 py-2.5", children: [
|
|
132
|
+
/* @__PURE__ */ t(
|
|
105
133
|
"button",
|
|
106
134
|
{
|
|
107
135
|
type: "button",
|
|
108
136
|
onClick: () => {
|
|
109
|
-
|
|
137
|
+
M(null), $(null), V([]), E("append");
|
|
110
138
|
},
|
|
111
139
|
"aria-label": "Choose another field",
|
|
112
140
|
"data-tip": "Choose another field",
|
|
113
141
|
className: "rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
|
|
114
|
-
children: /* @__PURE__ */
|
|
142
|
+
children: /* @__PURE__ */ t(te, { className: "h-3.5 w-3.5" })
|
|
115
143
|
}
|
|
116
144
|
),
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
-
/* @__PURE__ */
|
|
145
|
+
/* @__PURE__ */ a("div", { className: "min-w-0", children: [
|
|
146
|
+
/* @__PURE__ */ a("p", { className: "truncate text-[13px] font-semibold text-foreground", children: [
|
|
119
147
|
"Set ",
|
|
120
|
-
|
|
148
|
+
e.label
|
|
121
149
|
] }),
|
|
122
|
-
/* @__PURE__ */
|
|
150
|
+
/* @__PURE__ */ a("p", { className: "text-[11.5px] text-muted-foreground", children: [
|
|
123
151
|
"On ",
|
|
124
|
-
|
|
152
|
+
e.writable,
|
|
125
153
|
" of ",
|
|
126
|
-
|
|
154
|
+
h,
|
|
127
155
|
" record",
|
|
128
|
-
|
|
156
|
+
h === 1 ? "" : "s"
|
|
129
157
|
] })
|
|
130
158
|
] })
|
|
131
159
|
] }),
|
|
132
|
-
/* @__PURE__ */
|
|
133
|
-
|
|
134
|
-
|
|
160
|
+
/* @__PURE__ */ a("div", { className: "space-y-2 px-3 py-3", children: [
|
|
161
|
+
e.m2m ? /* @__PURE__ */ t(
|
|
162
|
+
be,
|
|
163
|
+
{
|
|
164
|
+
related: e.m2m.related,
|
|
165
|
+
fieldLabel: e.label,
|
|
166
|
+
fieldOptions: r == null ? void 0 : r.options,
|
|
167
|
+
mode: m,
|
|
168
|
+
ids: F,
|
|
169
|
+
onMode: E,
|
|
170
|
+
onIds: V
|
|
171
|
+
}
|
|
172
|
+
) : r ? /* @__PURE__ */ t(
|
|
173
|
+
ne,
|
|
135
174
|
{
|
|
136
175
|
field: { ...r, readonly: !1 },
|
|
137
|
-
value:
|
|
138
|
-
onChange:
|
|
139
|
-
relations:
|
|
140
|
-
collection:
|
|
176
|
+
value: c,
|
|
177
|
+
onChange: $,
|
|
178
|
+
relations: L.data ?? [],
|
|
179
|
+
collection: d,
|
|
141
180
|
itemId: "new"
|
|
142
181
|
}
|
|
143
|
-
) : /* @__PURE__ */
|
|
182
|
+
) : /* @__PURE__ */ t(
|
|
144
183
|
"input",
|
|
145
184
|
{
|
|
146
185
|
autoFocus: !0,
|
|
147
|
-
value:
|
|
148
|
-
onChange: (
|
|
149
|
-
"aria-label": `New ${
|
|
186
|
+
value: c == null ? "" : String(c),
|
|
187
|
+
onChange: (N) => $(N.target.value),
|
|
188
|
+
"aria-label": `New ${e.label}`,
|
|
150
189
|
className: "h-9 w-full rounded-md border border-input bg-background px-3 text-[13px] text-foreground focus-visible:border-nvr-cyan focus-visible:outline-none"
|
|
151
190
|
}
|
|
152
191
|
),
|
|
153
|
-
/* @__PURE__ */
|
|
192
|
+
/* @__PURE__ */ t(
|
|
154
193
|
"p",
|
|
155
194
|
{
|
|
156
195
|
className: "text-[11.5px] leading-4 text-muted-foreground",
|
|
157
196
|
id: "bulk-field-hint",
|
|
158
197
|
"data-bulk-field-hint": !0,
|
|
159
|
-
children:
|
|
198
|
+
children: p ? m === "replace" ? s ? e.required ? `${e.label} is required — pick at least one.` : null : `Each record’s ${e.label} becomes exactly these.` : s ? `Pick the records to ${m === "append" ? "add" : "remove"}.` : m === "append" ? "Links a record already has are left as they are." : "Only these links come off; the rest stay." : f ? `${e.label} is required — choose a value to apply.` : s ? `Leave it empty to clear ${e.label} on every record.` : "Records that already hold this value are left as they are."
|
|
199
|
+
}
|
|
200
|
+
),
|
|
201
|
+
p && m === "replace" && s && !e.required && /* @__PURE__ */ a(
|
|
202
|
+
"p",
|
|
203
|
+
{
|
|
204
|
+
role: "alert",
|
|
205
|
+
"data-bulk-links-clear-warning": !0,
|
|
206
|
+
className: "rounded-md border border-amber-300 bg-amber-50 px-2 py-1.5 text-[11.5px] leading-4 text-amber-800 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-200",
|
|
207
|
+
children: [
|
|
208
|
+
"Nothing picked: this removes every ",
|
|
209
|
+
e.label,
|
|
210
|
+
" link from the selected records."
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
),
|
|
214
|
+
!f && B && /* @__PURE__ */ t(
|
|
215
|
+
"div",
|
|
216
|
+
{
|
|
217
|
+
"aria-live": "polite",
|
|
218
|
+
"data-bulk-update-preview": !0,
|
|
219
|
+
className: "rounded-md bg-muted/60 px-2 py-1.5 text-[11.5px] leading-4",
|
|
220
|
+
children: k.isError ? /* @__PURE__ */ t("span", { className: "text-muted-foreground", children: "Could not count the changes — Apply still checks every record." }) : O ? /* @__PURE__ */ a(ee, { children: [
|
|
221
|
+
/* @__PURE__ */ t("span", { className: "font-medium text-foreground", "data-bulk-update-preview-headline": !0, children: O.headline }),
|
|
222
|
+
O.notes.length > 0 && /* @__PURE__ */ a("span", { className: "text-muted-foreground", children: [
|
|
223
|
+
" · ",
|
|
224
|
+
O.notes.join(" · ")
|
|
225
|
+
] })
|
|
226
|
+
] }) : /* @__PURE__ */ t(x, { className: "h-3 w-40" })
|
|
160
227
|
}
|
|
161
228
|
),
|
|
162
|
-
|
|
229
|
+
n && /* @__PURE__ */ a(
|
|
163
230
|
"p",
|
|
164
231
|
{
|
|
165
232
|
className: "text-[11.5px] leading-4 text-amber-700 dark:text-amber-300",
|
|
166
233
|
"data-bulk-field-note": !0,
|
|
167
234
|
children: [
|
|
168
|
-
|
|
235
|
+
n.charAt(0).toUpperCase() + n.slice(1),
|
|
169
236
|
". Those records are skipped."
|
|
170
237
|
]
|
|
171
238
|
}
|
|
172
239
|
)
|
|
173
240
|
] }),
|
|
174
|
-
/* @__PURE__ */
|
|
175
|
-
|
|
241
|
+
/* @__PURE__ */ a("div", { className: "flex items-center gap-1.5 border-t border-border px-3 py-2", children: [
|
|
242
|
+
w && !p && /* @__PURE__ */ t(
|
|
176
243
|
"button",
|
|
177
244
|
{
|
|
178
245
|
type: "button",
|
|
179
|
-
onClick: () =>
|
|
246
|
+
onClick: () => w(e.field, c),
|
|
180
247
|
"data-tip": "Save this update as a reusable recipe",
|
|
181
248
|
className: "h-8 rounded-md px-2.5 text-[12.5px] text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
|
|
182
249
|
children: "Save recipe"
|
|
183
250
|
}
|
|
184
251
|
),
|
|
185
|
-
/* @__PURE__ */
|
|
186
|
-
/* @__PURE__ */
|
|
252
|
+
/* @__PURE__ */ t("span", { className: "flex-1" }),
|
|
253
|
+
/* @__PURE__ */ t(
|
|
187
254
|
"button",
|
|
188
255
|
{
|
|
189
256
|
type: "button",
|
|
190
|
-
onClick:
|
|
257
|
+
onClick: P,
|
|
191
258
|
className: "h-8 rounded-md px-2.5 text-[12.5px] text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
|
|
192
259
|
children: "Cancel"
|
|
193
260
|
}
|
|
@@ -196,90 +263,101 @@ function X({
|
|
|
196
263
|
"button",
|
|
197
264
|
{
|
|
198
265
|
type: "button",
|
|
199
|
-
disabled:
|
|
200
|
-
"aria-describedby":
|
|
201
|
-
onClick: () =>
|
|
266
|
+
disabled: e.writable === 0 || f || ((G = k.data) == null ? void 0 : G.would_update) === 0,
|
|
267
|
+
"aria-describedby": f ? "bulk-field-hint" : void 0,
|
|
268
|
+
onClick: () => T(e.field, K),
|
|
202
269
|
"data-bulk-field-apply": !0,
|
|
203
270
|
className: "h-8 rounded-md bg-nvr-cyan px-3 text-[12.5px] font-semibold text-white transition-colors hover:bg-nvr-cyan/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan focus-visible:ring-offset-2 disabled:opacity-40",
|
|
204
|
-
children:
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
l.writable === 1 ? "" : "s"
|
|
209
|
-
]
|
|
271
|
+
children: (() => {
|
|
272
|
+
const N = k.data ? k.data.would_update : e.writable;
|
|
273
|
+
return `Apply to ${N.toLocaleString()} record${N === 1 ? "" : "s"}`;
|
|
274
|
+
})()
|
|
210
275
|
}
|
|
211
276
|
)
|
|
212
277
|
] })
|
|
213
278
|
] });
|
|
214
279
|
}
|
|
215
|
-
return /* @__PURE__ */
|
|
216
|
-
/* @__PURE__ */
|
|
217
|
-
/* @__PURE__ */
|
|
280
|
+
return /* @__PURE__ */ a("div", { className: "flex flex-col", "data-bulk-field-picker": !0, children: [
|
|
281
|
+
/* @__PURE__ */ a("div", { className: "border-b border-border px-3 py-2.5", children: [
|
|
282
|
+
/* @__PURE__ */ a("p", { className: "text-[13px] font-semibold text-foreground", children: [
|
|
218
283
|
"Update a field on ",
|
|
219
|
-
|
|
284
|
+
h,
|
|
220
285
|
" record",
|
|
221
|
-
|
|
286
|
+
h === 1 ? "" : "s"
|
|
222
287
|
] }),
|
|
223
|
-
S
|
|
288
|
+
S != null && /* @__PURE__ */ a(
|
|
289
|
+
"p",
|
|
290
|
+
{
|
|
291
|
+
"data-bulk-field-point-missed": !0,
|
|
292
|
+
className: "mt-1 text-[11.5px] leading-4 text-amber-700 dark:text-amber-300",
|
|
293
|
+
children: [
|
|
294
|
+
v[i ?? ""] || i,
|
|
295
|
+
" can’t be changed in bulk here",
|
|
296
|
+
S ? ` — ${S.charAt(0).toLowerCase()}${S.slice(1)}` : "",
|
|
297
|
+
". Pick another field."
|
|
298
|
+
]
|
|
299
|
+
}
|
|
300
|
+
),
|
|
301
|
+
I ? /* @__PURE__ */ t("p", { className: "text-[11.5px] text-muted-foreground", children: I }) : /* @__PURE__ */ t(x, { className: "mt-1 h-3 w-48" })
|
|
224
302
|
] }),
|
|
225
|
-
|
|
226
|
-
/* @__PURE__ */
|
|
227
|
-
/* @__PURE__ */
|
|
228
|
-
/* @__PURE__ */
|
|
229
|
-
/* @__PURE__ */
|
|
230
|
-
/* @__PURE__ */
|
|
231
|
-
] }) :
|
|
232
|
-
/* @__PURE__ */
|
|
233
|
-
/* @__PURE__ */
|
|
303
|
+
l.isLoading ? /* @__PURE__ */ a("div", { className: "space-y-2 p-3", "aria-busy": "true", children: [
|
|
304
|
+
/* @__PURE__ */ t(x, { className: "h-3 w-20" }),
|
|
305
|
+
/* @__PURE__ */ t(x, { className: "h-7 w-full" }),
|
|
306
|
+
/* @__PURE__ */ t(x, { className: "h-7 w-full" }),
|
|
307
|
+
/* @__PURE__ */ t(x, { className: "h-3 w-24" }),
|
|
308
|
+
/* @__PURE__ */ t(x, { className: "h-7 w-full" })
|
|
309
|
+
] }) : l.isError ? /* @__PURE__ */ a("div", { className: "space-y-2 px-3 py-4 text-[12.5px] text-muted-foreground", children: [
|
|
310
|
+
/* @__PURE__ */ t("p", { children: "Could not read these records’ forms." }),
|
|
311
|
+
/* @__PURE__ */ t(
|
|
234
312
|
"button",
|
|
235
313
|
{
|
|
236
314
|
type: "button",
|
|
237
|
-
onClick: () => void
|
|
315
|
+
onClick: () => void l.refetch(),
|
|
238
316
|
className: "h-7 rounded-md border border-border px-2.5 text-[12px] font-medium text-foreground hover:bg-muted",
|
|
239
317
|
children: "Try again"
|
|
240
318
|
}
|
|
241
319
|
)
|
|
242
|
-
] }) :
|
|
243
|
-
/* @__PURE__ */
|
|
244
|
-
/* @__PURE__ */
|
|
245
|
-
/* @__PURE__ */
|
|
246
|
-
|
|
247
|
-
const
|
|
248
|
-
return /* @__PURE__ */
|
|
249
|
-
|
|
320
|
+
] }) : o.length === 0 ? /* @__PURE__ */ t("p", { className: "px-3 py-5 text-[12.5px] leading-5 text-muted-foreground", children: h === 0 ? "You cannot open any of the selected records." : "Their form has no field you can change in bulk. Open a record to edit it there." }) : /* @__PURE__ */ a(oe, { className: "rounded-none bg-transparent", children: [
|
|
321
|
+
/* @__PURE__ */ t(de, { placeholder: "Find a field…", className: "h-9 text-[13px]" }),
|
|
322
|
+
/* @__PURE__ */ a(se, { className: "max-h-[320px]", children: [
|
|
323
|
+
/* @__PURE__ */ t(ie, { className: "py-5 text-center text-[12.5px] text-muted-foreground", children: "No field on the form matches." }),
|
|
324
|
+
o.map((r) => /* @__PURE__ */ t(ue, { heading: r.label, children: r.options.map((n) => {
|
|
325
|
+
const s = n.writable === 0, f = R(n, h);
|
|
326
|
+
return /* @__PURE__ */ a(
|
|
327
|
+
ce,
|
|
250
328
|
{
|
|
251
|
-
value: `${r.label} ${
|
|
252
|
-
disabled:
|
|
329
|
+
value: `${r.label} ${n.label} ${n.field}`,
|
|
330
|
+
disabled: s,
|
|
253
331
|
onSelect: () => {
|
|
254
|
-
|
|
332
|
+
M(n), $(null), V([]), E("append");
|
|
255
333
|
},
|
|
256
|
-
"data-bulk-field-option":
|
|
334
|
+
"data-bulk-field-option": n.field,
|
|
257
335
|
className: "items-start py-1.5 text-[13px] data-[disabled=true]:opacity-100",
|
|
258
336
|
children: [
|
|
259
|
-
/* @__PURE__ */
|
|
260
|
-
/* @__PURE__ */
|
|
337
|
+
/* @__PURE__ */ a("span", { className: "min-w-0 flex-1", children: [
|
|
338
|
+
/* @__PURE__ */ t(
|
|
261
339
|
"span",
|
|
262
340
|
{
|
|
263
|
-
className:
|
|
341
|
+
className: H(
|
|
264
342
|
"block truncate",
|
|
265
|
-
|
|
343
|
+
s ? "text-muted-foreground" : "text-foreground"
|
|
266
344
|
),
|
|
267
|
-
children:
|
|
345
|
+
children: n.label
|
|
268
346
|
}
|
|
269
347
|
),
|
|
270
|
-
|
|
348
|
+
f && /* @__PURE__ */ t(
|
|
271
349
|
"span",
|
|
272
350
|
{
|
|
273
|
-
className:
|
|
351
|
+
className: H(
|
|
274
352
|
"block truncate text-[11px] leading-4",
|
|
275
|
-
|
|
353
|
+
s ? "text-muted-foreground" : "text-amber-700 dark:text-amber-300"
|
|
276
354
|
),
|
|
277
|
-
children:
|
|
355
|
+
children: f.charAt(0).toUpperCase() + f.slice(1)
|
|
278
356
|
}
|
|
279
357
|
)
|
|
280
358
|
] }),
|
|
281
|
-
|
|
282
|
-
|
|
359
|
+
s && /* @__PURE__ */ t(
|
|
360
|
+
re,
|
|
283
361
|
{
|
|
284
362
|
className: "mt-0.5 h-3.5 w-3.5 text-muted-foreground",
|
|
285
363
|
"aria-label": "Locked"
|
|
@@ -287,14 +365,14 @@ function X({
|
|
|
287
365
|
)
|
|
288
366
|
]
|
|
289
367
|
},
|
|
290
|
-
|
|
368
|
+
n.field
|
|
291
369
|
);
|
|
292
370
|
}) }, r.key))
|
|
293
371
|
] })
|
|
294
372
|
] }),
|
|
295
|
-
((
|
|
373
|
+
((Q = l.data) == null ? void 0 : Q.capped) && /* @__PURE__ */ t("p", { className: "border-t border-border px-3 py-1.5 text-[11px] text-muted-foreground", children: "Checked the first 1,000 selected records." })
|
|
296
374
|
] });
|
|
297
375
|
}
|
|
298
376
|
export {
|
|
299
|
-
|
|
377
|
+
Ee as BulkFieldUpdate
|
|
300
378
|
};
|
|
@@ -1,73 +1,67 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { useState as
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as h } from "@tanstack/react-query";
|
|
3
|
+
import { useState as B } from "react";
|
|
4
4
|
import { toast as n } from "sonner";
|
|
5
|
-
import { useNivaroClient as
|
|
6
|
-
import { newBulkProgressId as
|
|
7
|
-
import { post as
|
|
8
|
-
import { errorToastOptions as
|
|
9
|
-
import { userErrorMessage as
|
|
10
|
-
import { invalidateRecordQueries as
|
|
11
|
-
import { BulkFieldUpdate as
|
|
12
|
-
|
|
5
|
+
import { useNivaroClient as U } from "../../context.js";
|
|
6
|
+
import { newBulkProgressId as w, startBulkProgress as F, endBulkProgress as P } from "../../lib/bulk-progress.js";
|
|
7
|
+
import { post as v } from "../../lib/commands.js";
|
|
8
|
+
import { errorToastOptions as C } from "../../lib/error-toast.js";
|
|
9
|
+
import { userErrorMessage as q } from "../../lib/safe-error.js";
|
|
10
|
+
import { invalidateRecordQueries as x } from "../item-edit/RecordLiveSync.js";
|
|
11
|
+
import { BulkFieldUpdate as I } from "./BulkFieldUpdate.js";
|
|
12
|
+
import { bulkUpdateOutcome as O } from "./bulk-update-preview.js";
|
|
13
|
+
function H({
|
|
13
14
|
targets: o,
|
|
14
|
-
disabled:
|
|
15
|
-
className:
|
|
15
|
+
disabled: f,
|
|
16
|
+
className: u,
|
|
16
17
|
onDone: s
|
|
17
18
|
}) {
|
|
18
|
-
const y =
|
|
19
|
+
const y = U(), k = h(), [b, a] = B(!1), p = [...new Set(o.map((t) => t.collection))];
|
|
19
20
|
if (o.length === 0) return null;
|
|
20
|
-
if (
|
|
21
|
-
return /* @__PURE__ */
|
|
21
|
+
if (p.length !== 1)
|
|
22
|
+
return /* @__PURE__ */ m(
|
|
22
23
|
"button",
|
|
23
24
|
{
|
|
24
25
|
type: "button",
|
|
25
26
|
disabled: !0,
|
|
26
27
|
"data-tip": "Pick records of one kind to update a field on them together",
|
|
27
|
-
className:
|
|
28
|
+
className: u,
|
|
28
29
|
children: "Update Field"
|
|
29
30
|
}
|
|
30
31
|
);
|
|
31
|
-
const i =
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
32
|
+
const i = p[0], r = o.map((t) => t.id), g = async (t, l) => {
|
|
33
|
+
a(!0);
|
|
34
|
+
const d = w();
|
|
35
|
+
F(d, r);
|
|
35
36
|
try {
|
|
36
37
|
const e = await y.request(
|
|
37
|
-
|
|
38
|
+
v(`/items/${i}/bulk-update?progress=${d}`, {
|
|
38
39
|
ids: r,
|
|
39
|
-
data: { [t]:
|
|
40
|
+
data: { [t]: l ?? null },
|
|
40
41
|
by_form: !0
|
|
41
42
|
})
|
|
42
|
-
), c =
|
|
43
|
-
|
|
44
|
-
e.skipped ? `${e.skipped} already set` : "",
|
|
45
|
-
e.refused ? `${e.refused} refused` : ""
|
|
46
|
-
].filter(Boolean);
|
|
47
|
-
e.refused ? n.warning(c.join(" · "), {
|
|
48
|
-
description: e.refused_reason ?? void 0,
|
|
49
|
-
duration: 8e3
|
|
50
|
-
}) : n.success(c.join(" · ")), C(k, i, r), s == null || s();
|
|
43
|
+
), c = O(e);
|
|
44
|
+
e.refused || e.failed ? n.warning(c, { duration: 8e3 }) : n.success(c), x(k, i, r), s == null || s();
|
|
51
45
|
} catch (e) {
|
|
52
46
|
n.error(
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
q(e, "Could not update the field"),
|
|
48
|
+
C(e, { action: "Update Field" })
|
|
55
49
|
);
|
|
56
50
|
} finally {
|
|
57
|
-
|
|
51
|
+
P(d), a(!1);
|
|
58
52
|
}
|
|
59
53
|
};
|
|
60
|
-
return /* @__PURE__ */
|
|
61
|
-
|
|
54
|
+
return /* @__PURE__ */ m(
|
|
55
|
+
I,
|
|
62
56
|
{
|
|
63
57
|
collection: i,
|
|
64
58
|
selectedIds: r,
|
|
65
|
-
disabled:
|
|
66
|
-
onApply: (t,
|
|
67
|
-
className:
|
|
59
|
+
disabled: f || b,
|
|
60
|
+
onApply: (t, l) => void g(t, l),
|
|
61
|
+
className: u
|
|
68
62
|
}
|
|
69
63
|
);
|
|
70
64
|
}
|
|
71
65
|
export {
|
|
72
|
-
|
|
66
|
+
H as BulkFieldUpdateButton
|
|
73
67
|
};
|