mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
add off by one handler for selection (#2009)
This commit is contained in:
@@ -236,21 +236,25 @@ export abstract class GridParentComponent {
|
|||||||
this.messagesFocussedContextKey.set(false);
|
this.messagesFocussedContextKey.set(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected getSelection(index?: number): ISlickRange[] {
|
||||||
|
let selection = this.slickgrids.toArray()[index || this.activeGrid].getSelectedRanges();
|
||||||
|
selection = selection.map(c => { return <ISlickRange>{ fromCell: c.fromCell - 1, toCell: c.toCell - 1, toRow: c.toRow, fromRow: c.fromRow }; });
|
||||||
|
return selection;
|
||||||
|
}
|
||||||
|
|
||||||
private copySelection(): void {
|
private copySelection(): void {
|
||||||
let messageText = this.getMessageText();
|
let messageText = this.getMessageText();
|
||||||
if (messageText.length > 0) {
|
if (messageText.length > 0) {
|
||||||
this.clipboardService.writeText(messageText);
|
this.clipboardService.writeText(messageText);
|
||||||
} else {
|
} else {
|
||||||
let activeGrid = this.activeGrid;
|
let activeGrid = this.activeGrid;
|
||||||
let selection = this.slickgrids.toArray()[activeGrid].getSelectedRanges();
|
this.dataService.copyResults(this.getSelection(activeGrid), this.renderedDataSets[activeGrid].batchId, this.renderedDataSets[activeGrid].resultId);
|
||||||
this.dataService.copyResults(selection, this.renderedDataSets[activeGrid].batchId, this.renderedDataSets[activeGrid].resultId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private copyWithHeaders(): void {
|
private copyWithHeaders(): void {
|
||||||
let activeGrid = this.activeGrid;
|
let activeGrid = this.activeGrid;
|
||||||
let selection = this.slickgrids.toArray()[activeGrid].getSelectedRanges();
|
this.dataService.copyResults(this.getSelection(activeGrid), this.renderedDataSets[activeGrid].batchId,
|
||||||
this.dataService.copyResults(selection, this.renderedDataSets[activeGrid].batchId,
|
|
||||||
this.renderedDataSets[activeGrid].resultId, true);
|
this.renderedDataSets[activeGrid].resultId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,8 +368,7 @@ export abstract class GridParentComponent {
|
|||||||
let activeGrid = this.activeGrid;
|
let activeGrid = this.activeGrid;
|
||||||
let batchId = this.renderedDataSets[activeGrid].batchId;
|
let batchId = this.renderedDataSets[activeGrid].batchId;
|
||||||
let resultId = this.renderedDataSets[activeGrid].resultId;
|
let resultId = this.renderedDataSets[activeGrid].resultId;
|
||||||
let selection = this.slickgrids.toArray()[activeGrid].getSelectedRanges();
|
this.dataService.sendSaveRequest({ batchIndex: batchId, resultSetNumber: resultId, format: format, selection: this.getSelection(activeGrid) });
|
||||||
this.dataService.sendSaveRequest({ batchIndex: batchId, resultSetNumber: resultId, format: format, selection: selection });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _keybindingFor(action: IAction): ResolvedKeybinding {
|
protected _keybindingFor(action: IAction): ResolvedKeybinding {
|
||||||
@@ -377,7 +380,7 @@ export abstract class GridParentComponent {
|
|||||||
let slick: any = this.slickgrids.toArray()[index];
|
let slick: any = this.slickgrids.toArray()[index];
|
||||||
let grid = slick._grid;
|
let grid = slick._grid;
|
||||||
|
|
||||||
let selection = this.slickgrids.toArray()[index].getSelectedRanges();
|
let selection = this.getSelection(index);
|
||||||
|
|
||||||
if (selection && selection.length === 0) {
|
if (selection && selection.length === 0) {
|
||||||
let cell = (grid as Slick.Grid<any>).getCellFromEvent(event);
|
let cell = (grid as Slick.Grid<any>).getCellFromEvent(event);
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
|
|||||||
icon: () => { return 'saveCsv'; },
|
icon: () => { return 'saveCsv'; },
|
||||||
hoverText: () => { return LocalizedConstants.saveCSVLabel; },
|
hoverText: () => { return LocalizedConstants.saveCSVLabel; },
|
||||||
functionality: (batchId, resultId, index) => {
|
functionality: (batchId, resultId, index) => {
|
||||||
let selection = this.slickgrids.toArray()[index].getSelectedRanges();
|
let selection = this.getSelection(index);
|
||||||
if (selection.length <= 1) {
|
if (selection.length <= 1) {
|
||||||
this.handleContextClick({ type: 'savecsv', batchId: batchId, resultId: resultId, index: index, selection: selection });
|
this.handleContextClick({ type: 'savecsv', batchId: batchId, resultId: resultId, index: index, selection: selection });
|
||||||
} else {
|
} else {
|
||||||
@@ -104,7 +104,7 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
|
|||||||
icon: () => { return 'saveJson'; },
|
icon: () => { return 'saveJson'; },
|
||||||
hoverText: () => { return LocalizedConstants.saveJSONLabel; },
|
hoverText: () => { return LocalizedConstants.saveJSONLabel; },
|
||||||
functionality: (batchId, resultId, index) => {
|
functionality: (batchId, resultId, index) => {
|
||||||
let selection = this.slickgrids.toArray()[index].getSelectedRanges();
|
let selection = this.getSelection(index);
|
||||||
if (selection.length <= 1) {
|
if (selection.length <= 1) {
|
||||||
this.handleContextClick({ type: 'savejson', batchId: batchId, resultId: resultId, index: index, selection: selection });
|
this.handleContextClick({ type: 'savejson', batchId: batchId, resultId: resultId, index: index, selection: selection });
|
||||||
} else {
|
} else {
|
||||||
@@ -117,7 +117,7 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
|
|||||||
icon: () => { return 'saveExcel'; },
|
icon: () => { return 'saveExcel'; },
|
||||||
hoverText: () => { return LocalizedConstants.saveExcelLabel; },
|
hoverText: () => { return LocalizedConstants.saveExcelLabel; },
|
||||||
functionality: (batchId, resultId, index) => {
|
functionality: (batchId, resultId, index) => {
|
||||||
let selection = this.slickgrids.toArray()[index].getSelectedRanges();
|
let selection = this.getSelection(index);
|
||||||
if (selection.length <= 1) {
|
if (selection.length <= 1) {
|
||||||
this.handleContextClick({ type: 'saveexcel', batchId: batchId, resultId: resultId, index: index, selection: selection });
|
this.handleContextClick({ type: 'saveexcel', batchId: batchId, resultId: resultId, index: index, selection: selection });
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user