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