Skip to content

Commit

Permalink
feat(services): add registerServices in Grid Options (#1)
Browse files Browse the repository at this point in the history
* feat(services): add registerServices in Grid Options
- the "registerServices" can accept an array of Services to register, this could be used by the user when he wants to load External Services like ExcelExportService, FileExportService, ...
- also add DataView interface
  • Loading branch information
ghiscoding authored Jun 2, 2020
1 parent 7f3dcdf commit e7c2e91
Show file tree
Hide file tree
Showing 188 changed files with 1,980 additions and 852 deletions.
2 changes: 0 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/array-type": "off",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/consistent-type-assertions": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
Expand All @@ -52,7 +51,6 @@
"SwitchCase": 1
}
],
"@typescript-eslint/interface-name-prefix": "error",
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/member-delimiter-style": "off",
"@typescript-eslint/no-empty-function": "off",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
"jest-junit": "^10.0.0",
"jsdom": "^16.2.2",
"jsdom-global": "^3.0.2",
"lerna": "^3.21.0",
"lerna": "^3.22.0",
"ts-jest": "^26.0.0",
"typescript": "^3.9.2"
"typescript": "^3.9.3"
},
"engines": {
"node": ">=12.13.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Editors } from '../index';
import { AutoCompleteEditor } from '../autoCompleteEditor';
import { KeyCode, FieldType } from '../../enums/index';
import { AutocompleteOption, Column, EditorArgs, EditorArguments, GridOption, } from '../../interfaces/index';
import { AutocompleteOption, Column, DataView, EditorArgs, EditorArguments, GridOption, SlickGrid } from '../../interfaces/index';

const KEY_CHAR_A = 97;
const containerId = 'demo-container';
Expand All @@ -11,7 +11,7 @@ const template = `<div id="${containerId}"></div>`;

const dataViewStub = {
refresh: jest.fn(),
};
} as unknown as DataView;

const gridOptionMock = {
autoCommitEdit: false,
Expand All @@ -28,7 +28,7 @@ const gridStub = {
getEditorLock: () => getEditorLockMock,
getHeaderRowColumn: jest.fn(),
render: jest.fn(),
};
} as unknown as SlickGrid;

describe('AutoCompleteEditor', () => {
let divContainer: HTMLDivElement;
Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/editors/__tests__/checkboxEditor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Editors } from '../index';
import { CheckboxEditor } from '../checkboxEditor';
import { AutocompleteOption, Column, EditorArgs, EditorArguments, GridOption } from '../../interfaces/index';
import { AutocompleteOption, Column, DataView, EditorArgs, EditorArguments, GridOption, SlickGrid } from '../../interfaces/index';

const KEY_CHAR_SPACE = 32;
const containerId = 'demo-container';
Expand All @@ -10,7 +10,7 @@ const template = `<div id="${containerId}"></div>`;

const dataViewStub = {
refresh: jest.fn(),
};
} as unknown as DataView;

const gridOptionMock = {
autoCommitEdit: false,
Expand All @@ -27,7 +27,7 @@ const gridStub = {
getEditorLock: () => getEditorLockMock,
getHeaderRowColumn: jest.fn(),
render: jest.fn(),
};
} as unknown as SlickGrid;

describe('CheckboxEditor', () => {
let divContainer: HTMLDivElement;
Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/editors/__tests__/dateEditor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as moment from 'moment';
import { Editors } from '../index';
import { DateEditor } from '../dateEditor';
import { FieldType } from '../../enums/index';
import { Column, EditorArgs, EditorArguments, GridOption } from '../../interfaces/index';
import { Column, DataView, EditorArgs, EditorArguments, GridOption, SlickGrid } from '../../interfaces/index';
import { TranslateServiceStub } from '../../../../../test/translateServiceStub';

const containerId = 'demo-container';
Expand All @@ -13,7 +13,7 @@ const template = `<div id="${containerId}"></div>`;

const dataViewStub = {
refresh: jest.fn(),
};
} as unknown as DataView;

const gridOptionMock = {
autoCommitEdit: false,
Expand All @@ -33,7 +33,7 @@ const gridStub = {
navigateNext: jest.fn(),
navigatePrev: jest.fn(),
render: jest.fn(),
};
} as unknown as SlickGrid;

describe('DateEditor', () => {
let translateService: TranslateServiceStub;
Expand Down
7 changes: 3 additions & 4 deletions packages/common/src/editors/__tests__/dualInputEditor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { Editors } from '../index';
import { DualInputEditor } from '../dualInputEditor';
import { KeyCode } from '../../enums/index';
import { Column, EditorArgs, EditorArguments, GridOption, ColumnEditorDualInput } from '../../interfaces/index';
import { Column, ColumnEditorDualInput, DataView, EditorArgs, EditorArguments, GridOption, SlickGrid } from '../../interfaces/index';

declare const Slick: any;
const KEY_CHAR_0 = 48;
const KEY_CHAR_A = 97;
const containerId = 'demo-container';

// define a <div> container to simulate the grid container
const template = `<div id="${containerId}"></div>`;

const dataViewStub = {
refresh: jest.fn(),
};
} as unknown as DataView;

const gridOptionMock = {
autoCommitEdit: false,
Expand All @@ -31,7 +30,7 @@ const gridStub = {
getHeaderRowColumn: jest.fn(),
onValidationError: new Slick.Event(),
render: jest.fn(),
};
} as unknown as SlickGrid;

describe('DualInputEditor', () => {
let divContainer: HTMLDivElement;
Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/editors/__tests__/floatEditor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Editors } from '../index';
import { FloatEditor } from '../floatEditor';
import { KeyCode } from '../../enums/index';
import { Column, EditorArgs, EditorArguments, GridOption, } from '../../interfaces/index';
import { Column, DataView, EditorArgs, EditorArguments, GridOption, SlickGrid } from '../../interfaces/index';

const KEY_CHAR_0 = 48;
const containerId = 'demo-container';
Expand All @@ -11,7 +11,7 @@ const template = `<div id="${containerId}"></div>`;

const dataViewStub = {
refresh: jest.fn(),
};
} as unknown as DataView;

const gridOptionMock = {
autoCommitEdit: false,
Expand All @@ -28,7 +28,7 @@ const gridStub = {
getEditorLock: () => getEditorLockMock,
getHeaderRowColumn: jest.fn(),
render: jest.fn(),
};
} as unknown as SlickGrid;

describe('FloatEditor', () => {
let divContainer: HTMLDivElement;
Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/editors/__tests__/integerEditor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Editors } from '../index';
import { IntegerEditor } from '../integerEditor';
import { KeyCode } from '../../enums/index';
import { Column, EditorArgs, EditorArguments, GridOption, } from '../../interfaces/index';
import { Column, DataView, EditorArgs, EditorArguments, GridOption, SlickGrid } from '../../interfaces/index';

const KEY_CHAR_0 = 48;
const containerId = 'demo-container';
Expand All @@ -11,7 +11,7 @@ const template = `<div id="${containerId}"></div>`;

const dataViewStub = {
refresh: jest.fn(),
};
} as unknown as DataView;

const gridOptionMock = {
autoCommitEdit: false,
Expand All @@ -28,7 +28,7 @@ const gridStub = {
getEditorLock: () => getEditorLockMock,
getHeaderRowColumn: jest.fn(),
render: jest.fn(),
};
} as unknown as SlickGrid;

describe('IntegerEditor', () => {
let divContainer: HTMLDivElement;
Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/editors/__tests__/longTextEditor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Editors } from '../index';
import { LongTextEditor } from '../longTextEditor';
import { KeyCode } from '../../enums/index';
import { AutocompleteOption, Column, EditorArgs, EditorArguments, GridOption } from '../../interfaces/index';
import { AutocompleteOption, Column, DataView, EditorArgs, EditorArguments, GridOption, SlickGrid } from '../../interfaces/index';
import { TranslateServiceStub } from '../../../../../test/translateServiceStub';

const KEY_CHAR_A = 97;
Expand All @@ -12,7 +12,7 @@ const template = `<div id="${containerId}"></div>`;

const dataViewStub = {
refresh: jest.fn(),
};
} as unknown as DataView;

const gridOptionMock = {
autoCommitEdit: false,
Expand All @@ -32,7 +32,7 @@ const gridStub = {
navigateNext: jest.fn(),
navigatePrev: jest.fn(),
render: jest.fn(),
};
} as unknown as SlickGrid;

describe('LongTextEditor', () => {
let divContainer: HTMLDivElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'multiple-select-adapted';
import { Editors } from '../index';
import { MultipleSelectEditor } from '../multipleSelectEditor';
import { CollectionService } from '../../services/collection.service';
import { Column, EditorArguments, GridOption } from '../../interfaces/index';
import { Column, DataView, EditorArguments, GridOption, SlickGrid } from '../../interfaces/index';
import { TranslateServiceStub } from '../../../../../test/translateServiceStub';

const containerId = 'demo-container';
Expand All @@ -14,7 +14,7 @@ const template = `<div id="${containerId}"></div>`;

const dataViewStub = {
refresh: jest.fn(),
};
} as unknown as DataView;

const gridOptionMock = {
autoCommitEdit: false,
Expand All @@ -34,7 +34,7 @@ const gridStub = {
navigateNext: jest.fn(),
navigatePrev: jest.fn(),
render: jest.fn(),
};
} as unknown as SlickGrid;

describe('MultipleSelectEditor', () => {
let translateService: TranslateServiceStub;
Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/editors/__tests__/selectEditor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Editors } from '../index';
import { SelectEditor } from '../selectEditor';
import { CollectionService } from './../../services/collection.service';
import { FieldType, OperatorType } from '../../enums/index';
import { AutocompleteOption, Column, EditorArgs, EditorArguments, GridOption, } from '../../interfaces/index';
import { AutocompleteOption, Column, DataView, EditorArgs, EditorArguments, GridOption, SlickGrid } from '../../interfaces/index';
import { TranslateServiceStub } from '../../../../../test/translateServiceStub';

const containerId = 'demo-container';
Expand All @@ -15,7 +15,7 @@ const template = `<div id="${containerId}"></div>`;

const dataViewStub = {
refresh: jest.fn(),
};
} as unknown as DataView;

const gridOptionMock = {
autoCommitEdit: false,
Expand All @@ -35,7 +35,7 @@ const gridStub = {
navigateNext: jest.fn(),
navigatePrev: jest.fn(),
render: jest.fn(),
};
} as unknown as SlickGrid;

describe('SelectEditor', () => {
let translateService: TranslateServiceStub;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'multiple-select-adapted';
import { Editors } from '../index';
import { SingleSelectEditor } from '../singleSelectEditor';
import { CollectionService } from '../../services/collection.service';
import { Column, EditorArguments, GridOption } from '../../interfaces/index';
import { Column, DataView, EditorArguments, GridOption, SlickGrid } from '../../interfaces/index';
import { TranslateServiceStub } from '../../../../../test/translateServiceStub';

const containerId = 'demo-container';
Expand All @@ -14,7 +14,7 @@ const template = `<div id="${containerId}"></div>`;

const dataViewStub = {
refresh: jest.fn(),
};
} as unknown as DataView;

const gridOptionMock = {
autoCommitEdit: false,
Expand All @@ -34,7 +34,7 @@ const gridStub = {
navigateNext: jest.fn(),
navigatePrev: jest.fn(),
render: jest.fn(),
};
} as unknown as SlickGrid;

describe('SingleSelectEditor', () => {
let translateService: TranslateServiceStub;
Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/editors/__tests__/sliderEditor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Editors } from '../index';
import { SliderEditor } from '../sliderEditor';
import { Column, EditorArgs, EditorArguments, GridOption } from '../../interfaces/index';
import { Column, DataView, EditorArgs, EditorArguments, GridOption, SlickGrid } from '../../interfaces/index';

const containerId = 'demo-container';

Expand All @@ -9,7 +9,7 @@ const template = `<div id="${containerId}"></div>`;

const dataViewStub = {
refresh: jest.fn(),
};
} as unknown as DataView;

const gridOptionMock = {
autoCommitEdit: false,
Expand All @@ -26,7 +26,7 @@ const gridStub = {
getEditorLock: () => getEditorLockMock,
getHeaderRowColumn: jest.fn(),
render: jest.fn(),
};
} as unknown as SlickGrid;

describe('SliderEditor', () => {
let divContainer: HTMLDivElement;
Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/editors/__tests__/textEditor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Editors } from '../index';
import { TextEditor } from '../textEditor';
import { KeyCode } from '../../enums/index';
import { AutocompleteOption, Column, EditorArgs, EditorArguments, GridOption } from '../../interfaces/index';
import { AutocompleteOption, Column, DataView, EditorArgs, EditorArguments, GridOption, SlickGrid } from '../../interfaces/index';

const KEY_CHAR_A = 97;
const containerId = 'demo-container';
Expand All @@ -11,7 +11,7 @@ const template = `<div id="${containerId}"></div>`;

const dataViewStub = {
refresh: jest.fn(),
};
} as unknown as DataView;

const gridOptionMock = {
autoCommitEdit: false,
Expand All @@ -28,7 +28,7 @@ const gridStub = {
getEditorLock: () => getEditorLockMock,
getHeaderRowColumn: jest.fn(),
render: jest.fn(),
};
} as unknown as SlickGrid;

describe('TextEditor', () => {
let divContainer: HTMLDivElement;
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/editors/autoCompleteEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
EditorArguments,
EditorValidator,
EditorValidatorOutput,
SlickGrid,
} from './../interfaces/index';
import { Constants } from './../constants';
import { findOrDefault, getDescendantProperty, setDeepValue } from '../services/utilities';
import { textValidator } from '../editorValidators/textValidator';

Expand All @@ -34,7 +34,7 @@ export class AutoCompleteEditor implements Editor {
private _$editorElm: any;

/** SlickGrid Grid object */
grid: any;
grid: SlickGrid;

/** The property name for labels in the collection */
labelName: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/editors/checkboxEditor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Constants } from './../constants';
import { Column, ColumnEditor, Editor, EditorArguments, EditorValidator, EditorValidatorOutput } from './../interfaces/index';
import { Column, ColumnEditor, Editor, EditorArguments, EditorValidator, EditorValidatorOutput, SlickGrid } from './../interfaces/index';
import { getDescendantProperty, setDeepValue } from '../services/utilities';

/*
Expand All @@ -11,7 +11,7 @@ export class CheckboxEditor implements Editor {
originalValue: boolean;

/** SlickGrid Grid object */
grid: any;
grid: SlickGrid;

constructor(private args: EditorArguments) {
if (!args) {
Expand Down
Loading

0 comments on commit e7c2e91

Please sign in to comment.