Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions apps/nestjs-backend/src/features/calculation/link.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ export class LinkService {
// Update link cell values for symmetric field of the foreign table
if (toDelete.length) {
toDelete.forEach((foreignRecordId) => {
if (!foreignRecordMap[foreignRecordId]) {
return;
}
const foreignCellValue = foreignRecordMap[foreignRecordId][symmetricFieldId] as
| ILinkCellValue[]
| ILinkCellValue
Expand Down Expand Up @@ -344,6 +347,9 @@ export class LinkService {
// Update link cell values for symmetric field of the foreign table
if (oldKey?.length) {
oldKey.forEach((foreignRecordId) => {
if (!foreignRecordMap[foreignRecordId]) {
return;
}
const foreignCellValue = foreignRecordMap[foreignRecordId][symmetricFieldId] as
| ILinkCellValue[]
| ILinkCellValue
Expand Down Expand Up @@ -423,6 +429,9 @@ export class LinkService {

if (toDelete.length) {
toDelete.forEach((foreignRecordId) => {
if (!foreignRecordMap[foreignRecordId]) {
return;
}
foreignRecordMap[foreignRecordId][symmetricFieldId] = null;
});
}
Expand All @@ -433,6 +442,9 @@ export class LinkService {
const sourceRecordTitle = this.extractLinkTitle(lookupValue, sourceLookupField);

toAdd.forEach((foreignRecordId) => {
if (!foreignRecordMap[foreignRecordId]) {
return;
}
foreignRecordMap[foreignRecordId][symmetricFieldId] = {
id: recordId,
title: sourceRecordTitle,
Expand Down Expand Up @@ -465,6 +477,9 @@ export class LinkService {

if (oldKey?.length) {
oldKey.forEach((foreignRecordId) => {
if (!foreignRecordMap[foreignRecordId]) {
return;
}
foreignRecordMap[foreignRecordId][symmetricFieldId] = null;
});
}
Expand All @@ -474,10 +489,12 @@ export class LinkService {
sourceLookedFieldId != null ? sourceRecordMap[recordId]?.[sourceLookedFieldId] : undefined;
const sourceRecordTitle = this.extractLinkTitle(lookupValue, sourceLookupField);

foreignRecordMap[newKey][symmetricFieldId] = {
id: recordId,
title: sourceRecordTitle,
};
if (foreignRecordMap[newKey]) {
foreignRecordMap[newKey][symmetricFieldId] = {
id: recordId,
title: sourceRecordTitle,
};
}
}
}

Expand Down
Loading
Loading