mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Adding row ID mapping to ensure correct IDs are used (#355)
This commit is contained in:
committed by
Karl Burtram
parent
f6497a9ac4
commit
2e19ab4595
@@ -52,6 +52,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
private currentCell: { row: number, column: number, isEditable: boolean };
|
private currentCell: { row: number, column: number, isEditable: boolean };
|
||||||
private currentEditCellValue: string;
|
private currentEditCellValue: string;
|
||||||
private removingNewRow: boolean;
|
private removingNewRow: boolean;
|
||||||
|
private rowIdMappings: {[gridRowId: number]: number} = {};
|
||||||
|
|
||||||
// Edit Data functions
|
// Edit Data functions
|
||||||
public onCellEditEnd: (event: { row: number, column: number, newValue: any }) => void;
|
public onCellEditEnd: (event: { row: number, column: number, newValue: any }) => void;
|
||||||
@@ -226,7 +227,12 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
if (this.currentCell.isEditable && this.currentEditCellValue !== null && !this.removingNewRow) {
|
if (this.currentCell.isEditable && this.currentEditCellValue !== null && !this.removingNewRow) {
|
||||||
// We're exiting a read/write cell after having changed the value, update the cell value in the service
|
// We're exiting a read/write cell after having changed the value, update the cell value in the service
|
||||||
cellSelectTasks = cellSelectTasks.then(() => {
|
cellSelectTasks = cellSelectTasks.then(() => {
|
||||||
return self.dataService.updateCell(self.currentCell.row, self.currentCell.column - 1, self.currentEditCellValue)
|
// Use the mapped row ID if we're on that row
|
||||||
|
let sessionRowId = self.rowIdMappings[self.currentCell.row] !== undefined
|
||||||
|
? self.rowIdMappings[self.currentCell.row]
|
||||||
|
: self.currentCell.row;
|
||||||
|
|
||||||
|
return self.dataService.updateCell(sessionRowId, self.currentCell.column - 1, self.currentEditCellValue)
|
||||||
.then(
|
.then(
|
||||||
result => {
|
result => {
|
||||||
// Cell update was successful, update the flags
|
// Cell update was successful, update the flags
|
||||||
@@ -252,6 +258,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
result => {
|
result => {
|
||||||
// Committing was successful, clean the grid
|
// Committing was successful, clean the grid
|
||||||
self.setGridClean();
|
self.setGridClean();
|
||||||
|
self.rowIdMappings = {};
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
@@ -458,27 +465,34 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
// Adds an extra row to the end of slickgrid (just for rendering purposes)
|
// Adds an extra row to the end of slickgrid (just for rendering purposes)
|
||||||
// Then sets the focused call afterwards
|
// Then sets the focused call afterwards
|
||||||
private addRow(row: number, column: number): void {
|
private addRow(row: number, column: number): void {
|
||||||
// Add a new row to the edit session in the tools service
|
let self = this;
|
||||||
this.dataService.createRow();
|
|
||||||
|
|
||||||
|
// Add a new row to the edit session in the tools service
|
||||||
|
this.dataService.createRow()
|
||||||
|
.then(result => {
|
||||||
|
// Map the new row ID to the row ID we have
|
||||||
|
self.rowIdMappings[row] = result.newRowId;
|
||||||
|
|
||||||
|
// Add a new "new row" to the end of the results
|
||||||
// Adding an extra row for 'new row' functionality
|
// Adding an extra row for 'new row' functionality
|
||||||
this.dataSet.totalRows++;
|
self.dataSet.totalRows++;
|
||||||
this.dataSet.maxHeight = this.getMaxHeight(this.dataSet.totalRows);
|
self.dataSet.maxHeight = self.getMaxHeight(this.dataSet.totalRows);
|
||||||
this.dataSet.minHeight = this.getMinHeight(this.dataSet.totalRows);
|
self.dataSet.minHeight = self.getMinHeight(this.dataSet.totalRows);
|
||||||
this.dataSet.dataRows = new VirtualizedCollection(
|
self.dataSet.dataRows = new VirtualizedCollection(
|
||||||
this.windowSize,
|
self.windowSize,
|
||||||
this.dataSet.totalRows,
|
self.dataSet.totalRows,
|
||||||
this.loadDataFunction,
|
self.loadDataFunction,
|
||||||
index => { return { values: [] }; }
|
index => { return { values: [] }; }
|
||||||
);
|
);
|
||||||
|
|
||||||
// Refresh grid
|
// Refresh grid
|
||||||
this.onScroll(0);
|
self.onScroll(0);
|
||||||
|
|
||||||
// Mark the row as dirty once the scroll has completed
|
// Mark the row as dirty once the scroll has completed
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.setRowDirtyState(row, true);
|
self.setRowDirtyState(row, true);
|
||||||
}, this.scrollTimeOutTime);
|
}, self.scrollTimeOutTime);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// removes a row from the end of slickgrid (just for rendering purposes)
|
// removes a row from the end of slickgrid (just for rendering purposes)
|
||||||
|
|||||||
Reference in New Issue
Block a user