Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): refactor code using the container service everywhere #197

Merged
merged 1 commit into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions packages/common/src/services/__tests__/shared.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,6 @@ describe('Shared Service', () => {
expect(service.hideHeaderRowAfterPageLoad).toEqual(true);
});

it('should call "internalPubSubService" GETTER and SETTER expect same value to be returned', () => {
service.internalPubSubService = pubSubServiceStub;
expect(service.internalPubSubService).toEqual(pubSubServiceStub);
});

it('should call "externalRegisteredResources" GETTER and return all columns', () => {
// @ts-ignore:2511
const mockRegisteredResources = [new ExcelExportService()];
Expand Down
5 changes: 3 additions & 2 deletions packages/common/src/services/excelExport.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { ExcelExportOption, SlickGrid } from '../interfaces/index';
import { SharedService } from '../services/shared.service';
import { ContainerService } from '../services/container.service';

export abstract class ExcelExportService {
/** ExcelExportService class name which is use to find service instance in the external registered services */
Expand All @@ -9,8 +9,9 @@ export abstract class ExcelExportService {
/**
* Initialize the Export Service
* @param _grid
* @param _containerService
*/
init(_grid: SlickGrid, _sharedService: SharedService): void {
init(_grid: SlickGrid, _containerService: ContainerService): void {
throw new Error('ExcelExportService the "init" method must be implemented');
}

Expand Down
11 changes: 0 additions & 11 deletions packages/common/src/services/shared.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Column, CurrentPagination, SlickDataView, GridOption, SlickGrid, SlickGroupItemMetadataProvider } from '../interfaces/index';
import { PubSubService } from '..';

export class SharedService {
private _allColumns: Column[];
Expand All @@ -11,7 +10,6 @@ export class SharedService {
private _visibleColumns: Column[];
private _hideHeaderRowAfterPageLoad = false;
private _hierarchicalDataset: any[] | undefined;
private _internalPubSubService: PubSubService;
private _externalRegisteredResources: any[];
private _frozenVisibleColumnId: string | number;

Expand Down Expand Up @@ -97,15 +95,6 @@ export class SharedService {
this._hideHeaderRowAfterPageLoad = hideHeaderRowAfterPageLoad;
}

/** Getter to know if user want to hide header row after 1st page load */
get internalPubSubService(): PubSubService {
return this._internalPubSubService;
}
/** Setter for knowing if user want to hide header row after 1st page load */
set internalPubSubService(internalPubSubService: PubSubService) {
this._internalPubSubService = internalPubSubService;
}

/** Getter to know if user want to hide header row after 1st page load */
get externalRegisteredResources(): any[] {
return this._externalRegisteredResources;
Expand Down
5 changes: 3 additions & 2 deletions packages/common/src/services/textExport.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { TextExportOption, SlickGrid } from '../interfaces/index';
import { SharedService } from './shared.service';
import { ContainerService } from '../services/container.service';

export abstract class TextExportService {
/** ExcelExportService class name which is use to find service instance in the external registered services */
Expand All @@ -9,8 +9,9 @@ export abstract class TextExportService {
/**
* Initialize the Export Service
* @param _grid
* @param _containerService
*/
init(_grid: SlickGrid, _sharedService: SharedService): void {
init(_grid: SlickGrid, _containerService: ContainerService): void {
throw new Error('ExportService the "init" method must be implemented');
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
SlickNamespace,
SlickDataView,
TranslaterService,
SharedService,
} from '@slickgrid-universal/common';

// using external non-typed js libraries
Expand Down Expand Up @@ -82,12 +81,16 @@ export class SlickCompositeEditorComponent {
this._bindEventService = new BindingEventService();
}

init(grid: SlickGrid, _sharedService: SharedService, containerService: ContainerService) {
init(grid: SlickGrid, containerService: ContainerService) {
this.grid = grid;
this.gridService = containerService.get<GridService>('GridService');
this.gridStateService = containerService.get<GridStateService>('GridStateService');
this.translaterService = containerService.get<TranslaterService>('TranslaterService');

if (!this.gridService || !this.gridStateService) {
throw new Error('[Slickgrid-Universal] it seems that the GridService and/or GridStateService are not being loaded properly, make sure the Container Service is properly implemented.');
}

if (this.gridOptions.enableTranslate && (!this.translaterService || !this.translaterService.translate)) {
throw new Error('[Slickgrid-Universal] requires a Translate Service to be installed and configured when the grid option "enableTranslate" is enabled.');
}
Expand Down
Loading