arreglado lo de el cambio

This commit is contained in:
pokepato2002 2025-05-01 23:35:47 -06:00
parent a469655981
commit 0313a70410

View File

@ -134,11 +134,10 @@ export default function TableField({ data, tid, index }) {
</Col>
<Col span={3}>
<Button
type={data.notNull ? "primary" : "tertiary"}
type={data.notNull || data.primary ? "primary" : "tertiary"}
title={t("not_null")}
theme={data.notNull ? "solid" : "light"}
theme={data.notNull || data.primary ? "solid" : "light"}
disabled={data.primary ? true: false }
onClick={() => {
setUndoStack((prev) => [
...prev,
@ -169,27 +168,41 @@ export default function TableField({ data, tid, index }) {
title={t("primary")}
theme={data.primary ? "solid" : "light"}
onClick={() => {
const mustSetNotNull = !data.primary && !data.notNull;
const undo = { primary: data.primary };
const redo = { primary: !data.primary };
const changes = { primary: !data.primary };
if (mustSetNotNull) {
undo.notNull = data.notNull;
redo.notNull = true;
changes.notNull = true;
}
setUndoStack((prev) => [
...prev,
{
action: Action.EDIT,
element: ObjectType.TABLE,
component: "field",
tid: tid,
tid,
fid: index,
undo: { primary: data.primary },
redo: { primary: !data.primary },
undo,
redo,
message: t("edit_table", {
tableName: tables[tid].name,
extra: "[field]",
}),
},
]);
setRedoStack([]);
updateField(tid, index, { primary: !data.primary });
updateField(tid, index, changes);
}}
icon={<IconKeyStroked />}
/>
</Col>
<Col span={3}>
<Popover