@ai-matrx/records-ui 0.115.85 → 0.115.87
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/CHANGELOG.md +22 -1
- package/dist/index.cjs +45 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +45 -22
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +26 -21
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +26 -21
- package/dist/pickers.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2770,6 +2770,28 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
|
|
|
2770
2770
|
setRefusal(null);
|
|
2771
2771
|
let holding;
|
|
2772
2772
|
let aside;
|
|
2773
|
+
const offerUndo = (migration) => {
|
|
2774
|
+
if (!migration || !notify?.reversible) return;
|
|
2775
|
+
const wasPerson = person && read && (to.id === "text" || to.id === "email") ? read : null;
|
|
2776
|
+
notify.reversible({
|
|
2777
|
+
verb: "change",
|
|
2778
|
+
noun: "column",
|
|
2779
|
+
subject: name,
|
|
2780
|
+
undo: async () => {
|
|
2781
|
+
const back = await client.migrateUndo({ migration_id: migration });
|
|
2782
|
+
if (!back.ok) throw new Error(refusalSentence(back.error));
|
|
2783
|
+
if (wasPerson) {
|
|
2784
|
+
const changes = wasPerson.rows.map((r) => ({ op: "update", record_id: r.recordId, patch: { [field2.key]: field2.multi ? r.ids : r.ids[0] ?? null } }));
|
|
2785
|
+
for (let i = 0; i < changes.length; i += 100) {
|
|
2786
|
+
const put = await client.recordChangeMany({ table_id: tableId, changes: changes.slice(i, i + 100) });
|
|
2787
|
+
if (!put.ok) throw new Error(refusalSentence(put.error));
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
tableShapeChanged(tableId);
|
|
2791
|
+
onRetyped?.();
|
|
2792
|
+
}
|
|
2793
|
+
});
|
|
2794
|
+
};
|
|
2773
2795
|
if (to.via !== "behaviour") {
|
|
2774
2796
|
const done = await client.fieldUpdate({ field_id: field2.id, patch: { parity_type: to.parity } });
|
|
2775
2797
|
setBusy(false);
|
|
@@ -2779,6 +2801,9 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
|
|
|
2779
2801
|
}
|
|
2780
2802
|
holding = preview?.converts ?? 0;
|
|
2781
2803
|
aside = preview?.keptAside ?? 0;
|
|
2804
|
+
const recorded = await client.migrations({ target_id: field2.id, limit: 1 });
|
|
2805
|
+
const newest = recorded.ok ? recorded.data[0] : void 0;
|
|
2806
|
+
if (newest && !newest.undone_at) offerUndo(newest.id);
|
|
2782
2807
|
} else {
|
|
2783
2808
|
const done = await client.migrateRetype({ field_id: field2.id, to: to.behaviour });
|
|
2784
2809
|
setBusy(false);
|
|
@@ -2788,27 +2813,7 @@ function FieldRetype({ field: field2, tableId, onRetyped }) {
|
|
|
2788
2813
|
}
|
|
2789
2814
|
holding = done.data.records_still_holding_a_value ?? 0;
|
|
2790
2815
|
aside = done.data.values_in_retired_for_this_field ?? 0;
|
|
2791
|
-
|
|
2792
|
-
if (migration && notify?.reversible) {
|
|
2793
|
-
notify.reversible({
|
|
2794
|
-
verb: "change",
|
|
2795
|
-
noun: "column",
|
|
2796
|
-
subject: name,
|
|
2797
|
-
undo: async () => {
|
|
2798
|
-
const back = await client.migrateUndo({ migration_id: migration });
|
|
2799
|
-
if (!back.ok) throw new Error(refusalSentence(back.error));
|
|
2800
|
-
if (person && read && (to.id === "text" || to.id === "email")) {
|
|
2801
|
-
const changes = read.rows.map((r) => ({ op: "update", record_id: r.recordId, patch: { [field2.key]: field2.multi ? r.ids : r.ids[0] ?? null } }));
|
|
2802
|
-
for (let i = 0; i < changes.length; i += 100) {
|
|
2803
|
-
const put = await client.recordChangeMany({ table_id: tableId, changes: changes.slice(i, i + 100) });
|
|
2804
|
-
if (!put.ok) throw new Error(refusalSentence(put.error));
|
|
2805
|
-
}
|
|
2806
|
-
}
|
|
2807
|
-
tableShapeChanged(tableId);
|
|
2808
|
-
onRetyped?.();
|
|
2809
|
-
}
|
|
2810
|
-
});
|
|
2811
|
-
}
|
|
2816
|
+
offerUndo(done.data.migration_id);
|
|
2812
2817
|
}
|
|
2813
2818
|
if (person && read && (to.id === "text" || to.id === "email")) {
|
|
2814
2819
|
const as = to.id === "email" ? "email" : "name";
|
|
@@ -7379,13 +7384,31 @@ function keptAsideReason(field2, entry) {
|
|
|
7379
7384
|
}
|
|
7380
7385
|
function KeptAsideValue({ field: field2, entry, shown: shown5 }) {
|
|
7381
7386
|
const why = keptAsideReason(field2, entry);
|
|
7387
|
+
const open = useRecordsUi().openPerson;
|
|
7388
|
+
const person = (Array.isArray(entry.value) ? entry.value : [entry.value]).find(isUserId);
|
|
7389
|
+
const opens = open && typeof person === "string";
|
|
7382
7390
|
return /* @__PURE__ */ jsx29(
|
|
7383
7391
|
"span",
|
|
7384
7392
|
{
|
|
7385
7393
|
"data-records-kept-aside": field2.key,
|
|
7386
7394
|
title: why,
|
|
7387
7395
|
"aria-label": `${shown5}. ${why}`,
|
|
7388
|
-
className: "cursor-help rounded-sm bg-amber-500/10 px-0.5 text-amber-700 dark:text-amber-300
|
|
7396
|
+
className: `${opens ? "cursor-pointer underline-offset-2 hover:underline" : "cursor-help"} rounded-sm bg-amber-500/10 px-0.5 text-amber-700 dark:text-amber-300`,
|
|
7397
|
+
...opens ? {
|
|
7398
|
+
role: "button",
|
|
7399
|
+
tabIndex: 0,
|
|
7400
|
+
onClick: (e) => {
|
|
7401
|
+
e.stopPropagation();
|
|
7402
|
+
void openStoredPerson(person, open);
|
|
7403
|
+
},
|
|
7404
|
+
onKeyDown: (e) => {
|
|
7405
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
7406
|
+
e.preventDefault();
|
|
7407
|
+
e.stopPropagation();
|
|
7408
|
+
void openStoredPerson(person, open);
|
|
7409
|
+
}
|
|
7410
|
+
}
|
|
7411
|
+
} : {},
|
|
7389
7412
|
children: shown5
|
|
7390
7413
|
}
|
|
7391
7414
|
);
|