From 486a2c8395c3da7b218fa1e9d1aa3ec65ee5c12d Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Fri, 11 Sep 2015 09:13:00 -0600 Subject: [PATCH 1/6] Employ generics in Angular ui-grid for entity type Merge branch 'master' of https://github.com/borisyankov/DefinitelyTyped into ui-grid # By Makis Maropoulos (6) and others # Via Horiuchi_H (9) and herrmanno (1) * 'master' of https://github.com/borisyankov/DefinitelyTyped: Added observe-js definition I moved the project, update the project's url here also Add the helpers property to the Handlebars module Updated node-jsfl-runner to 0.2.4 Updating lovefield definitions for Lovefield v2.0.62. Update node-mysql-wrapper-tests.ts Update node-mysql-wrapper.d.ts Update node-mysql-wrapper-tests.ts Update node-mysql-wrapper-tests.ts Update to V2.3.6. Refactoring of interfaces for SlickGrid event args add archiver update version update version update serve-favicon update cookie-parser --- ui-grid/ui-grid-tests.ts | 36 +++- ui-grid/ui-grid.d.ts | 386 +++++++++++++++++++-------------------- 2 files changed, 219 insertions(+), 203 deletions(-) diff --git a/ui-grid/ui-grid-tests.ts b/ui-grid/ui-grid-tests.ts index 21d42c021..5b644d2fa 100644 --- a/ui-grid/ui-grid-tests.ts +++ b/ui-grid/ui-grid-tests.ts @@ -1,19 +1,25 @@ /// /// -var columnDef: uiGrid.IColumnDef; +interface MyEntity { + name: string; + age: number; +} + +var columnDef: uiGrid.IColumnDef; columnDef.aggregationHideLabel = true; columnDef.aggregationHideLabel = false; columnDef.aggregationType = 1; columnDef.aggregationType = function () { return 1; }; columnDef.cellClass = 'test'; -columnDef.cellClass = function (gridRow: uiGrid.IGridRow, gridCol: uiGrid.IGridColumn, index: number) { +columnDef.cellClass = (gridRow, gridCol, index) => { + //types of gridRow, gridCol, and index are flowed in correctly return 'pizza'; }; columnDef.cellFilter = 'date'; columnDef.cellTemplate = '
hello
'; columnDef.cellTooltip = 'blah'; -columnDef.cellTooltip = function (gridRow: uiGrid.IGridRow, gridCol: uiGrid.IGridColumn) { +columnDef.cellTooltip = function (gridRow: uiGrid.IGridRow, gridCol: uiGrid.IGridColumn) { return 'blah'; }; columnDef.displayName = 'Jumper'; @@ -38,15 +44,16 @@ columnDef.filter = { columnDef.filterCellFiltered = false; columnDef.filterHeaderTemplate = '
'; columnDef.filters = [columnDef.filter]; -columnDef.footerCellClass = - (gridRow: uiGrid.IGridRow, rowRenderIndex: number, gridCol: uiGrid.IGridColumn, colRenderIndex: number) => { +columnDef.footerCellClass = (gridRow, rowRenderIndex, gridCol, colRenderIndex) => { + //types for gridRow, rowRenderIndex, gridCol, and colRenderIndex flow in properly return 'blah'; }; columnDef.footerCellClass = 'theClass'; columnDef.footerCellFilter = 'currency:$'; columnDef.footerCellTemplate = '
'; columnDef.headerCellClass = - (gridRow: uiGrid.IGridRow, rowRenderIndex: number, gridCol: uiGrid.IGridColumn, colRenderIndex: number) => { + (gridRow, rowRenderIndex, gridCol, colRenderIndex) => { + //types for gridRow, rowRenderIndex, gridCol, and colRenderIndex flow in properly return 'blah'; }; columnDef.headerCellClass = 'classy'; @@ -54,7 +61,8 @@ columnDef.headerCellFilter = 'currency:$'; columnDef.headerCellTemplate = '
'; columnDef.headerTooltip = false; columnDef.headerTooltip = 'The Tooltip'; -columnDef.headerTooltip = (col: uiGrid.IGridColumn) => { +columnDef.headerTooltip = (col) => { + //type of col flows in properly return 'tooly'; }; columnDef.maxWidth = 200; @@ -87,10 +95,10 @@ columnDef.width = 100; columnDef.width = '*'; -var gridApi: uiGrid.IGridApi; -var gridInstance: uiGrid.IGridInstance; +var gridApi: uiGrid.IGridApi; +var gridInstance: uiGrid.IGridInstance; var menuItem: uiGrid.IMenuItem; -var colProcessor: uiGrid.IColumnProcessor; +var colProcessor: uiGrid.IColumnProcessor; gridApi.core.clearAllFilters(true); gridApi.core.addToGridMenu(gridInstance, [menuItem]); @@ -100,3 +108,11 @@ gridApi.core.queueGridRefresh() gridApi.core.queueRefresh(); gridApi.core.registerColumnsProcessor(colProcessor, 100); +var gridOptions: uiGrid.IGridOptions = { + data: [{name: 'Bob', age: 100}], + onRegisterApi: (api) => { + api.selection.on.rowSelectionChanged(null, (row) => { + console.log(row.entity.name); + }) + } +} \ No newline at end of file diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index c41cac7c6..42eb36efd 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -120,12 +120,12 @@ declare module uiGrid { ALWAYS: number; } } - export interface IGridInstance { + export interface IGridInstance { /** * adds a row header column to the grid * @param {IColumnDef} colDef The column definition */ - addRowHeaderColumn(colDef: IColumnDef): void; + addRowHeaderColumn(colDef: IColumnDef): void; /** * uses the first row of data to assign colDef.type for any types not defined. */ @@ -134,7 +134,7 @@ declare module uiGrid { * Populates columnDefs from the provided data * @param {IRowBuilder} rowBuilder function to be called */ - buildColumnDefsFromData(rowBuilder: IRowBuilder): void; + buildColumnDefsFromData(rowBuilder: IRowBuilder): void; /** * creates GridColumn objects from the columnDefinition. * Calls each registered columnBuilder to further process the column @@ -193,48 +193,48 @@ declare module uiGrid { * @param {IGridColumn} col Column to access * @returns {string} Cell display value */ - getCellDisplayValue(row: IGridRow, col: IGridColumn): string; + getCellDisplayValue(row: IGridRow, col: IGridColumn): string; /** * Gets the displayed value of a cell * @param {IGridRow} row Row to access * @param {IGridColumn} col Column to access * @returns {any} Cell value */ - getCellValue(row: IGridRow, col: IGridColumn): any; + getCellValue(row: IGridRow, col: IGridColumn): any; /** * returns a grid colDef for the column name * @param {string} name Column name * @returns {IColumnDef} The column definition */ - getColDef(name: string): IColumnDef; + getColDef(name: string): IColumnDef; /** * returns a grid column by name * @param {string} name Column name * @returns {IGridColumn} The column */ - getColumn(name: string): IGridColumn; + getColumn(name: string): IGridColumn; /** * Return the columns that the grid is currently being sorted by * @returns {Array} the columns that the grid is currently being sorted by */ - getColumnSorting(): Array; + getColumnSorting(): Array>; /** * Returns the $parse-able accessor for a column within its $scope * @param {IGridColumn} col Column object * @returns {string} $parse-able accessor for a column within its $scope */ - getGridQualifiedColField(col: IGridColumn): string; + getGridQualifiedColField(col: IGridColumn): string; /** * returns all columns except for rowHeader columns * @returns {Array} All data columns */ - getOnlyDataColumns(): Array; + getOnlyDataColumns(): Array>; /** * returns the GridRow that contains the rowEntity * @param {any} rowEntity the gridOptionms.data array element instance * @param {Array} rows The rows to look in. if not provided then it looks in grid.rows */ - getRow(rowEntity: any, rows?: Array): IGridRow; + getRow(rowEntity: TEntity, rows?: Array>): IGridRow; /** * Triggered when the browser window resizes; automatically resizes the grid * @param {ng.IAngularEvent} $event Resize event @@ -270,7 +270,7 @@ declare module uiGrid { * @param {IGridColumn} column The column * @returns {boolean} true if the column is a row header */ - isRowHeaderColumn(column: IGridColumn): boolean; + isRowHeaderColumn(column: IGridColumn): boolean; /** * creates or removes GridRow objects from the newRawData array. Calls each registered * rowBuilder to further process the row @@ -309,7 +309,7 @@ declare module uiGrid { * @param {IGridRow} gridRow reference to gridRow * @returns {IGridRow} the gridRow with all additional behavior added */ - processRowBuilders(gridRow: IGridRow): IGridRow; + processRowBuilders(gridRow: IGridRow): IGridRow; /** * calls the row processors, specifically * intended to reset the sorting when an edit is called, @@ -360,7 +360,7 @@ declare module uiGrid { * additional properties to the column. * @param {IColumnBuilder} columnBuilder function to be called */ - registerColumnBuilder(columnBuilder: IColumnBuilder): void; + registerColumnBuilder(columnBuilder: IColumnBuilder): void; /** * Register a "columns processor" function. When the columns are updated, * the grid calls each registered "columns processor", which has a chance @@ -373,7 +373,7 @@ declare module uiGrid { * for other people to inject columns processors at intermediate priorities. * Lower priority columnsProcessors run earlier.priority */ - registerColumnsProcessor(columnProcessor: IColumnProcessor, priority: number): void; + registerColumnsProcessor(columnProcessor: IColumnProcessor, priority: number): void; /** * When a data change occurs, the data change callbacks of the specified type * will be called. The rules are: @@ -398,13 +398,13 @@ declare module uiGrid { * ALL * @returns {Function} deregister function - a function that can be called to deregister this callback */ - registerDataChangeCallback(callback: (grid: IGridInstance) => void, types: Array): Function; + registerDataChangeCallback(callback: (grid: IGridInstance) => void, types: Array): Function; /** * When the build creates rows from gridOptions.data, the rowBuilders will be called to add * additional properties to the row. * @param {IRowBuilder} rowBuilder Function to be called */ - registerRowBuilder(rowBuilder: IRowBuilder): void; + registerRowBuilder(rowBuilder: IRowBuilder): void; /** * Register a "rows processor" function. When the rows are updated, * the grid calls each registered "rows processor", which has a chance @@ -420,7 +420,7 @@ declare module uiGrid { * is running at 50, filter is running at 100, sort is at 200, grouping at 400, selectable rows at * 500, pagination at 900 (pagination will generally want to be last) */ - registerRowsProcessor(rowProcessor: IRowProcessor, priority: number): void; + registerRowsProcessor(rowProcessor: IRowProcessor, priority: number): void; /** * registered a styleComputation function * @@ -432,12 +432,12 @@ declare module uiGrid { * Remove a registered rows processor * @param {IRowProcessor} rows processor function */ - removeRowsProcessor(rows: IRowProcessor): void; + removeRowsProcessor(rows: IRowProcessor): void; /** * Return the columns that the grid is currently being sorted by * @param {IGridColumn} [excludedColumn] Optional GridColumn to exclude from having its sorting reset */ - resetColumnSorting(excludedColumn: IGridColumn): void; + resetColumnSorting(excludedColumn: IGridColumn): void; /** * Scroll the grid such that the specified * row and column is in view @@ -445,7 +445,7 @@ declare module uiGrid { * @param {IColumnDef} colDef to make visible * @returns {ng.IPromise} a promise that is resolved after any scrolling is finished */ - scrollTo(rowEntity: IGridRow, colDef: IColumnDef): ng.IPromise; + scrollTo(rowEntity: IGridRow, colDef: IColumnDef): ng.IPromise; /** * Scrolls the grid to make a certain row and column combo visible, * in the case that it is not completely visible on the screen already. @@ -453,7 +453,7 @@ declare module uiGrid { * @param {IGridColumn} gridCol column to make visible * @returns {ng.IPromise} a promise that is resolved when scrolling is complete */ - scrollToIfNecessary(gridRow: IGridRow, gridCol: IGridColumn): ng.IPromise; + scrollToIfNecessary(gridRow: IGridRow, gridCol: IGridColumn): ng.IPromise; /** * Set the sorting on a given column, optionally resetting any existing sorting on the Grid. * Emits the sortChanged event whenever the sort criteria are changed. @@ -465,7 +465,7 @@ declare module uiGrid { * reset any existing sorting and sort by this column only * @returns {ng.IPromise} A resolved promise that supplies the column. */ - sortColumn(column: IGridColumn, direction?: string, add?: boolean): ng.IPromise; + sortColumn(column: IGridColumn, direction?: string, add?: boolean): ng.IPromise>; /** * flags all render containers to update their canvas height */ @@ -509,22 +509,22 @@ declare module uiGrid { export interface IStyleComputation { ($scope: ng.IScope): string; } - export interface IColumnBuilder { - (colDef: IColumnDef, col: IGridColumn, gridOptions: IGridOptions): void; + export interface IColumnBuilder { + (colDef: IColumnDef, col: IGridColumn, gridOptions: IGridOptions): void; } - export interface IRowBuilder { - (row: IGridRow, gridOptions: IGridOptions): void; + export interface IRowBuilder { + (row: IGridRow, gridOptions: IGridOptions): void; } - export interface IRowProcessor { - (renderedRowsToProcess: Array, columns: Array): Array; + export interface IRowProcessor { + (renderedRowsToProcess: Array>, columns: Array>): Array>; } - export interface IColumnProcessor { - (renderedColumnsToProcess: Array, rows: Array): Array; + export interface IColumnProcessor { + (renderedColumnsToProcess: Array>, rows: Array>): Array>; } - export interface IGridOptions extends cellNav.IGridOptions, edit.IGridOptions, expandable.IGridOptions, - exporter.IGridOptions, grouping.IGridOptions, importer.IGridOptions, infiniteScroll.IGridOptions, + export interface IGridOptions extends cellNav.IGridOptions, edit.IGridOptions, expandable.IGridOptions, + exporter.IGridOptions, grouping.IGridOptions, importer.IGridOptions, infiniteScroll.IGridOptions, moveColumns.IGridOptions, pagination.IGridOptions, pinning.IGridOptions, resizeColumns.IGridOptions, - rowEdit.IGridOptions, saveState.IGridOptions, selection.IGridOptions, treeBase.IGridOptions, + rowEdit.IGridOptions, saveState.IGridOptions, selection.IGridOptions, treeBase.IGridOptions, treeView.IGridOptions { /** * Default time in milliseconds to throttle aggregation calcuations, defaults to 500ms @@ -538,7 +538,7 @@ declare module uiGrid { /** * Array of columnDef objects. Only required property is name. */ - columnDefs?: Array; + columnDefs?: Array>; /** * The height of the footer rows (column footer and grid footer) in pixels */ @@ -582,7 +582,7 @@ declare module uiGrid { * Where you do this, you need to take care in updating the data - you can't just update `$scope.myData` to some * other array, you need to update $scope.gridOptions.data to point to that new array as well. */ - data?: Array | string; + data?: Array | string; /** * True by default. When enabled, this setting displays a column * menu within each column. @@ -733,7 +733,7 @@ declare module uiGrid { * if needed * @param {IGridApi} gridApi */ - onRegisterApi?: (gridApi: IGridApi) => void; + onRegisterApi?: (gridApi: IGridApi) => void; /** * The height of the row in pixels, defaults to 30 * @default 30 @@ -801,14 +801,14 @@ declare module uiGrid { * @param {IGridRow} row The row for which you want the unique id * @returns {string} row uid */ - getRowIdentity?(row: IGridRow): any; + getRowIdentity?(row: IGridRow): any; /** * By default, rows are compared using object equality. This option can be overridden * to compare on any data item property or function * @param {IGridRow} entityA First Data Item to compare * @param {IGridRow} entityB Second Data Item to compare */ - rowEquality?(entityA: IGridRow, entityB: IGridRow): boolean; + rowEquality?(entityA: IGridRow, entityB: IGridRow): boolean; /** * This function is used to get and, if necessary, set the value uniquely identifying this row * (i.e. if an identity is not present it will set one). @@ -818,13 +818,13 @@ declare module uiGrid { */ rowIdentity?(): any; } - export interface IGridCoreApi { + export interface IGridCoreApi { // Methods /** * adds a row header column to the grid * @param {IColumnDef} column Column Definition */ - addRowHeaderColumn(column: IColumnDef): void; + addRowHeaderColumn(column: IColumnDef): void; /** * add items to the grid menu. Used by features * to add their menu items if they are enabled, can also be used by @@ -838,7 +838,7 @@ declare module uiGrid { * which is provided when you want to remove an item. The id should be unique. */ - addToGridMenu(grid: IGridInstance, items: Array): void; + addToGridMenu(grid: IGridInstance, items: Array): void; /** * Clears all filters and optionally refreshes the visible rows. * @param {boolean} [refreshRows=true] Defaults to true. @@ -847,7 +847,7 @@ declare module uiGrid { * @returns {ng.IPromise} If `refreshRows` is true, returns a promise of the rows refreshing. */ clearAllFilters(refreshRows?: boolean, clearConditions?: boolean, - clearFlags?: boolean): ng.IPromise>; + clearFlags?: boolean): ng.IPromise>>; /** * Clears any override on visibility for the row so that it returns to * using normal filtering and other visibility calculations. @@ -862,7 +862,7 @@ declare module uiGrid { * @param {IGridInstance} grid the grid you want to get visible rows from * @returns {Array} an array of gridRow */ - getVisibleRows(grid: IGridInstance): Array; + getVisibleRows(grid: IGridInstance): Array>; /** * Trigger a grid resize, normally this would be picked * up by a watch on window size, but in some circumstances it is necessary @@ -902,7 +902,7 @@ declare module uiGrid { * At present allRowsVisible is running at 50, filter is running at 100, sort is at 200, grouping at 400, * selectable rows at 500, pagination at 900 (pagination will generally want to be last) */ - registerColumnsProcessor(processorFunction: IColumnProcessor, priority: number): void; + registerColumnsProcessor(processorFunction: IColumnProcessor, priority: number): void; /** * Register a "rows processor" function. When the rows are updated, * the grid calls each registered "rows processor", which has a chance @@ -919,7 +919,7 @@ declare module uiGrid { * At present all rows visible is running at 50, filter is running at 100, sort is at 200, grouping at 400, * selectable rows at 500, pagination at 900 (pagination will generally want to be last) */ - registerRowsProcessor(rowProcessor: IRowProcessor, priority: number): void; + registerRowsProcessor(rowProcessor: IRowProcessor, priority: number): void; /** * Scroll the grid such that the specified * row and column is in view @@ -927,7 +927,7 @@ declare module uiGrid { * @param {IColumnDef} colDef to make visible * @returns {ng.IPromise} a promise that is resolved after any scrolling is finished */ - scrollTo(entity: any, colDef: IColumnDef): void; /*A row entity can be anything?*/ + scrollTo(entity: any, colDef: IColumnDef): void; /*A row entity can be anything?*/ /** * Scrolls the grid to make a certain row and column combo visible, * in the case that it is not completely visible on the screen already. @@ -935,7 +935,7 @@ declare module uiGrid { * @param {IGridColumn} gridCol column to make visible * @returns {ng.IPromise} a promise that is resolved when scrolling is complete */ - scrollToIfNecessary(gridRow: IGridRow, gridCol: IGridColumn): void; + scrollToIfNecessary(gridRow: IGridRow, gridCol: IGridColumn): void; /** * A null handling method that can be used when building custom sort * functions @@ -969,7 +969,7 @@ declare module uiGrid { * @param {columnVisibilityChangedHandler} callBack Will be called when the event is emited. * The function passes back the GridCol that has changed */ - columnVisibilityChanged: (scope: ng.IScope, callBack: columnVisibilityChangedHandler) => void; + columnVisibilityChanged: (scope: ng.IScope, callBack: columnVisibilityChangedHandler) => void; /** * is raised after the filter is changed. * The nature of the watch expression doesn't allow notification of what changed, @@ -977,13 +977,13 @@ declare module uiGrid { * @param {ng.IScope} scope Grid scope * @param {filterChangedHandler} handler Callback */ - filterChanged: (scope: ng.IScope, handler: filterChangedHandler) => void; + filterChanged: (scope: ng.IScope, handler: filterChangedHandler) => void; /** * is raised after the cache of visible rows is changed * @param {ng.IScope} scope Grid scope * @param {rowsRenderedHandler} handler callback */ - rowsRendered: (scope: ng.IScope, handler: rowsRenderedHandler) => void; + rowsRendered: (scope: ng.IScope, handler: rowsRenderedHandler) => void; /** * is raised after the rows that are visible change. * The filtering is zero-based, so it isn't possible to say which rows changed @@ -993,7 +993,7 @@ declare module uiGrid { * @param {ng.IScope} scope Grid scope * @param {rowsVisibleChangedHandler} handler callback */ - rowsVisibleChanged: (scope: ng.IScope, handler: rowsVisibleChangedHandler) => void; + rowsVisibleChanged: (scope: ng.IScope, handler: rowsVisibleChangedHandler) => void; /** * is raised when scroll begins. Is throttled, so won't be raised too frequently * @param {ng.IScope} scope Grid scope @@ -1008,12 +1008,12 @@ declare module uiGrid { scrollEnd: (scope: ng.IScope, handler: scrollEndHandler) => void; } } - export interface columnVisibilityChangedHandler { + export interface columnVisibilityChangedHandler { /** * Column visibility changed event handler * @param {IGridColumn} column Ui Grid column */ - (column: IGridColumn): void; + (column: IGridColumn): void; } export interface canvasHeightChangedHandler { /** @@ -1024,28 +1024,28 @@ declare module uiGrid { (oldHeight: number, newHeight: number): void; } - export interface filterChangedHandler{ + export interface filterChangedHandler { /** * Filter changed event callback * @param {IGridApi} gridApi grid api */ - (gridApi: IGridApi): void; + (gridApi: IGridApi): void; } - export interface rowsRenderedHandler { + export interface rowsRenderedHandler { /** * Rows rendered event callback * @param {IGridApi} gridApi Grid api object */ - (gridApi: IGridApi): void; + (gridApi: IGridApi): void; } - export interface rowsVisibleChangedHandler { + export interface rowsVisibleChangedHandler { /** * Rows visible changed event callback * @param {IGridApi} gridApi grid api object */ - (gridApi: IGridApi): void; + (gridApi: IGridApi): void; } export interface scrollBeginHandler { @@ -1102,24 +1102,24 @@ declare module uiGrid { allowCellFocus?: boolean; } - export interface ICellNavApi { + export interface ICellNavApi { // Methods /** * Gets the currently selected rows and columns. array is empty if no selection has occurred * @returns {Array} an array containing the current selection */ - getCurrentSelection(): Array; + getCurrentSelection(): Array>; /** * Gets the current focused cell. value is null if no selection has occurred * @returns {IRowCol} the current (or last if Grid does not have focus) focused row and column */ - getFocusedCell(): IRowCol; + getFocusedCell(): IRowCol; /** * Gets the index of the passed rowCol. Returns -1 if the RowCol isn't selected * @param rowCol * @returns the index in the order in which the RowCol was selected */ - rowColSelectIndex(rowCol: IRowCol): number; + rowColSelectIndex(rowCol: IRowCol): number; /** * Brings the specified row and column into view, and sets focus to that cell * @param {any} rowEntity gridOptions.data[] array instance to make visible and set focus @@ -1134,7 +1134,7 @@ declare module uiGrid { * @param {ng.IScope} scope The grid scope * @param {navigateHandler} handler Callback */ - navigate: (scope: ng.IScope, handler: navigateHandler) => void; + navigate: (scope: ng.IScope, handler: navigateHandler) => void; /** * viewportKeyDown is raised when the viewPort receives a keyDown event. * Cells never get focus in uiGrid due to the difficulties of setting focus on a cell that is @@ -1142,7 +1142,7 @@ declare module uiGrid { * @param {ng.IScope} scope The grid scope * @param {viewportKeyDownHandler} handler Callback */ - viewportKeyDown: (scope: ng.IScope, handler: viewportKeyDownHandler) => void; + viewportKeyDown: (scope: ng.IScope, handler: viewportKeyDownHandler) => void; /** * viewportKeyPress is raised when the viewPort receives a keyPress event. * Cells never get focus in uiGrid due to the difficulties of setting focus on a cell that is @@ -1150,47 +1150,47 @@ declare module uiGrid { * @param {ng.IScope} scope The grid scope * @param {viewportKeyPressHandler} handler Callback */ - viewportKeyPress: (scope: ng.IScope, handler: viewportKeyPressHandler) => void; + viewportKeyPress: (scope: ng.IScope, handler: viewportKeyPressHandler) => void; } } - export interface navigateHandler { + export interface navigateHandler { /** * Callback for navigate event * @param {IRowCol} newRowCol New position * @param {IRowCol} oldRowCol Old position */ - (newRowCol: IRowCol, oldRowCol: IRowCol): void; + (newRowCol: IRowCol, oldRowCol: IRowCol): void; } - export interface viewportKeyDownHandler { + export interface viewportKeyDownHandler { /** * Callback for viewport key down event * @param {JQueryKeyEventObject} event Keydown event * @param {IRowCol} rowCol Current row Col position */ - (event: JQueryKeyEventObject, rowCol: IRowCol): void; + (event: JQueryKeyEventObject, rowCol: IRowCol): void; } - export interface viewportKeyPressHandler { + export interface viewportKeyPressHandler { /** * Callback for viewport key press event * @param {JQueryKeyEventObject} event Keypress event * @param {IRowCol} rowCol Current row Col position */ - (event: JQueryKeyEventObject, rowCol: IRowCol): void; + (event: JQueryKeyEventObject, rowCol: IRowCol): void; } - export interface IRowColConstructor { - new (row: uiGrid.IGridRow, col: IGridColumn): IRowCol; + export interface IRowColConstructor { + new (row: uiGrid.IGridRow, col: IGridColumn): IRowCol; } /** * A row and column pair that represents the intersection of these two entities */ - export interface IRowCol { - row: uiGrid.IGridRow; - col: IGridColumn; + export interface IRowCol { + row: uiGrid.IGridRow; + col: IGridColumn; /** * Gets the intersection of where the row and column meet * @returns The value from the grid data that this RowCol points to. If the column has a cellFilter this @@ -1230,7 +1230,7 @@ declare module uiGrid { /** * Edit related Column Definition */ - export interface IColumnDef { + export interface IColumnDef { /** * If specified, either a value or function evaluated before editing cell. * If falsy, then editing of cell is not allowed. @@ -1282,7 +1282,7 @@ declare module uiGrid { reader.readAsText( files[0] ); } */ - editFileChooserCallback?: (gridRow: uiGrid.IGridRow, gridCol: IGridColumn, files: FileList) => void; + editFileChooserCallback?: (gridRow: uiGrid.IGridRow, gridCol: IGridColumn, files: FileList) => void; /** * A bindable string value that is used when binding to edit controls instead of colDef.field * For example if you have a complex property on an object like: @@ -1356,29 +1356,29 @@ declare module uiGrid { /** * Public Api for edit feature */ - export interface IGridEditApi { + export interface IGridEditApi { on: { /** * raised when cell editing is complete * @param scope The grid scope * @param {afterCellEditHandler} handler Callback */ - afterCellEdit: (scope: ng.IScope, handler: afterCellEditHandler) => void; + afterCellEdit: (scope: ng.IScope, handler: afterCellEditHandler) => void; /** * raised when cell editing starts on a cell * @param scope The grid scope * @param {beginCellEditHandler} handler Callback */ - beginCellEdit: (scope: ng.IScope, handler: beginCellEditHandler) => void; + beginCellEdit: (scope: ng.IScope, handler: beginCellEditHandler) => void; /** * raised when cell editing is cancelled on a cell * @param scope The grid scope * @param {cancelCellEditHandler} handler Callback */ - cancelCellEdit: (scope: ng.IScope, handler: cancelCellEditHandler) => void; + cancelCellEdit: (scope: ng.IScope, handler: cancelCellEditHandler) => void; } } - export interface afterCellEditHandler{ + export interface afterCellEditHandler { /** * raised when cell editing is complete * @param {any} rowEntity the options.data element that was edited @@ -1386,7 +1386,7 @@ declare module uiGrid { * @param {any} newValue New Value * @param {any} oldValue Old Value */ - (rowEntity: any, colDef: IColumnDef, newValue: any, oldValue: any): void; + (rowEntity: any, colDef: IColumnDef, newValue: any, oldValue: any): void; } /** @@ -1396,8 +1396,8 @@ declare module uiGrid { * @param {JQueryEventObject} triggerEvent the event that triggered the edit. Useful to prevent losing * keystrokes on some complex editors */ - export interface beginCellEditHandler{ - (rowEntity: any, colDef: IColumnDef, triggerEvent: JQueryEventObject): void; + export interface beginCellEditHandler { + (rowEntity: any, colDef: IColumnDef, triggerEvent: JQueryEventObject): void; } /** @@ -1405,8 +1405,8 @@ declare module uiGrid { * @param {any} rowEntity the options.data element that was edited * @param {IColumnDef} colDef The column that was edited */ - export interface cancelCellEditHandler{ - (rowEntity: any, colDef: IColumnDef): void; + export interface cancelCellEditHandler { + (rowEntity: any, colDef: IColumnDef): void; } /** @@ -1458,7 +1458,7 @@ declare module uiGrid { /** * Public Api for expandable feature */ - export interface IGridExpandableApi { + export interface IGridExpandableApi { // Methods /** * Collapse all subgrids. @@ -1485,16 +1485,16 @@ declare module uiGrid { * @param {ng.IScope} scope * @param {rowExpandedStateChangedHandler} handler */ - rowExpandedStateChanged: (scope: ng.IScope, handler: rowExpandedStateChangedHandler) => void; + rowExpandedStateChanged: (scope: ng.IScope, handler: rowExpandedStateChangedHandler) => void; } } - export interface rowExpandedStateChangedHandler { + export interface rowExpandedStateChangedHandler { /** * Raised when cell editing is complete * @param {IGridRow} row The row that was expanded */ - (row: IGridRow): void; + (row: IGridRow): void; } } @@ -1517,7 +1517,7 @@ declare module uiGrid { /** * GridOptions for exporter feature, these are available to be set using the ui-grid gridOptions */ - export interface IGridOptions { + export interface IGridOptions { /** * This promise is needed when exporting all rows, and the data need to be provided by server side. * Default is null @@ -1558,7 +1558,7 @@ declare module uiGrid { * @param {any} value The cell value * @returns {any} Formatted value */ - exporterFieldCallback?: (grid: IGridInstance, row: uiGrid.IGridRow, col: IGridColumn, value: any) => any; + exporterFieldCallback?: (grid: IGridInstance, row: uiGrid.IGridRow, col: IGridColumn, value: any) => any; /** * A function to apply to the header displayNames before exporting. Useful for internationalisation, * for example if you were using angular-translate you'd set this to $translate.instant. @@ -1827,7 +1827,7 @@ declare module uiGrid { /** * Public Api for grouping feature */ - export interface IGridGroupingApi { + export interface IGridGroupingApi { // Methods /** * Sets the aggregation type on a column. @@ -1884,13 +1884,13 @@ declare module uiGrid { * @param {ng.IScope} scope Grid Scope * @param {aggregationChangedHandler} handler Callback method */ - aggregationChanged: (scope: ng.IScope, handler: aggregationChangedHandler) => void; + aggregationChanged: (scope: ng.IScope, handler: aggregationChangedHandler) => void; /** * raised whenever the grouped columns change * @param {ng.IScope} scope Grid Scope * @param {groupingChangedHandler} handler Callback method */ - groupingChanged: (scope: ng.IScope, handler: groupingChangedHandler) => void; + groupingChanged: (scope: ng.IScope, handler: groupingChangedHandler) => void; }; } /** @@ -1929,22 +1929,22 @@ declare module uiGrid { export interface IGridExpandedHash { [key: string]: IGridExpandedHash | string; } - export interface aggregationChangedHandler { + export interface aggregationChangedHandler { /** * raised whenever aggregation is changed, added or removed from a column * @param {IGridColumn} col the column which on which aggregation changed. * The aggregation type is available as col.treeAggregation.type */ - (col: IGridColumn): void; + (col: IGridColumn): void; } - export interface groupingChangedHandler { + export interface groupingChangedHandler { /** * raised whenever the grouped columns changes * @param {IGridColumn} col the column which on which grouping changed. * The new grouping is available as col.grouping */ - (col: IGridColumn): void; + (col: IGridColumn): void; } /** @@ -1961,7 +1961,7 @@ declare module uiGrid { /** * GridOptions for importer feature, these are available to be set using the ui-grid gridOptions */ - export interface IGridOptions { + export interface IGridOptions { /** * A mandatory callback function that adds data to the source data array. * The grid generally doesn't add rows to the source data array, @@ -1969,7 +1969,7 @@ declare module uiGrid { * @param {IGridInstance} grid The grid we're importing into, may be useful in some way * @param {Array} newObjects An array of new objects that you should add to your data */ - importerDataAddCallback?: (grid: IGridInstance, newObjects: Array) => void; + importerDataAddCallback?: (grid: IGridInstance, newObjects: Array) => void; /** * A callback function that provides custom error handling, * rather than the standard grid behaviour of an alert box and a console message. @@ -1986,7 +1986,7 @@ declare module uiGrid { * @param {any} context the context data that importer would have appended to that console message, * often the file content itself or the element that is in error */ - importerErrorCallback?: (grid: IGridInstance, errorKey: string, consoleMessage: string, + importerErrorCallback?: (grid: IGridInstance, errorKey: string, consoleMessage: string, context: any) => void; /** * A callback function that will filter (usually translate) a single header. @@ -2006,7 +2006,7 @@ declare module uiGrid { * @returns {any} The modified object * @default angular.identity */ - importerObjectCallback?: (grid: IGridInstance, newObject: any) => any; + importerObjectCallback?: (grid: IGridInstance, newObject: any) => any; /** * A callback function that will process headers using custom * logic. Set this callback function if the headers that your user will provide in their @@ -2025,7 +2025,7 @@ declare module uiGrid { * which you need to match to column.names * @returns {Array} array of matching column names, in the same order as the headerArray */ - importerProcessHeaders?: (grid: IGridInstance, headerArray: Array) => Array; + importerProcessHeaders?: (grid: IGridInstance, headerArray: Array) => Array; /** * Whether or not importer is enabled. Automatically set * to false if the user's browser does not support the required fileApi. @@ -2088,7 +2088,7 @@ declare module uiGrid { /** * Public API for infinite scroll feature */ - export interface IGridInfiniteScrollApi { + export interface IGridInfiniteScrollApi { // Methods /** * Call this function when you have loaded the additional data requested. @@ -2128,7 +2128,7 @@ declare module uiGrid { * @param {boolean} scrollDown flag that there are pages downwards, so fire infinite scroll events downward * @returns {ng.IPromise} A promise that is resolved when scrolling finishes */ - dataRemovedBottom(grid: IGridInstance, scrollUp: boolean, scrollDown: boolean): ng.IPromise; + dataRemovedBottom(grid: IGridInstance, scrollUp: boolean, scrollDown: boolean): ng.IPromise; /** * Adjusts the scroll position after you've removed data at the bottom * @param {boolean} scrollUp flag that there are pages upwards, fire infinite scroll events upward @@ -2147,7 +2147,7 @@ declare module uiGrid { * @param {boolean} scrollDown flag that there are pages downwards, so fire infinite scroll events downward * @returns {ng.IPromise} A promise that is resolved when scrolling finishes */ - dataRemovedTop(grid: IGridInstance, scrollUp: boolean, scrollDown: boolean): ng.IPromise; + dataRemovedTop(grid: IGridInstance, scrollUp: boolean, scrollDown: boolean): ng.IPromise; /** * Call this function when you have taken some action that makes the current scroll position invalid. * For example, if you're using external sorting and you've resorted then you might reset the scroll, @@ -2356,14 +2356,14 @@ declare module uiGrid { enablePinning?: boolean; } - export interface IGridPinningApi { + export interface IGridPinningApi { // Methods /** * Pin column left, right, or none * @param {IGridColumn} col The column being pinned * @param {string} container One of the recognized container types from uiGridPinningConstants */ - pinColumn(col: IGridColumn, container: string): void; + pinColumn(col: IGridColumn, container: string): void; // Events /** @@ -2456,7 +2456,7 @@ declare module uiGrid { rowEditWaitInterval?: number; } - export interface IGridRowEditApi { + export interface IGridRowEditApi { // Methods /** * Triggers a save event for all currently dirty rows. @@ -2465,19 +2465,19 @@ declare module uiGrid { * @returns {ng.IPromise>} a promise that represents the aggregate of all of the individual save * promises. i.e. it will be resolved when all the individual save promises have been resolved. */ - flushDirtyRows(grid?: IGridInstance): ng.IPromise>; + flushDirtyRows(grid?: IGridInstance): ng.IPromise>; /** * Returns all currently dirty rows * @param {IGridInstance} grid The target grid * @returns {Array} An array of gridRows that are currently dirty */ - getDirtyRows(grid?: IGridInstance): Array; + getDirtyRows(grid?: IGridInstance): Array>; /** * Returns all currently errored rows * @param {IGridInstance} grid The target grid * @returns {Array} An array of gridRows that are currently in error */ - getErrorRows(grid?: IGridInstance): Array; + getErrorRows(grid?: IGridInstance): Array>; /** * Sets each of the rows passed in dataRows to be clean, * removing them from the dirty cache and the error cache, @@ -2804,7 +2804,7 @@ declare module uiGrid { /** * Public Api for selection feature */ - export interface IGridSelectionApi { + export interface IGridSelectionApi { // Methods /** * Unselects All Rows @@ -2841,10 +2841,10 @@ declare module uiGrid { selectAllVisibleRows(event?: ng.IAngularEvent): void; /** * Select row by data - * @param {any} rowEntity gridOptions.data[] array value + * @param {TEntity} rowEntity gridOptions.data[] array value * @param {ng.IAngularEvent} event object if raised from event */ - selectRow(rowEntity: any, event?: ng.IAngularEvent): void; + selectRow(rowEntity: TEntity, event?: ng.IAngularEvent): void; /** * Select the specified row by visible index * (i.e. if you specify row 0 you'll get the first visible row selected). @@ -2868,16 +2868,16 @@ declare module uiGrid { setMultiSelect(multiSelect: boolean): void; /** * Toggles data row as selected or unselected - * @param {any} rowEntity gridOptions.data[] array value + * @param {TEntity} rowEntity gridOptions.data[] array value * @param {ng.IAngularEvent} event object if raised from event */ - toggleRowSelection(rowEntity: any, event?: ng.IAngularEvent): void; + toggleRowSelection(rowEntity: TEntity, event?: ng.IAngularEvent): void; /** * UnSelect the data row - * @param {any} rowEntity gridOptions.data[] array value + * @param {TEntity} rowEntity gridOptions.data[] array value * @param {ng.IAngularEvent} event object if raised from event */ - unSelectRow(rowEntity: any, event?: ng.IAngularEvent): void; + unSelectRow(rowEntity: TEntity, event?: ng.IAngularEvent): void; // Events on: { @@ -2886,7 +2886,7 @@ declare module uiGrid { * @param {ng.IScope} scope grid scope * @param {rowSelectionChangedHandler} handler callback */ - rowSelectionChanged: (scope: ng.IScope, handler: rowSelectionChangedHandler) => void; + rowSelectionChanged: (scope: ng.IScope, handler: rowSelectionChangedHandler) => void; /** * is raised after the row.isSelected state is changed in bulk, * if the enableSelectionBatchEvent option is set to true (which it is by default). @@ -2894,25 +2894,25 @@ declare module uiGrid { * @param {ng.IScope} scope grid scope * @param {rowSelectionChangedBatchHandler} handler callback */ - rowSelectionChangedBatch: (scope: ng.IScope, handler: rowSelectionChangedBatchHandler) => void; + rowSelectionChangedBatch: (scope: ng.IScope, handler: rowSelectionChangedBatchHandler) => void; } } - export interface rowSelectionChangedHandler { + export interface rowSelectionChangedHandler { /** * Callback for row selection changed * @param {IGridRow} row The selected rows * @param {ng.IAngularEvent} event object if raised from event */ - (row: uiGrid.IGridRow, event?: ng.IAngularEvent): void; + (row: uiGrid.IGridRow, event?: ng.IAngularEvent): void; } - export interface rowSelectionChangedBatchHandler { + export interface rowSelectionChangedBatchHandler { /** * Callback for row selection changed batch * @param {IGridRow} row The selected rows * @param {ng.IAngularEvent} event object if raised from event */ - (row: Array, event?: ng.IAngularEvent): void; + (row: Array>, event?: ng.IAngularEvent): void; } } @@ -2920,7 +2920,7 @@ declare module uiGrid { /** * ColumnDef for tree feature, these are available to be set using the ui-grid gridOptions.columnDefs */ - export interface IColumnDef { + export interface IColumnDef { /** * A custom function that populates aggregation.rendered. * This is called when a particular aggregation has been fully calculated, and we want to render the value. @@ -2947,7 +2947,7 @@ declare module uiGrid { * @param {IGridRow} row Row objet */ customerTreeAggregationFn?: (aggregation: IGridTreeBaseAggregationObject, fieldValue: any, numValue: number, - row: IGridRow) => void; + row: IGridRow) => void; /** * A custom label to use for this aggregation. If providedm, we don't use native i18n */ @@ -2993,7 +2993,7 @@ declare module uiGrid { /** * Tree Base Grid Options */ - export interface IGridOptions { + export interface IGridOptions { /** * If set to true, show the expand/collapse button even if there are no children of a node. * You'd use this if you're planning to dynamically load the children @@ -3022,7 +3022,7 @@ declare module uiGrid { * Defaults to {} * @default {} */ - treeCustomAggregations?: { [index: string]: IGridTreeBaseCustomAggregation; }; + treeCustomAggregations?: { [index: string]: IGridTreeBaseCustomAggregation; }; /** * Number of pixels of indent for the icon at each tree level, wider indents are visually more pleasing, * but will make the tree row header wider @@ -3045,10 +3045,10 @@ declare module uiGrid { treeRowHeaderBaseWidth?: number; } - export interface IGridTreeBaseCustomAggregation { + export interface IGridTreeBaseCustomAggregation { label: string; aggregationFn: (aggregation: IGridTreeBaseAggregationObject, fieldValue: any, numValue: number, - row?: IGridRow) => void; + row?: IGridRow) => void; finalizerFn?: (aggregation: IGridTreeBaseAggregationObject) => void; } export interface IGridTreeBaseAggregationObject { @@ -3058,7 +3058,7 @@ declare module uiGrid { rendered?: string; } - export interface IGridTreeBaseApi { + export interface IGridTreeBaseApi { // Methods /** * Collapse all tree rows @@ -3068,13 +3068,13 @@ declare module uiGrid { * collapse the specified row. When you expand the row again, all grandchildren will retain their state * @param {IGridRow} row The row to collapse */ - collapseRow(row: IGridRow): void; + collapseRow(row: IGridRow): void; /** * collapse all children of the specified row. When you expand the row again, all grandchildren will be * collapsed * @param {IGridRow} row The row to collapse children of */ - collapseRowChildren(row: IGridRow): void; + collapseRowChildren(row: IGridRow): void; /** * Expands all tree rows */ @@ -3083,13 +3083,13 @@ declare module uiGrid { * Expand the immediate children of the specified row * @param {IGridRow} row The row to expand */ - expandRow(row: IGridRow): void; + expandRow(row: IGridRow): void; /** * Get the children of the specified row * @param {IGridRow} row The row you want the children of * @returns Array Array of children rows */ - getRowChildren(row: IGridRow): Array; + getRowChildren(row: IGridRow): Array>; /** * Get the tree state for this grid, used by the saveState feature Returned treeState as an object * ```{ expandedState: { uid: 'expanded', uid: 'collapsed' } }``` @@ -3107,7 +3107,7 @@ declare module uiGrid { * call expand if row is collapsed, and collapse if it is expanded * @param {IGridRow} row The row to toggle */ - toggleRowTreeState(row: IGridRow): void; + toggleRowTreeState(row: IGridRow): void; // Events on: { @@ -3116,7 +3116,7 @@ declare module uiGrid { * @param {ng.IScope} scope Grid scope * @param {rowCollapsedHandler} handler Callback */ - rowCollapsed: (scope: ng.IScope, handler: rowCollapsedHandler) => void; + rowCollapsed: (scope: ng.IScope, handler: rowCollapsedHandler) => void; /** * Raised whenever a row is expanded. * @@ -3127,7 +3127,7 @@ declare module uiGrid { * @param {ng.IScope} scope Grid Scope * @param {rowExpandedHandler} handler Callback */ - rowExpanded: (scope: ng.IScope, handler: rowExpandedHandler) => void; + rowExpanded: (scope: ng.IScope, handler: rowExpandedHandler) => void; } } @@ -3137,20 +3137,20 @@ declare module uiGrid { } } - export interface rowCollapsedHandler { + export interface rowCollapsedHandler { /** * Row Collapsed callback * @param {IGridRow} row The row that was collapsed. You can also retrieve the grid from this row with row.grid */ - (row: IGridRow): void; + (row: IGridRow): void; } - export interface rowExpandedHandler { + export interface rowExpandedHandler { /** * Row Expanded callback * @param {IGridRow} row The row that was expanded. You can also retrieve the grid from this row with row.grid */ - (row: IGridRow): void; + (row: IGridRow): void; } /** @@ -3200,10 +3200,10 @@ declare module uiGrid { // Tree View - export interface IGridApiConstructor { - new (grid: IGridInstance): IGridApi; + export interface IGridApiConstructor { + new (grid: IGridInstance): IGridApi; } - export interface IGridApi { + export interface IGridApi { /** * Registers a new event for the given feature. The event will get a .raise and .on prepended to it * @@ -3256,12 +3256,12 @@ declare module uiGrid { /** * Core Api */ - core: IGridCoreApi; + core: IGridCoreApi; /** * Cell Nav Api */ - cellNav: cellNav.ICellNavApi; + cellNav: cellNav.ICellNavApi; /** * Move Columns Api @@ -3276,12 +3276,12 @@ declare module uiGrid { /** * Edit Api */ - edit: edit.IGridEditApi; + edit: edit.IGridEditApi; /** * Expandable Api */ - expandable: expandable.IGridExpandableApi; + expandable: expandable.IGridExpandableApi; /** * Exporter Api @@ -3291,7 +3291,7 @@ declare module uiGrid { /** * Grouping Api */ - grouping: grouping.IGridGroupingApi; + grouping: grouping.IGridGroupingApi; /** * Importer Api @@ -3301,7 +3301,7 @@ declare module uiGrid { /** * Infinite Scroll Api */ - infiniteScroll: infiniteScroll.IGridInfiniteScrollApi; + infiniteScroll: infiniteScroll.IGridInfiniteScrollApi; /** * Pagination Api @@ -3311,12 +3311,12 @@ declare module uiGrid { /** * Pinning Api */ - pinning: pinning.IGridPinningApi; + pinning: pinning.IGridPinningApi; /** * Grid Row Edit Api */ - rowEdit: rowEdit.IGridRowEditApi; + rowEdit: rowEdit.IGridRowEditApi; /** * Grid Save State Api @@ -3325,19 +3325,19 @@ declare module uiGrid { /** * Selection Api */ - selection: selection.IGridSelectionApi; + selection: selection.IGridSelectionApi; /** * Tree Base Api */ - treeBase: treeBase.IGridTreeBaseApi; + treeBase: treeBase.IGridTreeBaseApi; /** * A grid instance is made available in the gridApi. */ - grid: IGridInstance; + grid: IGridInstance; } - export interface IGridRowConstructor { + export interface IGridRowConstructor { /** * GridRow is the viewModel for one logical row on the grid. * A grid Row is not necessarily a one-to-one relation to gridOptions.data. @@ -3345,13 +3345,13 @@ declare module uiGrid { * @param index the current position of the row in the array * @param reference to the parent grid */ - new(entity: any, index: number, reference: IGridInstance): IGridRow; + new(entity: TEntity, index: number, reference: IGridInstance): IGridRow; } - export interface IGridRow extends cellNav.IGridRow, edit.IGridRow, exporter.IGridRow, selection.IGridRow { + export interface IGridRow extends cellNav.IGridRow, edit.IGridRow, exporter.IGridRow, selection.IGridRow { /** A reference to an item in gridOptions.data[] */ - entity: any; + entity: TEntity; /** A reference back to the grid */ - grid: IGridInstance; + grid: IGridInstance; /** * height of each individual row. changing the height will flag all * row renderContainers to recalculate their canvas height @@ -3379,7 +3379,7 @@ declare module uiGrid { * Changed to just call the internal function row.clearThisRowInvisible(). * @param row the row we want to clear the invisible flag */ - clearRowInvisible(row: IGridRow): void; + clearRowInvisible(row: IGridRow): void; /** * Clears any override on the row visibility, returning it to normal visibility calculations. * Emits the rowsVisibleChanged event @@ -3399,13 +3399,13 @@ declare module uiGrid { * @param col column instance * @returns resulting name that can be evaluated against a row */ - getEntityQualifiedColField(col: IGridColumn): string; + getEntityQualifiedColField(col: IGridColumn): string; /** * returns the qualified field name as it exists on scope ie: row.entity.fieldA * @param col column instance * @returns resulting name that can be evaluated on scope */ - getQualifiedColField(col: IGridColumn): string; + getQualifiedColField(col: IGridColumn): string; /** * Sets an override on the row that forces it to always be invisible. * Emits the rowsVisibleChanged event if it changed the row visibility. @@ -3415,7 +3415,7 @@ declare module uiGrid { * Changed to just call the internal function row.setThisRowInvisible(). * @param row the row we want to set to invisible */ - setRowInvisible(row: IGridRow): void; + setRowInvisible(row: IGridRow): void; /** * Sets an override on the row that forces it to always be invisible. * Emits the rowsVisibleChanged event if it changed the row visibility @@ -3425,7 +3425,7 @@ declare module uiGrid { setThisRowInvisible(reason: string, fromRowsProcessor: boolean): void; } - export interface IGridColumnConstructor { + export interface IGridColumnConstructor { /** * Represents the viewModel for each column. * Any state or methods needed for a Grid Column are defined on this prototype @@ -3433,12 +3433,12 @@ declare module uiGrid { * @param index the current position of the column in the array * @param grid reference to the grid */ - new(gridCol: IColumnDef, index: number, grid: IGridInstance): IGridColumn; + new(gridCol: IColumnDef, index: number, grid: IGridInstance): IGridColumn; } - export interface IGridColumn { + export interface IGridColumn { /** Column definition */ - colDef: uiGrid.IColumnDef; + colDef: uiGrid.IColumnDef; /** * Column name that will be shown in the header. * If displayName is not provided then one is generated using the name. @@ -3468,7 +3468,7 @@ declare module uiGrid { * @param uid The unique and immutable uid we'd like to allocate to this column * @param grid the grid we'd like to create this column in */ - GridColumn(colDef: IColumnDef, uid: number, grid: IGridInstance): void; + GridColumn(colDef: IColumnDef, uid: number, grid: IGridInstance): void; /** * Gets the aggregation label from colDef.aggregationLabel if specified or by using i18n, * including deciding whether or not to display based on colDef.aggregationHideLabel. @@ -3506,7 +3506,7 @@ declare module uiGrid { * @param propName the property name we'd like to set * @param defaultValue the value to use if the colDef doesn't provide the setting */ - setPropertyOrDefault(colDef: IColumnDef, propName: string, defaultValue: any): void; + setPropertyOrDefault(colDef: IColumnDef, propName: string, defaultValue: any): void; /** Makes the column visible by setting colDef.visible = true */ showColumn(): void; /** @@ -3515,7 +3515,7 @@ declare module uiGrid { * @param isNew whether the column is being newly created, if not we're updating an existing * column, and some items such as the sort shouldn't be copied down */ - updateColumnDef(colDef: IColumnDef, isNew: boolean): void; + updateColumnDef(colDef: IColumnDef, isNew: boolean): void; } /** @@ -3523,8 +3523,8 @@ declare module uiGrid { * which would typically be one of many column definitions within the * gridOptions.columnDefs array */ - export interface IColumnDef extends cellNav.IColumnDef, edit.IColumnDef, exporter.IColumnDef, grouping.IColumnDef, - moveColumns.IColumnDef, pinning.IColumnDef, resizeColumns.IColumnDef, treeBase.IColumnDef { + export interface IColumnDef extends cellNav.IColumnDef, edit.IColumnDef, exporter.IColumnDef, grouping.IColumnDef, + moveColumns.IColumnDef, pinning.IColumnDef, resizeColumns.IColumnDef, treeBase.IColumnDef { /** * defaults to false * if set to true hides the label text in the aggregation footer, so only the value is displayed. @@ -3547,7 +3547,7 @@ declare module uiGrid { * or it can be a function(row,rowRenderIndex, col, colRenderIndex) * that returns a class name */ - cellClass?: string | ICellClassGetter; + cellClass?: string | ICellClassGetter; /** cellFilter is a filter to apply to the content of each cell */ cellFilter?: string; /** @@ -3567,7 +3567,7 @@ declare module uiGrid { * Defaults to false * @default false */ - cellTooltip?: boolean | string | ICellTooltipGetter; + cellTooltip?: boolean | string | ICellTooltipGetter; /** * Column name that will be shown in the header. * If displayName is not provided then one is generated using the name. @@ -3629,7 +3629,7 @@ declare module uiGrid { * footerCellClass can be a string specifying the class to append to a cell or it can be * a function(row,rowRenderIndex, col, colRenderIndex) that returns a class name */ - footerCellClass?: string | IHeaderFooterCellClassGetter; + footerCellClass?: string | IHeaderFooterCellClassGetter; /** footerCellFilter is a filter to apply to the content of the column footer */ footerCellFilter?: string; /** a custom template for the footer for this column. The default is ui-grid/uiGridFooterCell */ @@ -3638,7 +3638,7 @@ declare module uiGrid { * headerCellClass can be a string specifying the class to append to a cell or it can be * a function(row,rowRenderIndex, col, colRenderIndex) that returns a class name */ - headerCellClass?: string | IHeaderFooterCellClassGetter; + headerCellClass?: string | IHeaderFooterCellClassGetter; /** headerCellFilter is a filter to apply to the content of the column header */ headerCellFilter?: string; /** a custom template for the header for this column. The default is ui-grid/uiGridHeaderCell */ @@ -3653,7 +3653,7 @@ declare module uiGrid { * if a static string then shows that static string. * @default false */ - headerTooltip?: boolean | string | IHeaderTooltipGetter; + headerTooltip?: boolean | string | IHeaderTooltipGetter; /** sets the maximum column width */ maxWidth?: number; /** used to add menu items to a column. Refer to the tutorial on this functionality */ @@ -3705,18 +3705,18 @@ declare module uiGrid { width?: number | string; } - export interface ICellClassGetter { - (gridRow?: IGridRow, gridCol?: IGridColumn, colRenderIndex?: number): string; + export interface ICellClassGetter { + (gridRow?: IGridRow, gridCol?: IGridColumn, colRenderIndex?: number): string; } - export interface ICellTooltipGetter { - (gridRow: IGridRow, gridCol: IGridColumn): string; + export interface ICellTooltipGetter { + (gridRow: IGridRow, gridCol: IGridColumn): string; } - export interface IHeaderTooltipGetter { - (gridCol: IGridColumn): string; + export interface IHeaderTooltipGetter { + (gridCol: IGridColumn): string; } - export interface IHeaderFooterCellClassGetter { - (gridRow: IGridRow, rowRenderIndex: number, gridCol: IGridColumn, colRenderIndex: number): string; + export interface IHeaderFooterCellClassGetter { + (gridRow: IGridRow, rowRenderIndex: number, gridCol: IGridColumn, colRenderIndex: number): string; } export interface IMenuItem { /** controls the title that is displayed in the menu */ From 836a2e5e4c4419306ecfdb980c7d4885578cf878 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 23 Sep 2015 08:54:28 -0600 Subject: [PATCH 2/6] Add generic TEntity support for ui-grid --- ui-grid/ui-grid-tests.ts | 18 ++++++++++++------ ui-grid/ui-grid.d.ts | 40 ++++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/ui-grid/ui-grid-tests.ts b/ui-grid/ui-grid-tests.ts index f34a2eabe..5e1497594 100644 --- a/ui-grid/ui-grid-tests.ts +++ b/ui-grid/ui-grid-tests.ts @@ -116,11 +116,17 @@ var gridOptions: uiGrid.IGridOptions = { }) } } -var rowEntityToScrollTo = {anObject: 'inGridOptionsData'}; -var columnDefToScrollTo: uiGrid.IColumnDef; -gridInstance.scrollTo(); -gridInstance.scrollTo(rowEntityToScrollTo); -gridInstance.scrollTo(rowEntityToScrollTo, columnDefToScrollTo); +interface AnotherEntity { + anObject: string +} +var anotherGridInstance: uiGrid.IGridInstance; +var rowEntityToScrollTo = { + anObject: 'inGridOptionsData' +}; +var columnDefToScrollTo: uiGrid.IColumnDef; +anotherGridInstance.scrollTo(); +anotherGridInstance.scrollTo(rowEntityToScrollTo); +anotherGridInstance.scrollTo(rowEntityToScrollTo, columnDefToScrollTo); var selectedRowEntities: Array = gridApi.selection.getSelectedRows(); -var selectedGridRows: Array = gridApi.selection.getSelectedGridRows(); +var selectedGridRows: Array> = gridApi.selection.getSelectedGridRows(); diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index effd0f16c..3b63f6855 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -1,6 +1,6 @@ // Type definitions for ui-grid // Project: http://www.ui-grid.info/ -// Definitions by: Ben Tesser +// Definitions by: Ben Tesser , Joe Skeen // Definitions: https://github.com/borisyankov/DefinitelyTyped // These are very definitely preliminary. Please feel free to improve. @@ -289,7 +289,7 @@ declare module uiGrid { * @param {Array} newRawData The new grid data * @return {ng.IPromise} Promise which resolves when the rows have been created or removed */ - modifyRows(newRawData: Array): ng.IPromise; + modifyRows(newRawData: Array): ng.IPromise; /** * Notify the grid that a data or config change has occurred, * where that change isn't something the grid was otherwise noticing. This @@ -860,7 +860,7 @@ declare module uiGrid { * TODO: if a filter is active then we can't just set it to visible? * @param {any} rowEntity gridOptions.data[] array instance */ - clearRowInvisible(rowEntity: any): void; + clearRowInvisible(rowEntity: TEntity): void; /** * Returns all visible rows * @param {IGridInstance} grid the grid you want to get visible rows from @@ -931,7 +931,7 @@ declare module uiGrid { * @param {IColumnDef} colDef to make visible * @returns {ng.IPromise} a promise that is resolved after any scrolling is finished */ - scrollTo(entity: any, colDef: IColumnDef): void; /*A row entity can be anything?*/ + scrollTo(entity: TEntity, colDef: IColumnDef): void; /*A row entity can be anything?*/ /** * Scrolls the grid to make a certain row and column combo visible, * in the case that it is not completely visible on the screen already. @@ -1129,7 +1129,7 @@ declare module uiGrid { * @param {any} rowEntity gridOptions.data[] array instance to make visible and set focus * @param {IColumnDef} colDef Column definition to make visible and set focus */ - scrollToFocus(rowEntity: any, colDef: IColumnDef): ng.IPromise; + scrollToFocus(rowEntity: TEntity, colDef: IColumnDef): ng.IPromise; // Events on: { @@ -1390,7 +1390,7 @@ declare module uiGrid { * @param {any} newValue New Value * @param {any} oldValue Old Value */ - (rowEntity: any, colDef: IColumnDef, newValue: any, oldValue: any): void; + (rowEntity: TEntity, colDef: IColumnDef, newValue: any, oldValue: any): void; } /** @@ -1401,7 +1401,7 @@ declare module uiGrid { * keystrokes on some complex editors */ export interface beginCellEditHandler { - (rowEntity: any, colDef: IColumnDef, triggerEvent: JQueryEventObject): void; + (rowEntity: TEntity, colDef: IColumnDef, triggerEvent: JQueryEventObject): void; } /** @@ -1410,7 +1410,7 @@ declare module uiGrid { * @param {IColumnDef} colDef The column that was edited */ export interface cancelCellEditHandler { - (rowEntity: any, colDef: IColumnDef): void; + (rowEntity: TEntity, colDef: IColumnDef): void; } /** @@ -1480,7 +1480,7 @@ declare module uiGrid { * Toggle a specific row * @param {any} rowEntity The data entity for the row you want to expand */ - toggleRowExpansion(rowEntity: any): void; + toggleRowExpansion(rowEntity: TEntity): void; // Events on: { @@ -1528,7 +1528,7 @@ declare module uiGrid { * @default null * @returns {ng.IPromise>} A promise to load all data from server */ - exporterAllDataFn?: () => ng.IPromise>; + exporterAllDataFn?: () => ng.IPromise>; /** * @deprecated * DEPRECATED - exporterAllDataFn used to be called this, but it wasn't a promise, @@ -1536,7 +1536,7 @@ declare module uiGrid { * use exporterAllDataFn instead. * @returns {ng.IPromise>} A promise to load all data from server */ - exporterAllDataPromise?: () => ng.IPromise>; + exporterAllDataPromise?: () => ng.IPromise>; /** * The character to use as column separator link * Defaults to ',' @@ -1973,7 +1973,7 @@ declare module uiGrid { * @param {IGridInstance} grid The grid we're importing into, may be useful in some way * @param {Array} newObjects An array of new objects that you should add to your data */ - importerDataAddCallback?: (grid: IGridInstance, newObjects: Array) => void; + importerDataAddCallback?: (grid: IGridInstance, newObjects: Array) => void; /** * A callback function that provides custom error handling, * rather than the standard grid behaviour of an alert box and a console message. @@ -2010,7 +2010,7 @@ declare module uiGrid { * @returns {any} The modified object * @default angular.identity */ - importerObjectCallback?: (grid: IGridInstance, newObject: any) => any; + importerObjectCallback?: (grid: IGridInstance, newObject: TEntity) => TEntity; /** * A callback function that will process headers using custom * logic. Set this callback function if the headers that your user will provide in their @@ -2488,7 +2488,7 @@ declare module uiGrid { * and clearing the error flag and the dirty flag * @param {Array} dataRows the data entities for which the gridRows should be set clean */ - setRowsClean(dataRows: Array): void; + setRowsClean(dataRows: Array): void; /** * Sets each of the rows passed in dataRows to be dirty, * Note that if you have only just inserted the rows into your data, @@ -2496,7 +2496,7 @@ declare module uiGrid { * wrapped with $interval or $timeout. * @param {Array} dataRows the data entities for which the gridRows should be set dirty */ - setRowsDirty(dataRows: Array): void; + setRowsDirty(dataRows: Array): void; /** * Sets the promise associated with the row save, mandatory that the saveRow event handler calls this method * somewhere before returning @@ -2519,16 +2519,16 @@ declare module uiGrid { * @param {ng.IScope} scope The grid scope * @param {saveRowHandler} handler Callback */ - saveRow: (scope: ng.IScope, handler: saveRowHandler) => void; + saveRow: (scope: ng.IScope, handler: saveRowHandler) => void; } } - export interface saveRowHandler { + export interface saveRowHandler { /** * Callback method for save row * @param {any} rowEntity The options.data element that was edited */ - (rowEntity: Array): void; + (rowEntity: Array): void; } } @@ -2827,12 +2827,12 @@ declare module uiGrid { * returns all selected rows as gridRows * @returns {Array} The selected rows */ - getSelectedGridRows(): Array; + getSelectedGridRows(): Array>; /** * Gets selected rows as entities * @returns {Array} Selected row entities */ - getSelectedRows(): Array; + getSelectedRows(): Array; /** * Selects all rows. Does nothing if multiselect = false * @param {ng.IAngularEvent} event object if raised from event From 0b917b03d2c7b1de1f4347b0a276c16105c3f8ba Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 23 Sep 2015 20:32:32 -0600 Subject: [PATCH 3/6] Create type aliases to support use without generics --- ui-grid/ui-grid-tests.ts | 14 ++-- ui-grid/ui-grid.d.ts | 169 ++++++++++++++++++++------------------- 2 files changed, 94 insertions(+), 89 deletions(-) diff --git a/ui-grid/ui-grid-tests.ts b/ui-grid/ui-grid-tests.ts index 5e1497594..b4ba6e3ee 100644 --- a/ui-grid/ui-grid-tests.ts +++ b/ui-grid/ui-grid-tests.ts @@ -6,7 +6,7 @@ interface MyEntity { age: number; } -var columnDef: uiGrid.IColumnDef; +var columnDef: uiGrid.IColumnDefOf; columnDef.aggregationHideLabel = true; columnDef.aggregationHideLabel = false; columnDef.aggregationType = 1; @@ -19,7 +19,7 @@ columnDef.cellClass = (gridRow, gridCol, index) => { columnDef.cellFilter = 'date'; columnDef.cellTemplate = '
hello
'; columnDef.cellTooltip = 'blah'; -columnDef.cellTooltip = function (gridRow: uiGrid.IGridRow, gridCol: uiGrid.IGridColumn) { +columnDef.cellTooltip = function (gridRow: uiGrid.IGridRow, gridCol: uiGrid.IGridColumn) { return 'blah'; }; columnDef.displayName = 'Jumper'; @@ -96,7 +96,7 @@ columnDef.width = '*'; var gridApi: uiGrid.IGridApi; -var gridInstance: uiGrid.IGridInstance; +var gridInstance: uiGrid.IGridInstanceOf; var menuItem: uiGrid.IMenuItem; var colProcessor: uiGrid.IColumnProcessor; @@ -108,7 +108,7 @@ gridApi.core.queueGridRefresh() gridApi.core.queueRefresh(); gridApi.core.registerColumnsProcessor(colProcessor, 100); -var gridOptions: uiGrid.IGridOptions = { +var gridOptions: uiGrid.IGridOptionsOf = { data: [{name: 'Bob', age: 100}], onRegisterApi: (api) => { api.selection.on.rowSelectionChanged(null, (row) => { @@ -119,14 +119,14 @@ var gridOptions: uiGrid.IGridOptions = { interface AnotherEntity { anObject: string } -var anotherGridInstance: uiGrid.IGridInstance; +var anotherGridInstance: uiGrid.IGridInstance; var rowEntityToScrollTo = { anObject: 'inGridOptionsData' }; -var columnDefToScrollTo: uiGrid.IColumnDef; +var columnDefToScrollTo: uiGrid.IColumnDef; anotherGridInstance.scrollTo(); anotherGridInstance.scrollTo(rowEntityToScrollTo); anotherGridInstance.scrollTo(rowEntityToScrollTo, columnDefToScrollTo); var selectedRowEntities: Array = gridApi.selection.getSelectedRows(); -var selectedGridRows: Array> = gridApi.selection.getSelectedGridRows(); +var selectedGridRows: Array = gridApi.selection.getSelectedGridRows(); diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index 3b63f6855..2b6397122 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -120,12 +120,13 @@ declare module uiGrid { ALWAYS: number; } } - export interface IGridInstance { + export type IGridInstance = IGridInstanceOf; + export interface IGridInstanceOf { /** * adds a row header column to the grid * @param {IColumnDef} colDef The column definition */ - addRowHeaderColumn(colDef: IColumnDef): void; + addRowHeaderColumn(colDef: IColumnDefOf): void; /** * uses the first row of data to assign colDef.type for any types not defined. */ @@ -193,48 +194,48 @@ declare module uiGrid { * @param {IGridColumn} col Column to access * @returns {string} Cell display value */ - getCellDisplayValue(row: IGridRow, col: IGridColumn): string; + getCellDisplayValue(row: IGridRowOf, col: IGridColumnOf): string; /** * Gets the displayed value of a cell * @param {IGridRow} row Row to access * @param {IGridColumn} col Column to access * @returns {any} Cell value */ - getCellValue(row: IGridRow, col: IGridColumn): any; + getCellValue(row: IGridRowOf, col: IGridColumnOf): any; /** * returns a grid colDef for the column name * @param {string} name Column name * @returns {IColumnDef} The column definition */ - getColDef(name: string): IColumnDef; + getColDef(name: string): IColumnDefOf; /** * returns a grid column by name * @param {string} name Column name * @returns {IGridColumn} The column */ - getColumn(name: string): IGridColumn; + getColumn(name: string): IGridColumnOf; /** * Return the columns that the grid is currently being sorted by * @returns {Array} the columns that the grid is currently being sorted by */ - getColumnSorting(): Array>; + getColumnSorting(): Array>; /** * Returns the $parse-able accessor for a column within its $scope * @param {IGridColumn} col Column object * @returns {string} $parse-able accessor for a column within its $scope */ - getGridQualifiedColField(col: IGridColumn): string; + getGridQualifiedColField(col: IGridColumnOf): string; /** * returns all columns except for rowHeader columns * @returns {Array} All data columns */ - getOnlyDataColumns(): Array>; + getOnlyDataColumns(): Array>; /** * returns the GridRow that contains the rowEntity * @param {any} rowEntity the gridOptionms.data array element instance * @param {Array} rows The rows to look in. if not provided then it looks in grid.rows */ - getRow(rowEntity: TEntity, rows?: Array>): IGridRow; + getRow(rowEntity: TEntity, rows?: Array>): IGridRowOf; /** * Triggered when the browser window resizes; automatically resizes the grid * @param {ng.IAngularEvent} $event Resize event @@ -270,7 +271,7 @@ declare module uiGrid { * @param {IGridColumn} column The column * @returns {boolean} true if the column is a row header */ - isRowHeaderColumn(column: IGridColumn): boolean; + isRowHeaderColumn(column: IGridColumnOf): boolean; /** * creates or removes GridRow objects from the newRawData array. Calls each registered * rowBuilder to further process the row @@ -309,7 +310,7 @@ declare module uiGrid { * @param {IGridRow} gridRow reference to gridRow * @returns {IGridRow} the gridRow with all additional behavior added */ - processRowBuilders(gridRow: IGridRow): IGridRow; + processRowBuilders(gridRow: IGridRowOf): IGridRowOf; /** * calls the row processors, specifically * intended to reset the sorting when an edit is called, @@ -398,7 +399,7 @@ declare module uiGrid { * ALL * @returns {Function} deregister function - a function that can be called to deregister this callback */ - registerDataChangeCallback(callback: (grid: IGridInstance) => void, types: Array): Function; + registerDataChangeCallback(callback: (grid: IGridInstanceOf) => void, types: Array): Function; /** * When the build creates rows from gridOptions.data, the rowBuilders will be called to add * additional properties to the row. @@ -437,7 +438,7 @@ declare module uiGrid { * Return the columns that the grid is currently being sorted by * @param {IGridColumn} [excludedColumn] Optional GridColumn to exclude from having its sorting reset */ - resetColumnSorting(excludedColumn: IGridColumn): void; + resetColumnSorting(excludedColumn: IGridColumnOf): void; /** * Scroll the grid such that the specified * row and column is in view @@ -445,7 +446,7 @@ declare module uiGrid { * @param {IColumnDef} colDef to make visible * @returns {ng.IPromise} a promise that is resolved after any scrolling is finished */ - scrollTo(rowEntity?: TEntity, colDef?: IColumnDef): ng.IPromise; + scrollTo(rowEntity?: TEntity, colDef?: IColumnDefOf): ng.IPromise; /** * Scrolls the grid to make a certain row and column combo visible, * in the case that it is not completely visible on the screen already. @@ -453,7 +454,7 @@ declare module uiGrid { * @param {IGridColumn} gridCol column to make visible * @returns {ng.IPromise} a promise that is resolved when scrolling is complete */ - scrollToIfNecessary(gridRow: IGridRow, gridCol: IGridColumn): ng.IPromise; + scrollToIfNecessary(gridRow: IGridRowOf, gridCol: IGridColumnOf): ng.IPromise; /** * Set the sorting on a given column, optionally resetting any existing sorting on the Grid. * Emits the sortChanged event whenever the sort criteria are changed. @@ -465,7 +466,7 @@ declare module uiGrid { * reset any existing sorting and sort by this column only * @returns {ng.IPromise} A resolved promise that supplies the column. */ - sortColumn(column: IGridColumn, direction?: string, add?: boolean): ng.IPromise>; + sortColumn(column: IGridColumnOf, direction?: string, add?: boolean): ng.IPromise>; /** * flags all render containers to update their canvas height */ @@ -514,18 +515,19 @@ declare module uiGrid { ($scope: ng.IScope): string; } export interface IColumnBuilder { - (colDef: IColumnDef, col: IGridColumn, gridOptions: IGridOptions): void; + (colDef: IColumnDefOf, col: IGridColumnOf, gridOptions: IGridOptionsOf): void; } export interface IRowBuilder { - (row: IGridRow, gridOptions: IGridOptions): void; + (row: IGridRowOf, gridOptions: IGridOptionsOf): void; } export interface IRowProcessor { - (renderedRowsToProcess: Array>, columns: Array>): Array>; + (renderedRowsToProcess: Array>, columns: Array>): Array>; } export interface IColumnProcessor { - (renderedColumnsToProcess: Array>, rows: Array>): Array>; + (renderedColumnsToProcess: Array>, rows: Array>): Array>; } - export interface IGridOptions extends cellNav.IGridOptions, edit.IGridOptions, expandable.IGridOptions, + export type IGridOptions = IGridOptionsOf; + export interface IGridOptionsOf extends cellNav.IGridOptions, edit.IGridOptions, expandable.IGridOptions, exporter.IGridOptions, grouping.IGridOptions, importer.IGridOptions, infiniteScroll.IGridOptions, moveColumns.IGridOptions, pagination.IGridOptions, pinning.IGridOptions, resizeColumns.IGridOptions, rowEdit.IGridOptions, saveState.IGridOptions, selection.IGridOptions, treeBase.IGridOptions, @@ -542,7 +544,7 @@ declare module uiGrid { /** * Array of columnDef objects. Only required property is name. */ - columnDefs?: Array>; + columnDefs?: Array>; /** * The height of the footer rows (column footer and grid footer) in pixels */ @@ -805,14 +807,14 @@ declare module uiGrid { * @param {IGridRow} row The row for which you want the unique id * @returns {string} row uid */ - getRowIdentity?(row: IGridRow): any; + getRowIdentity?(row: IGridRowOf): any; /** * By default, rows are compared using object equality. This option can be overridden * to compare on any data item property or function * @param {IGridRow} entityA First Data Item to compare * @param {IGridRow} entityB Second Data Item to compare */ - rowEquality?(entityA: IGridRow, entityB: IGridRow): boolean; + rowEquality?(entityA: IGridRowOf, entityB: IGridRowOf): boolean; /** * This function is used to get and, if necessary, set the value uniquely identifying this row * (i.e. if an identity is not present it will set one). @@ -828,7 +830,7 @@ declare module uiGrid { * adds a row header column to the grid * @param {IColumnDef} column Column Definition */ - addRowHeaderColumn(column: IColumnDef): void; + addRowHeaderColumn(column: IColumnDefOf): void; /** * add items to the grid menu. Used by features * to add their menu items if they are enabled, can also be used by @@ -842,7 +844,7 @@ declare module uiGrid { * which is provided when you want to remove an item. The id should be unique. */ - addToGridMenu(grid: IGridInstance, items: Array): void; + addToGridMenu(grid: IGridInstanceOf, items: Array): void; /** * Clears all filters and optionally refreshes the visible rows. * @param {boolean} [refreshRows=true] Defaults to true. @@ -851,7 +853,7 @@ declare module uiGrid { * @returns {ng.IPromise} If `refreshRows` is true, returns a promise of the rows refreshing. */ clearAllFilters(refreshRows?: boolean, clearConditions?: boolean, - clearFlags?: boolean): ng.IPromise>>; + clearFlags?: boolean): ng.IPromise>>; /** * Clears any override on visibility for the row so that it returns to * using normal filtering and other visibility calculations. @@ -866,7 +868,7 @@ declare module uiGrid { * @param {IGridInstance} grid the grid you want to get visible rows from * @returns {Array} an array of gridRow */ - getVisibleRows(grid: IGridInstance): Array>; + getVisibleRows(grid: IGridInstanceOf): Array>; /** * Trigger a grid resize, normally this would be picked * up by a watch on window size, but in some circumstances it is necessary @@ -931,7 +933,7 @@ declare module uiGrid { * @param {IColumnDef} colDef to make visible * @returns {ng.IPromise} a promise that is resolved after any scrolling is finished */ - scrollTo(entity: TEntity, colDef: IColumnDef): void; /*A row entity can be anything?*/ + scrollTo(entity: TEntity, colDef: IColumnDefOf): void; /*A row entity can be anything?*/ /** * Scrolls the grid to make a certain row and column combo visible, * in the case that it is not completely visible on the screen already. @@ -939,7 +941,7 @@ declare module uiGrid { * @param {IGridColumn} gridCol column to make visible * @returns {ng.IPromise} a promise that is resolved when scrolling is complete */ - scrollToIfNecessary(gridRow: IGridRow, gridCol: IGridColumn): void; + scrollToIfNecessary(gridRow: IGridRowOf, gridCol: IGridColumnOf): void; /** * A null handling method that can be used when building custom sort * functions @@ -1017,7 +1019,7 @@ declare module uiGrid { * Column visibility changed event handler * @param {IGridColumn} column Ui Grid column */ - (column: IGridColumn): void; + (column: IGridColumnOf): void; } export interface canvasHeightChangedHandler { /** @@ -1186,15 +1188,15 @@ declare module uiGrid { } export interface IRowColConstructor { - new (row: uiGrid.IGridRow, col: IGridColumn): IRowCol; + new (row: uiGrid.IGridRowOf, col: IGridColumnOf): IRowCol; } /** * A row and column pair that represents the intersection of these two entities */ export interface IRowCol { - row: uiGrid.IGridRow; - col: IGridColumn; + row: uiGrid.IGridRowOf; + col: IGridColumnOf; /** * Gets the intersection of where the row and column meet * @returns The value from the grid data that this RowCol points to. If the column has a cellFilter this @@ -1286,7 +1288,7 @@ declare module uiGrid { reader.readAsText( files[0] ); } */ - editFileChooserCallback?: (gridRow: uiGrid.IGridRow, gridCol: IGridColumn, files: FileList) => void; + editFileChooserCallback?: (gridRow: uiGrid.IGridRowOf, gridCol: IGridColumnOf, files: FileList) => void; /** * A bindable string value that is used when binding to edit controls instead of colDef.field * For example if you have a complex property on an object like: @@ -1498,7 +1500,7 @@ declare module uiGrid { * Raised when cell editing is complete * @param {IGridRow} row The row that was expanded */ - (row: IGridRow): void; + (row: IGridRowOf): void; } } @@ -1562,7 +1564,7 @@ declare module uiGrid { * @param {any} value The cell value * @returns {any} Formatted value */ - exporterFieldCallback?: (grid: IGridInstance, row: uiGrid.IGridRow, col: IGridColumn, value: any) => any; + exporterFieldCallback?: (grid: IGridInstanceOf, row: uiGrid.IGridRowOf, col: IGridColumnOf, value: any) => any; /** * A function to apply to the header displayNames before exporting. Useful for internationalisation, * for example if you were using angular-translate you'd set this to $translate.instant. @@ -1939,7 +1941,7 @@ declare module uiGrid { * @param {IGridColumn} col the column which on which aggregation changed. * The aggregation type is available as col.treeAggregation.type */ - (col: IGridColumn): void; + (col: IGridColumnOf): void; } export interface groupingChangedHandler { @@ -1948,7 +1950,7 @@ declare module uiGrid { * @param {IGridColumn} col the column which on which grouping changed. * The new grouping is available as col.grouping */ - (col: IGridColumn): void; + (col: IGridColumnOf): void; } /** @@ -1973,7 +1975,7 @@ declare module uiGrid { * @param {IGridInstance} grid The grid we're importing into, may be useful in some way * @param {Array} newObjects An array of new objects that you should add to your data */ - importerDataAddCallback?: (grid: IGridInstance, newObjects: Array) => void; + importerDataAddCallback?: (grid: IGridInstanceOf, newObjects: Array) => void; /** * A callback function that provides custom error handling, * rather than the standard grid behaviour of an alert box and a console message. @@ -1990,7 +1992,7 @@ declare module uiGrid { * @param {any} context the context data that importer would have appended to that console message, * often the file content itself or the element that is in error */ - importerErrorCallback?: (grid: IGridInstance, errorKey: string, consoleMessage: string, + importerErrorCallback?: (grid: IGridInstanceOf, errorKey: string, consoleMessage: string, context: any) => void; /** * A callback function that will filter (usually translate) a single header. @@ -2010,7 +2012,7 @@ declare module uiGrid { * @returns {any} The modified object * @default angular.identity */ - importerObjectCallback?: (grid: IGridInstance, newObject: TEntity) => TEntity; + importerObjectCallback?: (grid: IGridInstanceOf, newObject: TEntity) => TEntity; /** * A callback function that will process headers using custom * logic. Set this callback function if the headers that your user will provide in their @@ -2029,7 +2031,7 @@ declare module uiGrid { * which you need to match to column.names * @returns {Array} array of matching column names, in the same order as the headerArray */ - importerProcessHeaders?: (grid: IGridInstance, headerArray: Array) => Array; + importerProcessHeaders?: (grid: IGridInstanceOf, headerArray: Array) => Array; /** * Whether or not importer is enabled. Automatically set * to false if the user's browser does not support the required fileApi. @@ -2132,7 +2134,7 @@ declare module uiGrid { * @param {boolean} scrollDown flag that there are pages downwards, so fire infinite scroll events downward * @returns {ng.IPromise} A promise that is resolved when scrolling finishes */ - dataRemovedBottom(grid: IGridInstance, scrollUp: boolean, scrollDown: boolean): ng.IPromise; + dataRemovedBottom(grid: IGridInstanceOf, scrollUp: boolean, scrollDown: boolean): ng.IPromise; /** * Adjusts the scroll position after you've removed data at the bottom * @param {boolean} scrollUp flag that there are pages upwards, fire infinite scroll events upward @@ -2151,7 +2153,7 @@ declare module uiGrid { * @param {boolean} scrollDown flag that there are pages downwards, so fire infinite scroll events downward * @returns {ng.IPromise} A promise that is resolved when scrolling finishes */ - dataRemovedTop(grid: IGridInstance, scrollUp: boolean, scrollDown: boolean): ng.IPromise; + dataRemovedTop(grid: IGridInstanceOf, scrollUp: boolean, scrollDown: boolean): ng.IPromise; /** * Call this function when you have taken some action that makes the current scroll position invalid. * For example, if you're using external sorting and you've resorted then you might reset the scroll, @@ -2367,7 +2369,7 @@ declare module uiGrid { * @param {IGridColumn} col The column being pinned * @param {string} container One of the recognized container types from uiGridPinningConstants */ - pinColumn(col: IGridColumn, container: string): void; + pinColumn(col: IGridColumnOf, container: string): void; // Events /** @@ -2469,19 +2471,19 @@ declare module uiGrid { * @returns {ng.IPromise>} a promise that represents the aggregate of all of the individual save * promises. i.e. it will be resolved when all the individual save promises have been resolved. */ - flushDirtyRows(grid?: IGridInstance): ng.IPromise>; + flushDirtyRows(grid?: IGridInstanceOf): ng.IPromise>; /** * Returns all currently dirty rows * @param {IGridInstance} grid The target grid * @returns {Array} An array of gridRows that are currently dirty */ - getDirtyRows(grid?: IGridInstance): Array>; + getDirtyRows(grid?: IGridInstanceOf): Array>; /** * Returns all currently errored rows * @param {IGridInstance} grid The target grid * @returns {Array} An array of gridRows that are currently in error */ - getErrorRows(grid?: IGridInstance): Array>; + getErrorRows(grid?: IGridInstanceOf): Array>; /** * Sets each of the rows passed in dataRows to be clean, * removing them from the dirty cache and the error cache, @@ -2827,7 +2829,7 @@ declare module uiGrid { * returns all selected rows as gridRows * @returns {Array} The selected rows */ - getSelectedGridRows(): Array>; + getSelectedGridRows(): Array>; /** * Gets selected rows as entities * @returns {Array} Selected row entities @@ -2907,7 +2909,7 @@ declare module uiGrid { * @param {IGridRow} row The selected rows * @param {ng.IAngularEvent} event object if raised from event */ - (row: uiGrid.IGridRow, event?: ng.IAngularEvent): void; + (row: uiGrid.IGridRowOf, event?: ng.IAngularEvent): void; } export interface rowSelectionChangedBatchHandler { @@ -2916,7 +2918,7 @@ declare module uiGrid { * @param {IGridRow} row The selected rows * @param {ng.IAngularEvent} event object if raised from event */ - (row: Array>, event?: ng.IAngularEvent): void; + (row: Array>, event?: ng.IAngularEvent): void; } } @@ -2951,7 +2953,7 @@ declare module uiGrid { * @param {IGridRow} row Row objet */ customerTreeAggregationFn?: (aggregation: IGridTreeBaseAggregationObject, fieldValue: any, numValue: number, - row: IGridRow) => void; + row: IGridRowOf) => void; /** * A custom label to use for this aggregation. If providedm, we don't use native i18n */ @@ -3052,7 +3054,7 @@ declare module uiGrid { export interface IGridTreeBaseCustomAggregation { label: string; aggregationFn: (aggregation: IGridTreeBaseAggregationObject, fieldValue: any, numValue: number, - row?: IGridRow) => void; + row?: IGridRowOf) => void; finalizerFn?: (aggregation: IGridTreeBaseAggregationObject) => void; } export interface IGridTreeBaseAggregationObject { @@ -3072,13 +3074,13 @@ declare module uiGrid { * collapse the specified row. When you expand the row again, all grandchildren will retain their state * @param {IGridRow} row The row to collapse */ - collapseRow(row: IGridRow): void; + collapseRow(row: IGridRowOf): void; /** * collapse all children of the specified row. When you expand the row again, all grandchildren will be * collapsed * @param {IGridRow} row The row to collapse children of */ - collapseRowChildren(row: IGridRow): void; + collapseRowChildren(row: IGridRowOf): void; /** * Expands all tree rows */ @@ -3087,13 +3089,13 @@ declare module uiGrid { * Expand the immediate children of the specified row * @param {IGridRow} row The row to expand */ - expandRow(row: IGridRow): void; + expandRow(row: IGridRowOf): void; /** * Get the children of the specified row * @param {IGridRow} row The row you want the children of * @returns Array Array of children rows */ - getRowChildren(row: IGridRow): Array>; + getRowChildren(row: IGridRowOf): Array>; /** * Get the tree state for this grid, used by the saveState feature Returned treeState as an object * ```{ expandedState: { uid: 'expanded', uid: 'collapsed' } }``` @@ -3111,7 +3113,7 @@ declare module uiGrid { * call expand if row is collapsed, and collapse if it is expanded * @param {IGridRow} row The row to toggle */ - toggleRowTreeState(row: IGridRow): void; + toggleRowTreeState(row: IGridRowOf): void; // Events on: { @@ -3146,7 +3148,7 @@ declare module uiGrid { * Row Collapsed callback * @param {IGridRow} row The row that was collapsed. You can also retrieve the grid from this row with row.grid */ - (row: IGridRow): void; + (row: IGridRowOf): void; } export interface rowExpandedHandler { @@ -3154,7 +3156,7 @@ declare module uiGrid { * Row Expanded callback * @param {IGridRow} row The row that was expanded. You can also retrieve the grid from this row with row.grid */ - (row: IGridRow): void; + (row: IGridRowOf): void; } /** @@ -3205,7 +3207,7 @@ declare module uiGrid { // Tree View export interface IGridApiConstructor { - new (grid: IGridInstance): IGridApi; + new (grid: IGridInstanceOf): IGridApi; } export interface IGridApi { /** @@ -3339,7 +3341,7 @@ declare module uiGrid { /** * A grid instance is made available in the gridApi. */ - grid: IGridInstance; + grid: IGridInstanceOf; } export interface IGridRowConstructor { /** @@ -3349,13 +3351,14 @@ declare module uiGrid { * @param index the current position of the row in the array * @param reference to the parent grid */ - new(entity: TEntity, index: number, reference: IGridInstance): IGridRow; + new(entity: TEntity, index: number, reference: IGridInstanceOf): IGridRowOf; } - export interface IGridRow extends cellNav.IGridRow, edit.IGridRow, exporter.IGridRow, selection.IGridRow { + export type IGridRow = IGridRowOf; + export interface IGridRowOf extends cellNav.IGridRow, edit.IGridRow, exporter.IGridRow, selection.IGridRow { /** A reference to an item in gridOptions.data[] */ entity: TEntity; /** A reference back to the grid */ - grid: IGridInstance; + grid: IGridInstanceOf; /** * height of each individual row. changing the height will flag all * row renderContainers to recalculate their canvas height @@ -3383,7 +3386,7 @@ declare module uiGrid { * Changed to just call the internal function row.clearThisRowInvisible(). * @param row the row we want to clear the invisible flag */ - clearRowInvisible(row: IGridRow): void; + clearRowInvisible(row: IGridRowOf): void; /** * Clears any override on the row visibility, returning it to normal visibility calculations. * Emits the rowsVisibleChanged event @@ -3403,13 +3406,13 @@ declare module uiGrid { * @param col column instance * @returns resulting name that can be evaluated against a row */ - getEntityQualifiedColField(col: IGridColumn): string; + getEntityQualifiedColField(col: IGridColumnOf): string; /** * returns the qualified field name as it exists on scope ie: row.entity.fieldA * @param col column instance * @returns resulting name that can be evaluated on scope */ - getQualifiedColField(col: IGridColumn): string; + getQualifiedColField(col: IGridColumnOf): string; /** * Sets an override on the row that forces it to always be invisible. * Emits the rowsVisibleChanged event if it changed the row visibility. @@ -3419,7 +3422,7 @@ declare module uiGrid { * Changed to just call the internal function row.setThisRowInvisible(). * @param row the row we want to set to invisible */ - setRowInvisible(row: IGridRow): void; + setRowInvisible(row: IGridRowOf): void; /** * Sets an override on the row that forces it to always be invisible. * Emits the rowsVisibleChanged event if it changed the row visibility @@ -3437,12 +3440,13 @@ declare module uiGrid { * @param index the current position of the column in the array * @param grid reference to the grid */ - new(gridCol: IColumnDef, index: number, grid: IGridInstance): IGridColumn; + new(gridCol: IColumnDefOf, index: number, grid: IGridInstanceOf): IGridColumnOf; } - export interface IGridColumn { + export type IGridColumn = IGridColumnOf; + export interface IGridColumnOf { /** Column definition */ - colDef: uiGrid.IColumnDef; + colDef: uiGrid.IColumnDefOf; /** * Column name that will be shown in the header. * If displayName is not provided then one is generated using the name. @@ -3472,7 +3476,7 @@ declare module uiGrid { * @param uid The unique and immutable uid we'd like to allocate to this column * @param grid the grid we'd like to create this column in */ - GridColumn(colDef: IColumnDef, uid: number, grid: IGridInstance): void; + GridColumn(colDef: IColumnDefOf, uid: number, grid: IGridInstanceOf): void; /** * Gets the aggregation label from colDef.aggregationLabel if specified or by using i18n, * including deciding whether or not to display based on colDef.aggregationHideLabel. @@ -3510,7 +3514,7 @@ declare module uiGrid { * @param propName the property name we'd like to set * @param defaultValue the value to use if the colDef doesn't provide the setting */ - setPropertyOrDefault(colDef: IColumnDef, propName: string, defaultValue: any): void; + setPropertyOrDefault(colDef: IColumnDefOf, propName: string, defaultValue: any): void; /** Makes the column visible by setting colDef.visible = true */ showColumn(): void; /** @@ -3519,7 +3523,7 @@ declare module uiGrid { * @param isNew whether the column is being newly created, if not we're updating an existing * column, and some items such as the sort shouldn't be copied down */ - updateColumnDef(colDef: IColumnDef, isNew: boolean): void; + updateColumnDef(colDef: IColumnDefOf, isNew: boolean): void; } /** @@ -3527,7 +3531,8 @@ declare module uiGrid { * which would typically be one of many column definitions within the * gridOptions.columnDefs array */ - export interface IColumnDef extends cellNav.IColumnDef, edit.IColumnDef, exporter.IColumnDef, grouping.IColumnDef, + export type IColumnDef = IColumnDefOf; + export interface IColumnDefOf extends cellNav.IColumnDef, edit.IColumnDef, exporter.IColumnDef, grouping.IColumnDef, moveColumns.IColumnDef, pinning.IColumnDef, resizeColumns.IColumnDef, treeBase.IColumnDef { /** * defaults to false @@ -3710,17 +3715,17 @@ declare module uiGrid { } export interface ICellClassGetter { - (gridRow?: IGridRow, gridCol?: IGridColumn, colRenderIndex?: number): string; + (gridRow?: IGridRowOf, gridCol?: IGridColumnOf, colRenderIndex?: number): string; } export interface ICellTooltipGetter { - (gridRow: IGridRow, gridCol: IGridColumn): string; + (gridRow: IGridRowOf, gridCol: IGridColumnOf): string; } export interface IHeaderTooltipGetter { - (gridCol: IGridColumn): string; + (gridCol: IGridColumnOf): string; } export interface IHeaderFooterCellClassGetter { - (gridRow: IGridRow, rowRenderIndex: number, gridCol: IGridColumn, colRenderIndex: number): string; + (gridRow: IGridRowOf, rowRenderIndex: number, gridCol: IGridColumnOf, colRenderIndex: number): string; } export interface IMenuItem { /** controls the title that is displayed in the menu */ From 9a4a74508e543ec53448e6d6400f1faeb29b7822 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Mon, 28 Sep 2015 11:29:41 -0600 Subject: [PATCH 4/6] Minor test improvements --- ui-grid/ui-grid-tests.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ui-grid/ui-grid-tests.ts b/ui-grid/ui-grid-tests.ts index b4ba6e3ee..7f53e9514 100644 --- a/ui-grid/ui-grid-tests.ts +++ b/ui-grid/ui-grid-tests.ts @@ -1,12 +1,12 @@ /// /// -interface MyEntity { +interface IMyEntity { name: string; age: number; } -var columnDef: uiGrid.IColumnDefOf; +var columnDef: uiGrid.IColumnDefOf; columnDef.aggregationHideLabel = true; columnDef.aggregationHideLabel = false; columnDef.aggregationType = 1; @@ -14,13 +14,13 @@ columnDef.aggregationType = function () { return 1; }; columnDef.cellClass = 'test'; columnDef.cellClass = (gridRow, gridCol, index) => { //types of gridRow, gridCol, and index are flowed in correctly - return 'pizza'; + return `${gridRow.entity.name}-${gridCol.field}-${index + 1}`; }; columnDef.cellFilter = 'date'; columnDef.cellTemplate = '
hello
'; columnDef.cellTooltip = 'blah'; columnDef.cellTooltip = function (gridRow: uiGrid.IGridRow, gridCol: uiGrid.IGridColumn) { - return 'blah'; + return `${gridRow.entity.unknownProperty}-${gridCol.displayName}`; }; columnDef.displayName = 'Jumper'; columnDef.enableColumnMenu = false; @@ -46,7 +46,7 @@ columnDef.filterHeaderTemplate = '
'; columnDef.filters = [columnDef.filter]; columnDef.footerCellClass = (gridRow, rowRenderIndex, gridCol, colRenderIndex) => { //types for gridRow, rowRenderIndex, gridCol, and colRenderIndex flow in properly - return 'blah'; + return `${gridRow.entity.age}-${rowRenderIndex + 1}-${gridCol.field}-${colRenderIndex - 1}`; }; columnDef.footerCellClass = 'theClass'; columnDef.footerCellFilter = 'currency:$'; @@ -54,7 +54,7 @@ columnDef.footerCellTemplate = '
'; columnDef.headerCellClass = (gridRow, rowRenderIndex, gridCol, colRenderIndex) => { //types for gridRow, rowRenderIndex, gridCol, and colRenderIndex flow in properly - return 'blah'; + return `${gridRow.entity.age}-${rowRenderIndex + 1}-${gridCol.field}-${colRenderIndex - 1}`; }; columnDef.headerCellClass = 'classy'; columnDef.headerCellFilter = 'currency:$'; @@ -63,7 +63,7 @@ columnDef.headerTooltip = false; columnDef.headerTooltip = 'The Tooltip'; columnDef.headerTooltip = (col) => { //type of col flows in properly - return 'tooly'; + return col.displayName; }; columnDef.maxWidth = 200; columnDef.menuItems = [{ @@ -95,10 +95,10 @@ columnDef.width = 100; columnDef.width = '*'; -var gridApi: uiGrid.IGridApi; -var gridInstance: uiGrid.IGridInstanceOf; +var gridApi: uiGrid.IGridApi; +var gridInstance: uiGrid.IGridInstanceOf; var menuItem: uiGrid.IMenuItem; -var colProcessor: uiGrid.IColumnProcessor; +var colProcessor: uiGrid.IColumnProcessor; gridApi.core.clearAllFilters(true); gridApi.core.addToGridMenu(gridInstance, [menuItem]); @@ -108,7 +108,7 @@ gridApi.core.queueGridRefresh() gridApi.core.queueRefresh(); gridApi.core.registerColumnsProcessor(colProcessor, 100); -var gridOptions: uiGrid.IGridOptionsOf = { +var gridOptions: uiGrid.IGridOptionsOf = { data: [{name: 'Bob', age: 100}], onRegisterApi: (api) => { api.selection.on.rowSelectionChanged(null, (row) => { @@ -116,7 +116,7 @@ var gridOptions: uiGrid.IGridOptionsOf = { }) } } -interface AnotherEntity { +interface IAnotherEntity { anObject: string } var anotherGridInstance: uiGrid.IGridInstance; From 2d0d678430c0ccf610633bbcc5c1e8a269301e1b Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Mon, 28 Sep 2015 11:36:38 -0600 Subject: [PATCH 5/6] wrap long lines --- ui-grid/ui-grid.d.ts | 46 +++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index 7124e0983..97c3cb2d8 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -466,7 +466,8 @@ declare module uiGrid { * reset any existing sorting and sort by this column only * @returns {ng.IPromise} A resolved promise that supplies the column. */ - sortColumn(column: IGridColumnOf, direction?: string, add?: boolean): ng.IPromise>; + sortColumn(column: IGridColumnOf, direction?: string, add?: boolean) + : ng.IPromise>; /** * flags all render containers to update their canvas height */ @@ -521,17 +522,19 @@ declare module uiGrid { (row: IGridRowOf, gridOptions: IGridOptionsOf): void; } export interface IRowProcessor { - (renderedRowsToProcess: Array>, columns: Array>): Array>; + (renderedRowsToProcess: Array>, columns: Array>) + : Array>; } export interface IColumnProcessor { - (renderedColumnsToProcess: Array>, rows: Array>): Array>; + (renderedColumnsToProcess: Array>, rows: Array>) + : Array>; } export type IGridOptions = IGridOptionsOf; export interface IGridOptionsOf extends cellNav.IGridOptions, edit.IGridOptions, expandable.IGridOptions, - exporter.IGridOptions, grouping.IGridOptions, importer.IGridOptions, infiniteScroll.IGridOptions, - moveColumns.IGridOptions, pagination.IGridOptions, pinning.IGridOptions, resizeColumns.IGridOptions, - rowEdit.IGridOptions, saveState.IGridOptions, selection.IGridOptions, treeBase.IGridOptions, - treeView.IGridOptions { + exporter.IGridOptions, grouping.IGridOptions, importer.IGridOptions, + infiniteScroll.IGridOptions, moveColumns.IGridOptions, pagination.IGridOptions, pinning.IGridOptions, + resizeColumns.IGridOptions, rowEdit.IGridOptions, saveState.IGridOptions, selection.IGridOptions, + treeBase.IGridOptions, treeView.IGridOptions { /** * Default time in milliseconds to throttle aggregation calcuations, defaults to 500ms */ @@ -1288,7 +1291,9 @@ declare module uiGrid { reader.readAsText( files[0] ); } */ - editFileChooserCallback?: (gridRow: uiGrid.IGridRowOf, gridCol: IGridColumnOf, files: FileList) => void; + editFileChooserCallback?: (gridRow: uiGrid.IGridRowOf, + gridCol: IGridColumnOf, + files: FileList) => void; /** * A bindable string value that is used when binding to edit controls instead of colDef.field * For example if you have a complex property on an object like: @@ -1564,7 +1569,10 @@ declare module uiGrid { * @param {any} value The cell value * @returns {any} Formatted value */ - exporterFieldCallback?: (grid: IGridInstanceOf, row: uiGrid.IGridRowOf, col: IGridColumnOf, value: any) => any; + exporterFieldCallback?: (grid: IGridInstanceOf, + row: uiGrid.IGridRowOf, + col: IGridColumnOf, + value: any) => any; /** * A function to apply to the header displayNames before exporting. Useful for internationalisation, * for example if you were using angular-translate you'd set this to $translate.instant. @@ -2008,7 +2016,8 @@ declare module uiGrid { * This callback can be used to change the decoded value back into a code. * Defaults to angular.identity. * @param {IGridInstance} grid The grid - * @param {TEntity} newObject The new object as importer has created it. Modify it and return modified version + * @param {TEntity} newObject The new object as importer has created it. Modify it and return modified + * version * @returns {TEntity} The modified object * @default angular.identity */ @@ -3146,7 +3155,8 @@ declare module uiGrid { export interface rowCollapsedHandler { /** * Row Collapsed callback - * @param {IGridRow} row The row that was collapsed. You can also retrieve the grid from this row with row.grid + * @param {IGridRow} row The row that was collapsed. You can also retrieve the grid from this row with + * row.grid */ (row: IGridRowOf): void; } @@ -3154,7 +3164,8 @@ declare module uiGrid { export interface rowExpandedHandler { /** * Row Expanded callback - * @param {IGridRow} row The row that was expanded. You can also retrieve the grid from this row with row.grid + * @param {IGridRow} row The row that was expanded. You can also retrieve the grid from this row with + * row.grid */ (row: IGridRowOf): void; } @@ -3354,7 +3365,8 @@ declare module uiGrid { new(entity: TEntity, index: number, reference: IGridInstanceOf): IGridRowOf; } export type IGridRow = IGridRowOf; - export interface IGridRowOf extends cellNav.IGridRow, edit.IGridRow, exporter.IGridRow, selection.IGridRow { + export interface IGridRowOf extends cellNav.IGridRow, edit.IGridRow, exporter.IGridRow, + selection.IGridRow { /** A reference to an item in gridOptions.data[] */ entity: TEntity; /** A reference back to the grid */ @@ -3532,8 +3544,9 @@ declare module uiGrid { * gridOptions.columnDefs array */ export type IColumnDef = IColumnDefOf; - export interface IColumnDefOf extends cellNav.IColumnDef, edit.IColumnDef, exporter.IColumnDef, grouping.IColumnDef, - moveColumns.IColumnDef, pinning.IColumnDef, resizeColumns.IColumnDef, treeBase.IColumnDef { + export interface IColumnDefOf extends cellNav.IColumnDef, edit.IColumnDef, exporter.IColumnDef, + grouping.IColumnDef, moveColumns.IColumnDef, pinning.IColumnDef, resizeColumns.IColumnDef, + treeBase.IColumnDef { /** * defaults to false * if set to true hides the label text in the aggregation footer, so only the value is displayed. @@ -3725,7 +3738,8 @@ declare module uiGrid { (gridCol: IGridColumnOf): string; } export interface IHeaderFooterCellClassGetter { - (gridRow: IGridRowOf, rowRenderIndex: number, gridCol: IGridColumnOf, colRenderIndex: number): string; + (gridRow: IGridRowOf, rowRenderIndex: number, gridCol: IGridColumnOf, colRenderIndex: number) + : string; } export interface IMenuItem { /** controls the title that is displayed in the menu */ From a7b029e1c225ac74cad334ffbb411b7c27675021 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Mon, 28 Sep 2015 16:14:13 -0600 Subject: [PATCH 6/6] Minor adjustments based on code review --- ui-grid/ui-grid-tests.ts | 4 ++-- ui-grid/ui-grid.d.ts | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/ui-grid/ui-grid-tests.ts b/ui-grid/ui-grid-tests.ts index 7f53e9514..95c81298a 100644 --- a/ui-grid/ui-grid-tests.ts +++ b/ui-grid/ui-grid-tests.ts @@ -95,7 +95,7 @@ columnDef.width = 100; columnDef.width = '*'; -var gridApi: uiGrid.IGridApi; +var gridApi: uiGrid.IGridApiOf; var gridInstance: uiGrid.IGridInstanceOf; var menuItem: uiGrid.IMenuItem; var colProcessor: uiGrid.IColumnProcessor; @@ -128,5 +128,5 @@ anotherGridInstance.scrollTo(); anotherGridInstance.scrollTo(rowEntityToScrollTo); anotherGridInstance.scrollTo(rowEntityToScrollTo, columnDefToScrollTo); -var selectedRowEntities: Array = gridApi.selection.getSelectedRows(); +var selectedRowEntities: Array = gridApi.selection.getSelectedRows(); var selectedGridRows: Array = gridApi.selection.getSelectedGridRows(); diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index 97c3cb2d8..481326b13 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -287,7 +287,7 @@ declare module uiGrid { * * Rows are identified using the hashKey if configured. If not configured, then rows * are identified using the gridOptions.rowEquality function - * @param {Array} newRawData The new grid data + * @param {Array} newRawData The new grid data * @return {ng.IPromise} Promise which resolves when the rows have been created or removed */ modifyRows(newRawData: Array): ng.IPromise; @@ -742,7 +742,7 @@ declare module uiGrid { * if needed * @param {IGridApi} gridApi */ - onRegisterApi?: (gridApi: IGridApi) => void; + onRegisterApi?: (gridApi: IGridApiOf) => void; /** * The height of the row in pixels, defaults to 30 * @default 30 @@ -1038,7 +1038,7 @@ declare module uiGrid { * Filter changed event callback * @param {IGridApi} gridApi grid api */ - (gridApi: IGridApi): void; + (gridApi: IGridApiOf): void; } export interface rowsRenderedHandler { @@ -1046,7 +1046,7 @@ declare module uiGrid { * Rows rendered event callback * @param {IGridApi} gridApi Grid api object */ - (gridApi: IGridApi): void; + (gridApi: IGridApiOf): void; } export interface rowsVisibleChangedHandler { @@ -1054,7 +1054,7 @@ declare module uiGrid { * Rows visible changed event callback * @param {IGridApi} gridApi grid api object */ - (gridApi: IGridApi): void; + (gridApi: IGridApiOf): void; } export interface scrollBeginHandler { @@ -1533,7 +1533,7 @@ declare module uiGrid { * This promise is needed when exporting all rows, and the data need to be provided by server side. * Default is null * @default null - * @returns {ng.IPromise>} A promise to load all data from server + * @returns {ng.IPromise>} A promise to load all data from server */ exporterAllDataFn?: () => ng.IPromise>; /** @@ -1541,7 +1541,7 @@ declare module uiGrid { * DEPRECATED - exporterAllDataFn used to be called this, but it wasn't a promise, * it was a function that returned a promise. Deprecated, but supported for backward compatibility, * use exporterAllDataFn instead. - * @returns {ng.IPromise>} A promise to load all data from server + * @returns {ng.IPromise>} A promise to load all data from server */ exporterAllDataPromise?: () => ng.IPromise>; /** @@ -1981,7 +1981,7 @@ declare module uiGrid { * The grid generally doesn't add rows to the source data array, * it is tidier to handle this through a user callback. * @param {IGridInstance} grid The grid we're importing into, may be useful in some way - * @param {Array} newObjects An array of new objects that you should add to your data + * @param {Array} newObjects An array of new objects that you should add to your data */ importerDataAddCallback?: (grid: IGridInstanceOf, newObjects: Array) => void; /** @@ -2497,7 +2497,7 @@ declare module uiGrid { * Sets each of the rows passed in dataRows to be clean, * removing them from the dirty cache and the error cache, * and clearing the error flag and the dirty flag - * @param {Array} dataRows the data entities for which the gridRows should be set clean + * @param {Array} dataRows the data entities for which the gridRows should be set clean */ setRowsClean(dataRows: Array): void; /** @@ -2505,7 +2505,7 @@ declare module uiGrid { * Note that if you have only just inserted the rows into your data, * you will need to wait for a $digest cycle before the gridRows are present. As a result, this is often * wrapped with $interval or $timeout. - * @param {Array} dataRows the data entities for which the gridRows should be set dirty + * @param {Array} dataRows the data entities for which the gridRows should be set dirty */ setRowsDirty(dataRows: Array): void; /** @@ -2841,7 +2841,7 @@ declare module uiGrid { getSelectedGridRows(): Array>; /** * Gets selected rows as entities - * @returns {Array} Selected row entities + * @returns {Array} Selected row entities */ getSelectedRows(): Array; /** @@ -3218,9 +3218,10 @@ declare module uiGrid { // Tree View export interface IGridApiConstructor { - new (grid: IGridInstanceOf): IGridApi; + new (grid: IGridInstanceOf): IGridApiOf; } - export interface IGridApi { + export type IGridApi = IGridApiOf; + export interface IGridApiOf { /** * Registers a new event for the given feature. The event will get a .raise and .on prepended to it *