Skip to content

Commit

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

- also changed all services to readonly
  • Loading branch information
ghiscoding authored Jan 27, 2021
1 parent 6ee07b1 commit 52cc702
Show file tree
Hide file tree
Showing 32 changed files with 156 additions and 155 deletions.
2 changes: 1 addition & 1 deletion packages/common/src/extensions/autoTooltipExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ declare const Slick: SlickNamespace;
export class AutoTooltipExtension implements Extension {
private _addon: SlickAutoTooltips | null;

constructor(private sharedService: SharedService) { }
constructor(private readonly sharedService: SharedService) { }

dispose() {
if (this._addon && this._addon.destroy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class CellExternalCopyManagerExtension implements Extension {
private _undoRedoBuffer: EditUndoRedoBuffer;
private _bindingEventService: BindingEventService;

constructor(private extensionUtility: ExtensionUtility, private sharedService: SharedService) {
constructor(private readonly extensionUtility: ExtensionUtility, private readonly sharedService: SharedService) {
this._eventHandler = new Slick.EventHandler() as SlickEventHandler;
this._bindingEventService = new BindingEventService();
}
Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/extensions/cellMenuExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export class CellMenuExtension implements Extension {
private _locales: Locale;

constructor(
private extensionUtility: ExtensionUtility,
private sharedService: SharedService,
private translaterService?: TranslaterService,
private readonly extensionUtility: ExtensionUtility,
private readonly sharedService: SharedService,
private readonly translaterService?: TranslaterService,
) {
this._eventHandler = new Slick.EventHandler();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class CheckboxSelectorExtension implements Extension {
private _addon: SlickCheckboxSelectColumn | null;
private _rowSelectionPlugin: SlickRowSelectionModel;

constructor(private sharedService: SharedService) { }
constructor(private readonly sharedService: SharedService) { }

dispose() {
if (this._addon && this._addon.destroy) {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/extensions/columnPickerExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class ColumnPickerExtension implements Extension {
private _addon: SlickColumnPicker | null;
private _columnPicker: ColumnPicker | null;

constructor(private extensionUtility: ExtensionUtility, private sharedService: SharedService) {
constructor(private readonly extensionUtility: ExtensionUtility, private readonly sharedService: SharedService) {
this._eventHandler = new Slick.EventHandler();
}

Expand Down
8 changes: 4 additions & 4 deletions packages/common/src/extensions/contextMenuExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export class ContextMenuExtension implements Extension {
private _userOriginalContextMenu: ContextMenu | undefined;

constructor(
private extensionUtility: ExtensionUtility,
private sharedService: SharedService,
private treeDataService: TreeDataService,
private translaterService?: TranslaterService,
private readonly extensionUtility: ExtensionUtility,
private readonly sharedService: SharedService,
private readonly treeDataService: TreeDataService,
private readonly translaterService?: TranslaterService,
) {
this._eventHandler = new Slick.EventHandler();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class DraggableGroupingExtension implements Extension {
private _draggableGroupingOptions: DraggableGrouping | null;
private _eventHandler: SlickEventHandler;

constructor(private extensionUtility: ExtensionUtility, private sharedService: SharedService) {
constructor(private readonly extensionUtility: ExtensionUtility, private readonly sharedService: SharedService) {
this._eventHandler = new Slick.EventHandler();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/extensions/extensionUtility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { TranslaterService } from '../services';
import { getTranslationPrefix } from '../services/utilities';

export class ExtensionUtility {
constructor(private sharedService: SharedService, private translaterService?: TranslaterService) { }
constructor(private readonly sharedService: SharedService, private readonly translaterService?: TranslaterService) { }

/**
* From a Grid Menu object property name, we will return the correct title output string following this order
Expand Down
10 changes: 5 additions & 5 deletions packages/common/src/extensions/gridMenuExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export class GridMenuExtension implements Extension {
private _userOriginalGridMenu: GridMenu;

constructor(
private extensionUtility: ExtensionUtility,
private filterService: FilterService,
private sharedService: SharedService,
private sortService: SortService,
private translaterService?: TranslaterService,
private readonly extensionUtility: ExtensionUtility,
private readonly filterService: FilterService,
private readonly sharedService: SharedService,
private readonly sortService: SortService,
private readonly translaterService?: TranslaterService,
) {
this._eventHandler = new Slick.EventHandler();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SharedService } from '../services/shared.service';
export class GroupItemMetaProviderExtension implements Extension {
private _addon: SlickGroupItemMetadataProvider | null;

constructor(private sharedService: SharedService) { }
constructor(private readonly sharedService: SharedService) { }

dispose() {
if (this._addon && this._addon.destroy) {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/extensions/headerButtonExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class HeaderButtonExtension implements Extension {
private _addon: SlickHeaderButtons | null;
private _headerButtonOptions: HeaderButton | null;

constructor(private extensionUtility: ExtensionUtility, private sharedService: SharedService) {
constructor(private readonly extensionUtility: ExtensionUtility, private readonly sharedService: SharedService) {
this._eventHandler = new Slick.EventHandler();
}

Expand Down
12 changes: 6 additions & 6 deletions packages/common/src/extensions/headerMenuExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ export class HeaderMenuExtension implements Extension {
private _eventHandler: SlickEventHandler;

constructor(
private extensionUtility: ExtensionUtility,
private filterService: FilterService,
private pubSubService: PubSubService,
private sharedService: SharedService,
private sortService: SortService,
private translaterService?: TranslaterService,
private readonly extensionUtility: ExtensionUtility,
private readonly filterService: FilterService,
private readonly pubSubService: PubSubService,
private readonly sharedService: SharedService,
private readonly sortService: SortService,
private readonly translaterService?: TranslaterService,
) {
this._eventHandler = new Slick.EventHandler();
}
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/extensions/rowDetailViewExtension.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Column, Extension, GridOption, SlickRowDetailView, SlickRowSelectionModel } from '../interfaces/index';

export class RowDetailViewExtension implements Extension {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/extensions/rowMoveManagerExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class RowMoveManagerExtension implements Extension {
private _eventHandler: SlickEventHandler;
private _rowSelectionPlugin: SlickRowSelectionModel;

constructor(private sharedService: SharedService) {
constructor(private readonly sharedService: SharedService) {
this._eventHandler = new Slick.EventHandler();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/extensions/rowSelectionExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ declare const Slick: SlickNamespace;
export class RowSelectionExtension implements Extension {
private _addon: SlickRowSelectionModel | null;

constructor(private sharedService: SharedService) { }
constructor(private readonly sharedService: SharedService) { }

dispose() {
if (this._addon && this._addon.destroy) {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/filters/autoCompleteFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class AutoCompleteFilter implements Filter {
/**
* Initialize the Filter
*/
constructor(protected translaterService: TranslaterService, protected collectionService: CollectionService) { }
constructor(protected readonly translaterService: TranslaterService, protected readonly collectionService: CollectionService) { }

/** Getter for the Autocomplete Option */
get autoCompleteOptions(): Partial<AutocompleteOption> {
Expand Down
34 changes: 17 additions & 17 deletions packages/common/src/filters/compoundDateFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ import { destroyObjectDomElementProps, getTranslationPrefix, mapFlatpickrDateFor
import { TranslaterService } from '../services/translater.service';

export class CompoundDateFilter implements Filter {
private _clearFilterTriggered = false;
private _currentDate: Date | undefined;
private _flatpickrOptions: FlatpickrOption;
private _shouldTriggerQuery = true;
private $filterElm: any;
private $filterInputElm: any;
private $selectOperatorElm: any;
private _currentValue: string;
private _operator: OperatorType | OperatorString;
protected _clearFilterTriggered = false;
protected _currentDate: Date | undefined;
protected _flatpickrOptions: FlatpickrOption;
protected _shouldTriggerQuery = true;
protected $filterElm: any;
protected $filterInputElm: any;
protected $selectOperatorElm: any;
protected _currentValue: string;
protected _operator: OperatorType | OperatorString;
flatInstance: any;
grid: SlickGrid;
searchTerms: SearchTerm[];
columnDef: Column;
callback: FilterCallback;

constructor(private translaterService: TranslaterService) { }
constructor(protected readonly translaterService: TranslaterService) { }

/** Getter for the Grid Options pulled through the Grid Object */
private get gridOptions(): GridOption {
protected get gridOptions(): GridOption {
return (this.grid && this.grid.getOptions) ? this.grid.getOptions() : {};
}

Expand Down Expand Up @@ -165,10 +165,10 @@ export class CompoundDateFilter implements Filter {
}

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

private buildDatePickerInput(searchTerm?: SearchTerm) {
protected buildDatePickerInput(searchTerm?: SearchTerm) {
const inputFormat = mapFlatpickrDateFormatWithFieldType(this.columnFilter.type || this.columnDef.type || FieldType.dateIso);
const outputFormat = mapFlatpickrDateFormatWithFieldType(this.columnDef.outputType || this.columnFilter.type || this.columnDef.type || FieldType.dateUtc);
const userFilterOptions = (this.columnFilter && this.columnFilter.filterOptions || {}) as FlatpickrOption;
Expand Down Expand Up @@ -229,7 +229,7 @@ export class CompoundDateFilter implements Filter {
return $filterInputElm;
}

private getOptionValues(): { operator: OperatorString, description: string }[] {
protected getOptionValues(): { operator: OperatorString, description: string }[] {
return [
{ operator: '', description: '' },
{ operator: '=', description: this.getOutputText('EQUAL_TO', 'TEXT_EQUAL_TO', 'Equal to') },
Expand All @@ -242,7 +242,7 @@ export class CompoundDateFilter implements Filter {
}

/** Get Locale, Translated or a Default Text if first two aren't detected */
private getOutputText(translationKey: string, localeText: string, defaultText: string): string {
protected getOutputText(translationKey: string, localeText: string, defaultText: string): string {
if (this.gridOptions?.enableTranslate && this.translaterService?.translate) {
const translationPrefix = getTranslationPrefix(this.gridOptions);
return this.translaterService.translate(`${translationPrefix}${translationKey}`);
Expand All @@ -253,7 +253,7 @@ export class CompoundDateFilter implements Filter {
/**
* Create the DOM element
*/
private createDomElement(searchTerm?: SearchTerm) {
protected createDomElement(searchTerm?: SearchTerm) {
const columnId = this.columnDef?.id ?? '';
const $headerElm = this.grid.getHeaderRowColumn(columnId);
$($headerElm).empty();
Expand Down Expand Up @@ -304,7 +304,7 @@ export class CompoundDateFilter implements Filter {
return $filterContainerElm;
}

private onTriggerEvent(e: Event | undefined) {
protected onTriggerEvent(e: Event | undefined) {
if (this._clearFilterTriggered) {
this.callback(e, { columnDef: this.columnDef, clearFilterTriggered: this._clearFilterTriggered, shouldTriggerQuery: this._shouldTriggerQuery });
this.$filterElm.removeClass('filled');
Expand Down
30 changes: 15 additions & 15 deletions packages/common/src/filters/compoundInputFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ import { getTranslationPrefix, mapOperatorToShorthandDesignation } from '../serv
import { TranslaterService } from '../services/translater.service';

export class CompoundInputFilter implements Filter {
private _clearFilterTriggered = false;
private _shouldTriggerQuery = true;
private _inputType = 'text';
private $filterElm: any;
private $filterInputElm: any;
private $selectOperatorElm: any;
private _operator: OperatorType | OperatorString;
protected _clearFilterTriggered = false;
protected _shouldTriggerQuery = true;
protected _inputType = 'text';
protected $filterElm: any;
protected $filterInputElm: any;
protected $selectOperatorElm: any;
protected _operator: OperatorType | OperatorString;
grid: SlickGrid;
searchTerms: SearchTerm[];
columnDef: Column;
callback: FilterCallback;

constructor(protected translaterService: TranslaterService) { }
constructor(protected readonly translaterService: TranslaterService) { }

/** Getter for the Grid Options pulled through the Grid Object */
private get gridOptions(): GridOption {
protected get gridOptions(): GridOption {
return (this.grid && this.grid.getOptions) ? this.grid.getOptions() : {};
}

Expand Down Expand Up @@ -138,10 +138,10 @@ export class CompoundInputFilter implements Filter {
}

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

private buildInputHtmlString() {
protected buildInputHtmlString() {
const columnId = this.columnDef?.id ?? '';
let placeholder = (this.gridOptions) ? (this.gridOptions.defaultFilterPlaceholder || '') : '';
if (this.columnFilter && this.columnFilter.placeholder) {
Expand All @@ -150,7 +150,7 @@ export class CompoundInputFilter implements Filter {
return `<input type="${this._inputType || 'text'}" class="form-control compound-input filter-${columnId}" role="presentation" autocomplete="off" placeholder="${placeholder}" /><span></span>`;
}

private getOptionValues(): { operator: OperatorString, description: string }[] {
protected getOptionValues(): { operator: OperatorString, description: string }[] {
const type = (this.columnDef.type && this.columnDef.type) ? this.columnDef.type : FieldType.string;
let optionValues = [];

Expand Down Expand Up @@ -183,7 +183,7 @@ export class CompoundInputFilter implements Filter {
}

/** Get Locale, Translated or a Default Text if first two aren't detected */
private getOutputText(translationKey: string, localeText: string, defaultText: string): string {
protected getOutputText(translationKey: string, localeText: string, defaultText: string): string {
if (this.gridOptions?.enableTranslate && this.translaterService?.translate) {
const translationPrefix = getTranslationPrefix(this.gridOptions);
return this.translaterService.translate(`${translationPrefix}${translationKey}`);
Expand All @@ -194,7 +194,7 @@ export class CompoundInputFilter implements Filter {
/**
* Create the DOM element
*/
private createDomElement(searchTerm?: SearchTerm) {
protected createDomElement(searchTerm?: SearchTerm) {
const columnId = this.columnDef?.id ?? '';
const $headerElm = this.grid.getHeaderRowColumn(columnId);
$($headerElm).empty();
Expand Down Expand Up @@ -244,7 +244,7 @@ export class CompoundInputFilter implements Filter {
}

/** Event trigger, could be called by the Operator dropdown or the input itself */
private onTriggerEvent(e: KeyboardEvent | undefined) {
protected onTriggerEvent(e: KeyboardEvent | undefined) {
// we'll use the "input" event for everything (keyup, change, mousewheel & spinner)
// with 1 small exception, we need to use the keyup event to handle ENTER key, everything will be processed by the "input" event
if (e && e.type === 'keyup' && e.key !== 'Enter') {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/filters/compoundInputNumberFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CompoundInputFilter } from './compoundInputFilter';

export class CompoundInputNumberFilter extends CompoundInputFilter {
/** Initialize the Filter */
constructor(protected translaterService: TranslaterService) {
constructor(protected readonly translaterService: TranslaterService) {
super(translaterService);
this.inputType = 'number';
}
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/filters/compoundInputPasswordFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CompoundInputFilter } from './compoundInputFilter';

export class CompoundInputPasswordFilter extends CompoundInputFilter {
/** Initialize the Filter */
constructor(protected translaterService: TranslaterService) {
constructor(protected readonly translaterService: TranslaterService) {
super(translaterService);
this.inputType = 'password';
}
Expand Down
Loading

0 comments on commit 52cc702

Please sign in to comment.