Skip to content

Commit

Permalink
feat(editors): change all private keyword to protected for extensabil…
Browse files Browse the repository at this point in the history
…ity (#247)

- also changed all services to readonly
  • Loading branch information
ghiscoding committed Jan 27, 2021
1 parent 6f7ccd8 commit 089b6cb
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 100 deletions.
18 changes: 9 additions & 9 deletions packages/common/src/editors/autoCompleteEditor.ts
Expand Up @@ -36,14 +36,14 @@ declare const Slick: SlickNamespace;
* KeyDown events are also handled to provide handling for Tab, Shift-Tab, Esc and Ctrl-Enter.
*/
export class AutoCompleteEditor implements Editor {
private _autoCompleteOptions: AutocompleteOption;
private _currentValue: any;
private _defaultTextValue: string;
private _elementCollection: any[] | null;
private _lastInputKeyEvent: JQuery.Event;
protected _autoCompleteOptions: AutocompleteOption;
protected _currentValue: any;
protected _defaultTextValue: string;
protected _elementCollection: any[] | null;
protected _lastInputKeyEvent: JQuery.Event;

/** The JQuery DOM element */
private _$editorElm: any;
protected _$editorElm: any;

/** is the Editor disabled? */
disabled = false;
Expand All @@ -68,7 +68,7 @@ export class AutoCompleteEditor implements Editor {
/** Final collection displayed in the UI, that is after processing filter/sort/override */
finalCollection: any[] = [];

constructor(private args: EditorArguments) {
constructor(protected readonly args: EditorArguments) {
if (!args) {
throw new Error('[Slickgrid-Universal] Something is wrong with this grid, an Editor must always have valid arguments.');
}
Expand Down Expand Up @@ -365,7 +365,7 @@ export class AutoCompleteEditor implements Editor {
}

//
// private functions
// protected functions
// ------------------

/** when it's a Composite Editor, we'll check if the Editor is editable (by checking onBeforeEditCell) and if not Editable we'll disable the Editor */
Expand Down Expand Up @@ -399,7 +399,7 @@ export class AutoCompleteEditor implements Editor {
);
}

// this function should be PRIVATE but for unit tests purposes we'll make it public until a better solution is found
// this function should be protected but for unit tests purposes we'll make it public until a better solution is found
// a better solution would be to get the autocomplete DOM element to work with selection but I couldn't find how to do that in Jest
onSelect(event: Event, ui: { item: any; }) {
if (ui && ui.item) {
Expand Down
16 changes: 8 additions & 8 deletions packages/common/src/editors/checkboxEditor.ts
Expand Up @@ -11,10 +11,10 @@ declare const Slick: SlickNamespace;
* KeyDown events are also handled to provide handling for Tab, Shift-Tab, Esc and Ctrl-Enter.
*/
export class CheckboxEditor implements Editor {
private _bindEventService: BindingEventService;
private _input: HTMLInputElement | null;
private _checkboxContainerElm: HTMLDivElement;
private _originalValue?: boolean | string;
protected _bindEventService: BindingEventService;
protected _input: HTMLInputElement | null;
protected _checkboxContainerElm: HTMLDivElement;
protected _originalValue?: boolean | string;

/** is the Editor disabled? */
disabled = false;
Expand All @@ -25,7 +25,7 @@ export class CheckboxEditor implements Editor {
/** Grid options */
gridOptions: GridOption;

constructor(private args: EditorArguments) {
constructor(protected readonly args: EditorArguments) {
if (!args) {
throw new Error('[Slickgrid-Universal] Something is wrong with this grid, an Editor must always have valid arguments.');
}
Expand Down Expand Up @@ -246,17 +246,17 @@ export class CheckboxEditor implements Editor {
}

// --
// private functions
// protected functions
// ------------------

/** when it's a Composite Editor, we'll check if the Editor is editable (by checking onBeforeEditCell) and if not Editable we'll disable the Editor */
private applyInputUsabilityState() {
protected applyInputUsabilityState() {
const activeCell = this.grid.getActiveCell();
const isCellEditable = this.grid.onBeforeEditCell.notify({ ...activeCell, item: this.args.item, column: this.args.column, grid: this.grid });
this.disable(isCellEditable === false);
}

private handleChangeOnCompositeEditor(event: Event | null, compositeEditorOptions: CompositeEditorOption, triggeredBy: 'user' | 'system' = 'user') {
protected handleChangeOnCompositeEditor(event: Event | null, compositeEditorOptions: CompositeEditorOption, triggeredBy: 'user' | 'system' = 'user') {
const activeCell = this.grid.getActiveCell();
const column = this.args.column;
const columnId = this.columnDef?.id ?? '';
Expand Down
24 changes: 12 additions & 12 deletions packages/common/src/editors/dateEditor.ts
Expand Up @@ -31,13 +31,13 @@ declare const Slick: SlickNamespace;
* https://chmln.github.io/flatpickr
*/
export class DateEditor implements Editor {
private _$inputWithData: any;
private _$input: any;
private _$editorInputElm: any;
private _$closeButtonGroupElm: any;
private _lastTriggeredByClearDate = false;
private _originalDate: string;
private _pickerMergedOptions: FlatpickrOption;
protected _$inputWithData: any;
protected _$input: any;
protected _$editorInputElm: any;
protected _$closeButtonGroupElm: any;
protected _lastTriggeredByClearDate = false;
protected _originalDate: string;
protected _pickerMergedOptions: FlatpickrOption;

flatInstance: FlatpickrInstance;
defaultDate: string;
Expand All @@ -54,7 +54,7 @@ export class DateEditor implements Editor {
/** The translate library */
protected _translaterService: TranslaterService;

constructor(private args: EditorArguments) {
constructor(protected readonly args: EditorArguments) {
if (!args) {
throw new Error('[Slickgrid-Universal] Something is wrong with this grid, an Editor must always have valid arguments.');
}
Expand Down Expand Up @@ -378,17 +378,17 @@ export class DateEditor implements Editor {
}

//
// private functions
// protected functions
// ------------------

/** when it's a Composite Editor, we'll check if the Editor is editable (by checking onBeforeEditCell) and if not Editable we'll disable the Editor */
private applyInputUsabilityState() {
protected applyInputUsabilityState() {
const activeCell = this.grid.getActiveCell();
const isCellEditable = this.grid.onBeforeEditCell.notify({ ...activeCell, item: this.args.item, column: this.args.column, grid: this.grid });
this.disable(isCellEditable === false);
}

private handleOnDateChange() {
protected handleOnDateChange() {
if (this.args) {
const compositeEditorOptions = this.args.compositeEditorOptions;
if (compositeEditorOptions) {
Expand All @@ -400,7 +400,7 @@ export class DateEditor implements Editor {
setTimeout(() => this._lastTriggeredByClearDate = false); // reset flag after a cycle
}

private handleChangeOnCompositeEditor(compositeEditorOptions: CompositeEditorOption, triggeredBy: 'user' | 'system' = 'user') {
protected handleChangeOnCompositeEditor(compositeEditorOptions: CompositeEditorOption, triggeredBy: 'user' | 'system' = 'user') {
const activeCell = this.grid.getActiveCell();
const column = this.args.column;
const columnId = this.columnDef?.id ?? '';
Expand Down
30 changes: 15 additions & 15 deletions packages/common/src/editors/dualInputEditor.ts
Expand Up @@ -27,17 +27,17 @@ declare const Slick: SlickNamespace;
* KeyDown events are also handled to provide handling for Tab, Shift-Tab, Esc and Ctrl-Enter.
*/
export class DualInputEditor implements Editor {
private _bindEventService: BindingEventService;
private _eventHandler: SlickEventHandler;
private _isValueSaveCalled = false;
private _lastEventType: string | undefined;
private _lastInputKeyEvent: KeyboardEvent;
private _leftInput: HTMLInputElement;
private _rightInput: HTMLInputElement;
private _leftFieldName: string;
private _rightFieldName: string;
private _originalLeftValue: string | number;
private _originalRightValue: string | number;
protected _bindEventService: BindingEventService;
protected _eventHandler: SlickEventHandler;
protected _isValueSaveCalled = false;
protected _lastEventType: string | undefined;
protected _lastInputKeyEvent: KeyboardEvent;
protected _leftInput: HTMLInputElement;
protected _rightInput: HTMLInputElement;
protected _leftFieldName: string;
protected _rightFieldName: string;
protected _originalLeftValue: string | number;
protected _originalRightValue: string | number;

/** is the Editor disabled? */
disabled = false;
Expand All @@ -48,7 +48,7 @@ export class DualInputEditor implements Editor {
/** Grid options */
gridOptions: GridOption;

constructor(private args: EditorArguments) {
constructor(protected readonly args: EditorArguments) {
if (!args) {
throw new Error('[Slickgrid-Universal] Something is wrong with this grid, an Editor must always have valid arguments.');
}
Expand Down Expand Up @@ -463,13 +463,13 @@ export class DualInputEditor implements Editor {
}

/** when it's a Composite Editor, we'll check if the Editor is editable (by checking onBeforeEditCell) and if not Editable we'll disable the Editor */
private applyInputUsabilityState() {
protected applyInputUsabilityState() {
const activeCell = this.grid.getActiveCell();
const isCellEditable = this.grid.onBeforeEditCell.notify({ ...activeCell, item: this.args.item, column: this.args.column, grid: this.grid });
this.disable(isCellEditable === false);
}

private handleChangeOnCompositeEditor(event: Event | null, compositeEditorOptions: CompositeEditorOption, triggeredBy: 'user' | 'system' = 'user') {
protected handleChangeOnCompositeEditor(event: Event | null, compositeEditorOptions: CompositeEditorOption, triggeredBy: 'user' | 'system' = 'user') {
const activeCell = this.grid.getActiveCell();
const column = this.args.column;
const leftInputId = this.columnEditor.params?.leftInput?.field ?? '';
Expand Down Expand Up @@ -499,7 +499,7 @@ export class DualInputEditor implements Editor {
);
}

private handleChangeOnCompositeEditorDebounce(event: KeyboardEvent) {
protected handleChangeOnCompositeEditorDebounce(event: KeyboardEvent) {
const compositeEditorOptions = this.args?.compositeEditorOptions;
if (compositeEditorOptions) {
const typingDelay = this.gridOptions?.editorTypingDebounce ?? 500;
Expand Down
20 changes: 10 additions & 10 deletions packages/common/src/editors/floatEditor.ts
Expand Up @@ -14,10 +14,10 @@ declare const Slick: SlickNamespace;
* KeyDown events are also handled to provide handling for Tab, Shift-Tab, Esc and Ctrl-Enter.
*/
export class FloatEditor implements Editor {
private _bindEventService: BindingEventService;
private _input: HTMLInputElement | null;
private _lastInputKeyEvent: KeyboardEvent;
private _originalValue: number | string;
protected _bindEventService: BindingEventService;
protected _input: HTMLInputElement | null;
protected _lastInputKeyEvent: KeyboardEvent;
protected _originalValue: number | string;

/** is the Editor disabled? */
disabled = false;
Expand All @@ -28,7 +28,7 @@ export class FloatEditor implements Editor {
/** Grid options */
gridOptions: GridOption;

constructor(private args: EditorArguments) {
constructor(protected readonly args: EditorArguments) {
if (!args) {
throw new Error('[Slickgrid-Universal] Something is wrong with this grid, an Editor must always have valid arguments.');
}
Expand Down Expand Up @@ -295,17 +295,17 @@ export class FloatEditor implements Editor {
}

// --
// private functions
// protected functions
// ------------------

/** when it's a Composite Editor, we'll check if the Editor is editable (by checking onBeforeEditCell) and if not Editable we'll disable the Editor */
private applyInputUsabilityState() {
protected applyInputUsabilityState() {
const activeCell = this.grid.getActiveCell();
const isCellEditable = this.grid.onBeforeEditCell.notify({ ...activeCell, item: this.args.item, column: this.args.column, grid: this.grid });
this.disable(isCellEditable === false);
}

private handleChangeOnCompositeEditor(event: Event | null, compositeEditorOptions: CompositeEditorOption, triggeredBy: 'user' | 'system' = 'user') {
protected handleChangeOnCompositeEditor(event: Event | null, compositeEditorOptions: CompositeEditorOption, triggeredBy: 'user' | 'system' = 'user') {
const activeCell = this.grid.getActiveCell();
const column = this.args.column;
const columnId = this.columnDef?.id ?? '';
Expand All @@ -330,14 +330,14 @@ export class FloatEditor implements Editor {
}

/** When the input value changes (this will cover the input spinner arrows on the right) */
private handleOnMouseWheel(event: KeyboardEvent) {
protected handleOnMouseWheel(event: KeyboardEvent) {
const compositeEditorOptions = this.args.compositeEditorOptions;
if (compositeEditorOptions) {
this.handleChangeOnCompositeEditor(event, compositeEditorOptions);
}
}

private handleOnInputChange(event: KeyboardEvent) {
protected handleOnInputChange(event: KeyboardEvent) {
const compositeEditorOptions = this.args.compositeEditorOptions;
if (compositeEditorOptions) {
const typingDelay = this.gridOptions?.editorTypingDebounce ?? 500;
Expand Down
20 changes: 10 additions & 10 deletions packages/common/src/editors/integerEditor.ts
Expand Up @@ -12,10 +12,10 @@ declare const Slick: SlickNamespace;
* KeyDown events are also handled to provide handling for Tab, Shift-Tab, Esc and Ctrl-Enter.
*/
export class IntegerEditor implements Editor {
private _bindEventService: BindingEventService;
private _lastInputKeyEvent: KeyboardEvent;
private _input: HTMLInputElement | null;
private _originalValue: number | string;
protected _bindEventService: BindingEventService;
protected _lastInputKeyEvent: KeyboardEvent;
protected _input: HTMLInputElement | null;
protected _originalValue: number | string;

/** is the Editor disabled? */
disabled = false;
Expand All @@ -26,7 +26,7 @@ export class IntegerEditor implements Editor {
/** Grid options */
gridOptions: GridOption;

constructor(private args: EditorArguments) {
constructor(protected readonly args: EditorArguments) {
if (!args) {
throw new Error('[Slickgrid-Universal] Something is wrong with this grid, an Editor must always have valid arguments.');
}
Expand Down Expand Up @@ -257,17 +257,17 @@ export class IntegerEditor implements Editor {
}

// --
// private functions
// protected functions
// ------------------

/** when it's a Composite Editor, we'll check if the Editor is editable (by checking onBeforeEditCell) and if not Editable we'll disable the Editor */
private applyInputUsabilityState() {
protected applyInputUsabilityState() {
const activeCell = this.grid.getActiveCell();
const isCellEditable = this.grid.onBeforeEditCell.notify({ ...activeCell, item: this.args.item, column: this.args.column, grid: this.grid });
this.disable(isCellEditable === false);
}

private handleChangeOnCompositeEditor(event: Event | null, compositeEditorOptions: CompositeEditorOption, triggeredBy: 'user' | 'system' = 'user') {
protected handleChangeOnCompositeEditor(event: Event | null, compositeEditorOptions: CompositeEditorOption, triggeredBy: 'user' | 'system' = 'user') {
const activeCell = this.grid.getActiveCell();
const column = this.args.column;
const columnId = this.columnDef?.id ?? '';
Expand All @@ -292,14 +292,14 @@ export class IntegerEditor implements Editor {
}

/** When the input value changes (this will cover the input spinner arrows on the right) */
private handleOnMouseWheel(event: KeyboardEvent) {
protected handleOnMouseWheel(event: KeyboardEvent) {
const compositeEditorOptions = this.args.compositeEditorOptions;
if (compositeEditorOptions) {
this.handleChangeOnCompositeEditor(event, compositeEditorOptions);
}
}

private handleOnInputChange(event: KeyboardEvent) {
protected handleOnInputChange(event: KeyboardEvent) {
const compositeEditorOptions = this.args.compositeEditorOptions;
if (compositeEditorOptions) {
const typingDelay = this.gridOptions?.editorTypingDebounce ?? 500;
Expand Down

0 comments on commit 089b6cb

Please sign in to comment.