Delete original relationship if table changes

This commit is contained in:
Mel O'Hagan 2023-01-13 17:22:04 +00:00
parent 5be6c241b7
commit db29b131eb
1 changed files with 14 additions and 6 deletions

View File

@ -267,13 +267,21 @@
close()
}
function hasTableChanged(fromTbl, toTbl) {
const areRelationshipsSet =
(originalFromName || originalToName) &&
originalFromTable?.name === fromTbl?.name &&
originalToTable?.name === toTbl?.name
return (
currentTables?.from?._id !== fromTbl?._id ||
currentTables?.to?._id !== toTbl?._id ||
!areRelationshipsSet
)
}
function tableChanged(fromTbl, toTbl) {
if (
(currentTables?.from?._id === fromTbl?._id &&
currentTables?.to?._id === toTbl?._id) ||
originalFromName ||
originalToName
) {
if (!hasTableChanged(fromTbl, toTbl)) {
return
}
fromRelationship.name = toTbl?.name || ""