From 52cc7022c4b847566d89e91a80c423373538a15a Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Wed, 27 Jan 2021 15:24:37 -0500 Subject: [PATCH] feat(filters): change all private keyword to protected for extensability (#245) - also changed all services to readonly --- .../src/extensions/autoTooltipExtension.ts | 2 +- .../cellExternalCopyManagerExtension.ts | 2 +- .../src/extensions/cellMenuExtension.ts | 6 +-- .../extensions/checkboxSelectorExtension.ts | 2 +- .../src/extensions/columnPickerExtension.ts | 2 +- .../src/extensions/contextMenuExtension.ts | 8 ++-- .../extensions/draggableGroupingExtension.ts | 2 +- .../common/src/extensions/extensionUtility.ts | 2 +- .../src/extensions/gridMenuExtension.ts | 10 ++--- .../groupItemMetaProviderExtension.ts | 2 +- .../src/extensions/headerButtonExtension.ts | 2 +- .../src/extensions/headerMenuExtension.ts | 12 +++--- .../src/extensions/rowDetailViewExtension.ts | 1 + .../src/extensions/rowMoveManagerExtension.ts | 2 +- .../src/extensions/rowSelectionExtension.ts | 2 +- .../common/src/filters/autoCompleteFilter.ts | 2 +- .../common/src/filters/compoundDateFilter.ts | 34 +++++++-------- .../common/src/filters/compoundInputFilter.ts | 30 ++++++------- .../src/filters/compoundInputNumberFilter.ts | 2 +- .../filters/compoundInputPasswordFilter.ts | 2 +- .../src/filters/compoundSliderFilter.ts | 42 +++++++++---------- .../common/src/filters/dateRangeFilter.ts | 28 ++++++------- packages/common/src/filters/filterFactory.ts | 2 +- .../common/src/filters/inputMaskFilter.ts | 6 +-- .../src/filters/multipleSelectFilter.ts | 2 +- .../common/src/filters/nativeSelectFilter.ts | 16 +++---- packages/common/src/filters/selectFilter.ts | 2 +- .../common/src/filters/singleSelectFilter.ts | 2 +- packages/common/src/filters/sliderFilter.ts | 28 ++++++------- .../common/src/filters/sliderRangeFilter.ts | 22 +++++----- .../common/src/services/extension.service.ts | 32 +++++++------- .../components/slick-pagination.component.ts | 2 +- 32 files changed, 156 insertions(+), 155 deletions(-) diff --git a/packages/common/src/extensions/autoTooltipExtension.ts b/packages/common/src/extensions/autoTooltipExtension.ts index 92235a36e..26dc5fcad 100644 --- a/packages/common/src/extensions/autoTooltipExtension.ts +++ b/packages/common/src/extensions/autoTooltipExtension.ts @@ -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) { diff --git a/packages/common/src/extensions/cellExternalCopyManagerExtension.ts b/packages/common/src/extensions/cellExternalCopyManagerExtension.ts index 7b5ac29fb..b747b5557 100644 --- a/packages/common/src/extensions/cellExternalCopyManagerExtension.ts +++ b/packages/common/src/extensions/cellExternalCopyManagerExtension.ts @@ -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(); } diff --git a/packages/common/src/extensions/cellMenuExtension.ts b/packages/common/src/extensions/cellMenuExtension.ts index 779822193..fc7d1d680 100644 --- a/packages/common/src/extensions/cellMenuExtension.ts +++ b/packages/common/src/extensions/cellMenuExtension.ts @@ -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(); } diff --git a/packages/common/src/extensions/checkboxSelectorExtension.ts b/packages/common/src/extensions/checkboxSelectorExtension.ts index b6139c9ff..7de48cea1 100644 --- a/packages/common/src/extensions/checkboxSelectorExtension.ts +++ b/packages/common/src/extensions/checkboxSelectorExtension.ts @@ -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) { diff --git a/packages/common/src/extensions/columnPickerExtension.ts b/packages/common/src/extensions/columnPickerExtension.ts index 7f8c3960e..c754bc4de 100644 --- a/packages/common/src/extensions/columnPickerExtension.ts +++ b/packages/common/src/extensions/columnPickerExtension.ts @@ -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(); } diff --git a/packages/common/src/extensions/contextMenuExtension.ts b/packages/common/src/extensions/contextMenuExtension.ts index 0eaaacb58..7ce6b8230 100644 --- a/packages/common/src/extensions/contextMenuExtension.ts +++ b/packages/common/src/extensions/contextMenuExtension.ts @@ -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(); } diff --git a/packages/common/src/extensions/draggableGroupingExtension.ts b/packages/common/src/extensions/draggableGroupingExtension.ts index 6c75adb11..dedce124e 100644 --- a/packages/common/src/extensions/draggableGroupingExtension.ts +++ b/packages/common/src/extensions/draggableGroupingExtension.ts @@ -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(); } diff --git a/packages/common/src/extensions/extensionUtility.ts b/packages/common/src/extensions/extensionUtility.ts index 88a4c10a4..3d576e5fe 100644 --- a/packages/common/src/extensions/extensionUtility.ts +++ b/packages/common/src/extensions/extensionUtility.ts @@ -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 diff --git a/packages/common/src/extensions/gridMenuExtension.ts b/packages/common/src/extensions/gridMenuExtension.ts index 852c2faa9..2d760c0ce 100644 --- a/packages/common/src/extensions/gridMenuExtension.ts +++ b/packages/common/src/extensions/gridMenuExtension.ts @@ -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(); } diff --git a/packages/common/src/extensions/groupItemMetaProviderExtension.ts b/packages/common/src/extensions/groupItemMetaProviderExtension.ts index 1c3686cc2..70ffa15ef 100644 --- a/packages/common/src/extensions/groupItemMetaProviderExtension.ts +++ b/packages/common/src/extensions/groupItemMetaProviderExtension.ts @@ -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) { diff --git a/packages/common/src/extensions/headerButtonExtension.ts b/packages/common/src/extensions/headerButtonExtension.ts index 46e4189ed..5cb760963 100644 --- a/packages/common/src/extensions/headerButtonExtension.ts +++ b/packages/common/src/extensions/headerButtonExtension.ts @@ -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(); } diff --git a/packages/common/src/extensions/headerMenuExtension.ts b/packages/common/src/extensions/headerMenuExtension.ts index 2872185ae..6bb5630d3 100644 --- a/packages/common/src/extensions/headerMenuExtension.ts +++ b/packages/common/src/extensions/headerMenuExtension.ts @@ -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(); } diff --git a/packages/common/src/extensions/rowDetailViewExtension.ts b/packages/common/src/extensions/rowDetailViewExtension.ts index 108fc9eac..9f4a1c5c6 100644 --- a/packages/common/src/extensions/rowDetailViewExtension.ts +++ b/packages/common/src/extensions/rowDetailViewExtension.ts @@ -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 { diff --git a/packages/common/src/extensions/rowMoveManagerExtension.ts b/packages/common/src/extensions/rowMoveManagerExtension.ts index ebd3a2638..d43d63131 100644 --- a/packages/common/src/extensions/rowMoveManagerExtension.ts +++ b/packages/common/src/extensions/rowMoveManagerExtension.ts @@ -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(); } diff --git a/packages/common/src/extensions/rowSelectionExtension.ts b/packages/common/src/extensions/rowSelectionExtension.ts index 695bf890b..58c8bb71d 100644 --- a/packages/common/src/extensions/rowSelectionExtension.ts +++ b/packages/common/src/extensions/rowSelectionExtension.ts @@ -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) { diff --git a/packages/common/src/filters/autoCompleteFilter.ts b/packages/common/src/filters/autoCompleteFilter.ts index 178a4185d..7b6dd542a 100644 --- a/packages/common/src/filters/autoCompleteFilter.ts +++ b/packages/common/src/filters/autoCompleteFilter.ts @@ -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 { diff --git a/packages/common/src/filters/compoundDateFilter.ts b/packages/common/src/filters/compoundDateFilter.ts index 7dcfc6493..748d236ef 100644 --- a/packages/common/src/filters/compoundDateFilter.ts +++ b/packages/common/src/filters/compoundDateFilter.ts @@ -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() : {}; } @@ -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; @@ -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') }, @@ -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}`); @@ -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(); @@ -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'); diff --git a/packages/common/src/filters/compoundInputFilter.ts b/packages/common/src/filters/compoundInputFilter.ts index 8bac68331..0b93c4e24 100644 --- a/packages/common/src/filters/compoundInputFilter.ts +++ b/packages/common/src/filters/compoundInputFilter.ts @@ -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() : {}; } @@ -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) { @@ -150,7 +150,7 @@ export class CompoundInputFilter implements Filter { return ``; } - 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 = []; @@ -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}`); @@ -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(); @@ -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') { diff --git a/packages/common/src/filters/compoundInputNumberFilter.ts b/packages/common/src/filters/compoundInputNumberFilter.ts index a176340e6..4de6ae314 100644 --- a/packages/common/src/filters/compoundInputNumberFilter.ts +++ b/packages/common/src/filters/compoundInputNumberFilter.ts @@ -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'; } diff --git a/packages/common/src/filters/compoundInputPasswordFilter.ts b/packages/common/src/filters/compoundInputPasswordFilter.ts index 898f52fc3..516333797 100644 --- a/packages/common/src/filters/compoundInputPasswordFilter.ts +++ b/packages/common/src/filters/compoundInputPasswordFilter.ts @@ -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'; } diff --git a/packages/common/src/filters/compoundSliderFilter.ts b/packages/common/src/filters/compoundSliderFilter.ts index a76131d93..00b1ef06c 100644 --- a/packages/common/src/filters/compoundSliderFilter.ts +++ b/packages/common/src/filters/compoundSliderFilter.ts @@ -19,22 +19,22 @@ const DEFAULT_MAX_VALUE = 100; const DEFAULT_STEP = 1; export class CompoundSliderFilter implements Filter { - private _clearFilterTriggered = false; - private _currentValue: number; - private _shouldTriggerQuery = true; - private _elementRangeInputId = ''; - private _elementRangeOutputId = ''; - private _operator: OperatorType | OperatorString; - private $containerInputGroupElm: any; - private $filterElm: any; - private $filterInputElm: any; - private $selectOperatorElm: any; + protected _clearFilterTriggered = false; + protected _currentValue: number; + protected _shouldTriggerQuery = true; + protected _elementRangeInputId = ''; + protected _elementRangeOutputId = ''; + protected _operator: OperatorType | OperatorString; + protected $containerInputGroupElm: any; + protected $filterElm: any; + protected $filterInputElm: any; + protected $selectOperatorElm: any; grid: SlickGrid; searchTerms: SearchTerm[]; columnDef: Column; callback: FilterCallback; - constructor(private translaterService: TranslaterService) { } + constructor(protected readonly translaterService: TranslaterService) { } /** Getter for the Filter Operator */ get columnFilter(): ColumnFilter { @@ -47,17 +47,17 @@ export class CompoundSliderFilter implements Filter { } /** Getter for the Filter Generic Params */ - private get filterParams(): any { + protected get filterParams(): any { return this.columnDef && this.columnDef.filter && this.columnDef.filter.params || {}; } /** Getter for the `filter` properties */ - private get filterProperties(): ColumnFilter { + protected get filterProperties(): ColumnFilter { return this.columnDef && this.columnDef.filter || {}; } /** 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() : {}; } @@ -181,11 +181,11 @@ export class CompoundSliderFilter implements Filter { } // - // private functions + // protected functions // ------------------ /** Build HTML Template for the input range (slider) */ - private buildTemplateHtmlString() { + protected buildTemplateHtmlString() { const minValue = this.filterProperties.hasOwnProperty('minValue') ? this.filterProperties.minValue : DEFAULT_MIN_VALUE; const maxValue = this.filterProperties.hasOwnProperty('maxValue') ? this.filterProperties.maxValue : DEFAULT_MAX_VALUE; const defaultValue = this.filterParams.hasOwnProperty('sliderStartValue') ? this.filterParams.sliderStartValue : minValue; @@ -197,7 +197,7 @@ export class CompoundSliderFilter implements Filter { } /** Build HTML Template for the text (number) that is shown appended to the slider */ - private buildTemplateSliderTextHtmlString() { + protected buildTemplateSliderTextHtmlString() { const minValue = this.filterProperties.hasOwnProperty('minValue') ? this.filterProperties.minValue : DEFAULT_MIN_VALUE; const defaultValue = this.filterParams.hasOwnProperty('sliderStartValue') ? this.filterParams.sliderStartValue : minValue; @@ -205,7 +205,7 @@ export class CompoundSliderFilter implements Filter { } /** Get the available operator option values */ - 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') }, @@ -218,7 +218,7 @@ export class CompoundSliderFilter 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}`); @@ -229,7 +229,7 @@ export class CompoundSliderFilter implements Filter { /** * Create the DOM element */ - private createDomElement(searchTerm?: SearchTerm) { + protected createDomElement(searchTerm?: SearchTerm) { const columnId = this.columnDef?.id ?? ''; const minValue = (this.filterProperties.hasOwnProperty('minValue') && this.filterProperties.minValue) ? this.filterProperties.minValue : DEFAULT_MIN_VALUE; const startValue = +(this.filterParams.hasOwnProperty('sliderStartValue') ? this.filterParams.sliderStartValue : minValue); @@ -295,7 +295,7 @@ export class CompoundSliderFilter implements Filter { return $filterContainerElm; } - private onTriggerEvent(e: Event | undefined) { + protected onTriggerEvent(e: Event | undefined) { const value = this.$filterInputElm.val(); this._currentValue = +value; diff --git a/packages/common/src/filters/dateRangeFilter.ts b/packages/common/src/filters/dateRangeFilter.ts index 286460013..88ef27973 100644 --- a/packages/common/src/filters/dateRangeFilter.ts +++ b/packages/common/src/filters/dateRangeFilter.ts @@ -25,24 +25,24 @@ import { destroyObjectDomElementProps, mapFlatpickrDateFormatWithFieldType, mapM import { TranslaterService } from '../services/translater.service'; export class DateRangeFilter implements Filter { - private _clearFilterTriggered = false; - private _currentValue: string; - private _currentDates: Date[]; - private _currentDateStrings: string[]; - private _flatpickrOptions: FlatpickrOption; - private _shouldTriggerQuery = true; - private $filterElm: any; - private $filterInputElm: any; + protected _clearFilterTriggered = false; + protected _currentValue: string; + protected _currentDates: Date[]; + protected _currentDateStrings: string[]; + protected _flatpickrOptions: FlatpickrOption; + protected _shouldTriggerQuery = true; + protected $filterElm: any; + protected $filterInputElm: any; 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() : {}; } @@ -165,9 +165,9 @@ export class DateRangeFilter implements Filter { } // - // private functions + // protected functions // ------------------ - private buildDatePickerInput(searchTerms?: SearchTerm | SearchTerm[]) { + protected buildDatePickerInput(searchTerms?: SearchTerm | SearchTerm[]) { const columnId = this.columnDef?.id ?? ''; 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); @@ -246,7 +246,7 @@ export class DateRangeFilter implements Filter { * Create the DOM element * @params searchTerms */ - private createDomElement(searchTerms?: SearchTerm[]) { + protected createDomElement(searchTerms?: SearchTerm[]) { const columnId = this.columnDef?.id ?? ''; const $headerElm = this.grid.getHeaderRowColumn(columnId); $($headerElm).empty(); @@ -278,7 +278,7 @@ export class DateRangeFilter implements Filter { return this.$filterInputElm; } - 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'); diff --git a/packages/common/src/filters/filterFactory.ts b/packages/common/src/filters/filterFactory.ts index 503ed9188..3f528e7eb 100644 --- a/packages/common/src/filters/filterFactory.ts +++ b/packages/common/src/filters/filterFactory.ts @@ -7,7 +7,7 @@ export class FilterFactory { /** The options from the SlickgridConfig */ private _options: any; - constructor(private config: SlickgridConfig, private translaterService?: TranslaterService, private collectionService?: CollectionService) { + constructor(private config: SlickgridConfig, private readonly translaterService?: TranslaterService, private readonly collectionService?: CollectionService) { this._options = this.config?.options ?? {}; } diff --git a/packages/common/src/filters/inputMaskFilter.ts b/packages/common/src/filters/inputMaskFilter.ts index a36909726..4d8e1ccee 100644 --- a/packages/common/src/filters/inputMaskFilter.ts +++ b/packages/common/src/filters/inputMaskFilter.ts @@ -2,7 +2,7 @@ import { InputFilter } from './inputFilter'; import { FilterArguments } from '../interfaces/filterArguments.interface'; export class InputMaskFilter extends InputFilter { - private _inputMask: string; + protected _inputMask: string; /** Initialize the Filter */ constructor() { @@ -86,7 +86,7 @@ export class InputMaskFilter extends InputFilter { } /** From a regular string, we will use the mask to output a new string */ - private maskValue(inputValue: string): string { + protected maskValue(inputValue: string): string { let i = 0; let maskedValue = ''; @@ -107,7 +107,7 @@ export class InputMaskFilter extends InputFilter { } /** From a masked string, we will remove the mask and make a regular string again */ - private unmaskValue(maskedValue: string): string { + protected unmaskValue(maskedValue: string): string { // remove anything else but digits and chars from both the input mask and the input masked value for later comparison // e.g. (000) 000-0000 would return 0000000000 const valueWithoutSymbols = maskedValue.replace(/[^0-9a-z]*/gi, ''); diff --git a/packages/common/src/filters/multipleSelectFilter.ts b/packages/common/src/filters/multipleSelectFilter.ts index 5413c66ef..d13e9ed35 100644 --- a/packages/common/src/filters/multipleSelectFilter.ts +++ b/packages/common/src/filters/multipleSelectFilter.ts @@ -6,7 +6,7 @@ export class MultipleSelectFilter extends SelectFilter { /** * Initialize the Filter */ - constructor(protected translaterService: TranslaterService, protected collectionService: CollectionService) { + constructor(protected readonly translaterService: TranslaterService, protected readonly collectionService: CollectionService) { super(translaterService, collectionService, true); } } diff --git a/packages/common/src/filters/nativeSelectFilter.ts b/packages/common/src/filters/nativeSelectFilter.ts index 5f20bfcce..bead9ead2 100644 --- a/packages/common/src/filters/nativeSelectFilter.ts +++ b/packages/common/src/filters/nativeSelectFilter.ts @@ -11,16 +11,16 @@ import { OperatorType, OperatorString, SearchTerm } from '../enums/index'; import { TranslaterService } from '../services/translater.service'; export class NativeSelectFilter implements Filter { - private _clearFilterTriggered = false; - private _shouldTriggerQuery = true; - private _currentValues: any | any[] = []; + protected _clearFilterTriggered = false; + protected _shouldTriggerQuery = true; + protected _currentValues: any | any[] = []; $filterElm: any; grid: SlickGrid; searchTerms: SearchTerm[]; columnDef: Column; callback: FilterCallback; - constructor(private translater: TranslaterService) { } + constructor(protected readonly translater: TranslaterService) { } /** Getter for the Column Filter itself */ protected get columnFilter(): ColumnFilter { @@ -133,10 +133,10 @@ export class NativeSelectFilter implements Filter { } // - // private functions + // protected functions // ------------------ - private buildTemplateHtmlString() { + protected buildTemplateHtmlString() { const collection = this.columnFilter && this.columnFilter.collection || []; if (!Array.isArray(collection)) { throw new Error('The "collection" passed to the Native Select Filter is not a valid array.'); @@ -171,7 +171,7 @@ export class NativeSelectFilter implements Filter { * From the html template string, create a DOM element * @param filterTemplate */ - private createDomElement(filterTemplate: string, searchTerm?: SearchTerm) { + protected createDomElement(filterTemplate: string, searchTerm?: SearchTerm) { const columnId = this.columnDef?.id ?? ''; const $headerElm = this.grid.getHeaderRowColumn(columnId); $($headerElm).empty(); @@ -195,7 +195,7 @@ export class NativeSelectFilter implements Filter { return $filterElm; } - private handleOnChange(e: any) { + protected handleOnChange(e: any) { const value = e && e.target && e.target.value || ''; this._currentValues = [value]; diff --git a/packages/common/src/filters/selectFilter.ts b/packages/common/src/filters/selectFilter.ts index 196cef03e..11e9a66ec 100644 --- a/packages/common/src/filters/selectFilter.ts +++ b/packages/common/src/filters/selectFilter.ts @@ -49,7 +49,7 @@ export class SelectFilter implements Filter { /** * Initialize the Filter */ - constructor(protected translaterService: TranslaterService, protected collectionService: CollectionService, isMultipleSelect = true) { + constructor(protected readonly translaterService: TranslaterService, protected readonly collectionService: CollectionService, isMultipleSelect = true) { this._isMultipleSelect = isMultipleSelect; } diff --git a/packages/common/src/filters/singleSelectFilter.ts b/packages/common/src/filters/singleSelectFilter.ts index 708ffda92..1366b476c 100644 --- a/packages/common/src/filters/singleSelectFilter.ts +++ b/packages/common/src/filters/singleSelectFilter.ts @@ -6,7 +6,7 @@ export class SingleSelectFilter extends SelectFilter { /** * Initialize the Filter */ - constructor(protected translaterService: TranslaterService, protected collectionService: CollectionService) { + constructor(protected readonly translaterService: TranslaterService, protected readonly collectionService: CollectionService) { super(translaterService, collectionService, false); } } diff --git a/packages/common/src/filters/sliderFilter.ts b/packages/common/src/filters/sliderFilter.ts index 6f9304133..096ca4b0b 100644 --- a/packages/common/src/filters/sliderFilter.ts +++ b/packages/common/src/filters/sliderFilter.ts @@ -13,14 +13,14 @@ const DEFAULT_MAX_VALUE = 100; const DEFAULT_STEP = 1; export class SliderFilter implements Filter { - private _clearFilterTriggered = false; - private _currentValue: number; - private _shouldTriggerQuery = true; - private _elementRangeInputId = ''; - private _elementRangeOutputId = ''; - private $filterElm: any; - private $filterInputElm: any; - private $filterNumberElm: any; + protected _clearFilterTriggered = false; + protected _currentValue: number; + protected _shouldTriggerQuery = true; + protected _elementRangeInputId = ''; + protected _elementRangeOutputId = ''; + protected $filterElm: any; + protected $filterInputElm: any; + protected $filterNumberElm: any; grid: SlickGrid; searchTerms: SearchTerm[]; columnDef: Column; @@ -37,12 +37,12 @@ export class SliderFilter implements Filter { } /** Getter for the Filter Generic Params */ - private get filterParams(): any { + protected get filterParams(): any { return this.columnDef && this.columnDef.filter && this.columnDef.filter.params || {}; } /** Getter for the `filter` properties */ - private get filterProperties(): ColumnFilter { + protected get filterProperties(): ColumnFilter { return this.columnDef && this.columnDef.filter || {}; } @@ -153,13 +153,13 @@ export class SliderFilter implements Filter { } // - // private functions + // protected functions // ------------------ /** * Create the HTML template as a string */ - private buildTemplateHtmlString() { + protected buildTemplateHtmlString() { const columnId = this.columnDef?.id ?? ''; const minValue = this.filterProperties.hasOwnProperty('minValue') ? this.filterProperties.minValue : DEFAULT_MIN_VALUE; const maxValue = this.filterProperties.hasOwnProperty('maxValue') ? this.filterProperties.maxValue : DEFAULT_MAX_VALUE; @@ -193,7 +193,7 @@ export class SliderFilter implements Filter { * @param filterTemplate string * @param searchTerm optional preset search terms */ - private createDomElement(filterTemplate: string, searchTerm?: SearchTerm) { + protected createDomElement(filterTemplate: string, searchTerm?: SearchTerm) { const columnId = this.columnDef && this.columnDef.id; const minValue = (this.filterProperties.hasOwnProperty('minValue') && this.filterProperties.minValue !== undefined) ? this.filterProperties.minValue : DEFAULT_MIN_VALUE; const startValue = +(this.filterParams.hasOwnProperty('sliderStartValue') ? this.filterParams.sliderStartValue : minValue); @@ -230,7 +230,7 @@ export class SliderFilter implements Filter { return $filterElm; } - private handleOnChange(e: any) { + protected handleOnChange(e: any) { const value = e && e.target && e.target.value; this._currentValue = +value; diff --git a/packages/common/src/filters/sliderRangeFilter.ts b/packages/common/src/filters/sliderRangeFilter.ts index 412970f2d..436f1b1d4 100644 --- a/packages/common/src/filters/sliderRangeFilter.ts +++ b/packages/common/src/filters/sliderRangeFilter.ts @@ -19,24 +19,24 @@ const DEFAULT_STEP = 1; /** A Slider Range Filter which uses jQuery UI, this is only meant to be used as a range filter (with 2 handles lowest & highest values) */ export class SliderRangeFilter implements Filter { - private _clearFilterTriggered = false; - private _currentValues: number[]; - private _shouldTriggerQuery = true; - private _sliderOptions: JQueryUiSliderOption; - private $filterElm: any; - private $filterContainerElm: any; + protected _clearFilterTriggered = false; + protected _currentValues: number[]; + protected _shouldTriggerQuery = true; + protected _sliderOptions: JQueryUiSliderOption; + protected $filterElm: any; + protected $filterContainerElm: any; grid: SlickGrid; searchTerms: SearchTerm[]; columnDef: Column; callback: FilterCallback; /** Getter for the Filter Generic Params */ - private get filterParams(): any { + protected get filterParams(): any { return this.columnDef && this.columnDef.filter && this.columnDef.filter.params || {}; } /** Getter for the `filter` properties */ - private get filterProperties(): ColumnFilter { + protected get filterProperties(): ColumnFilter { return this.columnDef && this.columnDef.filter || {}; } @@ -170,14 +170,14 @@ export class SliderRangeFilter implements Filter { } // - // private functions + // protected functions // ------------------ /** * From the html template string, create a DOM element * @param searchTerm optional preset search terms */ - private createDomElement(searchTerms?: SearchTerm | SearchTerm[]) { + protected createDomElement(searchTerms?: SearchTerm | SearchTerm[]) { if (this.columnFilter && this.columnFilter.filterOptions && (this.columnFilter.filterOptions.change || this.columnFilter.filterOptions.slide)) { throw new Error(`[Slickgrid-Universal] You cannot override the "change" and/or the "slide" callback methods since they are used in SliderRange Filter itself, however any other methods can be used for example the "create", "start", "stop" methods.`); @@ -256,7 +256,7 @@ export class SliderRangeFilter implements Filter { } /** On a value change event triggered */ - private onValueChanged(e: Event, ui: JQueryUiSliderResponse) { + protected onValueChanged(e: Event, ui: JQueryUiSliderResponse) { const values = ui && Array.isArray(ui.values) ? ui.values : []; const value = values.join('..'); diff --git a/packages/common/src/services/extension.service.ts b/packages/common/src/services/extension.service.ts index a55ec42ac..7a9881a34 100644 --- a/packages/common/src/services/extension.service.ts +++ b/packages/common/src/services/extension.service.ts @@ -33,22 +33,22 @@ export class ExtensionService { } constructor( - private autoTooltipExtension: AutoTooltipExtension, - private cellExternalCopyExtension: CellExternalCopyManagerExtension, - private cellMenuExtension: CellMenuExtension, - private checkboxSelectorExtension: CheckboxSelectorExtension, - private columnPickerExtension: ColumnPickerExtension, - private contextMenuExtension: ContextMenuExtension, - private draggableGroupingExtension: DraggableGroupingExtension, - private gridMenuExtension: GridMenuExtension, - private groupItemMetaExtension: GroupItemMetaProviderExtension, - private headerButtonExtension: HeaderButtonExtension, - private headerMenuExtension: HeaderMenuExtension, - private rowDetailViewExtension: RowDetailViewExtension, - private rowMoveManagerExtension: RowMoveManagerExtension, - private rowSelectionExtension: RowSelectionExtension, - private sharedService: SharedService, - private translaterService?: TranslaterService, + private readonly autoTooltipExtension: AutoTooltipExtension, + private readonly cellExternalCopyExtension: CellExternalCopyManagerExtension, + private readonly cellMenuExtension: CellMenuExtension, + private readonly checkboxSelectorExtension: CheckboxSelectorExtension, + private readonly columnPickerExtension: ColumnPickerExtension, + private readonly contextMenuExtension: ContextMenuExtension, + private readonly draggableGroupingExtension: DraggableGroupingExtension, + private readonly gridMenuExtension: GridMenuExtension, + private readonly groupItemMetaExtension: GroupItemMetaProviderExtension, + private readonly headerButtonExtension: HeaderButtonExtension, + private readonly headerMenuExtension: HeaderMenuExtension, + private readonly rowDetailViewExtension: RowDetailViewExtension, + private readonly rowMoveManagerExtension: RowMoveManagerExtension, + private readonly rowSelectionExtension: RowSelectionExtension, + private readonly sharedService: SharedService, + private readonly translaterService?: TranslaterService, ) { } /** Dispose of all the controls & plugins */ diff --git a/packages/vanilla-bundle/src/components/slick-pagination.component.ts b/packages/vanilla-bundle/src/components/slick-pagination.component.ts index b8321f688..e63f30648 100644 --- a/packages/vanilla-bundle/src/components/slick-pagination.component.ts +++ b/packages/vanilla-bundle/src/components/slick-pagination.component.ts @@ -31,7 +31,7 @@ export class SlickPaginationComponent { textOf = 'of'; textPage = 'Page'; - constructor(private paginationService: PaginationService, private pubSubService: PubSubService, private sharedService: SharedService, private translaterService?: TranslaterService) { + constructor(private readonly paginationService: PaginationService, private readonly pubSubService: PubSubService, private readonly sharedService: SharedService, private readonly translaterService?: TranslaterService) { this._bindingHelper = new BindingHelper(); this._bindingHelper.querySelectorPrefix = `.${this.gridUid} `;