@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/pickers.js
CHANGED
|
@@ -5899,6 +5899,28 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5899
5899
|
setRefusal(null);
|
|
5900
5900
|
let holding;
|
|
5901
5901
|
let aside;
|
|
5902
|
+
const offerUndo = (migration) => {
|
|
5903
|
+
if (!migration || !notify?.reversible) return;
|
|
5904
|
+
const wasPerson = person && read && (to.id === "text" || to.id === "email") ? read : null;
|
|
5905
|
+
notify.reversible({
|
|
5906
|
+
verb: "change",
|
|
5907
|
+
noun: "column",
|
|
5908
|
+
subject: name,
|
|
5909
|
+
undo: async () => {
|
|
5910
|
+
const back = await client.migrateUndo({ migration_id: migration });
|
|
5911
|
+
if (!back.ok) throw new Error(refusalSentence(back.error));
|
|
5912
|
+
if (wasPerson) {
|
|
5913
|
+
const changes = wasPerson.rows.map((r) => ({ op: "update", record_id: r.recordId, patch: { [field.key]: field.multi ? r.ids : r.ids[0] ?? null } }));
|
|
5914
|
+
for (let i = 0; i < changes.length; i += 100) {
|
|
5915
|
+
const put = await client.recordChangeMany({ table_id: tableId, changes: changes.slice(i, i + 100) });
|
|
5916
|
+
if (!put.ok) throw new Error(refusalSentence(put.error));
|
|
5917
|
+
}
|
|
5918
|
+
}
|
|
5919
|
+
tableShapeChanged2(tableId);
|
|
5920
|
+
onRetyped?.();
|
|
5921
|
+
}
|
|
5922
|
+
});
|
|
5923
|
+
};
|
|
5902
5924
|
if (to.via !== "behaviour") {
|
|
5903
5925
|
const done = await client.fieldUpdate({ field_id: field.id, patch: { parity_type: to.parity } });
|
|
5904
5926
|
setBusy(false);
|
|
@@ -5908,6 +5930,9 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5908
5930
|
}
|
|
5909
5931
|
holding = preview?.converts ?? 0;
|
|
5910
5932
|
aside = preview?.keptAside ?? 0;
|
|
5933
|
+
const recorded = await client.migrations({ target_id: field.id, limit: 1 });
|
|
5934
|
+
const newest = recorded.ok ? recorded.data[0] : void 0;
|
|
5935
|
+
if (newest && !newest.undone_at) offerUndo(newest.id);
|
|
5911
5936
|
} else {
|
|
5912
5937
|
const done = await client.migrateRetype({ field_id: field.id, to: to.behaviour });
|
|
5913
5938
|
setBusy(false);
|
|
@@ -5917,27 +5942,7 @@ function FieldRetype({ field, tableId, onRetyped }) {
|
|
|
5917
5942
|
}
|
|
5918
5943
|
holding = done.data.records_still_holding_a_value ?? 0;
|
|
5919
5944
|
aside = done.data.values_in_retired_for_this_field ?? 0;
|
|
5920
|
-
|
|
5921
|
-
if (migration && notify?.reversible) {
|
|
5922
|
-
notify.reversible({
|
|
5923
|
-
verb: "change",
|
|
5924
|
-
noun: "column",
|
|
5925
|
-
subject: name,
|
|
5926
|
-
undo: async () => {
|
|
5927
|
-
const back = await client.migrateUndo({ migration_id: migration });
|
|
5928
|
-
if (!back.ok) throw new Error(refusalSentence(back.error));
|
|
5929
|
-
if (person && read && (to.id === "text" || to.id === "email")) {
|
|
5930
|
-
const changes = read.rows.map((r) => ({ op: "update", record_id: r.recordId, patch: { [field.key]: field.multi ? r.ids : r.ids[0] ?? null } }));
|
|
5931
|
-
for (let i = 0; i < changes.length; i += 100) {
|
|
5932
|
-
const put = await client.recordChangeMany({ table_id: tableId, changes: changes.slice(i, i + 100) });
|
|
5933
|
-
if (!put.ok) throw new Error(refusalSentence(put.error));
|
|
5934
|
-
}
|
|
5935
|
-
}
|
|
5936
|
-
tableShapeChanged2(tableId);
|
|
5937
|
-
onRetyped?.();
|
|
5938
|
-
}
|
|
5939
|
-
});
|
|
5940
|
-
}
|
|
5945
|
+
offerUndo(done.data.migration_id);
|
|
5941
5946
|
}
|
|
5942
5947
|
if (person && read && (to.id === "text" || to.id === "email")) {
|
|
5943
5948
|
const as = to.id === "email" ? "email" : "name";
|