Fix relationship position update bug in undo

This commit is contained in:
1ilit 2024-01-23 08:57:21 +02:00
parent f29716814d
commit 646571ef76
2 changed files with 4 additions and 5 deletions

View File

@ -223,7 +223,7 @@ export default function ControlPanel({
} else if (a.component === "field_delete") { } else if (a.component === "field_delete") {
setRelationships((prev) => { setRelationships((prev) => {
return prev.map((e) => { return prev.map((e) => {
if (e.startTableId === a.tid && e.startFieldId > a.data.id) { if (e.startTableId === a.tid && e.startFieldId >= a.data.id) {
return { return {
...e, ...e,
startFieldId: e.startFieldId + 1, startFieldId: e.startFieldId + 1,
@ -231,7 +231,7 @@ export default function ControlPanel({
startY: tables[a.tid].y + (e.startFieldId + 1) * 36 + 50 + 19, startY: tables[a.tid].y + (e.startFieldId + 1) * 36 + 50 + 19,
}; };
} }
if (e.endTableId === a.tid && e.endFieldId > a.data.id) { if (e.endTableId === a.tid && e.endFieldId >= a.data.id) {
return { return {
...e, ...e,
endFieldId: e.endFieldId + 1, endFieldId: e.endFieldId + 1,
@ -1256,8 +1256,8 @@ export default function ControlPanel({
field.comment = ""; field.comment = "";
field.unique = false; field.unique = false;
if (d.unique) field.unique = true; if (d.unique) field.unique = true;
field.auto_increment = false; field.increment = false;
if (d.auto_increment) field.auto_increment = true; if (d.auto_increment) field.increment = true;
field.notNull = false; field.notNull = false;
if (d.nullable) field.notNull = true; if (d.nullable) field.notNull = true;
field.primary = false; field.primary = false;

View File

@ -1266,7 +1266,6 @@ export default function Table(props) {
</div> </div>
<div className="text-zinc-400"> <div className="text-zinc-400">
{hoveredField === index ? ( {hoveredField === index ? (
<Button <Button
theme="solid" theme="solid"
size="small" size="small"