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

Commit ceb0d77

Browse files
authored
fix(metrics): use onRowsOrCountChanged to refresh metrics (#681)
* fix(metrics): use onRowsOrCountChanged to refresh metrics
1 parent 029a90c commit ceb0d77

File tree

5 files changed

+22
-28
lines changed

5 files changed

+22
-28
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
"@types/flatpickr": "^3.1.2",
138138
"@types/jest": "^24.0.25",
139139
"@types/moment": "^2.13.0",
140-
"@types/node": "^14.14.20",
140+
"@types/node": "^14.14.22",
141141
"@types/text-encoding-utf-8": "^1.0.1",
142142
"babel-jest": "^24.9.0",
143143
"bootstrap": "3.4.1",
@@ -163,17 +163,17 @@
163163
"ngx-bootstrap": "^4.3.0",
164164
"node-sass": "4.14.1",
165165
"npm-run-all": "^4.1.5",
166-
"postcss-cli": "^7.1.1",
166+
"postcss-cli": "^7.1.2",
167167
"require-dir": "^1.2.0",
168168
"rimraf": "^3.0.2",
169169
"run-sequence": "^2.2.1",
170-
"standard-version": "^9.0.0",
170+
"standard-version": "^9.1.0",
171171
"ts-node": "~3.3.0",
172172
"tsickle": "^0.37.0",
173173
"tslib": "^2.0.1",
174174
"tslint": "^5.20.1",
175175
"typescript": "3.5.3",
176-
"uglify-js": "^3.12.4",
176+
"uglify-js": "^3.12.5",
177177
"vinyl-paths": "^2.1.0",
178178
"yargs": "^16.2.0",
179179
"zone.js": "~0.9.1"

src/app/modules/angular-slickgrid/components/__tests__/angular-slickgrid-constructor.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ const mockDataView = {
179179
mapIdsToRows: jest.fn(),
180180
mapRowsToIds: jest.fn(),
181181
onRowsChanged: new Slick.Event(),
182-
onRowCountChanged: jest.fn(),
183-
onSetItemsCalled: jest.fn(),
182+
onRowsOrCountChanged: jest.fn(),
184183
reSort: jest.fn(),
185184
setItems: jest.fn(),
186185
syncGridSelection: jest.fn(),

src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -625,14 +625,9 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
625625

626626
if (dataView && grid) {
627627
// When data changes in the DataView, we need to refresh the metrics and/or display a warning if the dataset is empty
628-
// we will do that via the following 2 handlers (onSetItemsCalled, onRowCountChanged)
629-
this._eventHandler.subscribe(dataView.onSetItemsCalled, () => {
630-
this.handleOnItemsChanged(this.dataset.length);
631-
});
632-
633-
this._eventHandler.subscribe(dataView.onRowCountChanged, (_e: Event, args: any) => {
628+
this._eventHandler.subscribe(dataView.onRowsOrCountChanged, (_e: Event, args: any) => {
634629
grid.invalidate();
635-
this.handleOnItemsChanged(args.current || 0);
630+
this.handleOnItemCountChanged(args.currentRowCount || 0);
636631
});
637632

638633
// Tree Data with Pagiantion is not supported, throw an error when user tries to do that
@@ -772,7 +767,7 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
772767
}
773768

774769
/** When data changes in the DataView, we'll refresh the metrics and/or display a warning if the dataset is empty */
775-
private handleOnItemsChanged(itemCount: number) {
770+
private handleOnItemCountChanged(itemCount: number) {
776771
this.metrics = {
777772
startTime: new Date(),
778773
endTime: new Date(),

test/cypress/integration/example21.spec.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,28 +120,28 @@ describe('Example 21 - Row Detail View', () => {
120120
const expectedTasks = ['Task 0', 'Task 1', 'Task 3', 'Task 4', 'Task 5'];
121121

122122
cy.get('#grid21')
123-
.find('.slick-row:nth(0)')
123+
.find('.slick-row:nth(2)')
124124
.click();
125125

126126
cy.get('#grid21')
127-
.find('.innerDetailView_0 .container_0')
128-
.as('detailContainer0');
127+
.find('.innerDetailView_3 .container_3')
128+
.as('detailContainer3');
129129

130-
cy.get('@detailContainer0')
130+
cy.get('@detailContainer3')
131131
.find('h3')
132-
.contains('Task 0');
132+
.contains('Task 3');
133133

134134
cy.get('#grid21')
135-
.find('.slick-row:nth(8)')
135+
.find('.slick-row:nth(0)')
136136
.click();
137137

138138
cy.get('#grid21')
139-
.find('.innerDetailView_3 .container_3')
140-
.as('detailContainer3');
139+
.find('.innerDetailView_0 .container_0')
140+
.as('detailContainer0');
141141

142-
cy.get('@detailContainer3')
142+
cy.get('@detailContainer0')
143143
.find('h3')
144-
.contains('Task 3');
144+
.contains('Task 0');
145145

146146
cy.get('[data-test=close-all-btn]')
147147
.click();
@@ -154,7 +154,7 @@ describe('Example 21 - Row Detail View', () => {
154154
.should('not.exist');
155155

156156
cy.get('#grid21')
157-
.find('.innerDetailView_3 .container_3')
157+
.find('.innerDetailView_1 .container_1')
158158
.should('not.exist');
159159

160160
cy.get('#grid21')

test/cypress/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"author": "Ghislain B.",
1111
"license": "MIT",
1212
"devDependencies": {
13-
"cypress": "^6.2.1",
14-
"mocha": "^8.2.0",
15-
"mochawesome": "^6.1.1"
13+
"cypress": "^6.3.0",
14+
"mocha": "^8.2.1",
15+
"mochawesome": "^6.2.1"
1616
}
1717
}

0 commit comments

Comments
 (0)