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