Skip to content
Merged
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
41 changes: 22 additions & 19 deletions ui/src/app/components/object-detail/object-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export class ObjectDetailComponent implements OnInit {
this.setColumnsToAdd()
this.setAddPkColumnList()
this.setPkOrder()
this.setSrcPkOrder()
this.setPkRows()
this.setFkRows()
this.setCCRows()
Expand Down Expand Up @@ -808,7 +809,9 @@ export class ObjectDetailComponent implements OnInit {
spArr.sort((a, b) => {
return a.spOrder - b.spOrder
})

srcArr.sort((a, b) => {
return a.srcOrder - b.srcOrder
})
for (let i = 0; i < Math.min(srcArr.length, spArr.length); i++) {
this.pkArray.push(
new FormGroup({
Expand Down Expand Up @@ -1092,6 +1095,7 @@ export class ObjectDetailComponent implements OnInit {
})
this.pkData[index].spOrder = newColumnOrder
this.setAddPkColumnList()
this.setSrcPkOrder()
this.setPkRows()
}

Expand All @@ -1113,23 +1117,9 @@ export class ObjectDetailComponent implements OnInit {
}

setPkOrder() {
if (
this.currentObject &&
this.conv.SpSchema[this.currentObject!.id]?.PrimaryKeys.length == this.pkData.length
) {
this.pkData.forEach((pk: IColumnTabData, i: number) => {
if (
this.pkData[i].spId === this.conv.SpSchema[this.currentObject!.id].PrimaryKeys[i].ColId
) {
this.pkData[i].spOrder = this.conv.SpSchema[this.currentObject!.id].PrimaryKeys[i].Order
} else {
let index = this.conv.SpSchema[this.currentObject!.id].PrimaryKeys.map(
(item) => item.ColId
).indexOf(pk.spId)
pk.spOrder = this.conv.SpSchema[this.currentObject!.id].PrimaryKeys[index]?.Order
}
})
} else {
if (!this.currentObject || !this.conv.SrcSchema[this.currentObject!.id]?.PrimaryKeys) {
return; // Early exit if there's no current object or primary key data
}
this.pkData.forEach((pk: IColumnTabData, i: number) => {
let index = this.conv.SpSchema[this.currentObject!.id]?.PrimaryKeys.map(
(item) => item.ColId
Expand All @@ -1138,9 +1128,21 @@ export class ObjectDetailComponent implements OnInit {
pk.spOrder = this.conv.SpSchema[this.currentObject!.id]?.PrimaryKeys[index].Order
}
})
}
}

setSrcPkOrder() {
if (!this.currentObject || !this.conv.SrcSchema[this.currentObject!.id]?.PrimaryKeys) {
return; // Early exit if there's no current object or primary key data
}
const srcPrimaryKeys = this.conv.SrcSchema[this.currentObject!.id].PrimaryKeys;
this.pkData.forEach((pk: IColumnTabData) => {
let index = srcPrimaryKeys.map(item => item.ColId).indexOf(pk.srcId);
if (index !== -1) {
pk.srcOrder = srcPrimaryKeys[index].Order;
}
});
}

pkOrderValidation() {
let arr = this.pkData
.filter((column: IColumnTabData) => {
Expand Down Expand Up @@ -1204,6 +1206,7 @@ export class ObjectDetailComponent implements OnInit {
this.pkData = this.conversion.getPkMapping(this.tableData)
this.setAddPkColumnList()
this.setPkOrder()
this.setSrcPkOrder()
this.setPkRows()
this.isPkEditMode = false
} else {
Expand Down
Loading