diff --git a/demo-apps/ts-webpack/src/column-binding-eg/column-picker.component.ts b/demo-apps/ts-webpack/src/column-binding-eg/column-picker.component.ts index c69c7d7f..119bd832 100644 --- a/demo-apps/ts-webpack/src/column-binding-eg/column-picker.component.ts +++ b/demo-apps/ts-webpack/src/column-binding-eg/column-picker.component.ts @@ -1,5 +1,5 @@ import { IComponentOptions } from 'angular'; -import { IColumnDef } from 'ng-table'; +import { ColumnDef } from 'ng-table'; export class ColumnPickerComponent implements IComponentOptions { templateUrl = './column-picker.html'; @@ -9,5 +9,5 @@ export class ColumnPickerComponent implements IComponentOptions { } } class ColumnPickerController { - columns: IColumnDef[]; + columns: ColumnDef[]; } \ No newline at end of file diff --git a/demo-apps/ts-webpack/src/column-binding-eg/declarative-table.component.ts b/demo-apps/ts-webpack/src/column-binding-eg/declarative-table.component.ts index 5ea4f02d..bf5964a0 100644 --- a/demo-apps/ts-webpack/src/column-binding-eg/declarative-table.component.ts +++ b/demo-apps/ts-webpack/src/column-binding-eg/declarative-table.component.ts @@ -1,5 +1,5 @@ import { IComponentOptions, IComponentController } from 'angular'; -import { IColumnDef, NgTableParams } from 'ng-table'; +import { ColumnDef, NgTableParams } from 'ng-table'; import { Person } from '../shared'; export class DeclarativeTableComponent implements IComponentOptions { @@ -10,7 +10,7 @@ export class DeclarativeTableComponent implements IComponentOptions { }; } class DeclarativeTableController implements IComponentController { - exportedColumns: IColumnDef[]; + exportedColumns: ColumnDef[]; data: Person[]; tableParams = new NgTableParams({}); $onInit(){ diff --git a/demo-apps/ts-webpack/src/column-binding-eg/dynamic-table.component.ts b/demo-apps/ts-webpack/src/column-binding-eg/dynamic-table.component.ts index 4a50f67e..b3087afd 100644 --- a/demo-apps/ts-webpack/src/column-binding-eg/dynamic-table.component.ts +++ b/demo-apps/ts-webpack/src/column-binding-eg/dynamic-table.component.ts @@ -1,8 +1,8 @@ import { IComponentOptions, IComponentController } from 'angular'; -import { IDynamicTableColDef, NgTableParams } from 'ng-table'; +import { DynamicTableColDef, NgTableParams } from 'ng-table'; import { Person } from '../shared'; -interface IExtendedDynamicTableColDef extends IDynamicTableColDef { +interface ExtendedDynamicTableColDef extends DynamicTableColDef { field: string; } @@ -14,7 +14,7 @@ export class DynamicTableComponent implements IComponentOptions { }; } class DynamicTableController implements IComponentController { - columns: IExtendedDynamicTableColDef[] = [ + columns: ExtendedDynamicTableColDef[] = [ { field: 'name', title: 'Name', show: true, filter: { name: 'text' }, sortable: 'name' }, { field: 'age', title: 'Age', show: true, filter: { age: 'number' }, sortable: 'age' }, { field: 'money', title: 'Money', show: true, filter: { money: 'number' }, sortable: 'money' } diff --git a/src/browser/ngTable.directive.ts b/src/browser/ngTable.directive.ts index 4927dbfe..2171610a 100644 --- a/src/browser/ngTable.directive.ts +++ b/src/browser/ngTable.directive.ts @@ -8,12 +8,12 @@ import { IAugmentedJQuery, IDirective, IQService, IParseService, IPromise, IScope } from 'angular'; import * as ng1 from 'angular'; import { - IColumnDef, ColumnFieldContext, IColumnField, IFilterTemplateDefMap, SelectData, ITableInputAttributes + ColumnDef, ColumnFieldContext, ColumnField, FilterTemplateDefMap, SelectData, TableInputAttributes } from './public-interfaces'; import { NgTableController } from './ngTableController'; -interface IScopeExtensions { - $columns: IColumnDef[] +interface ScopeExtensions { + $columns: ColumnDef[] } ngTable.$inject = ['$q', '$parse']; @@ -45,7 +45,7 @@ export function ngTable($q: IQService, $parse: IParseService) : IDirective { scope: true, controller: 'ngTableController', compile: function(element: IAugmentedJQuery) { - let columns: IColumnDef[] = [], + let columns: ColumnDef[] = [], i = 0, dataRow: JQuery, groupRow: JQuery @@ -79,7 +79,7 @@ export function ngTable($q: IQService, $parse: IParseService) : IDirective { } }; - const parsedAttribute = function(attr: string): IColumnField { + const parsedAttribute = function(attr: string): ColumnField { const expr = getAttrValue(attr); if (!expr){ return undefined; @@ -102,7 +102,7 @@ export function ngTable($q: IQService, $parse: IParseService) : IDirective { localValue = value; } }; - return getter as IColumnField; + return getter as ColumnField; }; const titleExpr = getAttrValue('title-alt') || getAttrValue('title'); if (titleExpr){ @@ -117,7 +117,7 @@ export function ngTable($q: IQService, $parse: IParseService) : IDirective { headerTitle: parsedAttribute('header-title'), sortable: parsedAttribute('sortable'), 'class': parsedAttribute('header-class'), - filter: parsedAttribute('filter'), + filter: parsedAttribute('filter'), groupable: parsedAttribute('groupable'), headerTemplateURL: parsedAttribute('header'), filterData: parsedAttribute | SelectData>('filter-data'), @@ -132,7 +132,7 @@ export function ngTable($q: IQService, $parse: IParseService) : IDirective { setAttrValue('ng-if', '$columns[' + (columns.length - 1) + '].show(this)'); } }); - return function(scope: IScope & IScopeExtensions, element: IAugmentedJQuery, attrs: ITableInputAttributes, controller: NgTableController) { + return function(scope: IScope & ScopeExtensions, element: IAugmentedJQuery, attrs: TableInputAttributes, controller: NgTableController) { scope.$columns = columns = controller.buildColumns(columns); controller.setupBindingsToInternalScope(attrs.ngTable); diff --git a/src/browser/ngTableColumn.ts b/src/browser/ngTableColumn.ts index 605fcd6a..c6c8d966 100644 --- a/src/browser/ngTableColumn.ts +++ b/src/browser/ngTableColumn.ts @@ -8,7 +8,7 @@ import { IScope } from 'angular'; import * as ng1 from 'angular'; -import { IColumnDef, IDynamicTableColDef } from './public-interfaces'; +import { ColumnDef, DynamicTableColDef } from './public-interfaces'; /** * @private @@ -21,7 +21,7 @@ function isScopeLike(object: any) { * @private * Service to construct a $column definition used by {@link ngTable ngTable} directive */ -export class NgTableColumn { +export class NgTableColumn { static $inject: string[] = []; /** @@ -32,7 +32,7 @@ export class NgTableColumn { * @param columns a reference to the $columns array to make available on the context supplied to the * $column getter methods */ - buildColumn(column: TCol, defaultScope: IScope, columns: IColumnDef[]): IColumnDef { + buildColumn(column: TCol, defaultScope: IScope, columns: ColumnDef[]): ColumnDef { // note: we're not modifying the original column object. This helps to avoid unintended side affects const extendedCol = Object.create(column); const defaults = this.createDefaults(); @@ -90,7 +90,7 @@ export class NgTableColumn { extendedCol[prop] = getterSetter; } } - return extendedCol as IColumnDef; + return extendedCol as ColumnDef; } private createDefaults() { diff --git a/src/browser/ngTableColumnsBinding.directive.ts b/src/browser/ngTableColumnsBinding.directive.ts index 2278aec3..87ba2d5d 100644 --- a/src/browser/ngTableColumnsBinding.directive.ts +++ b/src/browser/ngTableColumnsBinding.directive.ts @@ -7,13 +7,13 @@ */ import { IAugmentedJQuery, IAttributes, IDirective, IParseService } from 'angular'; -import { ITableScope } from './ngTableController'; -import { IColumnDef } from './public-interfaces'; +import { TableScope } from './ngTableController'; +import { ColumnDef } from './public-interfaces'; /** * @private */ -interface IInputAttributes extends IAttributes { +interface InputAttributes extends IAttributes { ngTableColumnsBinding: string; } @@ -39,10 +39,10 @@ export function ngTableColumnsBinding($parse: IParseService) : IDirective { }; return directive; - function linkFn($scope: ITableScope, $element: IAugmentedJQuery, $attrs: IInputAttributes){ + function linkFn($scope: TableScope, $element: IAugmentedJQuery, $attrs: InputAttributes){ const setter = $parse($attrs.ngTableColumnsBinding).assign; if (setter){ - $scope.$watch('$columns', newColumns => { + $scope.$watch('$columns', newColumns => { const shallowClone = (newColumns || []).slice(0); setter($scope, shallowClone); }); diff --git a/src/browser/ngTableController.ts b/src/browser/ngTableController.ts index 04a80925..a47623ab 100644 --- a/src/browser/ngTableController.ts +++ b/src/browser/ngTableController.ts @@ -12,17 +12,17 @@ import { } from 'angular'; import * as ng1 from 'angular'; import { - DataResult, DataResults, IDataRowGroup, GroupedDataResults, NgTableParams, NgTableEventsChannel, - IPageButton + DataResult, DataResults, DataRowGroup, GroupedDataResults, NgTableParams, NgTableEventsChannel, + PageButton } from '../core'; -import { IColumnDef, IDynamicTableColDef, SelectData, ITableInputAttributes } from './public-interfaces'; +import { ColumnDef, DynamicTableColDef, SelectData, TableInputAttributes } from './public-interfaces'; import { NgTableColumn } from './ngTableColumn'; /** * @private */ -export interface ITableScope extends IScope { - $columns: IColumnDef[]; +export interface TableScope extends IScope { + $columns: ColumnDef[]; $loading: boolean; $filterRow: { disabled: boolean; @@ -33,7 +33,7 @@ export interface ITableScope extends IScope { show: boolean; }; show_filter: boolean; - pages: IPageButton[]; + pages: PageButton[]; templates: { header: string; pagination: string; @@ -44,7 +44,7 @@ export interface ITableScope extends IScope { /** * The controller for the {@link ngTable ngTable} and {@link ngTableDynamic ngTableDynamic} directives */ -export class NgTableController { +export class NgTableController { static $inject = [ '$scope', '$timeout', '$parse', '$compile', '$attrs', '$element', '$document', 'ngTableColumn', 'ngTableEventsChannel' ]; @@ -57,11 +57,11 @@ export class NgTableController, + private $scope: TableScope, $timeout: ITimeoutService, private $parse: IParseService, private $compile: ICompileService, - private $attrs: IAttributes & ITableInputAttributes, + private $attrs: IAttributes & TableInputAttributes, private $element: IAugmentedJQuery, private $document: IDocumentService, private ngTableColumn: NgTableColumn, @@ -156,7 +156,7 @@ export class NgTableController { const result = $column.filterData(this.$scope); if (!result) { @@ -186,9 +186,9 @@ export class NgTableController { result.push(this.ngTableColumn.buildColumn(col, this.$scope, result)); }); diff --git a/src/browser/ngTableDynamic.directive.ts b/src/browser/ngTableDynamic.directive.ts index e777dd3e..042a4f13 100644 --- a/src/browser/ngTableDynamic.directive.ts +++ b/src/browser/ngTableDynamic.directive.ts @@ -8,11 +8,11 @@ import { IAugmentedJQuery, IDirective, IScope } from 'angular'; import * as ng1 from 'angular'; -import { IColumnDef, IDynamicTableColDef, ITableInputAttributes } from './public-interfaces'; +import { ColumnDef, DynamicTableColDef, TableInputAttributes } from './public-interfaces'; import { NgTableController } from './ngTableController'; -interface IScopeExtensions { - $columns: IColumnDef[] +interface ScopeExtensions { + $columns: ColumnDef[] } ngTableDynamic.$inject = []; @@ -68,13 +68,13 @@ export function ngTableDynamic () : IDirective{ el.attr('ng-if', '$columns[$index].show(this)'); } }); - return function (scope: IScope & IScopeExtensions, element: IAugmentedJQuery, attrs: ITableInputAttributes, controller: NgTableController) { + return function (scope: IScope & ScopeExtensions, element: IAugmentedJQuery, attrs: TableInputAttributes, controller: NgTableController) { const expr = controller.parseNgTableDynamicExpr(attrs.ngTableDynamic); controller.setupBindingsToInternalScope(expr.tableParams); controller.compileDirectiveTemplates(); - scope.$watchCollection(expr.columns, (newCols/*, oldCols*/) => { + scope.$watchCollection(expr.columns, (newCols/*, oldCols*/) => { scope.$columns = controller.buildColumns(newCols); controller.loadFilterData(scope.$columns); }); diff --git a/src/browser/ngTableFilterConfig.ts b/src/browser/ngTableFilterConfig.ts index 5757127c..cd92b8e3 100644 --- a/src/browser/ngTableFilterConfig.ts +++ b/src/browser/ngTableFilterConfig.ts @@ -8,7 +8,7 @@ import * as ng1 from 'angular'; import { IServiceProvider, auto } from 'angular'; -import { IFilterConfigValues, IFilterTemplateDef } from './public-interfaces'; +import { FilterConfigValues, FilterTemplateDef } from './public-interfaces'; /** * The angular provider used to configure the behaviour of the `NgTableFilterConfig` service. @@ -16,8 +16,8 @@ import { IFilterConfigValues, IFilterTemplateDef } from './public-interfaces'; export class NgTableFilterConfigProvider implements IServiceProvider { static $inject = ['$injector']; $get: () => NgTableFilterConfig; - private config: IFilterConfigValues; - private defaultConfig: IFilterConfigValues = { + private config: FilterConfigValues; + private defaultConfig: FilterConfigValues = { defaultBaseUrl: 'ng-table/filters/', defaultExt: '.html', aliasUrls: {} @@ -40,7 +40,7 @@ export class NgTableFilterConfigProvider implements IServiceProvider { /** * Set the config values used by `NgTableFilterConfig` service */ - setConfig(customConfig: IFilterConfigValues) { + setConfig(customConfig: FilterConfigValues) { const mergeConfig = ng1.extend({}, this.config, customConfig); mergeConfig.aliasUrls = ng1.extend({}, this.config.aliasUrls, customConfig.aliasUrls); this.config = mergeConfig; @@ -57,7 +57,7 @@ export class NgTableFilterConfig { /** * Readonly copy of the final values used to configure the service. */ - public readonly config: IFilterConfigValues + public readonly config: FilterConfigValues ) { } /** @@ -69,9 +69,9 @@ export class NgTableFilterConfig { /** * Return the url of the html filter template for the supplied definition and key. - * For more information see the documentation for {@link IFilterTemplateMap} + * For more information see the documentation for {@link FilterTemplateMap} */ - getTemplateUrl(filterDef: string | IFilterTemplateDef, filterKey?: string) { + getTemplateUrl(filterDef: string | FilterTemplateDef, filterKey?: string) { let filterName: string; if (typeof filterDef !== 'string') { filterName = filterDef.id; diff --git a/src/browser/ngTableFilterRowController.ts b/src/browser/ngTableFilterRowController.ts index 79b757e6..119fafd8 100644 --- a/src/browser/ngTableFilterRowController.ts +++ b/src/browser/ngTableFilterRowController.ts @@ -7,14 +7,14 @@ */ import { IScope } from 'angular'; -import { IFilterTemplateDef, IFilterTemplateDefMap } from './public-interfaces'; +import { FilterTemplateDef, FilterTemplateDefMap } from './public-interfaces'; import { NgTableFilterConfig } from './ngTableFilterConfig'; /** * @private */ -export interface IScopeExtensions { - getFilterPlaceholderValue(filterDef: string | IFilterTemplateDef, filterKey?: string): string; +export interface ScopeExtensions { + getFilterPlaceholderValue(filterDef: string | FilterTemplateDef, filterKey?: string): string; } /** @@ -23,7 +23,7 @@ export interface IScopeExtensions { export class NgTableFilterRowController { static $inject = ['$scope', 'ngTableFilterConfig']; config: NgTableFilterConfig; - constructor($scope: IScope & IScopeExtensions, ngTableFilterConfig: NgTableFilterConfig) { + constructor($scope: IScope & ScopeExtensions, ngTableFilterConfig: NgTableFilterConfig) { this.config = ngTableFilterConfig; // todo: stop doing this. Why? @@ -33,7 +33,7 @@ export class NgTableFilterRowController { $scope.getFilterPlaceholderValue = this.getFilterPlaceholderValue.bind(this); } - getFilterCellCss(filter: IFilterTemplateDefMap, layout: string) { + getFilterCellCss(filter: FilterTemplateDefMap, layout: string) { if (layout !== 'horizontal') { return 's12'; } @@ -43,7 +43,7 @@ export class NgTableFilterRowController { return 's' + width; } - getFilterPlaceholderValue(filterDef: string | IFilterTemplateDef, filterKey?: string) { + getFilterPlaceholderValue(filterDef: string | FilterTemplateDef, filterKey?: string) { if (typeof filterDef === 'string') { return ''; } else { diff --git a/src/browser/ngTableGroupRowController.ts b/src/browser/ngTableGroupRowController.ts index 512a3528..a08c77f4 100644 --- a/src/browser/ngTableGroupRowController.ts +++ b/src/browser/ngTableGroupRowController.ts @@ -7,15 +7,15 @@ */ import { IPromise } from 'angular'; -import { DataResult, IGroupingFunc, Grouping, GroupSort } from '../core'; -import { IColumnDef } from './public-interfaces'; -import { ITableScope } from './ngTableController'; +import { DataResult, GroupingFunc, Grouping, GroupSort } from '../core'; +import { ColumnDef } from './public-interfaces'; +import { TableScope } from './ngTableController'; /** * @private */ -export interface IScopeExtensions { - $selGroup: IGroupingFunc | string; +export interface ScopeExtensions { + $selGroup: GroupingFunc | string; $selGroupTitle: string; } @@ -25,8 +25,8 @@ export interface IScopeExtensions { */ export class NgTableGroupRowController { static $inject = ['$scope']; - private groupFns: Array | IColumnDef> = []; - constructor(private $scope: ITableScope & IScopeExtensions) { + private groupFns: Array | ColumnDef> = []; + constructor(private $scope: TableScope & ScopeExtensions) { $scope.$watch>('params.group()', (newGrouping) => { this.setGroup(newGrouping); }, true); @@ -37,7 +37,7 @@ export class NgTableGroupRowController { return this.groupFns.concat(groupableCols); } - getGroupTitle(group: IGroupingFunc | IColumnDef) { + getGroupTitle(group: GroupingFunc | ColumnDef) { return this.isGroupingFunc(group) ? group.title : group.title(this.$scope); } @@ -46,7 +46,7 @@ export class NgTableGroupRowController { return this.$scope.$columns.filter($column => $column.show(this.$scope)) } - groupBy(group: IGroupingFunc | IColumnDef) { + groupBy(group: GroupingFunc | ColumnDef) { if (this.isSelectedGroup(group)) { this.changeSortDirection(); } else { @@ -61,7 +61,7 @@ export class NgTableGroupRowController { } } - isSelectedGroup(group: IGroupingFunc | IColumnDef) { + isSelectedGroup(group: GroupingFunc | ColumnDef) { if (this.isGroupingFunc(group)) { return group === this.$scope.$selGroup; } else { @@ -86,11 +86,11 @@ export class NgTableGroupRowController { this.$scope.params.group(this.$scope.$selGroup, newDirection); } - private findGroupColumn(groupKey: IGroupingFunc | string) { + private findGroupColumn(groupKey: GroupingFunc | string) { return this.$scope.$columns.filter($column => $column.groupable(this.$scope) === groupKey)[0]; } - private isGroupingFunc(val: IColumnDef | Grouping): val is IGroupingFunc { + private isGroupingFunc(val: ColumnDef | Grouping): val is GroupingFunc { return typeof val === 'function'; } diff --git a/src/browser/ngTablePagination.directive.ts b/src/browser/ngTablePagination.directive.ts index e7a7e465..1c788710 100644 --- a/src/browser/ngTablePagination.directive.ts +++ b/src/browser/ngTablePagination.directive.ts @@ -7,11 +7,11 @@ */ import * as ng1 from 'angular'; -import { NgTableEventsChannel, IPageButton } from '../core' -import { ITableScope } from './ngTableController'; +import { NgTableEventsChannel, PageButton } from '../core' +import { TableScope } from './ngTableController'; -interface IScopeExtensions { - pages: IPageButton[] +interface ScopeExtensions { + pages: PageButton[] } ngTablePagination.$inject = ['$compile', '$document', 'ngTableEventsChannel']; @@ -29,7 +29,7 @@ export function ngTablePagination($compile: ng1.ICompileService, $document: n 'templateUrl': '=' }, replace: false, - link: function(scope: ITableScope & IScopeExtensions, element: ng1.IAugmentedJQuery/*, attrs*/) { + link: function(scope: TableScope & ScopeExtensions, element: ng1.IAugmentedJQuery/*, attrs*/) { ngTableEventsChannel.onAfterReloadData(function(pubParams) { scope.pages = pubParams.generatePagesArray(); diff --git a/src/browser/ngTableSelectFilterDs.directive.ts b/src/browser/ngTableSelectFilterDs.directive.ts index 87e1fe8c..77fb8a30 100644 --- a/src/browser/ngTableSelectFilterDs.directive.ts +++ b/src/browser/ngTableSelectFilterDs.directive.ts @@ -7,20 +7,20 @@ */ import * as ng1 from 'angular'; -import { IColumnDef, SelectData, ISelectDataFunc, ISelectOption } from './public-interfaces'; +import { ColumnDef, SelectData, SelectDataFunc, SelectOption } from './public-interfaces'; /** * @private */ -export interface IInputAttributes extends ng1.IAttributes { +export interface InputAttributes extends ng1.IAttributes { ngTableSelectFilterDs: string; } /** * @private */ -export interface IScopeExtensions { - $selectData: ISelectOption[] +export interface ScopeExtensions { + $selectData: SelectOption[] } ngTableSelectFilterDs.$inject = []; @@ -49,11 +49,11 @@ function ngTableSelectFilterDs(): ng1.IDirective { */ export class NgTableSelectFilterDsController { static $inject = ['$scope', '$parse', '$attrs', '$q']; - $column: IColumnDef; + $column: ColumnDef; constructor( - private $scope: ng1.IScope & IScopeExtensions, + private $scope: ng1.IScope & ScopeExtensions, $parse: ng1.IParseService, - private $attrs: IInputAttributes, + private $attrs: InputAttributes, private $q: ng1.IQService) { this.$column = $parse($attrs.ngTableSelectFilterDs)($scope); @@ -71,7 +71,7 @@ export class NgTableSelectFilterDsController { }); } - private hasEmptyOption(data: ISelectOption[]) { + private hasEmptyOption(data: SelectOption[]) { let isMatch: boolean; for (let i = 0; i < data.length; i++) { const item = data[i]; @@ -83,7 +83,7 @@ export class NgTableSelectFilterDsController { return isMatch; } - private getSelectListData($column: IColumnDef) { + private getSelectListData($column: ColumnDef) { const dataInput = $column.data; if (dataInput instanceof Array) { return this.$q.when(dataInput); diff --git a/src/browser/ngTableSorterRowController.ts b/src/browser/ngTableSorterRowController.ts index 2899b79b..321d8239 100644 --- a/src/browser/ngTableSorterRowController.ts +++ b/src/browser/ngTableSorterRowController.ts @@ -6,9 +6,9 @@ * @license New BSD License */ import { IAngularEvent } from 'angular'; -import { SortDirection, ISortingValues } from '../core'; -import { IColumnDef } from './public-interfaces'; -import { ITableScope } from './ngTableController'; +import { SortDirection, SortingValues } from '../core'; +import { ColumnDef } from './public-interfaces'; +import { TableScope } from './ngTableController'; /** * @private @@ -22,9 +22,9 @@ export interface IAugmentedMouseEvent extends IAngularEvent { */ export class NgTableSorterRowController { static $inject = ['$scope']; - constructor(private $scope: ITableScope) {} + constructor(private $scope: TableScope) {} - sortBy($column: IColumnDef, event: IAugmentedMouseEvent) { + sortBy($column: ColumnDef, event: IAugmentedMouseEvent) { const parsedSortable = $column.sortable && $column.sortable(); if (!parsedSortable || typeof parsedSortable !== 'string') { return; @@ -32,7 +32,7 @@ export class NgTableSorterRowController { const defaultSort = this.$scope.params.settings().defaultSort; const inverseSort: SortDirection = (defaultSort === 'asc' ? 'desc' : 'asc'); const sorting = this.$scope.params.sorting() && this.$scope.params.sorting()[parsedSortable] && (this.$scope.params.sorting()[parsedSortable] === defaultSort); - const sortingParams: ISortingValues = (event.ctrlKey || event.metaKey) ? this.$scope.params.sorting() : {}; + const sortingParams: SortingValues = (event.ctrlKey || event.metaKey) ? this.$scope.params.sorting() : {}; sortingParams[parsedSortable] = (sorting ? inverseSort : defaultSort); this.$scope.params.parameters({ sorting: sortingParams diff --git a/src/browser/public-interfaces.ts b/src/browser/public-interfaces.ts index 712a8c65..a46c2c56 100644 --- a/src/browser/public-interfaces.ts +++ b/src/browser/public-interfaces.ts @@ -4,14 +4,14 @@ import { IAttributes, IPromise, IScope } from 'angular'; * The scope available to a table column getter */ export type ColumnFieldContext = IScope & { - $column?: IColumnDef; - $columns: IColumnDef[]; + $column?: ColumnDef; + $columns: ColumnDef[]; } /** * Signature of a getter/setter on a {@link IColumnDef} instance */ -export interface IColumnField { +export interface ColumnField { (context?: ColumnFieldContext): T; (value: T): void; assign($scope: IScope, value: T): void; @@ -30,13 +30,13 @@ export interface IColumnField { * * ``` */ -export interface IColumnDef { +export interface ColumnDef { /** * Custom CSS class that should be added to the `th` tag(s) of this column in the table header * * To set this on the `td` tag of a html table use the attribute `header-class` or `data-header-class` */ - class: IColumnField; + class: ColumnField; /** * The `ISelectOption`s that can be used in a html filter template for this colums. */ @@ -49,64 +49,64 @@ export interface IColumnDef { * The definition of 0 or more html filter templates that should be rendered for this column in * the table header */ - filter: IColumnField; + filter: ColumnField; /** * Supplies the `ISelectOption`s that can be used in a html filter template for this colums. * At the creation of the `NgTableParams` this field will be called and the result then assigned * to the `data` field of this column. */ - filterData: IColumnField | SelectData>; + filterData: ColumnField | SelectData>; /** * The name of the data row field that will be used to group on, or false when this column * does not support grouping */ - groupable: IColumnField; + groupable: ColumnField; /** * The url of a custom html template that should be used to render a table header for this column * * To set this on the `td` tag for a html table use the attribute `header` or `data-header` */ - headerTemplateURL: IColumnField; + headerTemplateURL: ColumnField; /** * The text that should be used as a tooltip for this column in the table header */ - headerTitle: IColumnField; + headerTitle: ColumnField; /** * Determines whether this column should be displayed in the table * * To set this on the `td` tag for a html table use the attribute `ng-if` */ - show: IColumnField; + show: ColumnField; /** * The name of the data row field that will be used to sort on, or false when this column * does not support sorting */ - sortable: IColumnField; + sortable: ColumnField; /** * The title of this column that should be displayed in the table header */ - title: IColumnField; + title: ColumnField; /** * An alternate column title. Typically this can be used for responsive table layouts * where the titleAlt should be used for small screen sizes */ - titleAlt: IColumnField; + titleAlt: ColumnField; } -export type DynamicTableColField = IDynamicTableColFieldFunc | T; +export type DynamicTableColField = DynamicTableColFieldFunc | T; /** * Signature of a getter/setter on a {@link IDynamicTableColDef} instance */ -export interface IDynamicTableColFieldFunc { +export interface DynamicTableColFieldFunc { (context: ColumnFieldContext): T; } /** * The definition of the column supplied to a {@link ngTableDynamic} directive. */ -export interface IDynamicTableColDef { +export interface DynamicTableColDef { /** * Custom CSS class that should be added to the `th` tag(s) of this column in the table header */ @@ -115,7 +115,7 @@ export interface IDynamicTableColDef { * The definition of 0 or more html filter templates that should be rendered for this column in * the table header */ - filter?: DynamicTableColField; + filter?: DynamicTableColField; /** * Supplies the `ISelectOption`s that can be used in a html filter template for this colums. * At the creation of the `NgTableParams` this field will be called and the result then assigned @@ -158,7 +158,7 @@ export interface IDynamicTableColDef { /** * Configuration values that determine the behaviour of the `ngTableFilterConfig` service */ -export interface IFilterConfigValues { +export interface FilterConfigValues { /** * The default base url to use when deriving the url for a filter template given just an alias name * Defaults to 'ng-table/filters/' @@ -194,14 +194,14 @@ export interface IFilterConfigValues { * vm.ageFilter = { "age": { id: "number", placeholder: "Age of person"} } * ``` */ -export interface IFilterTemplateDefMap { - [name: string]: string | IFilterTemplateDef +export interface FilterTemplateDefMap { + [name: string]: string | FilterTemplateDef } /** * A fully qualified template definition for a single filter */ -export interface IFilterTemplateDef { +export interface FilterTemplateDef { /** * A url to a html template or an alias to a url registered using the {@link ngTableFilterConfigProvider} */ @@ -212,12 +212,12 @@ export interface IFilterTemplateDef { placeholder: string } -export type SelectData = ISelectOption[] | ISelectDataFunc +export type SelectData = SelectOption[] | SelectDataFunc /** * An object to be rendered as a html select option */ -export interface ISelectOption { +export interface SelectOption { id: string | number; title: string; } @@ -225,14 +225,14 @@ export interface ISelectOption { /** * Signature of a function that will return the options that will be rendered by a html select */ -export interface ISelectDataFunc { - (): ISelectOption[] | IPromise +export interface SelectDataFunc { + (): SelectOption[] | IPromise } /** * The definition of the html attributes accepted by the {@link ngTable ngTable} and {@link ngTableDynamic} directives */ -export interface ITableInputAttributes extends IAttributes { +export interface TableInputAttributes extends IAttributes { disableFilter?: string; ngTable?: string; ngTableDynamic?: string; diff --git a/src/core/data/getData.ts b/src/core/data/getData.ts index f4a54d22..209e80de 100644 --- a/src/core/data/getData.ts +++ b/src/core/data/getData.ts @@ -6,16 +6,16 @@ import { NgTableParams } from '../ngTableParams'; * data rows into the table. * @param params the table requesting the data rows */ -export interface IGetDataFunc { +export interface GetDataFunc { (params: NgTableParams): T[] | IPromise; } /** - * Variation of the {@link IGetDataFunc} function signature that allows for flexibility for + * Variation of the {@link GetDataFunc} function signature that allows for flexibility for * the shape of the return value. * Typcially you will use this function signature when you want to configure {@link NgTableParams} * with interceptors that will return the final data rows array. */ -export interface IInterceptableGetDataFunc { +export interface InterceptableGetDataFunc { (params: NgTableParams): TResult; } \ No newline at end of file diff --git a/src/core/data/interceptor.ts b/src/core/data/interceptor.ts index 6114fdc2..33997924 100644 --- a/src/core/data/interceptor.ts +++ b/src/core/data/interceptor.ts @@ -4,7 +4,7 @@ import { NgTableParams } from '../ngTableParams' * A custom object that can be registered with an {@link NgTableParams} instance that can be used * to post-process the results (and failures) returned by its `getData` function */ -export interface IInterceptor { +export interface Interceptor { response?: (data: TData, params: NgTableParams) => TData; responseError?: (reason: any, params: NgTableParams) => any; } \ No newline at end of file diff --git a/src/core/data/ngTableDefaultGetData.ts b/src/core/data/ngTableDefaultGetData.ts index 837f96a0..ba62dc2b 100644 --- a/src/core/data/ngTableDefaultGetData.ts +++ b/src/core/data/ngTableDefaultGetData.ts @@ -8,7 +8,7 @@ import * as ng1 from 'angular'; import { IFilterFilter, IFilterOrderBy, IFilterService, IPromise, IServiceProvider} from 'angular'; -import { IFilterFunc } from '../filtering'; +import { FilterFunc } from '../filtering'; import { NgTableParams } from '../ngTableParams'; import { NgTableEventsChannel } from '../ngTableEventsChannel'; @@ -21,7 +21,7 @@ import { NgTableEventsChannel } from '../ngTableEventsChannel'; * - return the resulting array * - assign the total item count after filtering to the `total` of the `NgTableParams` instance supplied */ -export interface IDefaultGetData { +export interface DefaultGetData { (data: T[], params: NgTableParams): T[]; /** * Convenience function that this service will use to apply paging to the data rows. @@ -33,7 +33,7 @@ export interface IDefaultGetData { /** * Returns a reference to the function that this service will use to filter data rows */ - getFilterFn(params: NgTableParams): IFilterFunc, + getFilterFn(params: NgTableParams): FilterFunc, /** * Returns a reference to the function that this service will use to sort data rows */ @@ -41,7 +41,7 @@ export interface IDefaultGetData { } /** - * Implementation of the {@link IDefaultGetDataProvider} interface + * Implementation of the {@link DefaultGetDataProvider} interface */ export class NgTableDefaultGetDataProvider implements IServiceProvider { /** @@ -56,22 +56,22 @@ export class NgTableDefaultGetDataProvider implements IServiceProvider { * (defaults to the angular `orderBy` filter service) */ sortingFilterName = 'orderBy'; - $get: ($filter: IFilterService, ngTableEventsChannel: NgTableEventsChannel) => IDefaultGetData; + $get: ($filter: IFilterService, ngTableEventsChannel: NgTableEventsChannel) => DefaultGetData; constructor() { const provider = this; this.$get = ngTableDefaultGetData; ngTableDefaultGetData.$inject = ['$filter', 'ngTableEventsChannel']; - function ngTableDefaultGetData($filter: IFilterService, ngTableEventsChannel: NgTableEventsChannel): IDefaultGetData { + function ngTableDefaultGetData($filter: IFilterService, ngTableEventsChannel: NgTableEventsChannel): DefaultGetData { - (getData as IDefaultGetData).applyPaging = applyPaging; - (getData as IDefaultGetData).getFilterFn = getFilterFn; - (getData as IDefaultGetData).getOrderByFn = getOrderByFn; + (getData as DefaultGetData).applyPaging = applyPaging; + (getData as DefaultGetData).getFilterFn = getFilterFn; + (getData as DefaultGetData).getOrderByFn = getOrderByFn; - return getData as IDefaultGetData; + return getData as DefaultGetData; - function getFilterFn(params: NgTableParams): IFilterFunc { + function getFilterFn(params: NgTableParams): FilterFunc { const filterOptions = params.settings().filterOptions; if (ng1.isFunction(filterOptions.filterFn)) { return filterOptions.filterFn; diff --git a/src/core/data/results.ts b/src/core/data/results.ts index 7bcc18b9..5716fbef 100644 --- a/src/core/data/results.ts +++ b/src/core/data/results.ts @@ -1,6 +1,6 @@ -export type DataResult = T | IDataRowGroup; +export type DataResult = T | DataRowGroup; -export interface IDataRowGroup { +export interface DataRowGroup { data: T[]; $hideRows: boolean; value: string; @@ -16,4 +16,4 @@ export type DataResults = T[] & { visibleColumnCount: number }; * The augmented grouped data row array displayed by the table * Note: this array is made available to the table templete as the `$groups` field */ -export type GroupedDataResults = IDataRowGroup[] & { visibleColumnCount: number }; \ No newline at end of file +export type GroupedDataResults = DataRowGroup[] & { visibleColumnCount: number }; \ No newline at end of file diff --git a/src/core/filtering/filterComparator.ts b/src/core/filtering/filterComparator.ts index b2f94788..477066be 100644 --- a/src/core/filtering/filterComparator.ts +++ b/src/core/filtering/filterComparator.ts @@ -1,8 +1,8 @@ -export type FilterComparator = boolean | IFilterComparatorFunc; +export type FilterComparator = boolean | FilterComparatorFunc; /** * Signature of a function to compare two data values for equality */ -export interface IFilterComparatorFunc { +export interface FilterComparatorFunc { (actual: T, expected: T): boolean; } diff --git a/src/core/filtering/filterFunc.ts b/src/core/filtering/filterFunc.ts index 880e2baf..013d34b0 100644 --- a/src/core/filtering/filterFunc.ts +++ b/src/core/filtering/filterFunc.ts @@ -3,12 +3,12 @@ import { FilterComparator } from './filterComparator'; /** * Map of the names of fields declared on a data row and the corrosponding filter value */ -export interface IFilterValues { [name: string]: any } +export interface FilterValues { [name: string]: any } /** * Signature of a function used as a custom filter implementation */ -export interface IFilterFunc { - (data: T[], filter: IFilterValues, filterComparator: FilterComparator): T[] +export interface FilterFunc { + (data: T[], filter: FilterValues, filterComparator: FilterComparator): T[] } \ No newline at end of file diff --git a/src/core/filtering/filterSettings.ts b/src/core/filtering/filterSettings.ts index 58d71322..86c21209 100644 --- a/src/core/filtering/filterSettings.ts +++ b/src/core/filtering/filterSettings.ts @@ -1,5 +1,5 @@ import { FilterComparator } from './filterComparator'; -import { IFilterFunc } from './filterFunc'; +import { FilterFunc } from './filterFunc'; export type FilterLayout = 'stack' | 'horizontal'; @@ -12,8 +12,8 @@ export class FilterSettings { * `$filter` filter service * * Defaults to `undefined` which will result in a case insensitive susbstring match when - * `IDefaultGetData` service is supplying the implementation for the - * `ISettings.getData` function + * `DefaultGetData` service is supplying the implementation for the + * `Settings.getData` function */ filterComparator?: FilterComparator = undefined; // look for a substring match in case insensitive way /** @@ -27,15 +27,15 @@ export class FilterSettings { */ filterDelayThreshold: number | null = 10000; /** - * Overrides `IDefaultGetDataProvider.filterFilterName`. + * Overrides `DefaultGetDataProvider.filterFilterName`. * The value supplied should be the name of the angular `$filter` service that will be selected to perform * the actual filter logic. */ filterFilterName?: string = undefined; /** - * Tells `IDefaultGetData` to use this function supplied to perform the filtering instead of selecting an angular $filter. + * Tells `DefaultGetData` to use this function supplied to perform the filtering instead of selecting an angular $filter. */ - filterFn?: IFilterFunc = undefined; + filterFn?: FilterFunc = undefined; /** * The layout to use when multiple html templates are to rendered in a single table header column. */ diff --git a/src/core/grouping/getGroup.ts b/src/core/grouping/getGroup.ts index 1f1f72fb..3e1fe383 100644 --- a/src/core/grouping/getGroup.ts +++ b/src/core/grouping/getGroup.ts @@ -1,12 +1,12 @@ import { IPromise } from 'angular'; import { NgTableParams } from '../ngTableParams' -import { IDataRowGroup } from '../data' +import { DataRowGroup } from '../data' /** * Signature of a function that will called whenever {@link NgTableParams} requires to group * the data rows for display in the table * @param params the table requesting the rows to be grouped */ -export interface IGetGroupFunc { - (params: NgTableParams): IDataRowGroup[] | IPromise[]> +export interface GetGroupFunc { + (params: NgTableParams): DataRowGroup[] | IPromise[]> } \ No newline at end of file diff --git a/src/core/grouping/groupingFunc.ts b/src/core/grouping/groupingFunc.ts index 012387dd..e3be592b 100644 --- a/src/core/grouping/groupingFunc.ts +++ b/src/core/grouping/groupingFunc.ts @@ -1,15 +1,15 @@ import { GroupSort } from './groupSettings'; -export type Grouping = IGroupValues | IGroupingFunc; +export type Grouping = GroupValues | GroupingFunc; /** * Signature of a function that should return the name of the group * that the `item` should be placed within */ -export interface IGroupingFunc { +export interface GroupingFunc { (item: T): string; /** - * leave undefined to let the value of `ISettings.groupOptions.defaultSort` apply + * leave undefined to let the value of `Settings.groupOptions.defaultSort` apply */ sortDirection?: GroupSort; title?: string; @@ -18,4 +18,4 @@ export interface IGroupingFunc { /** * Map of the names of fields on a data row and the corrosponding sort direction */ -export interface IGroupValues { [name: string]: GroupSort } \ No newline at end of file +export interface GroupValues { [name: string]: GroupSort } \ No newline at end of file diff --git a/src/core/grouping/ngTableDefaultGetGroups.ts b/src/core/grouping/ngTableDefaultGetGroups.ts index 83e8f6d4..6755b726 100644 --- a/src/core/grouping/ngTableDefaultGetGroups.ts +++ b/src/core/grouping/ngTableDefaultGetGroups.ts @@ -2,25 +2,25 @@ import { IQService } from 'angular'; import * as ng1 from 'angular'; import { convertSortToOrderBy, isGroupingFun } from '../util'; import { NgTableParams, } from '../ngTableParams'; -import { IDataRowGroup, IDefaultGetData, IGetDataFunc } from '../data'; -import { IGetGroupFunc, Grouping, IGroupingFunc, GroupSort } from './'; -import { ISortingValues } from '../sorting'; +import { DataRowGroup, DefaultGetData, GetDataFunc } from '../data'; +import { GetGroupFunc, Grouping, GroupingFunc, GroupSort } from './'; +import { SortingValues } from '../sorting'; ngTableDefaultGetGroups.$inject = ['$q', 'ngTableDefaultGetData']; /** - * Implementation of the {@link IDefaultGetData IDefaultGetData} interface + * Implementation of the {@link DefaultGetData} interface * * @ngdoc service */ -export function ngTableDefaultGetGroups($q: IQService, ngTableDefaultGetData: IDefaultGetData>): IGetGroupFunc { +export function ngTableDefaultGetGroups($q: IQService, ngTableDefaultGetData: DefaultGetData>): GetGroupFunc { return getGroups; function getGroups(params: NgTableParams) { const group = params.group(); - let groupFn: IGroupingFunc; + let groupFn: GroupingFunc; let sortDirection: GroupSort = undefined; if (isGroupingFun(group)) { groupFn = group; @@ -37,10 +37,10 @@ export function ngTableDefaultGetGroups($q: IQService, ngTableDefaultGetData: const settings = params.settings(); const originalDataOptions = settings.dataOptions; settings.dataOptions = ng1.extend({}, originalDataOptions, { applyPaging: false }); - const getData: IGetDataFunc = settings.getData; + const getData: GetDataFunc = settings.getData; const gotData = $q.when(getData(params)); return gotData.then(data => { - const groups: { [name: string]: IDataRowGroup } = {}; + const groups: { [name: string]: DataRowGroup } = {}; ng1.forEach(data, item => { const groupName = groupFn(item); groups[groupName] = groups[groupName] || { @@ -50,7 +50,7 @@ export function ngTableDefaultGetGroups($q: IQService, ngTableDefaultGetData: }; groups[groupName].data.push(item); }); - let result: IDataRowGroup[] = []; + let result: DataRowGroup[] = []; for (const i in groups) { result.push(groups[i]); } diff --git a/src/core/index.ts b/src/core/index.ts index bf410104..937b9c03 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -1,7 +1,7 @@ import * as angular from 'angular'; -import { NgTableDefaultGetDataProvider, IDefaultGetData } from './data'; +import { NgTableDefaultGetDataProvider, DefaultGetData } from './data'; import { GroupSettingsPartial, ngTableDefaultGetGroups } from './grouping'; -import { ngTableDefaults, IDefaults } from './ngTableDefaults'; +import { ngTableDefaults, Defaults } from './ngTableDefaults'; import { NgTableSettings, SettingsPartial, Settings } from './ngTableSettings'; import { NgTableParams } from './ngTableParams'; import { NgTableEventsChannel } from './ngTableEventsChannel'; @@ -21,7 +21,7 @@ ngTableCoreModule.value('NgTableParams', NgTableParams) export { ngTableCoreModule }; -export { IDefaults } from './ngTableDefaults'; +export { Defaults } from './ngTableDefaults'; export * from './ngTableEventsChannel'; export { SettingsPartial, Settings }; export * from './ngTableParams'; diff --git a/src/core/ngTableDefaults.ts b/src/core/ngTableDefaults.ts index ae12a1f9..74817d02 100644 --- a/src/core/ngTableDefaults.ts +++ b/src/core/ngTableDefaults.ts @@ -6,7 +6,7 @@ * @license New BSD License */ -import { IParamValues } from './ngTableParams'; +import { ParamValues } from './ngTableParams'; import { SettingsPartial } from './ngTableSettings'; @@ -14,15 +14,15 @@ import { SettingsPartial } from './ngTableSettings'; * An angular value object that allow for overriding of the initial default values used when constructing * an instance of `NgTableParams` */ -export interface IDefaults { - params?: IParamValues; +export interface Defaults { + params?: ParamValues; settings?: SettingsPartial } /** * Default values for ngTable */ -export let ngTableDefaults : IDefaults = { +export let ngTableDefaults : Defaults = { params: {}, settings: {} }; \ No newline at end of file diff --git a/src/core/ngTableEventsChannel.ts b/src/core/ngTableEventsChannel.ts index 12a8ab65..94dc0d60 100644 --- a/src/core/ngTableEventsChannel.ts +++ b/src/core/ngTableEventsChannel.ts @@ -8,57 +8,57 @@ import * as ng1 from 'angular'; import { IScope } from 'angular'; -import { DataResult, IDefaultGetData } from './data'; -import { IPageButton } from './paging'; +import { DataResult, DefaultGetData } from './data'; +import { PageButton } from './paging'; import { InternalTableParams, NgTableParams } from './ngTableParams'; /** * Alias for the types that can be used to filter events */ -export type EventSelector = NgTableParams | IEventSelectorFunc +export type EventSelector = NgTableParams | EventSelectorFunc /** * Signature of the event hander that is registered to receive the *afterCreated* event */ -export interface IAfterCreatedListener { +export interface AfterCreatedListener { (publisher: NgTableParams): any } /** * Signature of the event hander that is registered to receive the *afterReloadData* event */ -export interface IAfterReloadDataListener { +export interface AfterReloadDataListener { (publisher: NgTableParams, newData: DataResult[], oldData: DataResult[]): any } /** * Signature of the event hander that is registered to receive the *datasetChanged* event */ -export interface IDatasetChangedListener { +export interface DatasetChangedListener { (publisher: NgTableParams, newDataset: T[], oldDataset: T[]): any } /** * Signature of the function used to filter the events to only specific instances of * {@link NgTableParams} */ -export interface IEventSelectorFunc { +export interface EventSelectorFunc { (publisher: NgTableParams): boolean } /** * Signature of the event hander that is registered to receive the *pagesChanged* event */ -export interface IPagesChangedListener { - (publisher: NgTableParams, newPages: IPageButton[], oldPages: IPageButton[]): any +export interface PagesChangedListener { + (publisher: NgTableParams, newPages: PageButton[], oldPages: PageButton[]): any } /** * Signature of the event hander that is registered to receive the *afterDataFiltered* event */ -export interface IAfterDataFilteredListener { +export interface AfterDataFilteredListener { (publisher: NgTableParams, newData: DataResult[] ): any } /** * Signature of the event hander that is registered to receive the *afterDataSorted* event */ -export interface IAfterDataSortedListener { +export interface AfterDataSortedListener { (publisher: NgTableParams, newData: DataResult[] ): any } @@ -66,7 +66,7 @@ export interface IAfterDataSortedListener { * Signature of the function used to explicitly unregister an event handler so that it stops * receiving notifications */ -export interface IUnregistrationFunc { +export interface UnregistrationFunc { (): void } @@ -77,7 +77,7 @@ export interface IUnregistrationFunc { * * * afterCreated - raised when a new instance of {@link NgTableParams} has finished being constructed * * afterReloadData - raised when the {@link NgTableParams} `reload` method has finished loading new data - * * datasetChanged - raised when {@link ISettings} `dataset` receives a new data array + * * datasetChanged - raised when {@link Settings} `dataset` receives a new data array * * pagesChanged - raised when a new pages array has been generated */ export interface NgTableEventsChannel { @@ -91,7 +91,7 @@ export interface NgTableEventsChannel { * @param eventFilter a predicate function that should return true to receive the event * @return a unregistration function that when called will unregister the `listener` */ - onAfterCreated(listener: IAfterCreatedListener, scope: IScope, eventFilter?: IEventSelectorFunc): IUnregistrationFunc; + onAfterCreated(listener: AfterCreatedListener, scope: IScope, eventFilter?: EventSelectorFunc): UnregistrationFunc; /** * Subscribe to receive notification whenever a new `NgTableParams` instance has finished being constructed. * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. @@ -100,7 +100,7 @@ export interface NgTableEventsChannel { * @param eventFilter a predicate function that should return true to receive the event * @return a unregistration function that when called will unregister the `listener` */ - onAfterCreated(listener: IAfterCreatedListener, eventFilter?: IEventSelectorFunc): IUnregistrationFunc; + onAfterCreated(listener: AfterCreatedListener, eventFilter?: EventSelectorFunc): UnregistrationFunc; /** * Subscribe to receive notification whenever the `reload` method of an `NgTableParams` instance has successfully executed * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a @@ -111,7 +111,7 @@ export interface NgTableEventsChannel { * @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event * @return a unregistration function that when called will unregister the `listener` */ - onAfterReloadData(listener: IAfterReloadDataListener, scope: IScope, eventFilter?: EventSelector): IUnregistrationFunc; + onAfterReloadData(listener: AfterReloadDataListener, scope: IScope, eventFilter?: EventSelector): UnregistrationFunc; /** * Subscribe to receive notification whenever the `reload` method of an `NgTableParams` instance has successfully executed * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. @@ -120,7 +120,7 @@ export interface NgTableEventsChannel { * @param eventFilter a predicate function that should return true to receive the event * @return a unregistration function that when called will unregister the `listener` */ - onAfterReloadData(listener: IAfterReloadDataListener, eventFilter?: EventSelector): IUnregistrationFunc; + onAfterReloadData(listener: AfterReloadDataListener, eventFilter?: EventSelector): UnregistrationFunc; /** * Subscribe to receive notification whenever a new data rows *array* is supplied as a `settings` value to a `NgTableParams` instance. @@ -132,7 +132,7 @@ export interface NgTableEventsChannel { * @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event * @return a unregistration function that when called will unregister the `listener` */ - onDatasetChanged(listener: IDatasetChangedListener, scope: IScope, eventFilter?: EventSelector): IUnregistrationFunc; + onDatasetChanged(listener: DatasetChangedListener, scope: IScope, eventFilter?: EventSelector): UnregistrationFunc; /** * Subscribe to receive notification whenever a new data rows *array* is supplied as a `settings` value to a `NgTableParams` instance. * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. @@ -141,7 +141,7 @@ export interface NgTableEventsChannel { * @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event * @return a unregistration function that when called will unregister the `listener` */ - onDatasetChanged(listener: IDatasetChangedListener, eventFilter?: EventSelector): IUnregistrationFunc; + onDatasetChanged(listener: DatasetChangedListener, eventFilter?: EventSelector): UnregistrationFunc; /** * Subscribe to receive notification whenever the paging buttons for an `NgTableParams` instance change @@ -153,7 +153,7 @@ export interface NgTableEventsChannel { * @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event * @return a unregistration function that when called will unregister the `listener` */ - onPagesChanged(listener: IPagesChangedListener, scope: IScope, eventFilter?: EventSelector): IUnregistrationFunc; + onPagesChanged(listener: PagesChangedListener, scope: IScope, eventFilter?: EventSelector): UnregistrationFunc; /** * Subscribe to receive notification whenever the paging buttons for an `NgTableParams` instance change * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. @@ -162,51 +162,51 @@ export interface NgTableEventsChannel { * @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event * @return a unregistration function that when called will unregister the `listener` */ - onPagesChanged(listener: IPagesChangedListener, eventFilter?: EventSelector): IUnregistrationFunc; + onPagesChanged(listener: PagesChangedListener, eventFilter?: EventSelector): UnregistrationFunc; /** * Subscribe to receive notification whenever a `ngTableDefaultGetData` instance filters data * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. * * @param listener the function that will be called when the event fires * @param scope the angular `$scope` that will limit the lifetime of the event subscription - * @param eventFilter either the specific `IDefaultGetData` instance you want to receive events for or a predicate function that should return true to receive the event + * @param eventFilter either the specific `DefaultGetData` instance you want to receive events for or a predicate function that should return true to receive the event * @return a unregistration function that when called will unregister the `listener` */ - onAfterDataFiltered(listener: IAfterDataFilteredListener, scope: IScope, eventFilter?: EventSelector ): IUnregistrationFunc; + onAfterDataFiltered(listener: AfterDataFilteredListener, scope: IScope, eventFilter?: EventSelector ): UnregistrationFunc; /** * Subscribe to receive notification whenever a `ngTableDefaultGetData` instance filters data * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. * * @param listener the function that will be called when the event fires - * @param eventFilter either the specific `IDefaultGetData` instance you want to receive events for or a predicate function that should return true to receive the event + * @param eventFilter either the specific `DefaultGetData` instance you want to receive events for or a predicate function that should return true to receive the event * @return a unregistration function that when called will unregister the `listener` */ - onAfterDataFiltered(listener: IAfterDataFilteredListener, eventFilter?: EventSelector ): IUnregistrationFunc; + onAfterDataFiltered(listener: AfterDataFilteredListener, eventFilter?: EventSelector ): UnregistrationFunc; /** * Subscribe to receive notification whenever a `ngTableDefaultGetData` instance orders data * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. * * @param listener the function that will be called when the event fires * @param scope the angular `$scope` that will limit the lifetime of the event subscription - * @param eventFilter either the specific `IDefaultGetData` instance you want to receive events for or a predicate function that should return true to receive the event + * @param eventFilter either the specific `DefaultGetData` instance you want to receive events for or a predicate function that should return true to receive the event * @return a unregistration function that when called will unregister the `listener` */ - onAfterDataSorted(listener: IAfterDataSortedListener, scope: IScope, eventFilter?: EventSelector ): IUnregistrationFunc; + onAfterDataSorted(listener: AfterDataSortedListener, scope: IScope, eventFilter?: EventSelector ): UnregistrationFunc; /** * Subscribe to receive notification whenever a `ngTableDefaultGetData` instance orders data * Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. * * @param listener the function that will be called when the event fires - * @param eventFilter either the specific `IDefaultGetData` instance you want to receive events for or a predicate function that should return true to receive the event + * @param eventFilter either the specific `DefaultGetData` instance you want to receive events for or a predicate function that should return true to receive the event * @return a unregistration function that when called will unregister the `listener` */ - onAfterDataSorted(listener: IAfterDataSortedListener, eventFilter?: EventSelector ): IUnregistrationFunc; + onAfterDataSorted(listener: AfterDataSortedListener, eventFilter?: EventSelector ): UnregistrationFunc; publishAfterCreated(publisher: NgTableParams): void; publishAfterReloadData(publisher: NgTableParams, newData: T[], oldData: T[]): void; publishDatasetChanged(publisher: NgTableParams, newDataset: T[], oldDataset: T[]): void; - publishPagesChanged(publisher: NgTableParams, newPages: IPageButton[], oldPages: IPageButton[]): void; + publishPagesChanged(publisher: NgTableParams, newPages: PageButton[], oldPages: PageButton[]): void; publishAfterDataFiltered(publisher: NgTableParams, newData: T[]): void; publishAfterDataSorted(params: NgTableParams, newData: T[]): void; } diff --git a/src/core/ngTableParams.ts b/src/core/ngTableParams.ts index 9bafdffd..4aed402b 100644 --- a/src/core/ngTableParams.ts +++ b/src/core/ngTableParams.ts @@ -9,14 +9,14 @@ import * as ng1 from 'angular'; import { ILogService, IPromise, IQService } from 'angular'; import { convertSortToOrderBy, isGroupingFun } from './util'; -import { IDefaults } from './ngTableDefaults' +import { Defaults } from './ngTableDefaults' import { NgTableEventsChannel } from './ngTableEventsChannel' import { NgTableSettings, SettingsPartial, Settings } from './ngTableSettings' -import { DataResult, IDataRowGroup, IGetDataFunc } from './data'; -import { IFilterValues } from './filtering'; -import { IGetGroupFunc, Grouping, IGroupingFunc, GroupSort, IGroupValues } from './grouping'; -import { SortDirection, ISortingValues } from './sorting'; -import { IPageButton } from './paging'; +import { DataResult, DataRowGroup, GetDataFunc } from './data'; +import { FilterValues } from './filtering'; +import { GetGroupFunc, Grouping, GroupingFunc, GroupSort, GroupValues } from './grouping'; +import { SortDirection, SortingValues } from './sorting'; +import { PageButton } from './paging'; /** * @private @@ -29,7 +29,7 @@ export interface InternalTableParams extends NgTableParams { * The runtime values for {@link NgTableParams} that determine the set of data rows and * how they are to be displayed in a table */ -export interface IParamValues { +export interface ParamValues { /** * The index of the "slice" of data rows, starting at 1, to be displayed by the table. */ @@ -41,11 +41,11 @@ export interface IParamValues { /** * The filter that should be applied to restrict the set of data rows */ - filter?: IFilterValues; + filter?: FilterValues; /** * The sort order that should be applied to the data rows. */ - sorting?: ISortingValues; + sorting?: SortingValues; /** * The grouping that should be applied to the data rows */ @@ -64,7 +64,7 @@ function isNumber(n: any) { * @private */ type Memento = { - params: IParamValues; + params: ParamValues; groupSortDirection?: string; }; @@ -82,11 +82,11 @@ export class NgTableParams { private isCommittedDataset = false; isNullInstance: boolean; private initialEvents: Function[] = []; - private ngTableDefaults: IDefaults + private ngTableDefaults: Defaults private ngTableEventsChannel: NgTableEventsChannel; private ngTableSettings: NgTableSettings; private prevParamsMemento: Memento; - private _params: IParamValues = { + private _params: ParamValues = { page: 1, count: 10, filter: {}, @@ -96,7 +96,7 @@ export class NgTableParams { private _settings = this.defaultSettings; private $q: IQService; private $log: ILogService - constructor(baseParameters?: IParamValues | boolean, baseSettings?: SettingsPartial) { + constructor(baseParameters?: ParamValues | boolean, baseSettings?: SettingsPartial) { // the ngTableController "needs" to create a dummy/null instance and it's important to know whether an instance // is one of these @@ -105,7 +105,7 @@ export class NgTableParams { } this.reloadPages = (() => { - let currentPages: IPageButton[]; + let currentPages: PageButton[]; return () => { const oldPages = currentPages; const newPages = this.generatePagesArray(this.page(), this.total(), this.count()); @@ -150,13 +150,13 @@ export class NgTableParams { * @param trim supply true to return the current filter minus any insignificant values * (null, undefined and empty string) */ - filter(trim?: boolean): IFilterValues + filter(trim?: boolean): FilterValues /** * Sets filter values to the `filter` supplied; any existing filter will be removed * Changes to filter will cause `isDataReloadRequired` to return true and the current `page` to be set to 1 */ - filter(filter: IFilterValues): this - filter(filter?: IFilterValues | boolean) { + filter(filter: FilterValues): this + filter(filter?: FilterValues | boolean) { if (filter != null && typeof filter === 'object') { return this.parameters({ 'filter': filter, @@ -164,7 +164,7 @@ export class NgTableParams { }); } else if (filter === true) { const keys = Object.keys(this._params.filter); - const significantFilter: IFilterValues = {}; + const significantFilter: FilterValues = {}; for (let i = 0; i < keys.length; i++) { const filterValue = this._params.filter[keys[i]]; if (filterValue != null && filterValue !== '') { @@ -195,7 +195,7 @@ export class NgTableParams { let maxPage: number, maxPivotPages: number, minPage: number, numPages: number; maxBlocks = maxBlocks && maxBlocks < 6 ? 6 : maxBlocks; - const pages: IPageButton[] = []; + const pages: PageButton[] = []; numPages = Math.ceil(totalItems / pageSize); if (numPages > 1) { pages.push({ @@ -252,7 +252,7 @@ export class NgTableParams { * Sets grouping to the `group` supplied; any existing grouping will be removed. * Changes to group will cause `isDataReloadRequired` to return true and the current `page` to be set to 1 */ - group(group: IGroupValues): this + group(group: GroupValues): this /** * Sets grouping to the `field` and `sortDirection` supplied; any existing grouping will be removed * Changes to group will cause `isDataReloadRequired` to return true and the current `page` to be set to 1 @@ -263,13 +263,13 @@ export class NgTableParams { * If `sortDirection` is supplied, this will be assigned to the sortDirection property of `group` * Changes to group will cause `isDataReloadRequired` to return true and the current `page` to be set to 1 */ - group(group: IGroupingFunc | string, sortDirection?: GroupSort): this + group(group: GroupingFunc | string, sortDirection?: GroupSort): this group(group?: Grouping | string, sortDirection?: GroupSort): string | Grouping | this { if (group === undefined) { return this._params.group; } - const newParameters: IParamValues = { + const newParameters: ParamValues = { page: 1 }; if (isGroupingFun(group) && sortDirection !== undefined) { @@ -313,8 +313,8 @@ export class NgTableParams { /** * Returns true when the `group` and when supplied, the `sortDirection` matches an existing group */ - hasGroup(group: string | IGroupingFunc, sortDirection?: string): boolean - hasGroup(group?: string | IGroupingFunc, sortDirection?: string) { + hasGroup(group: string | GroupingFunc, sortDirection?: string): boolean + hasGroup(group?: string | GroupingFunc, sortDirection?: string) { if (group == null) { return isGroupingFun(this._params.group) || Object.keys(this._params.group).length > 0 } @@ -329,7 +329,7 @@ export class NgTableParams { if (sortDirection == null) { return Object.keys(this._params.group).indexOf(group) !== -1; } else { - return (this._params.group as IGroupValues)[group] === sortDirection; + return (this._params.group as GroupValues)[group] === sortDirection; } } } @@ -379,12 +379,12 @@ export class NgTableParams { 'page': page }) : this._params.page; } - parameters(): IParamValues + parameters(): ParamValues /** * Set new parameters */ - parameters(newParameters?: IParamValues | { [name: string]: string }, parseParamsFromUrl?: boolean): this - parameters(newParameters?: IParamValues | { [name: string]: string }, parseParamsFromUrl?: boolean): IParamValues | this { + parameters(newParameters?: ParamValues | { [name: string]: string }, parseParamsFromUrl?: boolean): this + parameters(newParameters?: ParamValues | { [name: string]: string }, parseParamsFromUrl?: boolean): ParamValues | this { parseParamsFromUrl = parseParamsFromUrl || false; if (typeof newParameters !== undefined) { for (const key in newParameters) { @@ -431,7 +431,7 @@ export class NgTableParams { if (this.hasGroup()) { pData = this.runInterceptorPipeline(this.$q.when(this._settings.getGroups(this))); } else { - const fn = this._settings.getData as IGetDataFunc; + const fn = this._settings.getData as GetDataFunc; pData = this.runInterceptorPipeline(this.$q.when(fn(this))); } @@ -500,17 +500,17 @@ export class NgTableParams { * Returns the current sorting used to order the data rows. * Changes to sorting will cause `isDataReloadRequired` to return true */ - sorting(): ISortingValues + sorting(): SortingValues /** * Sets sorting values to the `sorting` supplied; any existing sorting will be removed. * Changes to sorting will cause `isDataReloadRequired` to return true */ - sorting(sorting: ISortingValues): this + sorting(sorting: SortingValues): this /** * Sets sorting to the `field` and `direction` supplied; any existing sorting will be removed */ sorting(field: string, direction: string): this - sorting(sorting?: ISortingValues | string, direction?: SortDirection) { + sorting(sorting?: SortingValues | string, direction?: SortDirection) { if (typeof sorting === 'string') { this.parameters({ 'sorting': { [sorting]: direction } @@ -643,7 +643,7 @@ export class NgTableParams { static init( $q: IQService, $log: ILogService, - ngTableDefaults: IDefaults, + ngTableDefaults: Defaults, ngTableEventsChannel: NgTableEventsChannel, ngTableSettings: NgTableSettings) { ng1.extend(NgTableParams.prototype, { diff --git a/src/core/ngTableSettings.ts b/src/core/ngTableSettings.ts index c951400e..cf8dc66e 100644 --- a/src/core/ngTableSettings.ts +++ b/src/core/ngTableSettings.ts @@ -1,10 +1,10 @@ import * as ng1 from 'angular'; import { assignPartialDeep } from '../shared'; import { IPromise } from 'angular'; -import { IDefaults } from './ngTableDefaults'; -import { IDataRowGroup, DataSettingsPartial, DataSettings, IDefaultGetData, IGetDataFunc, IInterceptor, IInterceptableGetDataFunc } from './data'; -import { IFilterValues, FilterSettingsPartial, FilterSettings } from './filtering'; -import { IGetGroupFunc, GroupSettingsPartial, GroupSettings } from './grouping'; +import { Defaults } from './ngTableDefaults'; +import { DataRowGroup, DataSettingsPartial, DataSettings, DefaultGetData, GetDataFunc, Interceptor, InterceptableGetDataFunc } from './data'; +import { FilterValues, FilterSettingsPartial, FilterSettings } from './filtering'; +import { GetGroupFunc, GroupSettingsPartial, GroupSettings } from './grouping'; import { SortDirection } from './sorting'; import { NgTableParams } from './ngTableParams'; @@ -47,19 +47,19 @@ export class Settings { * Typically you will supply a custom function when you need to execute filtering, paging and sorting * on the server */ - getData: IGetDataFunc | IInterceptableGetDataFunc = (params: NgTableParams) => { + getData: GetDataFunc | InterceptableGetDataFunc = (params: NgTableParams) => { return Settings.ngTableDefaultGetData(params.settings().dataset, params) as T[]; }; /** * The function that will be used group data rows according to the groupings returned by {@link NgTableParams} `group` */ - getGroups: IGetGroupFunc = Settings.ngTableDefaultGetGroups; + getGroups: GetGroupFunc = Settings.ngTableDefaultGetGroups; groupOptions = new GroupSettings(); /** * The collection of interceptors that should apply to the results of a call to * the `getData` function before the data rows are displayed in the table */ - interceptors = new Array>(); + interceptors = new Array>(); /** * Configuration for the template that will display the page size buttons */ @@ -72,10 +72,10 @@ export class Settings { * The html tag that will be used to display the sorting indicator in the table header */ sortingIndicator = 'span' - private static ngTableDefaultGetData: IDefaultGetData; - private static ngTableDefaultGetGroups: IGetGroupFunc; - static init(ngTableDefaultGetData: IDefaultGetData, - ngTableDefaultGetGroups: IGetGroupFunc) { + private static ngTableDefaultGetData: DefaultGetData; + private static ngTableDefaultGetGroups: GetGroupFunc; + static init(ngTableDefaultGetData: DefaultGetData, + ngTableDefaultGetGroups: GetGroupFunc) { Settings.ngTableDefaultGetData = ngTableDefaultGetData; Settings.ngTableDefaultGetGroups = ngTableDefaultGetGroups; } @@ -110,7 +110,7 @@ export class NgTableSettings { static $inject = ['ngTableDefaults']; private defaults = new Settings(); constructor( - private ngTableDefaults: IDefaults) { + private ngTableDefaults: Defaults) { } createDefaults(): Settings { return this.merge(this.defaults, this.ngTableDefaults.settings); diff --git a/src/core/paging/index.ts b/src/core/paging/index.ts index febf97ed..11c82426 100644 --- a/src/core/paging/index.ts +++ b/src/core/paging/index.ts @@ -1,7 +1,7 @@ /** * Definition of the buttons rendered by the data row pager directive */ -export interface IPageButton { +export interface PageButton { type: string; number?: number; active: boolean; diff --git a/src/core/sorting/index.ts b/src/core/sorting/index.ts index bb123dcb..dc53e7b3 100644 --- a/src/core/sorting/index.ts +++ b/src/core/sorting/index.ts @@ -2,6 +2,6 @@ export type SortDirection = 'asc' | 'desc'; /** * Map of the names of fields on a data row and the corrosponding sort direction; - * Set the value of a key to undefined to let value of {@link ISettings} `defaultSort` apply + * Set the value of a key to undefined to let value of {@link Settings} `defaultSort` apply */ -export interface ISortingValues { [name: string]: SortDirection } +export interface SortingValues { [name: string]: SortDirection } diff --git a/src/core/util.ts b/src/core/util.ts index eabaeb13..94913fe6 100644 --- a/src/core/util.ts +++ b/src/core/util.ts @@ -1,10 +1,10 @@ -import { Grouping, IGroupingFunc } from './grouping'; -import { ISortingValues } from './sorting'; +import { Grouping, GroupingFunc } from './grouping'; +import { SortingValues } from './sorting'; /** * @private */ -export function convertSortToOrderBy(sorting: ISortingValues) { +export function convertSortToOrderBy(sorting: SortingValues) { const result: string[] = []; for (let column in sorting) { result.push((sorting[column] === "asc" ? "+" : "-") + column); @@ -15,6 +15,6 @@ export function convertSortToOrderBy(sorting: ISortingValues) { /** * @private */ -export function isGroupingFun(val: string | Grouping): val is IGroupingFunc { +export function isGroupingFun(val: string | Grouping): val is GroupingFunc { return typeof val === 'function' } \ No newline at end of file diff --git a/test/specs/ngTableDefaultGetData.spec.ts b/test/specs/ngTableDefaultGetData.spec.ts index 48ebd606..070e2e65 100644 --- a/test/specs/ngTableDefaultGetData.spec.ts +++ b/test/specs/ngTableDefaultGetData.spec.ts @@ -1,6 +1,6 @@ import * as ng1 from 'angular'; import { - NgTableDefaultGetDataProvider, IDefaultGetData, NgTableParams, + NgTableDefaultGetDataProvider, DefaultGetData, NgTableParams, ngTableCoreModule } from '../../src/core'; @@ -31,13 +31,13 @@ describe('ngTableDefaultGetData', () => { }); describe('service', () => { - let ngTableDefaultGetData: IDefaultGetData, + let ngTableDefaultGetData: DefaultGetData, tableParams: NgTableParams; beforeEach(ng1.mock.module('ngTable-core')); beforeEach(inject(( - _ngTableDefaultGetData_: IDefaultGetData) => { + _ngTableDefaultGetData_: DefaultGetData) => { ngTableDefaultGetData = _ngTableDefaultGetData_; tableParams = new NgTableParams({ count: 10 }, { counts: [10] }); })); @@ -251,7 +251,7 @@ describe('ngTableDefaultGetData', () => { }); describe('service, custom filters', () => { - var ngTableDefaultGetData: IDefaultGetData, + var ngTableDefaultGetData: DefaultGetData, tableParams: NgTableParams; type PersonCriteria = { ages: number[] }; @@ -274,7 +274,7 @@ describe('ngTableDefaultGetData', () => { }); beforeEach(inject(( - _ngTableDefaultGetData_: IDefaultGetData) => { + _ngTableDefaultGetData_: DefaultGetData) => { ngTableDefaultGetData = _ngTableDefaultGetData_; tableParams = new NgTableParams({ count: 10 }, { counts: [10] }); })); diff --git a/test/specs/selectFilterDs.spec.ts b/test/specs/selectFilterDs.spec.ts index 85583062..eb37895f 100644 --- a/test/specs/selectFilterDs.spec.ts +++ b/test/specs/selectFilterDs.spec.ts @@ -1,26 +1,26 @@ import { ICompileService, IScope, ITimeoutService } from 'angular'; import * as ng1 from 'angular'; -import { SelectData, ISelectOption, ngTableBrowserModule } from '../../src/browser'; +import { SelectData, SelectOption, ngTableBrowserModule } from '../../src/browser'; describe('ngTableSelectFilterDs directive', () => { - interface IColumnScope extends IScope { + interface ColumnScope extends IScope { $column?: { data?: SelectData }; - $selectData?: ISelectOption[]; + $selectData?: SelectOption[]; } - interface ITableScope extends IScope { - $new(): IColumnScope; + interface TableScope extends IScope { + $new(): ColumnScope; } - let $scope: IColumnScope, + let $scope: ColumnScope, elem: string, $compile: ICompileService; beforeAll(() => expect(ngTableBrowserModule).toBeDefined()); beforeEach(ng1.mock.module('ngTable-browser')); - beforeEach(inject(($rootScope: ITableScope, _$compile_: ICompileService) => { + beforeEach(inject(($rootScope: TableScope, _$compile_: ICompileService) => { $scope = $rootScope.$new(); $compile = _$compile_; elem = ''; @@ -92,7 +92,7 @@ describe('ngTableSelectFilterDs directive', () => { // allow for the user to select an empty select option thus removing column filter // given - let data: ISelectOption[] = []; + let data: SelectOption[] = []; $scope.$column = { data: data }; @@ -137,7 +137,7 @@ describe('ngTableSelectFilterDs directive', () => { describe('function datasource', () => { - let data: ISelectOption[]; + let data: SelectOption[]; beforeEach(() => { $scope.$column = { data: () => data @@ -229,7 +229,7 @@ describe('ngTableSelectFilterDs directive', () => { }); describe('asyn function datasource', () => { - let data: ISelectOption[]; + let data: SelectOption[]; let $timeout: ITimeoutService; beforeEach(inject((_$timeout_: ITimeoutService) => { $timeout = _$timeout_; diff --git a/test/specs/settings.spec.ts b/test/specs/settings.spec.ts index 8cd185cc..ecfc4ba4 100644 --- a/test/specs/settings.spec.ts +++ b/test/specs/settings.spec.ts @@ -2,7 +2,7 @@ import * as ng1 from 'angular'; import * as _ from 'lodash'; import { areFunctions, areFunctionsEqual } from '../util/jasmine-extensions'; import { - DataSettings, FilterSettings, IGetDataFunc, IGetGroupFunc, + DataSettings, FilterSettings, GetDataFunc, GetGroupFunc, GroupSettings, SettingsPartial, Settings, ngTableCoreModule } from '../../src/core'; import { NgTableSettings } from '../../src/core/ngTableSettings' diff --git a/test/specs/table.spec.ts b/test/specs/table.spec.ts index 17504b40..aeb68413 100644 --- a/test/specs/table.spec.ts +++ b/test/specs/table.spec.ts @@ -1,11 +1,11 @@ import { IAugmentedJQuery, ICompileService, IQService, IPromise, IScope, ITimeoutService } from 'angular'; import * as ng1 from 'angular'; import { ngTableModule } from '../../index'; -import { NgTableParams, IParamValues, SettingsPartial, ISortingValues } from '../../src/core'; -import { IColumnDef, IFilterTemplateDef, IFilterTemplateDefMap, ISelectOption } from '../../src/browser' +import { NgTableParams, ParamValues, SettingsPartial, SortingValues } from '../../src/core'; +import { ColumnDef, FilterTemplateDef, FilterTemplateDefMap, SelectOption } from '../../src/browser' describe('ng-table', () => { - interface IPerson { + interface Person { id?: number; name?: string; age: number; @@ -14,31 +14,31 @@ describe('ng-table', () => { interface INgTableChildScope extends IScope { params: NgTableParams; - $columns: IColumnDef[]; + $columns: ColumnDef[]; } - interface ICustomizedScope extends IScope { + interface CustomizedScope extends IScope { $$childHead: INgTableChildScope; model: { - exportedCols?: IColumnDef[]; + exportedCols?: ColumnDef[]; }; - ageFilter: IFilterTemplateDefMap; - ageExpandedFilter: { [name: string]: IFilterTemplateDef }; + ageFilter: FilterTemplateDefMap; + ageExpandedFilter: { [name: string]: FilterTemplateDef }; ageTitle: string | { (): string }; - captureColumn: ($columnDef: IColumnDef) => any; - getCustomClass($column: IColumnDef): string; - getFilter($column: IColumnDef): IFilterTemplateDefMap; + captureColumn: ($columnDef: ColumnDef) => any; + getCustomClass($column: ColumnDef): string; + getFilter($column: ColumnDef): FilterTemplateDefMap; isAgeVisible: boolean; nameTitle(): string; - money: () => IPromise; + money: () => IPromise; moneyTitle(): string; showAge: boolean; showFilterRow: boolean; showMoney: boolean; showName: boolean; - tableParams: NgTableParams; - usernameFilter: IFilterTemplateDefMap; - usernameExpandedFilter: { [name: string]: IFilterTemplateDef }; + tableParams: NgTableParams; + usernameFilter: FilterTemplateDefMap; + usernameExpandedFilter: { [name: string]: FilterTemplateDef }; } const dataset = [ @@ -64,18 +64,18 @@ describe('ng-table', () => { beforeAll(() => expect(ngTableModule).toBeDefined()); beforeEach(ng1.mock.module('ngTable')); - let scope: ICustomizedScope; + let scope: CustomizedScope; let $compile: ICompileService; beforeEach(inject(($rootScope: IScope, _$compile_: ICompileService) => { - scope = $rootScope.$new(true) as ICustomizedScope; + scope = $rootScope.$new(true) as CustomizedScope; $compile = _$compile_; scope.model = {}; })); - function createNgTableParams(initialParams?: IParamValues, settings?: SettingsPartial): NgTableParams; + function createNgTableParams(initialParams?: ParamValues, settings?: SettingsPartial): NgTableParams; function createNgTableParams(settings?: SettingsPartial): NgTableParams; function createNgTableParams(settings?: any): NgTableParams { - let initialParams: IParamValues; + let initialParams: ParamValues; if (arguments.length === 2) { initialParams = arguments[0]; settings = arguments[1]; @@ -90,8 +90,8 @@ describe('ng-table', () => { return tableParams; } - function createTable(htmlTemplate: string, params?: NgTableParams) { - params = params || createNgTableParams(); + function createTable(htmlTemplate: string, params?: NgTableParams) { + params = params || createNgTableParams(); const tableElm = ng1.element(htmlTemplate); $compile(tableElm)(scope); @@ -347,7 +347,7 @@ describe('ng-table', () => { ` it('should add $column definition to context of sortable expression', () => { - let columnDef: IColumnDef; + let columnDef: ColumnDef; scope.captureColumn = function ($column) { columnDef = $column; return 'age' @@ -365,13 +365,13 @@ describe('ng-table', () => { it('should apply initial sort', () => { - let actualSort: ISortingValues; - let params = createNgTableParams({ + let actualSort: SortingValues; + let params = createNgTableParams({ sorting: { age: 'desc' } }, { getData: function (params) { actualSort = params.sorting(); - let results: IPerson[] = []; + let results: Person[] = []; return results; } }); @@ -435,7 +435,7 @@ describe('ng-table', () => { } it('should use initial NgTableParams constructor value', () => { - const params = createNgTableParams({ page: 2 }, null); + const params = createNgTableParams({ page: 2 }, null); scope.tableParams = params; scope.$digest(); verifyPageWas(2); @@ -443,7 +443,7 @@ describe('ng-table', () => { }); it('should use initial NgTableParams constructor value combined with filter', () => { - const params = createNgTableParams({ page: 2, filter: { age: 5 } }, null); + const params = createNgTableParams({ page: 2, filter: { age: 5 } }, null); scope.tableParams = params; scope.$digest(); verifyPageWas(2); @@ -451,7 +451,7 @@ describe('ng-table', () => { }); it('changing page # should trigger reload of data', () => { - const params = createNgTableParams({ page: 3 }, null); + const params = createNgTableParams({ page: 3 }, null); scope.tableParams = params; scope.$digest(); verifyPageWas(3); @@ -465,7 +465,7 @@ describe('ng-table', () => { describe('filters', () => { - let $capturedColumn: IColumnDef; + let $capturedColumn: ColumnDef; beforeEach(inject(() => { // stash a reference to $column definition so that its available in asserts scope.captureColumn = function ($column) { @@ -476,11 +476,11 @@ describe('ng-table', () => { describe('filter specified as alias', () => { let tableElm: IAugmentedJQuery, - tp: NgTableParams; + tp: NgTableParams; beforeEach(() => { // 'text' is a shortcut alias for the template ng-table/filters/text scope.usernameFilter = { username: 'text' }; - const params = createNgTableParams({ filterOptions: { filterDelay: 10 } }); + const params = createNgTableParams({ filterOptions: { filterDelay: 10 } }); const html = `
@@ -630,7 +630,7 @@ describe('ng-table', () => { describe('dynamic filter', () => { let tableElm: IAugmentedJQuery, - ageFilter: IFilterTemplateDefMap; + ageFilter: FilterTemplateDefMap; beforeEach(() => { ageFilter = { age: 'text' }; @@ -691,7 +691,7 @@ describe('ng-table', () => { describe('filter with placeholder value and alias', () => { let tableElm: IAugmentedJQuery, - tp: NgTableParams; + tp: NgTableParams; beforeEach(() => { const html = `
@@ -736,7 +736,7 @@ describe('ng-table', () => { describe('filter with placeholder value and url', () => { let tableElm: IAugmentedJQuery, - tp: NgTableParams; + tp: NgTableParams; beforeEach(() => { const html = `
@@ -813,7 +813,7 @@ describe('ng-table', () => { describe('$columns', () => { let tableElm: IAugmentedJQuery, - params: NgTableParams; + params: NgTableParams; beforeEach(() => { const html = `
@@ -887,7 +887,7 @@ describe('ng-table', () => { expect(ageCol.show()).toBe(false); expect(scope.isAgeVisible).toBe(false); - const newFilter: IFilterTemplateDefMap = { age: 'select' }; + const newFilter: FilterTemplateDefMap = { age: 'select' }; ageCol.filter.assign(scope.$$childHead, newFilter); expect(ageCol.filter()).toBe(newFilter); expect(scope.ageFilter).toBe(newFilter); @@ -931,7 +931,7 @@ describe('ng-table', () => { expect(ageCol.show()).toBe(false); expect(scope.isAgeVisible).toBe(false); - const newFilter: IFilterTemplateDefMap = { age: 'select' }; + const newFilter: FilterTemplateDefMap = { age: 'select' }; ageCol.filter(newFilter); expect(ageCol.filter()).toBe(newFilter); expect(scope.ageFilter).toBe(newFilter); @@ -968,7 +968,7 @@ describe('ng-table', () => { describe('groups', () => { - let $capturedColumn: IColumnDef; + let $capturedColumn: ColumnDef; beforeEach(inject(() => { // stash a reference to $column definition so that its available in asserts scope.captureColumn = function ($column) { @@ -980,7 +980,7 @@ describe('ng-table', () => { let tableElm: IAugmentedJQuery, thead: HTMLElement, - tp: NgTableParams; + tp: NgTableParams; beforeEach(() => { const html = `
@@ -1136,7 +1136,7 @@ describe('ng-table', () => { })); it('should reload when binding a new tableParams to scope', () => { - const tp = createNgTableParams(); + const tp = createNgTableParams(); scope.tableParams = tp; scope.$digest(); @@ -1160,13 +1160,13 @@ describe('ng-table', () => { }); it('should reload when binding a new tableParams to scope multiple times', () => { - const tp1 = createNgTableParams(); + const tp1 = createNgTableParams(); scope.tableParams = tp1; scope.$digest(); expect((tp1.settings().getData as jasmine.Spy).calls.count()).toBe(1); - const tp2 = createNgTableParams(); + const tp2 = createNgTableParams(); scope.tableParams = tp2; scope.$digest(); @@ -1208,7 +1208,7 @@ describe('ng-table', () => { it('should reload 1 time when initial load fails', inject(function ($q: IQService) { // given - const tp = createNgTableParams({ + const tp = createNgTableParams({ getData: () => { return $q.reject('BANG!'); } @@ -1245,7 +1245,7 @@ describe('ng-table', () => { }); it('changing filter, orderBy, or page and then calling reload should not invoke getData twice', () => { - const tp = createNgTableParams(); + const tp = createNgTableParams(); scope.tableParams = tp; scope.$digest(); (tp.settings().getData as jasmine.Spy).calls.reset(); @@ -1261,7 +1261,7 @@ describe('ng-table', () => { it('change to filter that fails to load should not cause infinite reload loop', inject(function ($q: IQService) { const tp = createNgTableParams({ - getData: function (): IPromise | IPerson[] { + getData: function (): IPromise | Person[] { if ((tp.settings().getData as jasmine.Spy).calls.count() > 1) { return $q.reject('BANG!'); } @@ -1284,7 +1284,7 @@ describe('ng-table', () => { })); it('changing filter, orderBy, or page in a callback to reload should re-invoke getData 1 time only', () => { - const tp = createNgTableParams(); + const tp = createNgTableParams(); scope.tableParams = tp; scope.$digest(); (tp.settings().getData as jasmine.Spy).calls.reset(); @@ -1307,7 +1307,7 @@ describe('ng-table', () => { // todo: refactor the watches in ngTableController to handle this case - const tp = createNgTableParams(); + const tp = createNgTableParams(); scope.tableParams = tp; scope.$digest(); (tp.settings().getData as jasmine.Spy).calls.reset(); @@ -1327,7 +1327,7 @@ describe('ng-table', () => { it('should not reload when filter value is assigned the same value', () => { // given - const tp = createNgTableParams({ filter: { age: 10 } }, {}); + const tp = createNgTableParams({ filter: { age: 10 } }, {}); scope.tableParams = tp; scope.$digest(); (tp.settings().getData as jasmine.Spy).calls.reset(); @@ -1341,7 +1341,7 @@ describe('ng-table', () => { it('should reload when filter value changes', () => { // given - const tp = createNgTableParams({ filter: { age: 10 } }, {}); + const tp = createNgTableParams({ filter: { age: 10 } }, {}); scope.tableParams = tp; scope.$digest(); (tp.settings().getData as jasmine.Spy).calls.reset(); @@ -1359,7 +1359,7 @@ describe('ng-table', () => { { age: 1 }, { age: 2 } ]; - const tp = createNgTableParams(); + const tp = createNgTableParams(); scope.tableParams = tp; scope.$digest(); (tp.settings().getData as jasmine.Spy).calls.reset(); diff --git a/test/specs/tableDynamic.spec.ts b/test/specs/tableDynamic.spec.ts index 9cb824e6..de144728 100644 --- a/test/specs/tableDynamic.spec.ts +++ b/test/specs/tableDynamic.spec.ts @@ -3,37 +3,37 @@ import * as ng1 from 'angular'; import * as _ from 'lodash'; import { ngTableModule } from '../../index'; import { NgTableParams } from '../../src/core'; -import { ColumnFieldContext, IColumnDef, DynamicTableColField, IDynamicTableColDef, IFilterTemplateDefMap, ISelectOption } from '../../src/browser'; +import { ColumnFieldContext, ColumnDef, DynamicTableColField, DynamicTableColDef, FilterTemplateDefMap, SelectOption } from '../../src/browser'; describe('ng-table-dynamic', () => { - interface IPerson { + interface Person { id?: number; name?: string; age: number; money?: number; } - interface INgTableChildScope extends IScope { + interface NgTableChildScope extends IScope { params: NgTableParams; - $columns: IColumnDef[]; + $columns: ColumnDef[]; } - interface IExtendedDynamicTableColDef extends IDynamicTableColDef { + interface ExtendedDynamicTableColDef extends DynamicTableColDef { field: DynamicTableColField } - interface ICustomizedScope extends IScope { - $$childHead: INgTableChildScope; - tableParams: NgTableParams; - cols: IExtendedDynamicTableColDef[]; + interface CustomizedScope extends IScope { + $$childHead: NgTableChildScope; + tableParams: NgTableParams; + cols: ExtendedDynamicTableColDef[]; model: { - exportedCols?: IColumnDef[] + exportedCols?: ColumnDef[] }; } - function createTable(htmlTemplate: string, params?: NgTableParams) { - params = params || new NgTableParams({}); + function createTable(htmlTemplate: string, params?: NgTableParams) { + params = params || new NgTableParams({}); const tableElm = ng1.element(htmlTemplate); $compile(tableElm)(scope); @@ -68,10 +68,10 @@ describe('ng-table-dynamic', () => { beforeAll(() => expect(ngTableModule).toBeDefined()); beforeEach(ng1.mock.module('ngTable')); - let scope: ICustomizedScope; + let scope: CustomizedScope; let $compile: ICompileService; beforeEach(inject(($rootScope: IScope, _$compile_: ICompileService) => { - scope = $rootScope.$new(true) as ICustomizedScope; + scope = $rootScope.$new(true) as CustomizedScope; $compile = _$compile_; scope.model = {}; })); @@ -295,7 +295,7 @@ describe('ng-table-dynamic', () => { })); it('adding new column should update table header', () => { - const newCol: IExtendedDynamicTableColDef = { + const newCol: ExtendedDynamicTableColDef = { 'class': 'moneyadd', field: 'money', filter: { action: 'select' }, @@ -378,7 +378,7 @@ describe('ng-table-dynamic', () => { { field: 'age', title: 'Age', titleAlt: 'Age' }, { field: 'money', title: 'Money', titleAlt: '£' } ]; - const params = new NgTableParams({ + const params = new NgTableParams({ page: 1, // show first page count: 10 // count per page }, { @@ -515,7 +515,7 @@ describe('ng-table-dynamic', () => { expect((select[0] as HTMLSelectElement).options.length).toBeGreaterThan(0); const $column = (select.scope() as ColumnFieldContext).$column; const plucker = _.partialRight(_.pick, ['id', 'title']); - const actual = _.map($column.data as ISelectOption[], plucker); + const actual = _.map($column.data as SelectOption[], plucker); expect(actual).toEqual([{ 'id': '', 'title': '' @@ -534,7 +534,7 @@ describe('ng-table-dynamic', () => { expect((select[0] as HTMLSelectElement).options.length).toBeGreaterThan(0); const $column = (select.scope() as ColumnFieldContext).$column; const plucker = _.partialRight(_.pick, ['id', 'title']); - const actual = _.map($column.data as ISelectOption[], plucker); + const actual = _.map($column.data as SelectOption[], plucker); expect(actual).toEqual([{ 'id': '', 'title': '' @@ -579,11 +579,11 @@ describe('ng-table-dynamic', () => { describe('dynamic filter', () => { - let ageFilter: IFilterTemplateDefMap; + let ageFilter: FilterTemplateDefMap; beforeEach(() => { ageFilter = { age: 'text' }; - function getFilter(paramsScope: ColumnFieldContext): IFilterTemplateDefMap { + function getFilter(paramsScope: ColumnFieldContext): FilterTemplateDefMap { if (paramsScope.$column.title() === 'Name of user') { return { username: 'text' }; } else if (paramsScope.$column.title() === 'Age') { @@ -639,7 +639,7 @@ describe('ng-table-dynamic', () => { describe('$columns', () => { let tableElm: IAugmentedJQuery, - params: NgTableParams; + params: NgTableParams; beforeEach(() => { const html = `
@@ -701,7 +701,7 @@ describe('ng-table-dynamic', () => { expect(ageCol.show()).toBe(false); expect(scope.cols[0].show).toBe(false); - const newFilter: IFilterTemplateDefMap = { age: 'select' }; + const newFilter: FilterTemplateDefMap = { age: 'select' }; ageCol.filter.assign(scope.$$childHead, newFilter); expect(ageCol.filter()).toBe(newFilter); expect(scope.cols[0].filter).toBe(newFilter); @@ -745,7 +745,7 @@ describe('ng-table-dynamic', () => { expect(ageCol.show()).toBe(false); expect(scope.cols[0].show).toBe(false); - const newFilter: IFilterTemplateDefMap = { age: 'select' }; + const newFilter: FilterTemplateDefMap = { age: 'select' }; ageCol.filter(newFilter); expect(ageCol.filter()).toBe(newFilter); expect(scope.cols[0].filter).toBe(newFilter); diff --git a/test/specs/tableParams.spec.ts b/test/specs/tableParams.spec.ts index b0eff08b..c59eca44 100644 --- a/test/specs/tableParams.spec.ts +++ b/test/specs/tableParams.spec.ts @@ -2,18 +2,18 @@ import { IControllerService, IQService, IScope } from 'angular'; import * as ng1 from 'angular'; import * as _ from 'lodash'; import { - IDataRowGroup, DataSettings, IDefaultGetData, IDefaults, NgTableEventsChannel, FilterSettings, - IGroupingFunc, GroupSettings, IGroupValues, InternalTableParams, NgTableParams, IPageButton, IParamValues, SettingsPartial, + DataRowGroup, DataSettings, DefaultGetData, Defaults, NgTableEventsChannel, FilterSettings, + GroupingFunc, GroupSettings, GroupValues, InternalTableParams, NgTableParams, PageButton, ParamValues, SettingsPartial, ngTableCoreModule } from '../../src/core'; describe('NgTableParams', () => { - interface IScopeWithPrivates extends IScope { + interface ScopeWithPrivates extends IScope { $$listenerCount: { [name: string]: number } } let scope: IScope, - $rootScope: IScopeWithPrivates; + $rootScope: ScopeWithPrivates; beforeAll(() => expect(ngTableCoreModule).toBeDefined()); @@ -24,21 +24,21 @@ describe('NgTableParams', () => { createSpy.$inject = ['$delegate']; - function createSpy(ngTableDefaultGetData: IDefaultGetData) { + function createSpy(ngTableDefaultGetData: DefaultGetData) { return jasmine.createSpy('ngTableDefaultGetDataSpy', ngTableDefaultGetData).and.callThrough(); } }); }); - beforeEach(inject(($controller: IControllerService, _$rootScope_: IScopeWithPrivates) => { + beforeEach(inject(($controller: IControllerService, _$rootScope_: ScopeWithPrivates) => { $rootScope = _$rootScope_; scope = $rootScope.$new(); })); - function createNgTableParams(initialParams?: IParamValues, settings?: SettingsPartial): NgTableParams; + function createNgTableParams(initialParams?: ParamValues, settings?: SettingsPartial): NgTableParams; function createNgTableParams(settings?: SettingsPartial): NgTableParams; function createNgTableParams(settings?: any): NgTableParams { - let initialParams: IParamValues; + let initialParams: ParamValues; if (arguments.length === 2) { initialParams = arguments[0]; settings = arguments[1]; @@ -67,14 +67,14 @@ describe('NgTableParams', () => { { type: 'page', number: 2, active: true, current: false }, { type: 'last', number: 3, active: true, current: false }, { type: 'next', number: 2, active: true } - ] as IPageButton[]); + ] as PageButton[]); expect(params.generatePagesArray(2, 30, 10)).toEqual([ { type: 'prev', number: 1, active: true }, { type: 'first', number: 1, active: true, current: false }, { type: 'page', number: 2, active: false, current: true }, { type: 'last', number: 3, active: true, current: false }, { type: 'next', number: 3, active: true } - ] as IPageButton[]); + ] as PageButton[]); expect(params.generatePagesArray(2, 100, 10)).toEqual([ { type: 'prev', number: 1, active: true }, { type: 'first', number: 1, active: true, current: false }, @@ -87,7 +87,7 @@ describe('NgTableParams', () => { { type: 'more', active: false }, { type: 'last', number: 10, active: true, current: false }, { type: 'next', number: 3, active: true } - ] as IPageButton[]); + ] as PageButton[]); }); it('should use own parameter values to generate pages when no arguments supplied', () => { @@ -99,7 +99,7 @@ describe('NgTableParams', () => { { type: 'page', number: 2, active: false, current: true }, { type: 'last', number: 3, active: true, current: false }, { type: 'next', number: 3, active: true } - ] as IPageButton[]); + ] as PageButton[]); }); }); @@ -231,7 +231,7 @@ describe('NgTableParams', () => { expect(params.group()).toEqual(ng1.identity); - const fn: IGroupingFunc = () => ''; + const fn: GroupingFunc = () => ''; fn.sortDirection = 'desc'; params.group(fn); expect(params.hasGroup(fn)).toBe(true); @@ -258,7 +258,7 @@ describe('NgTableParams', () => { groupOptions: { defaultSort: 'desc' } }); - const newGroups = _.extend({}, params.group(), { age: 'desc' }); + const newGroups = _.extend({}, params.group(), { age: 'desc' }); params.group(newGroups); expect(params.hasGroup()).toBe(true); expect(params.hasGroup('role')).toBe(true); @@ -403,12 +403,12 @@ describe('NgTableParams', () => { describe('getGroups', () => { - interface IEmployee { + interface Employee { name: string; role: string; } - let dataset: IEmployee[]; + let dataset: Employee[]; beforeEach(() => { dataset = [ { 'name': 'Hanson', 'role': 'Accounting' }, @@ -431,13 +431,13 @@ describe('NgTableParams', () => { it('should group data then apply paging to groups', () => { const tp = createNgTableParams({ count: 2, group: { role: '' } }, { dataset: dataset }); - let actualRoleGroups: IDataRowGroup[]; - tp.reload>().then(groups => { + let actualRoleGroups: DataRowGroup[]; + tp.reload>().then(groups => { actualRoleGroups = groups; }); $rootScope.$digest(); - const expectedRoleGroups: IDataRowGroup[] = [ + const expectedRoleGroups: DataRowGroup[] = [ { $hideRows: false, value: 'Accounting', @@ -466,8 +466,8 @@ describe('NgTableParams', () => { group: { role: '' } }, { dataset: dataset }); - let actualRoleGroups: IDataRowGroup[]; - tp.reload>().then(groups => { + let actualRoleGroups: DataRowGroup[]; + tp.reload>().then(groups => { actualRoleGroups = groups; }); $rootScope.$digest(); @@ -493,7 +493,7 @@ describe('NgTableParams', () => { }); it('should use group function to group data', () => { - const grouper: IGroupingFunc = (item) => item.name[0]; + const grouper: GroupingFunc = (item) => item.name[0]; grouper.sortDirection = ''; const tp = createNgTableParams({ count: 2, @@ -501,8 +501,8 @@ describe('NgTableParams', () => { group: grouper }, { dataset: dataset }); - let actualRoleGroups: IDataRowGroup[]; - tp.reload>().then(groups => { + let actualRoleGroups: DataRowGroup[]; + tp.reload>().then(groups => { actualRoleGroups = groups; }); $rootScope.$digest(); @@ -538,8 +538,8 @@ describe('NgTableParams', () => { dataset: dataset }); - let actualRoleGroups: IDataRowGroup[]; - tp.reload>().then(groups => { + let actualRoleGroups: DataRowGroup[]; + tp.reload>().then(groups => { actualRoleGroups = groups; }); $rootScope.$digest(); @@ -577,8 +577,8 @@ describe('NgTableParams', () => { } }); - let actualRoleGroups: IDataRowGroup[]; - tp.reload>().then(groups => { + let actualRoleGroups: DataRowGroup[]; + tp.reload>().then(groups => { actualRoleGroups = groups; }); $rootScope.$digest(); @@ -610,7 +610,7 @@ describe('NgTableParams', () => { }); it('should use sortDirection defined on group function to sort groups', () => { - const groupFn: IGroupingFunc = item => item.role; + const groupFn: GroupingFunc = item => item.role; groupFn.sortDirection = 'desc'; const tp = createNgTableParams({ count: 3, @@ -625,8 +625,8 @@ describe('NgTableParams', () => { } }); - let actualRoleGroups: IDataRowGroup[]; - tp.reload>().then(groups => { + let actualRoleGroups: DataRowGroup[]; + tp.reload>().then(groups => { actualRoleGroups = groups; }); $rootScope.$digest(); @@ -660,11 +660,11 @@ describe('NgTableParams', () => { describe('getGroups with nested property', () => { - interface IComplexEmployee { + interface ComplexEmployee { details: { name: string, role: string }; } - let dataset: IComplexEmployee[]; + let dataset: ComplexEmployee[]; beforeEach(() => { dataset = [ { 'details': { 'name': 'Hanson', 'role': 'Accounting' } }, @@ -687,13 +687,13 @@ describe('NgTableParams', () => { it('should group data then apply paging to groups', () => { const tp = createNgTableParams({ count: 2, group: { 'details.role': '' } }, { dataset: dataset }); - let actualRoleGroups: IDataRowGroup[]; - tp.reload>().then(groups => { + let actualRoleGroups: DataRowGroup[]; + tp.reload>().then(groups => { actualRoleGroups = groups; }); $rootScope.$digest(); - let expectedRoleGroups: IDataRowGroup[] = [ + let expectedRoleGroups: DataRowGroup[] = [ { $hideRows: false, value: 'Accounting', @@ -722,13 +722,13 @@ describe('NgTableParams', () => { group: { 'details.role': '' } }, { dataset: dataset }); - let actualRoleGroups: IDataRowGroup[]; - tp.reload>().then(groups => { + let actualRoleGroups: DataRowGroup[]; + tp.reload>().then(groups => { actualRoleGroups = groups; }); $rootScope.$digest(); - let expectedRoleGroups: IDataRowGroup[] = [ + let expectedRoleGroups: DataRowGroup[] = [ { $hideRows: false, value: 'Asset Management', @@ -750,7 +750,7 @@ describe('NgTableParams', () => { }); it('should use group function to group data', () => { - const grouper: IGroupingFunc = item => item.details.name[0]; + const grouper: GroupingFunc = item => item.details.name[0]; grouper.sortDirection = ''; const tp = createNgTableParams({ count: 2, @@ -758,13 +758,13 @@ describe('NgTableParams', () => { group: grouper }, { dataset: dataset }); - let actualRoleGroups: IDataRowGroup[]; - tp.reload>().then(groups => { + let actualRoleGroups: DataRowGroup[]; + tp.reload>().then(groups => { actualRoleGroups = groups; }); $rootScope.$digest(); - let expectedRoleGroups: IDataRowGroup[] = [ + let expectedRoleGroups: DataRowGroup[] = [ { $hideRows: false, value: 'Y', @@ -796,13 +796,13 @@ describe('NgTableParams', () => { dataset: dataset }); - let actualRoleGroups: IDataRowGroup[]; - tp.reload>().then(groups => { + let actualRoleGroups: DataRowGroup[]; + tp.reload>().then(groups => { actualRoleGroups = groups; }); $rootScope.$digest(); - let expectedRoleGroups: IDataRowGroup[] = [ + let expectedRoleGroups: DataRowGroup[] = [ { $hideRows: false, value: 'Accounting', @@ -836,13 +836,13 @@ describe('NgTableParams', () => { } }); - let actualRoleGroups: IDataRowGroup[]; - tp.reload>().then(groups => { + let actualRoleGroups: DataRowGroup[]; + tp.reload>().then(groups => { actualRoleGroups = groups; }); $rootScope.$digest(); - let expectedRoleGroups: IDataRowGroup[] = [ + let expectedRoleGroups: DataRowGroup[] = [ { $hideRows: false, value: 'Payroll', @@ -870,7 +870,7 @@ describe('NgTableParams', () => { }); it('should use sortDirection defined on group function to sort groups', () => { - const groupFn: IGroupingFunc = item => item.details.role; + const groupFn: GroupingFunc = item => item.details.role; groupFn.sortDirection = 'desc'; const tp = createNgTableParams({ count: 3, @@ -885,13 +885,13 @@ describe('NgTableParams', () => { } }); - let actualRoleGroups: IDataRowGroup[]; - tp.reload>().then(groups => { + let actualRoleGroups: DataRowGroup[]; + tp.reload>().then(groups => { actualRoleGroups = groups; }); $rootScope.$digest(); - let expectedRoleGroups: IDataRowGroup[] = [ + let expectedRoleGroups: DataRowGroup[] = [ { $hideRows: false, value: 'Payroll', @@ -919,7 +919,7 @@ describe('NgTableParams', () => { }); }); - it('ngTableParams test defaults', inject(($q: IQService, ngTableDefaults: IDefaults) => { + it('ngTableParams test defaults', inject(($q: IQService, ngTableDefaults: Defaults) => { ngTableDefaults.params.count = 2; ngTableDefaults.settings.counts = []; let tp = new NgTableParams({}); @@ -1051,7 +1051,7 @@ describe('NgTableParams', () => { // when, then... - const grouper: IGroupingFunc = () => ''; + const grouper: GroupingFunc = () => ''; tp.group(grouper); expect(tp.isDataReloadRequired()).toBe(true); @@ -1397,14 +1397,14 @@ describe('NgTableParams', () => { }); it('should be able to modify reason returned by getData', inject(($q: IQService) => { - interface IResponseError { + interface ResponseError { description: string; code?: number; } // given const interceptor = { - responseError: (reason: IResponseError/*, params*/) => { + responseError: (reason: ResponseError/*, params*/) => { reason.code = 400; return $q.reject(reason); } @@ -1415,7 +1415,7 @@ describe('NgTableParams', () => { }); // when - let actualReason: IResponseError; + let actualReason: ResponseError; tp.reload().catch(reason => { actualReason = reason; });