From 47dbdcbe61b5e00d1d7ec3fb22542fb190055feb Mon Sep 17 00:00:00 2001 From: Ghislain Beaulac Date: Tue, 22 May 2018 18:11:35 -0400 Subject: [PATCH] refactor(grid): Remove all deprecated code and functions --- .../components/angular-slickgrid.component.ts | 19 ++++++++----------- .../components/slick-pagination.component.ts | 4 ++-- .../angular-slickgrid/filters/selectFilter.ts | 3 --- .../models/backendServiceOption.interface.ts | 3 --- .../models/gridOption.interface.ts | 7 ++----- .../services/controlAndPlugin.service.ts | 4 ++-- .../services/filter.service.ts | 2 +- .../services/graphql.service.ts | 2 +- .../services/grid-odata.service.ts | 2 +- .../services/sort.service.ts | 2 +- 10 files changed, 18 insertions(+), 30 deletions(-) diff --git a/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts b/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts index 0a66cd6da..a82f7297a 100644 --- a/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts +++ b/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts @@ -217,7 +217,7 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn // attach the Backend Service API callback functions only after the grid is initialized // because the preProcess() and onInit() might get triggered - if (this.gridOptions && (this.gridOptions.backendServiceApi || this.gridOptions.onBackendEventApi)) { + if (this.gridOptions && this.gridOptions.backendServiceApi) { this.attachBackendCallbackFunctions(this.gridOptions); } @@ -242,8 +242,8 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn * For now, this is GraphQL Service only feautre and it will basically refresh the Dataset & Pagination without having the user to create his own PostProcess every time */ createBackendApiInternalPostProcessCallback(gridOptions: GridOption) { - if (gridOptions && (gridOptions.backendServiceApi || gridOptions.onBackendEventApi)) { - const backendApi = gridOptions.backendServiceApi || gridOptions.onBackendEventApi; + if (gridOptions && gridOptions.backendServiceApi) { + const backendApi = gridOptions.backendServiceApi; // internalPostProcess only works with a GraphQL Service, so make sure it is that type if (backendApi && backendApi.service && backendApi.service instanceof GraphqlService) { @@ -273,7 +273,7 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn // attach external sorting (backend) when available or default onSort (dataView) if (gridOptions.enableSorting) { - (gridOptions.backendServiceApi || gridOptions.onBackendEventApi) ? this.sortService.attachBackendOnSort(grid, dataView) : this.sortService.attachLocalOnSort(grid, dataView); + gridOptions.backendServiceApi ? this.sortService.attachBackendOnSort(grid, dataView) : this.sortService.attachLocalOnSort(grid, dataView); } // attach external filter (backend) when available or default onFilter (dataView) @@ -284,15 +284,12 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn if (gridOptions.presets && gridOptions.presets.filters) { this.filterService.populateColumnFilterSearchTerms(grid); } - (gridOptions.backendServiceApi || gridOptions.onBackendEventApi) ? this.filterService.attachBackendOnFilter(grid) : this.filterService.attachLocalOnFilter(grid, this._dataView); + gridOptions.backendServiceApi ? this.filterService.attachBackendOnFilter(grid) : this.filterService.attachLocalOnFilter(grid, this._dataView); } // if user set an onInit Backend, we'll run it right away (and if so, we also need to run preProcess, internalPostProcess & postProcess) - if (gridOptions.backendServiceApi || gridOptions.onBackendEventApi) { - const backendApi = gridOptions.backendServiceApi || gridOptions.onBackendEventApi; - if (gridOptions.onBackendEventApi) { - console.warn(`"onBackendEventApi" has been DEPRECATED, please consider using "backendServiceApi" in the short term since "onBackendEventApi" will be removed in future versions. You can take look at the Angular-Slickgrid Wikis for OData/GraphQL Services implementation`); - } + if (gridOptions.backendServiceApi) { + const backendApi = gridOptions.backendServiceApi; if (backendApi && backendApi.service && backendApi.service.init) { backendApi.service.init(backendApi.options, gridOptions.pagination, this.grid); @@ -328,7 +325,7 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn } attachBackendCallbackFunctions(gridOptions: GridOption) { - const backendApi = gridOptions.backendServiceApi || gridOptions.onBackendEventApi; + const backendApi = gridOptions.backendServiceApi; const serviceOptions: BackendServiceOption = (backendApi && backendApi.service && backendApi.service.options) ? backendApi.service.options : {}; const isExecuteCommandOnInit = (!serviceOptions) ? false : ((serviceOptions && serviceOptions.hasOwnProperty('executeProcessCommandOnInit')) ? serviceOptions['executeProcessCommandOnInit'] : true); diff --git a/src/app/modules/angular-slickgrid/components/slick-pagination.component.ts b/src/app/modules/angular-slickgrid/components/slick-pagination.component.ts index d14a034c8..6ab12c02c 100644 --- a/src/app/modules/angular-slickgrid/components/slick-pagination.component.ts +++ b/src/app/modules/angular-slickgrid/components/slick-pagination.component.ts @@ -112,7 +112,7 @@ export class SlickPaginationComponent implements AfterViewInit, OnDestroy { } refreshPagination(isPageNumberReset: boolean = false) { - const backendApi = this._gridPaginationOptions.backendServiceApi || this._gridPaginationOptions.onBackendEventApi; + const backendApi = this._gridPaginationOptions.backendServiceApi; if (!backendApi || !backendApi.service || !backendApi.process) { throw new Error(`BackendServiceApi requires at least a "process" function and a "service" defined`); } @@ -149,7 +149,7 @@ export class SlickPaginationComponent implements AfterViewInit, OnDestroy { async onPageChanged(event: Event | undefined, pageNumber: number) { this.recalculateFromToIndexes(); - const backendApi = this._gridPaginationOptions.backendServiceApi || this._gridPaginationOptions.onBackendEventApi; + const backendApi = this._gridPaginationOptions.backendServiceApi; if (!backendApi || !backendApi.service || !backendApi.process) { throw new Error(`BackendServiceApi requires at least a "process" function and a "service" defined`); } diff --git a/src/app/modules/angular-slickgrid/filters/selectFilter.ts b/src/app/modules/angular-slickgrid/filters/selectFilter.ts index 4ff6d439d..8879040b9 100644 --- a/src/app/modules/angular-slickgrid/filters/selectFilter.ts +++ b/src/app/modules/angular-slickgrid/filters/selectFilter.ts @@ -74,9 +74,6 @@ export class SelectFilter implements Filter { if (!this.columnDef || !this.columnDef.filter || (!this.columnDef.filter.collection && !this.columnDef.filter.selectOptions)) { throw new Error(`[Angular-SlickGrid] You need to pass a "collection" for the Select Filter to work correctly. Also each option should include a value/label pair (or value/labelKey when using Locale). For example:: { filter: type: FilterType.select, collection: [{ value: true, label: 'True' }, { value: false, label: 'False'}] }`); } - if (!this.columnDef.filter.collection && this.columnDef.filter.selectOptions) { - console.warn(`[Angular-SlickGrid] The Select Filter "selectOptions" property will de deprecated in future version. Please use the new "collection" property which is more generic and can be used with other Filters (not just Select).`); - } const optionCollection = this.columnDef.filter.collection || this.columnDef.filter.selectOptions || []; const labelName = (this.columnDef.filter.customStructure) ? this.columnDef.filter.customStructure.label : 'label'; diff --git a/src/app/modules/angular-slickgrid/models/backendServiceOption.interface.ts b/src/app/modules/angular-slickgrid/models/backendServiceOption.interface.ts index 7bd18d95e..325d03a64 100644 --- a/src/app/modules/angular-slickgrid/models/backendServiceOption.interface.ts +++ b/src/app/modules/angular-slickgrid/models/backendServiceOption.interface.ts @@ -23,7 +23,4 @@ export interface BackendServiceOption { * users (first: 20, offset: 10, userId: 123) { ... } */ extraQueryArguments?: QueryArgument[]; - - /** Backend Event callbacks that will be used by the Backend Service */ - onBackendEventApi?: BackendEventChanged; } diff --git a/src/app/modules/angular-slickgrid/models/gridOption.interface.ts b/src/app/modules/angular-slickgrid/models/gridOption.interface.ts index 3d680bdbd..05c1df3b7 100644 --- a/src/app/modules/angular-slickgrid/models/gridOption.interface.ts +++ b/src/app/modules/angular-slickgrid/models/gridOption.interface.ts @@ -58,7 +58,7 @@ export interface GridOption { maxToolTipLength: number; }; - /** Backend Service API definition (GraphQL/OData Services), also goes with onBackendEventApi */ + /** Backend Service API definition (GraphQL/OData Services) */ backendServiceApi?: BackendServiceApi; /** CSS class name used to simulate cell flashing */ @@ -187,7 +187,7 @@ export interface GridOption { /** Some default options to set for the export service */ exportOptions?: ExportOption; - /** @deprecated Defaults to false, which leads to all Formatters of the grid being evaluated on export. You can also override a column by changing the propery on the column itself */ + /** Defaults to false, which leads to all Formatters of the grid being evaluated on export. You can also override a column by changing the propery on the column itself */ exportWithFormatter?: boolean; /** Defaults to 25, which is the grid footer row panel height */ @@ -238,9 +238,6 @@ export interface GridOption { /** Defaults to true, which will display numbers indicating column sort precedence are displayed in the columns when multiple columns selected */ numberedMultiColumnSort?: boolean; - /** @deprecated Please use "backendServiceApi" instead */ - onBackendEventApi?: BackendEventChanged; - /** Pagination options, these are currently used ONLY with a Backend Service API (GraphQL/OData Services) */ pagination?: Pagination; diff --git a/src/app/modules/angular-slickgrid/services/controlAndPlugin.service.ts b/src/app/modules/angular-slickgrid/services/controlAndPlugin.service.ts index a84660bf1..25a5522c4 100644 --- a/src/app/modules/angular-slickgrid/services/controlAndPlugin.service.ts +++ b/src/app/modules/angular-slickgrid/services/controlAndPlugin.service.ts @@ -406,7 +406,7 @@ export class ControlAndPluginService { * @return gridMenu */ private addGridMenuCustomCommands(grid: any, options: GridOption) { - const backendApi = options.backendServiceApi || options.onBackendEventApi || null; + const backendApi = options.backendServiceApi || null; if (options.enableFiltering) { // show grid menu: clear all filters @@ -645,7 +645,7 @@ export class ControlAndPluginService { /** Refresh the dataset through the Backend Service */ refreshBackendDataset() { let query; - const backendApi = this._gridOptions.backendServiceApi || this._gridOptions.onBackendEventApi; + const backendApi = this._gridOptions.backendServiceApi; if (!backendApi || !backendApi.service || !backendApi.process) { throw new Error(`BackendServiceApi requires at least a "process" function and a "service" defined`); } diff --git a/src/app/modules/angular-slickgrid/services/filter.service.ts b/src/app/modules/angular-slickgrid/services/filter.service.ts index baefa4808..31383ebb4 100644 --- a/src/app/modules/angular-slickgrid/services/filter.service.ts +++ b/src/app/modules/angular-slickgrid/services/filter.service.ts @@ -75,7 +75,7 @@ export class FilterService { if (!args || !args.grid) { throw new Error('Something went wrong when trying to attach the "attachBackendOnFilterSubscribe(event, args)" function, it seems that "args" is not populated correctly'); } - const backendApi = this._gridOptions.backendServiceApi || this._gridOptions.onBackendEventApi; + const backendApi = this._gridOptions.backendServiceApi; if (!backendApi || !backendApi.process || !backendApi.service) { throw new Error(`BackendServiceApi requires at least a "process" function and a "service" defined`); } diff --git a/src/app/modules/angular-slickgrid/services/graphql.service.ts b/src/app/modules/angular-slickgrid/services/graphql.service.ts index c71dee2b6..a2761159e 100644 --- a/src/app/modules/angular-slickgrid/services/graphql.service.ts +++ b/src/app/modules/angular-slickgrid/services/graphql.service.ts @@ -246,7 +246,7 @@ export class GraphqlService implements BackendService { */ onFilterChanged(event: Event, args: FilterChangedArgs): Promise { const gridOptions: GridOption = this._gridOptions || args.grid.getOptions(); - const backendApi = gridOptions.backendServiceApi || gridOptions.onBackendEventApi; + const backendApi = gridOptions.backendServiceApi; if (backendApi === undefined) { throw new Error('Something went wrong in the GraphqlService, "backendServiceApi" is not initialized'); diff --git a/src/app/modules/angular-slickgrid/services/grid-odata.service.ts b/src/app/modules/angular-slickgrid/services/grid-odata.service.ts index 29f504139..cf055b2c6 100644 --- a/src/app/modules/angular-slickgrid/services/grid-odata.service.ts +++ b/src/app/modules/angular-slickgrid/services/grid-odata.service.ts @@ -121,7 +121,7 @@ export class GridOdataService implements BackendService { */ onFilterChanged(event: Event, args: FilterChangedArgs): Promise { const serviceOptions: GridOption = args.grid.getOptions(); - const backendApi = serviceOptions.backendServiceApi || serviceOptions.onBackendEventApi; + const backendApi = serviceOptions.backendServiceApi; if (backendApi === undefined) { throw new Error('Something went wrong in the GridOdataService, "backendServiceApi" is not initialized'); diff --git a/src/app/modules/angular-slickgrid/services/sort.service.ts b/src/app/modules/angular-slickgrid/services/sort.service.ts index f16cd38e0..f1834332a 100644 --- a/src/app/modules/angular-slickgrid/services/sort.service.ts +++ b/src/app/modules/angular-slickgrid/services/sort.service.ts @@ -57,7 +57,7 @@ export class SortService { throw new Error('Something went wrong when trying to attach the "onBackendSortChanged(event, args)" function, it seems that "args" is not populated correctly'); } const gridOptions: GridOption = args.grid.getOptions() || {}; - const backendApi = gridOptions.backendServiceApi || gridOptions.onBackendEventApi; + const backendApi = gridOptions.backendServiceApi; if (!backendApi || !backendApi.process || !backendApi.service) { throw new Error(`BackendServiceApi requires at least a "process" function and a "service" defined`);