Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 029a90c

Browse files
authored
feat(editors): change all private keyword to protected for extensability (#680)
- also changed all services to readonly
1 parent e5b5e8d commit 029a90c

File tree

9 files changed

+59
-59
lines changed

9 files changed

+59
-59
lines changed

src/app/modules/angular-slickgrid/editors/autoCompleteEditor.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ const MIN_LENGTH = 3;
2828
* KeyDown events are also handled to provide handling for Tab, Shift-Tab, Esc and Ctrl-Enter.
2929
*/
3030
export class AutoCompleteEditor implements Editor {
31-
private _autoCompleteOptions: AutocompleteOption;
32-
private _currentValue: any;
33-
private _defaultTextValue: string;
34-
private _elementCollection: any[] | null;
35-
private _lastInputEvent: JQuery.Event;
31+
protected _autoCompleteOptions: AutocompleteOption;
32+
protected _currentValue: any;
33+
protected _defaultTextValue: string;
34+
protected _elementCollection: any[] | null;
35+
protected _lastInputEvent: JQuery.Event;
3636

3737
/** The JQuery DOM element */
38-
private _$editorElm: any;
38+
protected _$editorElm: any;
3939

4040
/** SlickGrid Grid object */
4141
grid: any;
@@ -54,7 +54,7 @@ export class AutoCompleteEditor implements Editor {
5454

5555
forceUserInput: boolean;
5656

57-
constructor(private args: EditorArguments) {
57+
constructor(protected args: EditorArguments) {
5858
if (!args) {
5959
throw new Error('[Angular-SlickGrid] Something is wrong with this grid, an Editor must always have valid arguments.');
6060
}
@@ -268,10 +268,10 @@ export class AutoCompleteEditor implements Editor {
268268
}
269269

270270
//
271-
// private functions
271+
// protected functions
272272
// ------------------
273273

274-
// this function should be PRIVATE but for unit tests purposes we'll make it public until a better solution is found
274+
// this function should be protected but for unit tests purposes we'll make it public until a better solution is found
275275
// 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
276276
onSelect(_event: Event, ui: { item: any; }) {
277277
if (ui && ui.item) {
@@ -288,7 +288,7 @@ export class AutoCompleteEditor implements Editor {
288288
return false;
289289
}
290290

291-
private renderCustomItem(ul: HTMLElement, item: any) {
291+
protected renderCustomItem(ul: HTMLElement, item: any) {
292292
const templateString = this._autoCompleteOptions && this._autoCompleteOptions.renderItem && this._autoCompleteOptions.renderItem.templateCallback(item) || '';
293293

294294
// sanitize any unauthorized html tags like script and others
@@ -301,7 +301,7 @@ export class AutoCompleteEditor implements Editor {
301301
.appendTo(ul);
302302
}
303303

304-
private renderCollectionItem(ul: HTMLElement, item: any) {
304+
protected renderCollectionItem(ul: HTMLElement, item: any) {
305305
const isRenderHtmlEnabled = this.columnEditor && this.columnEditor.enableRenderHtml || false;
306306
const prefixText = item.labelPrefix || '';
307307
const labelText = item.label || '';
@@ -319,7 +319,7 @@ export class AutoCompleteEditor implements Editor {
319319
.appendTo(ul);
320320
}
321321

322-
private renderDomElement(collection: any[]) {
322+
protected renderDomElement(collection: any[]) {
323323
if (!Array.isArray(collection)) {
324324
throw new Error('The "collection" passed to the Autocomplete Editor is not a valid array.');
325325
}

src/app/modules/angular-slickgrid/editors/checkboxEditor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ declare const $: any;
1010
* KeyDown events are also handled to provide handling for Tab, Shift-Tab, Esc and Ctrl-Enter.
1111
*/
1212
export class CheckboxEditor implements Editor {
13-
private _$input: any;
13+
protected _$input: any;
1414
originalValue: boolean;
1515

1616
/** SlickGrid Grid object */
1717
grid: any;
1818

19-
constructor(private args: EditorArguments) {
19+
constructor(protected args: EditorArguments) {
2020
if (!args) {
2121
throw new Error('[Angular-SlickGrid] Something is wrong with this grid, an Editor must always have valid arguments.');
2222
}

src/app/modules/angular-slickgrid/editors/dateEditor.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ declare const $: any;
3131
* https://chmln.github.io/flatpickr
3232
*/
3333
export class DateEditor implements Editor {
34-
private _$inputWithData: any;
35-
private _$input: any;
36-
private _$editorInputElm: any;
37-
private _originalDate: string;
38-
private _pickerMergedOptions: FlatpickrOption;
34+
protected _$inputWithData: any;
35+
protected _$input: any;
36+
protected _$editorInputElm: any;
37+
protected _originalDate: string;
38+
protected _pickerMergedOptions: FlatpickrOption;
3939

4040
/** The translate library */
41-
private _translate: TranslateService;
41+
protected _translate: TranslateService;
4242

4343
flatInstance: any;
4444
defaultDate: string;
@@ -50,7 +50,7 @@ export class DateEditor implements Editor {
5050
/** Grid options */
5151
gridOptions: GridOption;
5252

53-
constructor(private args: EditorArguments) {
53+
constructor(protected args: EditorArguments) {
5454
if (!args) {
5555
throw new Error('[Angular-SlickGrid] Something is wrong with this grid, an Editor must always have valid arguments.');
5656
}

src/app/modules/angular-slickgrid/editors/dualInputEditor.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ declare const Slick: any;
2323
* KeyDown events are also handled to provide handling for Tab, Shift-Tab, Esc and Ctrl-Enter.
2424
*/
2525
export class DualInputEditor implements Editor {
26-
private _bindEventService: BindingEventService;
27-
private _eventHandler: SlickEventHandler;
28-
private _isValueSaveCalled = false;
29-
private _lastEventType: string | undefined;
30-
private _lastInputKeyEvent: JQuery.Event;
31-
private _leftInput: HTMLInputElement;
32-
private _rightInput: HTMLInputElement;
33-
private _leftFieldName: string;
34-
private _rightFieldName: string;
26+
protected _bindEventService: BindingEventService;
27+
protected _eventHandler: SlickEventHandler;
28+
protected _isValueSaveCalled = false;
29+
protected _lastEventType: string | undefined;
30+
protected _lastInputKeyEvent: JQuery.Event;
31+
protected _leftInput: HTMLInputElement;
32+
protected _rightInput: HTMLInputElement;
33+
protected _leftFieldName: string;
34+
protected _rightFieldName: string;
3535
originalLeftValue: string | number;
3636
originalRightValue: string | number;
3737

@@ -41,7 +41,7 @@ export class DualInputEditor implements Editor {
4141
/** Grid options */
4242
gridOptions: GridOption;
4343

44-
constructor(private args: EditorArguments) {
44+
constructor(protected args: EditorArguments) {
4545
if (!args) {
4646
throw new Error('[Angular-Slickgrid] Something is wrong with this grid, an Editor must always have valid arguments.');
4747
}

src/app/modules/angular-slickgrid/editors/floatEditor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ const defaultDecimalPlaces = 0;
1212
* KeyDown events are also handled to provide handling for Tab, Shift-Tab, Esc and Ctrl-Enter.
1313
*/
1414
export class FloatEditor implements Editor {
15-
private _lastInputEvent: JQuery.Event;
16-
private _$input: any;
15+
protected _lastInputEvent: JQuery.Event;
16+
protected _$input: any;
1717
originalValue: number | string;
1818

1919
/** SlickGrid Grid object */
2020
grid: any;
2121

22-
constructor(private args: EditorArguments) {
22+
constructor(protected args: EditorArguments) {
2323
if (!args) {
2424
throw new Error('[Angular-SlickGrid] Something is wrong with this grid, an Editor must always have valid arguments.');
2525
}

src/app/modules/angular-slickgrid/editors/integerEditor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ declare const $: any;
1010
* KeyDown events are also handled to provide handling for Tab, Shift-Tab, Esc and Ctrl-Enter.
1111
*/
1212
export class IntegerEditor implements Editor {
13-
private _lastInputEvent: JQuery.Event;
14-
private _$input: any;
13+
protected _lastInputEvent: JQuery.Event;
14+
protected _$input: any;
1515
originalValue: number | string;
1616

1717
/** SlickGrid Grid object */
1818
grid: any;
1919

20-
constructor(private args: EditorArguments) {
20+
constructor(protected args: EditorArguments) {
2121
if (!args) {
2222
throw new Error('[Angular-SlickGrid] Something is wrong with this grid, an Editor must always have valid arguments.');
2323
}

src/app/modules/angular-slickgrid/editors/longTextEditor.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ declare const $: any;
2525
* KeyDown events are also handled to provide handling for Tab, Shift-Tab, Esc and Ctrl-Enter.
2626
*/
2727
export class LongTextEditor implements Editor {
28-
private _locales: Locale;
29-
private _$textarea: any;
30-
private _$currentLengthElm: any;
31-
private _$wrapper: any;
28+
protected _locales: Locale;
29+
protected _$textarea: any;
30+
protected _$currentLengthElm: any;
31+
protected _$wrapper: any;
3232
defaultValue: any;
3333

3434
/** SlickGrid Grid object */
@@ -38,9 +38,9 @@ export class LongTextEditor implements Editor {
3838
gridOptions: GridOption;
3939

4040
/** The translate library */
41-
private _translate: TranslateService;
41+
protected _translate: TranslateService;
4242

43-
constructor(private args: EditorArguments) {
43+
constructor(protected args: EditorArguments) {
4444
if (!args) {
4545
throw new Error('[Angular-SlickGrid] Something is wrong with this grid, an Editor must always have valid arguments.');
4646
}
@@ -289,10 +289,10 @@ export class LongTextEditor implements Editor {
289289
}
290290

291291
// --
292-
// private functions
292+
// protected functions
293293
// ------------------
294294

295-
private handleKeyDown(event: KeyboardEvent) {
295+
protected handleKeyDown(event: KeyboardEvent) {
296296
const keyCode = event.keyCode || event.code;
297297
if (keyCode === KeyCode.ENTER && event.ctrlKey) {
298298
this.save();
@@ -313,7 +313,7 @@ export class LongTextEditor implements Editor {
313313
}
314314

315315
/** On every input change event, we'll update the current text length counter */
316-
private handleOnInputChange(event: JQuery.Event & { originalEvent: any, target: HTMLTextAreaElement }) {
316+
protected handleOnInputChange(event: JQuery.Event & { originalEvent: any, target: HTMLTextAreaElement }) {
317317
const maxLength = this.columnEditor && this.columnEditor.maxLength;
318318

319319
// when user defines a maxLength, we'll make sure that it doesn't go over this limit if so then truncate the text (disregard the extra text)
@@ -337,7 +337,7 @@ export class LongTextEditor implements Editor {
337337
* @param maxLength - max acceptable length
338338
* @returns truncated - returns True if it truncated or False otherwise
339339
*/
340-
private truncateText($inputElm: JQuery<HTMLTextAreaElement>, maxLength: number): boolean {
340+
protected truncateText($inputElm: JQuery<HTMLTextAreaElement>, maxLength: number): boolean {
341341
const text = $inputElm.val() + '';
342342
if (text.length > maxLength) {
343343
$inputElm.val(text.substring(0, maxLength));

src/app/modules/angular-slickgrid/editors/sliderEditor.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ const DEFAULT_MAX_VALUE = 100;
1010
const DEFAULT_STEP = 1;
1111

1212
export class SliderEditor implements Editor {
13-
private _defaultValue = 0;
14-
private _elementRangeInputId: string;
15-
private _elementRangeOutputId: string;
16-
private _$editorElm: any;
17-
private _$input: any;
13+
protected _defaultValue = 0;
14+
protected _elementRangeInputId: string;
15+
protected _elementRangeOutputId: string;
16+
protected _$editorElm: any;
17+
protected _$input: any;
1818
$sliderNumber: any;
1919
originalValue: any;
2020

2121
/** SlickGrid Grid object */
2222
grid: any;
2323

24-
constructor(private args: EditorArguments) {
24+
constructor(protected args: EditorArguments) {
2525
if (!args) {
2626
throw new Error('[Angular-SlickGrid] Something is wrong with this grid, an Editor must always have valid arguments.');
2727
}
@@ -49,7 +49,7 @@ export class SliderEditor implements Editor {
4949
}
5050

5151
/** Getter for the Editor Generic Params */
52-
private get editorParams(): any {
52+
protected get editorParams(): any {
5353
return this.columnEditor.params || {};
5454
}
5555

@@ -185,13 +185,13 @@ export class SliderEditor implements Editor {
185185
}
186186

187187
//
188-
// private functions
188+
// protected functions
189189
// ------------------
190190

191191
/**
192192
* Create the HTML template as a string
193193
*/
194-
private buildTemplateHtmlString() {
194+
protected buildTemplateHtmlString() {
195195
const fieldId = this.columnDef && this.columnDef.id;
196196
const title = this.columnEditor && this.columnEditor.title || '';
197197
const minValue = this.columnEditor.hasOwnProperty('minValue') ? this.columnEditor.minValue : DEFAULT_MIN_VALUE;

src/app/modules/angular-slickgrid/editors/textEditor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ declare const $: any;
1010
* KeyDown events are also handled to provide handling for Tab, Shift-Tab, Esc and Ctrl-Enter.
1111
*/
1212
export class TextEditor implements Editor {
13-
private _lastInputEvent: JQuery.Event;
14-
private _$input: any;
13+
protected _lastInputEvent: JQuery.Event;
14+
protected _$input: any;
1515
originalValue: string;
1616

1717
/** SlickGrid Grid object */
1818
grid: any;
1919

20-
constructor(private args: EditorArguments) {
20+
constructor(protected args: EditorArguments) {
2121
if (!args) {
2222
throw new Error('[Angular-SlickGrid] Something is wrong with this grid, an Editor must always have valid arguments.');
2323
}

0 commit comments

Comments
 (0)