Skip to content

Commit

Permalink
refactor(grid): Remove all deprecated code and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghislain Beaulac authored and Ghislain Beaulac committed May 22, 2018
1 parent 4d170cb commit 47dbdcb
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 30 deletions.
Expand Up @@ -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);
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
Expand Up @@ -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`);
}
Expand Down Expand Up @@ -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`);
}
Expand Down
3 changes: 0 additions & 3 deletions src/app/modules/angular-slickgrid/filters/selectFilter.ts
Expand Up @@ -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';
Expand Down
Expand Up @@ -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;
}
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;

Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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`);
}
Expand Down
Expand Up @@ -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`);
}
Expand Down
Expand Up @@ -246,7 +246,7 @@ export class GraphqlService implements BackendService {
*/
onFilterChanged(event: Event, args: FilterChangedArgs): Promise<string> {
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');
Expand Down
Expand Up @@ -121,7 +121,7 @@ export class GridOdataService implements BackendService {
*/
onFilterChanged(event: Event, args: FilterChangedArgs): Promise<string> {
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');
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/angular-slickgrid/services/sort.service.ts
Expand Up @@ -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`);
Expand Down

0 comments on commit 47dbdcb

Please sign in to comment.