@ai-matrx/records-ui 0.115.86 → 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 +1 -1
- package/dist/index.cjs +26 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -21
- 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 +4 -4
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";
|