mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-28 17:23:19 -05:00
table designer new features (#18682)
* support graph tables * ignore script compare * ability to refresh view after edit * reserve focus after refresh view * primary key and default constraint * bug fixes * vbump sts * comments * update type * fix issue
This commit is contained in:
37
src/sql/workbench/browser/designer/designerTableUtil.ts
Normal file
37
src/sql/workbench/browser/designer/designerTableUtil.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Table } from 'sql/base/browser/ui/table/table';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { deepClone } from 'vs/base/common/objects';
|
||||
|
||||
export const TableRowHeight = 25;
|
||||
export const TableHeaderRowHeight = 28;
|
||||
const minHeight = getTableHeight(2);
|
||||
|
||||
/**
|
||||
* Layout the table, the height will be determined by the number of rows in it.
|
||||
* @param table the table.
|
||||
* @param width width of the table
|
||||
*/
|
||||
export function layoutDesignerTable(table: Table<Slick.SlickData>, width: number): void {
|
||||
let activeCell: Slick.Cell = undefined;
|
||||
if (table.container.contains(document.activeElement)) {
|
||||
// Note down the current active cell if the focus is currently in the table
|
||||
// After the table layout operation is done, the focus will be restored.
|
||||
activeCell = deepClone(table.activeCell);
|
||||
}
|
||||
const rows = table.getData().getLength();
|
||||
const actualHeight = getTableHeight(rows);
|
||||
const height = Math.max(minHeight, actualHeight);
|
||||
table.layout(new DOM.Dimension(width - 20 /* Padding and scroll bar */, height));
|
||||
if (activeCell && rows > activeCell.row) {
|
||||
table.setActiveCell(activeCell.row, activeCell.cell);
|
||||
}
|
||||
}
|
||||
|
||||
function getTableHeight(rows: number): number {
|
||||
return rows * TableRowHeight + TableHeaderRowHeight;
|
||||
}
|
||||
Reference in New Issue
Block a user