in ui/src/app/components/object-detail/object-detail.component.ts [585:659]
dropColumn(element: any) {
let srcColName = element.get('srcColName').value
let srcColId = element.get('srcId').value
let spColId = element.get('spId').value
let colId = srcColId != '' ? srcColId : spColId
let spColName = element.get('spColName').value
let associatedIndexes = this.getAssociatedIndexs(colId)
if (this.checkIfCcColumn(colId) && this.checkIfPkColumn(colId)) {
let message = `Column ${spColName} is a part of`;
const dependencies = [];
if (this.checkIfPkColumn(colId)) {
dependencies.push(' Primary key');
}
if (associatedIndexes.length !== 0) {
dependencies.push(` Index ${associatedIndexes}`);
}
// Join dependencies with appropriate punctuation
if (dependencies.length > 0) {
message += `${dependencies.join(' ,')} and`;
}
message += ' check constraints. Remove the dependencies from respective tabs before dropping the Column.';
this.dialog.open(InfodialogComponent, {
data: {
message,
type: 'error',
},
maxWidth: '500px',
});
}else if (this.checkIfPkColumn(colId) || associatedIndexes.length != 0) {
let pkWarning: string = ''
let indexWaring: string = ''
let connectingString: string = ''
if (this.checkIfPkColumn(colId)) {
pkWarning = ` Primary key`
}
if (associatedIndexes.length != 0) {
indexWaring = ` Index ${associatedIndexes}`
}
if (pkWarning != '' && indexWaring != '') {
connectingString = ` and`
}
this.dialog.open(InfodialogComponent, {
data: {
message: `Column ${spColName} is a part of${pkWarning}${connectingString}${indexWaring}. Remove the dependencies from respective tabs before dropping the Column. `,
type: 'error',
},
maxWidth: '500px',
})
} else if (this.checkIfCcColumn(colId)) {
let message = `Column ${spColName} is a part of`;
message += ' check constraints. Remove the dependencies from respective tabs before dropping the Column.';
this.dialog.open(InfodialogComponent, {
data: {
message,
type: 'error',
},
maxWidth: '500px',
});
}
else {
this.spRowArray.value.forEach((col: IColumnTabData, i: number) => {
if (col.spId === spColId) {
this.droppedColumns.push(col)
}
})
this.dropColumnFromUI(spColId)
if (srcColName !== '') {
this.droppedSourceColumns.push(srcColName)
}
}
}