mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Edit Data: Fix editing stopping after tab switch (#579)
* Reverts should not be committed * WIP * Updating the angular2-slickgrid package that will fix the issue * Updating package as per yarn stuff
This commit is contained in:
committed by
Karl Burtram
parent
3df522536f
commit
24ea675d7d
@@ -585,7 +585,7 @@ extend@~1.2.1:
|
|||||||
"extensions-modules@file:../extensions-modules":
|
"extensions-modules@file:../extensions-modules":
|
||||||
version "0.1.0"
|
version "0.1.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
dataprotocol-client "file:./../../AppData/Local/Yarn/cache/v1/dataprotocol-client"
|
dataprotocol-client "file:../../../Library/Caches/Yarn/v1/dataprotocol-client"
|
||||||
decompress "^4.2.0"
|
decompress "^4.2.0"
|
||||||
fs-extra-promise "^1.0.1"
|
fs-extra-promise "^1.0.1"
|
||||||
http-proxy-agent "^2.0.0"
|
http-proxy-agent "^2.0.0"
|
||||||
|
|||||||
@@ -493,7 +493,7 @@ extend@^3.0.0, extend@~3.0.0, extend@~3.0.1:
|
|||||||
"extensions-modules@file:../extensions-modules":
|
"extensions-modules@file:../extensions-modules":
|
||||||
version "0.1.0"
|
version "0.1.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
dataprotocol-client "file:./../../AppData/Local/Yarn/cache/v1/dataprotocol-client"
|
dataprotocol-client "file:../../../Library/Caches/Yarn/v1/dataprotocol-client"
|
||||||
decompress "^4.2.0"
|
decompress "^4.2.0"
|
||||||
fs-extra-promise "^1.0.1"
|
fs-extra-promise "^1.0.1"
|
||||||
http-proxy-agent "^2.0.0"
|
http-proxy-agent "^2.0.0"
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
"@angular/router": "~4.1.3",
|
"@angular/router": "~4.1.3",
|
||||||
"@angular/upgrade": "~4.1.3",
|
"@angular/upgrade": "~4.1.3",
|
||||||
"angular2-grid": "2.0.6",
|
"angular2-grid": "2.0.6",
|
||||||
"angular2-slickgrid": "git://github.com/Microsoft/angular2-slickgrid.git#1.3.7",
|
"angular2-slickgrid": "git://github.com/Microsoft/angular2-slickgrid.git#1.3.8",
|
||||||
"applicationinsights": "0.17.1",
|
"applicationinsights": "0.17.1",
|
||||||
"chart.js": "^2.6.0",
|
"chart.js": "^2.6.0",
|
||||||
"core-js": "^2.4.1",
|
"core-js": "^2.4.1",
|
||||||
@@ -166,4 +166,4 @@
|
|||||||
"windows-process-tree": "0.1.6",
|
"windows-process-tree": "0.1.6",
|
||||||
"fsevents": "0.3.8"
|
"fsevents": "0.3.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
showHeader="true"
|
showHeader="true"
|
||||||
[resized]="dataSet.resized"
|
[resized]="dataSet.resized"
|
||||||
[plugins]="slickgridPlugins"
|
[plugins]="slickgridPlugins"
|
||||||
|
(activeCellChanged)="onActiveCellChanged($event)"
|
||||||
(cellEditBegin)="onCellEditBegin($event)"
|
(cellEditBegin)="onCellEditBegin($event)"
|
||||||
(cellEditExit)="onCellEditEnd($event)"
|
(cellEditExit)="onCellEditEnd($event)"
|
||||||
(rowEditBegin)="onRowEditBegin($event)"
|
(rowEditBegin)="onRowEditBegin($event)"
|
||||||
|
|||||||
@@ -50,10 +50,12 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
// Current selected cell state
|
// Current selected cell state
|
||||||
private currentCell: { row: number, column: number, isEditable: boolean };
|
private currentCell: { row: number, column: number, isEditable: boolean };
|
||||||
private currentEditCellValue: string;
|
private currentEditCellValue: string;
|
||||||
|
private newRowVisible: boolean;
|
||||||
private removingNewRow: boolean;
|
private removingNewRow: boolean;
|
||||||
private rowIdMappings: {[gridRowId: number]: number} = {};
|
private rowIdMappings: {[gridRowId: number]: number} = {};
|
||||||
|
|
||||||
// Edit Data functions
|
// Edit Data functions
|
||||||
|
public onActiveCellChanged: (event: { row: number, column: number }) => void;
|
||||||
public onCellEditEnd: (event: { row: number, column: number, newValue: any }) => void;
|
public onCellEditEnd: (event: { row: number, column: number, newValue: any }) => void;
|
||||||
public onCellEditBegin: (event: { row: number, column: number }) => void;
|
public onCellEditBegin: (event: { row: number, column: number }) => void;
|
||||||
public onRowEditBegin: (event: { row: number }) => void;
|
public onRowEditBegin: (event: { row: number }) => void;
|
||||||
@@ -133,6 +135,8 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.onActiveCellChanged = this.onCellSelect;
|
||||||
|
|
||||||
this.onCellEditEnd = (event: { row: number, column: number, newValue: any }): void => {
|
this.onCellEditEnd = (event: { row: number, column: number, newValue: any }): void => {
|
||||||
// Store the value that was set
|
// Store the value that was set
|
||||||
self.currentEditCellValue = event.newValue;
|
self.currentEditCellValue = event.newValue;
|
||||||
@@ -190,7 +194,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
return (index: number): void => {
|
return (index: number): void => {
|
||||||
self.dataService.deleteRow(index)
|
self.dataService.deleteRow(index)
|
||||||
.then(() => self.dataService.commitEdit())
|
.then(() => self.dataService.commitEdit())
|
||||||
.then(() => self.removeRow(index, 0));
|
.then(() => self.removeRow(index));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,13 +206,14 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
|
|
||||||
// Perform a revert row operation
|
// Perform a revert row operation
|
||||||
self.dataService.revertRow(index)
|
self.dataService.revertRow(index)
|
||||||
.then(() => self.dataService.commitEdit())
|
|
||||||
.then(() => self.refreshResultsets());
|
.then(() => self.refreshResultsets());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
onCellSelect(row: number, column: number): void {
|
onCellSelect(event: { row: number, column: number }): void {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
let row = event.row;
|
||||||
|
let column = event.column;
|
||||||
|
|
||||||
// Skip processing if the newly selected cell is undefined or we don't have column
|
// Skip processing if the newly selected cell is undefined or we don't have column
|
||||||
// definition for the column (ie, the selection was reset)
|
// definition for the column (ie, the selection was reset)
|
||||||
@@ -258,6 +263,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
// Committing was successful, clean the grid
|
// Committing was successful, clean the grid
|
||||||
self.setGridClean();
|
self.setGridClean();
|
||||||
self.rowIdMappings = {};
|
self.rowIdMappings = {};
|
||||||
|
self.newRowVisible = false;
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
@@ -272,7 +278,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
if (this.isNullRow(row) && !this.removingNewRow) {
|
if (this.isNullRow(row) && !this.removingNewRow) {
|
||||||
// We've entered the "new row", so we need to add a row and jump to it
|
// We've entered the "new row", so we need to add a row and jump to it
|
||||||
cellSelectTasks = cellSelectTasks.then(() => {
|
cellSelectTasks = cellSelectTasks.then(() => {
|
||||||
self.addRow(row, column);
|
self.addRow(row);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,16 +365,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
this.currentCell = { row: null, column: null, isEditable: null };
|
this.currentCell = { row: null, column: null, isEditable: null };
|
||||||
this.currentEditCellValue = null;
|
this.currentEditCellValue = null;
|
||||||
this.removingNewRow = false;
|
this.removingNewRow = false;
|
||||||
|
this.newRowVisible = false;
|
||||||
// HACK: unsafe reference to the slickgrid object
|
|
||||||
// TODO: Reimplement by adding selectCell event to angular2-slickgrid
|
|
||||||
self._cd.detectChanges();
|
|
||||||
let slick: any = self.slickgrids.toArray()[0];
|
|
||||||
let grid: Slick.Grid<any> = slick._grid;
|
|
||||||
|
|
||||||
grid.onActiveCellChanged.subscribe((event: Slick.EventData, data: Slick.OnActiveCellChangedEventArgs<any>) => {
|
|
||||||
self.onCellSelect(data.row, data.cell);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -408,13 +405,14 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
// If the esc key was pressed while in a create session
|
// If the esc key was pressed while in a create session
|
||||||
let currentNewRowIndex = this.dataSet.totalRows - 2;
|
let currentNewRowIndex = this.dataSet.totalRows - 2;
|
||||||
|
|
||||||
if (e.keyCode === jQuery.ui.keyCode.ESCAPE && this.currentCell.row === currentNewRowIndex) {
|
if (e.keyCode === jQuery.ui.keyCode.ESCAPE && this.newRowVisible && this.currentCell.row === currentNewRowIndex) {
|
||||||
// revert our last new row
|
// revert our last new row
|
||||||
this.removingNewRow = true;
|
this.removingNewRow = true;
|
||||||
|
|
||||||
this.dataService.revertRow(this.idMapping[currentNewRowIndex])
|
this.dataService.revertRow(this.idMapping[currentNewRowIndex])
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.removeRow(currentNewRowIndex, 0);
|
this.removeRow(currentNewRowIndex);
|
||||||
|
this.newRowVisible = false;
|
||||||
});
|
});
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
@@ -463,7 +461,7 @@ 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): void {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
// Add a new row to the edit session in the tools service
|
// Add a new row to the edit session in the tools service
|
||||||
@@ -471,6 +469,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
.then(result => {
|
.then(result => {
|
||||||
// Map the new row ID to the row ID we have
|
// Map the new row ID to the row ID we have
|
||||||
self.rowIdMappings[row] = result.newRowId;
|
self.rowIdMappings[row] = result.newRowId;
|
||||||
|
self.newRowVisible = true;
|
||||||
|
|
||||||
// Add a new "new row" to the end of the results
|
// 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
|
||||||
@@ -496,7 +495,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
|||||||
|
|
||||||
// removes a row from the end of slickgrid (just for rendering purposes)
|
// removes a row from the end of slickgrid (just for rendering purposes)
|
||||||
// Then sets the focused call afterwards
|
// Then sets the focused call afterwards
|
||||||
private removeRow(row: number, column: number): void {
|
private removeRow(row: number): void {
|
||||||
// Removing the new row
|
// Removing the new row
|
||||||
this.dataSet.totalRows--;
|
this.dataSet.totalRows--;
|
||||||
this.dataSet.dataRows = new VirtualizedCollection(
|
this.dataSet.dataRows = new VirtualizedCollection(
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ export abstract class GridParentComponent {
|
|||||||
@ViewChildren('slickgrid') slickgrids: QueryList<SlickGrid>;
|
@ViewChildren('slickgrid') slickgrids: QueryList<SlickGrid>;
|
||||||
|
|
||||||
// Edit Data functions
|
// Edit Data functions
|
||||||
|
public onActiveCellChanged: (event: { row: number, column: number }) => void;
|
||||||
public onCellEditEnd: (event: { row: number, column: number, newValue: any }) => void;
|
public onCellEditEnd: (event: { row: number, column: number, newValue: any }) => void;
|
||||||
public onCellEditBegin: (event: { row: number, column: number }) => void;
|
public onCellEditBegin: (event: { row: number, column: number }) => void;
|
||||||
public onRowEditBegin: (event: { row: number }) => void;
|
public onRowEditBegin: (event: { row: number }) => void;
|
||||||
|
|||||||
@@ -162,9 +162,9 @@ angular2-grid@2.0.6:
|
|||||||
version "2.0.6"
|
version "2.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/angular2-grid/-/angular2-grid-2.0.6.tgz#01fe225dc13b2822370b6c61f9a6913b3a26f989"
|
resolved "https://registry.yarnpkg.com/angular2-grid/-/angular2-grid-2.0.6.tgz#01fe225dc13b2822370b6c61f9a6913b3a26f989"
|
||||||
|
|
||||||
"angular2-slickgrid@git://github.com/Microsoft/angular2-slickgrid.git#1.3.7":
|
"angular2-slickgrid@git://github.com/Microsoft/angular2-slickgrid.git#1.3.8":
|
||||||
version "1.3.6"
|
version "1.3.6"
|
||||||
resolved "git://github.com/Microsoft/angular2-slickgrid.git#c6ede45d37b5aa6df3823dac096dbdd8010bbccd"
|
resolved "git://github.com/Microsoft/angular2-slickgrid.git#310850e240f9abe62dc117d78a2375008e7b28ed"
|
||||||
|
|
||||||
ansi-escapes@^1.1.0:
|
ansi-escapes@^1.1.0:
|
||||||
version "1.4.0"
|
version "1.4.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user