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

Commit 65aac1c

Browse files
authored
Merge pull request #1325 from ghiscoding/feat/universal4
BREAKING CHANGE: migrate to Slickgrid-Universal v4.0 new major version
2 parents 39c65e0 + 97e3cea commit 65aac1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1064
-1158
lines changed

angular.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"excel-builder-webpacker",
2525
"fetch-jsonp",
2626
"flatpickr",
27-
"slickgrid",
2827
"stream"
2928
],
3029
"assets": [
@@ -60,8 +59,7 @@
6059
"src/styles.scss"
6160
],
6261
"scripts": [
63-
"node_modules/bootstrap/dist/js/bootstrap.min.js",
64-
"node_modules/sortablejs/Sortable.min.js"
62+
"node_modules/bootstrap/dist/js/bootstrap.min.js"
6563
],
6664
"vendorChunk": true,
6765
"extractLicenses": false,

cypress/downloads/downloads.htm

1.21 KB
Binary file not shown.

package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@
5050
},
5151
"dependencies": {
5252
"@ngx-translate/core": "^15.0.0",
53-
"@slickgrid-universal/common": "~3.7.2",
54-
"@slickgrid-universal/custom-footer-component": "~3.7.2",
55-
"@slickgrid-universal/empty-warning-component": "~3.7.2",
56-
"@slickgrid-universal/event-pub-sub": "~3.7.0",
57-
"@slickgrid-universal/pagination-component": "~3.7.2",
58-
"@slickgrid-universal/row-detail-view-plugin": "~3.7.2",
59-
"@slickgrid-universal/rxjs-observable": "~3.7.2",
53+
"@slickgrid-universal/common": "~4.0.2",
54+
"@slickgrid-universal/custom-footer-component": "~4.0.2",
55+
"@slickgrid-universal/empty-warning-component": "~4.0.2",
56+
"@slickgrid-universal/event-pub-sub": "~4.0.2",
57+
"@slickgrid-universal/pagination-component": "~4.0.2",
58+
"@slickgrid-universal/row-detail-view-plugin": "~4.0.2",
59+
"@slickgrid-universal/rxjs-observable": "~4.0.2",
6060
"dequal": "^2.0.3",
6161
"dompurify": "^3.0.6",
6262
"rxjs": "^7.8.1",
@@ -87,20 +87,20 @@
8787
"@ngx-translate/http-loader": "^8.0.0",
8888
"@popperjs/core": "^2.11.8",
8989
"@release-it/conventional-changelog": "^8.0.1",
90-
"@slickgrid-universal/composite-editor-component": "~3.7.2",
91-
"@slickgrid-universal/custom-tooltip-plugin": "~3.7.2",
92-
"@slickgrid-universal/excel-export": "~3.7.2",
93-
"@slickgrid-universal/graphql": "~3.7.2",
94-
"@slickgrid-universal/odata": "~3.7.2",
95-
"@slickgrid-universal/text-export": "~3.7.2",
90+
"@slickgrid-universal/composite-editor-component": "~4.0.2",
91+
"@slickgrid-universal/custom-tooltip-plugin": "~4.0.2",
92+
"@slickgrid-universal/excel-export": "~4.0.2",
93+
"@slickgrid-universal/graphql": "~4.0.2",
94+
"@slickgrid-universal/odata": "~4.0.2",
95+
"@slickgrid-universal/text-export": "~4.0.2",
9696
"@types/dompurify": "^3.0.5",
9797
"@types/flatpickr": "^3.1.2",
9898
"@types/fnando__sparkline": "^0.3.7",
9999
"@types/jest": "^29.5.11",
100100
"@types/node": "^20.10.4",
101101
"@types/sortablejs": "^1.15.7",
102-
"@typescript-eslint/eslint-plugin": "^6.13.2",
103-
"@typescript-eslint/parser": "^6.13.2",
102+
"@typescript-eslint/eslint-plugin": "^6.14.0",
103+
"@typescript-eslint/parser": "^6.14.0",
104104
"bootstrap": "^5.3.2",
105105
"copyfiles": "^2.4.1",
106106
"custom-event-polyfill": "^1.0.7",

src/app/examples/custom-inputEditor.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
Editor,
55
EditorValidator,
66
EditorValidationResult,
7-
KeyCode,
87
} from './../modules/angular-slickgrid';
98

109
/*
@@ -67,7 +66,7 @@ export class CustomInputEditor implements Editor {
6766

6867
onKeydown(event: KeyboardEvent) {
6968
this._lastInputEvent = event;
70-
if (event.keyCode === KeyCode.LEFT || event.keyCode === KeyCode.RIGHT) {
69+
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
7170
event.stopImmediatePropagation();
7271
}
7372
}
@@ -107,8 +106,8 @@ export class CustomInputEditor implements Editor {
107106
}
108107

109108
isValueChanged() {
110-
const lastEvent = this._lastInputEvent?.keyCode;
111-
if (this.columnEditor?.alwaysSaveOnEnterKey && lastEvent === KeyCode.ENTER) {
109+
const lastKeyEvent = this._lastInputEvent?.key;
110+
if (this.columnEditor?.alwaysSaveOnEnterKey && lastKeyEvent === 'Enter') {
112111
return true;
113112
}
114113
return (!(this.inputElm.value === '' && this.defaultValue === null) && this.inputElm.value !== this.defaultValue);

src/app/examples/grid-additem.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ export class GridAddItemComponent implements OnInit {
6262
id: 'delete',
6363
field: 'id',
6464
excludeFromHeaderMenu: true,
65-
formatter: Formatters.deleteIcon,
65+
formatter: Formatters.icon,
66+
params: { iconCssClass: 'fa fa-trash pointer' },
6667
minWidth: 30,
6768
maxWidth: 30,
6869
// use onCellClick OR grid.onClick.subscribe which you can see down below

src/app/examples/grid-angular.component.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
Formatters,
1212
GridOption,
1313
OnEventArgs,
14-
SlickNamespace,
14+
SlickGlobalEditorLock,
1515
} from './../modules/angular-slickgrid';
1616
import { EditorNgSelectComponent } from './editor-ng-select.component';
1717
import { CustomAngularComponentEditor } from './custom-angularComponentEditor';
@@ -20,9 +20,6 @@ import { CustomTitleFormatterComponent } from './custom-titleFormatter.component
2020
import { FilterNgSelectComponent } from './filter-ng-select.component';
2121
import { CustomButtonFormatterComponent } from './custom-buttonFormatter.component';
2222

23-
// using external non-typed js libraries
24-
declare const Slick: SlickNamespace;
25-
2623
const NB_ITEMS = 100;
2724

2825
@Component({
@@ -364,7 +361,7 @@ export class GridAngularComponent implements OnInit {
364361

365362
undo() {
366363
const command = this._commandQueue.pop();
367-
if (command && Slick.GlobalEditorLock.cancelCurrentEdit()) {
364+
if (command && SlickGlobalEditorLock.cancelCurrentEdit()) {
368365
command.undo();
369366
this.gridObj.gotoCell(command.row, command.cell, false);
370367
}

src/app/examples/grid-composite-editor.component.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
22
import { HttpClient } from '@angular/common/http';
33
import { ExcelExportService } from '@slickgrid-universal/excel-export';
4-
import { SlickCompositeEditorComponent } from '@slickgrid-universal/composite-editor-component';
4+
import { SlickCompositeEditor, SlickCompositeEditorComponent } from '@slickgrid-universal/composite-editor-component';
55

66
import {
77
AngularGridInstance,
@@ -20,17 +20,14 @@ import {
2020
GridStateChange,
2121
LongTextEditorOption,
2222
OnCompositeEditorChangeEventArgs,
23+
SlickGlobalEditorLock,
2324
SlickGrid,
24-
SlickNamespace,
2525
SortComparers,
2626
} from '../modules/angular-slickgrid';
2727

2828
const NB_ITEMS = 500;
2929
const URL_COUNTRIES_COLLECTION = 'assets/data/countries.json';
3030

31-
// using external SlickGrid JS libraries
32-
declare const Slick: SlickNamespace;
33-
3431
/**
3532
* Check if the current item (cell) is editable or not
3633
* @param {*} dataContext - item data context object
@@ -489,7 +486,7 @@ export class GridCompositeEditorComponent implements OnInit {
489486
handleValidationError(_e: Event, args: any) {
490487
if (args.validationResults) {
491488
let errorMsg = args.validationResults.msg || '';
492-
if (args.editor && (args.editor instanceof Slick.CompositeEditor)) {
489+
if (args.editor && (args.editor instanceof SlickCompositeEditor)) {
493490
if (args.validationResults.errors) {
494491
errorMsg += '\n';
495492
for (const error of args.validationResults.errors) {
@@ -720,7 +717,7 @@ export class GridCompositeEditorComponent implements OnInit {
720717
undoLastEdit(showLastEditor = false) {
721718
const lastEdit = this.editQueue.pop();
722719
const lastEditCommand = lastEdit?.editCommand;
723-
if (lastEdit && lastEditCommand && Slick.GlobalEditorLock.cancelCurrentEdit()) {
720+
if (lastEdit && lastEditCommand && SlickGlobalEditorLock.cancelCurrentEdit()) {
724721
lastEditCommand.undo();
725722

726723
// remove unsaved css class from that cell
@@ -740,7 +737,7 @@ export class GridCompositeEditorComponent implements OnInit {
740737
undoAllEdits() {
741738
for (const lastEdit of this.editQueue) {
742739
const lastEditCommand = lastEdit?.editCommand;
743-
if (lastEditCommand && Slick.GlobalEditorLock.cancelCurrentEdit()) {
740+
if (lastEditCommand && SlickGlobalEditorLock.cancelCurrentEdit()) {
744741
lastEditCommand.undo();
745742

746743
// remove unsaved css class from that cell

src/app/examples/grid-editor.component.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@ import {
2121
OnEventArgs,
2222
OperatorType,
2323
SortComparers,
24-
SlickNamespace,
24+
SlickGlobalEditorLock,
2525
} from './../modules/angular-slickgrid';
2626
import { CustomInputEditor } from './custom-inputEditor';
2727
import { CustomInputFilter } from './custom-inputFilter';
2828
import { Subject } from 'rxjs';
2929

30-
// using external non-typed js libraries
31-
declare const Slick: SlickNamespace;
32-
3330
const NB_ITEMS = 100;
3431
const URL_SAMPLE_COLLECTION_DATA = 'assets/data/collection_100_numbers.json';
3532
const URL_COUNTRIES_COLLECTION = 'assets/data/countries.json';
@@ -120,7 +117,8 @@ export class GridEditorComponent implements OnInit {
120117
excludeFromColumnPicker: true,
121118
excludeFromGridMenu: true,
122119
excludeFromHeaderMenu: true,
123-
formatter: Formatters.editIcon,
120+
formatter: Formatters.icon,
121+
params: { iconCssClass: 'fa fa-pencil pointer' },
124122
minWidth: 30,
125123
maxWidth: 30,
126124
// use onCellClick OR grid.onClick.subscribe which you can see down below
@@ -136,7 +134,8 @@ export class GridEditorComponent implements OnInit {
136134
excludeFromColumnPicker: true,
137135
excludeFromGridMenu: true,
138136
excludeFromHeaderMenu: true,
139-
formatter: Formatters.deleteIcon,
137+
formatter: Formatters.icon,
138+
params: { iconCssClass: 'fa fa-trash pointer' },
140139
minWidth: 30,
141140
maxWidth: 30,
142141
// use onCellClick OR grid.onClick.subscribe which you can see down below
@@ -686,7 +685,7 @@ export class GridEditorComponent implements OnInit {
686685
undo() {
687686
const command = this._commandQueue.pop();
688687
const item = this.angularGrid.dataView.getItem(command.row);
689-
if (command && Slick.GlobalEditorLock.cancelCurrentEdit()) {
688+
if (command && SlickGlobalEditorLock.cancelCurrentEdit()) {
690689
command.undo();
691690
this.gridObj.gotoCell(command.row, command.cell, false);
692691
}

src/app/examples/grid-frozen.component.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
2-
import { AngularGridInstance, Column, ColumnEditorDualInput, Editors, FieldType, formatNumber, Formatters, Filters, GridOption, SlickNamespace } from './../modules/angular-slickgrid';
3-
4-
declare const Slick: SlickNamespace;
2+
import { AngularGridInstance, Column, ColumnEditorDualInput, Editors, FieldType, formatNumber, Formatters, Filters, GridOption, SlickEventHandler } from './../modules/angular-slickgrid';
53

64
@Component({
75
templateUrl: './grid-frozen.component.html',
@@ -31,7 +29,7 @@ export class GridFrozenComponent implements OnInit, OnDestroy {
3129
slickEventHandler: any;
3230

3331
constructor() {
34-
this.slickEventHandler = new Slick.EventHandler();
32+
this.slickEventHandler = new SlickEventHandler();
3533
}
3634

3735
ngOnInit(): void {

src/app/examples/grid-headerbutton.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class GridHeaderButtonComponent implements OnInit {
9898
};
9999
}
100100

101-
handleOnCommand(_e: Event, args: any, gridNo: 1 | 2) {
101+
handleOnCommand(_e: any, args: any, gridNo: 1 | 2) {
102102
const column = args.column;
103103
const button = args.button;
104104
const command = args.command;

src/app/examples/grid-remote.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fetchJsonp from 'fetch-jsonp';
22
// import 'slickgrid/slick.remotemodel'; // SlickGrid Remote Plugin
33

44
import { Component, OnInit, OnDestroy } from '@angular/core';
5-
import { AngularGridInstance, Column, Formatter, GridOption } from './../modules/angular-slickgrid';
5+
import { AngularGridInstance, Column, Formatter, GridOption, SlickEventHandler } from './../modules/angular-slickgrid';
66

77
declare const Slick: any;
88

@@ -22,7 +22,7 @@ const mpnFormatter: Formatter = (_row, _cell, _value, _columnDef, dataContext) =
2222
templateUrl: './grid-remote.component.html'
2323
})
2424
export class GridRemoteComponent implements OnDestroy, OnInit {
25-
private _eventHandler: any = new Slick.EventHandler();
25+
private _eventHandler: any = new SlickEventHandler();
2626

2727
title = 'Example 18: Octopart Catalog Search - Remote Model Plugin';
2828
subTitle = `

src/app/examples/grid-resize-by-content.component.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import { Component, OnInit, ViewEncapsulation } from '@angular/core';
22
import { HttpClient } from '@angular/common/http';
33
import { ExcelExportService } from '@slickgrid-universal/excel-export';
44

5-
import { AngularGridInstance, Column, GridOption, Filters, Formatter, LongTextEditorOption, FieldType, Editors, Formatters, AutocompleterOption, EditCommand, formatNumber, SortComparers, SlickGrid, SlickNamespace } from '../modules/angular-slickgrid';
5+
import { AngularGridInstance, Column, GridOption, Filters, Formatter, LongTextEditorOption, FieldType, Editors, Formatters, AutocompleterOption, EditCommand, formatNumber, SortComparers, SlickGrid, SlickGlobalEditorLock } from '../modules/angular-slickgrid';
66

77
const URL_COUNTRIES_COLLECTION = 'assets/data/countries.json';
8-
declare const Slick: SlickNamespace;
98

109
/**
1110
* Check if the current item (cell) is editable or not
@@ -38,9 +37,9 @@ const customEditableInputFormatter: Formatter = (_row, _cell, value, columnDef,
3837
};
3938

4039
// you can create custom validator to pass to an inline editor
41-
const myCustomTitleValidator = (value: any, args: any) => {
42-
if ((value === null || value === undefined || !value.length) && (args.compositeEditorOptions && args.compositeEditorOptions.modalType === 'create' || args.compositeEditorOptions.modalType === 'edit')) {
43-
// we will only check if the field is supplied when it's an inline editing OR a composite editor of type create/edit
40+
const myCustomTitleValidator = (value: any) => {
41+
if ((value === null || value === undefined || !value.length)) {
42+
// we will only check if the field is supplied when it's an inline editing
4443
return { valid: false, msg: 'This is a required field.' };
4544
} else if (!/^(task\s\d+)*$/i.test(value)) {
4645
return { valid: false, msg: 'Your title is invalid, it must start with "Task" followed by a number.' };
@@ -65,7 +64,6 @@ export class GridResizeByContentComponent implements OnInit {
6564
editedItems: any = {};
6665
isUsingDefaultResize = false;
6766
isGridEditable = true;
68-
isCompositeDisabled = false;
6967
isMassSelectionDisabled = true;
7068
complexityLevelList = [
7169
{ value: 0, label: 'Very Simple' },
@@ -344,7 +342,6 @@ export class GridResizeByContentComponent implements OnInit {
344342
rowHeight: 33,
345343
headerRowHeight: 35,
346344
editCommandHandler: (item, column, editCommand) => {
347-
// composite editors values are saved as array, so let's convert to array in any case and we'll loop through these values
348345
const prevSerializedValues = Array.isArray(editCommand.prevSerializedValue) ? editCommand.prevSerializedValue : [editCommand.prevSerializedValue];
349346
const serializedValues = Array.isArray(editCommand.serializedValue) ? editCommand.serializedValue : [editCommand.serializedValue];
350347
const editorColumns = this.columnDefinitions.filter((col) => col.editor !== undefined);
@@ -365,8 +362,7 @@ export class GridResizeByContentComponent implements OnInit {
365362
}
366363
});
367364

368-
// queued editor only keeps 1 item object even when it's a composite editor,
369-
// so we'll push only 1 change at the end but with all columns modified
365+
// queued editor, so we'll push only 1 change at the end but with all columns modified
370366
// this way we can undo the entire row change (for example if user changes 3 field in the editor modal, then doing a undo last change will undo all 3 in 1 shot)
371367
this.editQueue.push({ item, columns: modifiedColumns, editCommand });
372368
},
@@ -477,7 +473,6 @@ export class GridResizeByContentComponent implements OnInit {
477473

478474
// then change a single grid options to make the grid non-editable (readonly)
479475
this.isGridEditable = !this.isGridEditable;
480-
this.isCompositeDisabled = !this.isGridEditable;
481476
if (!this.isGridEditable) {
482477
this.isMassSelectionDisabled = true;
483478
}
@@ -558,7 +553,7 @@ export class GridResizeByContentComponent implements OnInit {
558553
undoLastEdit(showLastEditor = false) {
559554
const lastEdit = this.editQueue.pop();
560555
const lastEditCommand = lastEdit?.editCommand;
561-
if (lastEdit && lastEditCommand && Slick.GlobalEditorLock.cancelCurrentEdit()) {
556+
if (lastEdit && lastEditCommand && SlickGlobalEditorLock.cancelCurrentEdit()) {
562557
lastEditCommand.undo();
563558

564559
// remove unsaved css class from that cell
@@ -578,7 +573,7 @@ export class GridResizeByContentComponent implements OnInit {
578573
undoAllEdits() {
579574
for (const lastEdit of this.editQueue) {
580575
const lastEditCommand = lastEdit?.editCommand;
581-
if (lastEditCommand && Slick.GlobalEditorLock.cancelCurrentEdit()) {
576+
if (lastEditCommand && SlickGlobalEditorLock.cancelCurrentEdit()) {
582577
lastEditCommand.undo();
583578

584579
// remove unsaved css class from that cell

src/app/examples/grid-rowdetail.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class GridRowDetailComponent implements OnInit {
4444
// you can get the SlickGrid RowDetail plugin (addon) instance via 2 ways
4545

4646
// option 1
47-
return (this.angularGrid.extensions.rowDetailView.instance || {});
47+
return (this.angularGrid.extensions.rowDetailView?.instance || {});
4848

4949
// OR option 2
5050
// return this.angularGrid?.extensionService.getExtensionInstanceByName(ExtensionName.rowDetailView) || {};
@@ -132,7 +132,7 @@ export class GridRowDetailComponent implements OnInit {
132132

133133
getData() {
134134
// mock a dataset
135-
const tmpData = [];
135+
const tmpData: any[] = [];
136136
for (let i = 0; i < NB_ITEMS; i++) {
137137
const randomYear = 2000 + Math.floor(Math.random() * 10);
138138
const randomMonth = Math.floor(Math.random() * 11);
@@ -157,7 +157,7 @@ export class GridRowDetailComponent implements OnInit {
157157
changeDetailViewRowCount() {
158158
if (this.angularGrid?.extensionService) {
159159
const options = this.rowDetailInstance.getOptions();
160-
if (options && options.panelRows) {
160+
if (options?.panelRows) {
161161
options.panelRows = this.detailViewRowCount; // change number of rows dynamically
162162
this.rowDetailInstance.setOptions(options);
163163
}

0 commit comments

Comments
 (0)