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:
Alan Ren
2022-03-09 14:17:01 -08:00
committed by GitHub
parent 27763c860c
commit e50bded5d1
19 changed files with 352 additions and 153 deletions

View 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;
}