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() 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) { function tableChanged(fromTbl, toTbl) {
if ( if (!hasTableChanged(fromTbl, toTbl)) {
(currentTables?.from?._id === fromTbl?._id &&
currentTables?.to?._id === toTbl?._id) ||
originalFromName ||
originalToName
) {
return return
} }
fromRelationship.name = toTbl?.name || "" fromRelationship.name = toTbl?.name || ""