Skip to content

Commit 6f06d1d

Browse files
committed
fix(presets): Multiple Select Filter Grid Presets values should be shown
- our filter conditions assume that values will always be treated as string when filtering but the grid presets was not doing the same assumptions, we can cast both the option value and the search term to string while comparing on what to show as pre-selected items
1 parent cd494ce commit 6f06d1d

File tree

4 files changed

+33
-21
lines changed

4 files changed

+33
-21
lines changed

package.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,18 @@
118118
},
119119
"devDependencies": {
120120
"@angular-builders/jest": "^7.4.4",
121-
"@angular-devkit/build-angular": "~0.1102.4",
122-
"@angular/animations": "^11.2.5",
123-
"@angular/cli": "^11.2.4",
124-
"@angular/common": "^11.2.5",
125-
"@angular/compiler": "^11.2.5",
126-
"@angular/compiler-cli": "^11.2.5",
127-
"@angular/core": "^11.2.5",
128-
"@angular/forms": "^11.2.5",
129-
"@angular/language-service": "^11.2.5",
130-
"@angular/platform-browser": "^11.2.5",
131-
"@angular/platform-browser-dynamic": "^11.2.5",
132-
"@angular/router": "^11.2.5",
121+
"@angular-devkit/build-angular": "~0.1102.5",
122+
"@angular/animations": "^11.2.6",
123+
"@angular/cli": "^11.2.5",
124+
"@angular/common": "^11.2.6",
125+
"@angular/compiler": "^11.2.6",
126+
"@angular/compiler-cli": "^11.2.6",
127+
"@angular/core": "^11.2.6",
128+
"@angular/forms": "^11.2.6",
129+
"@angular/language-service": "^11.2.6",
130+
"@angular/platform-browser": "^11.2.6",
131+
"@angular/platform-browser-dynamic": "^11.2.6",
132+
"@angular/router": "^11.2.6",
133133
"@ng-select/ng-select": "^6.1.0",
134134
"@ngx-translate/core": "^13.0.0",
135135
"@ngx-translate/http-loader": "^6.0.0",
@@ -174,7 +174,7 @@
174174
"tslib": "^2.1.0",
175175
"tslint": "~6.1.0",
176176
"typescript": "4.0.7",
177-
"uglify-js": "^3.12.5",
177+
"uglify-js": "^3.13.2",
178178
"vinyl-paths": "^2.1.0",
179179
"yargs": "^16.2.0",
180180
"zone.js": "~0.10.2"

src/app/modules/angular-slickgrid/filters/selectFilter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ export class SelectFilter implements Filter {
382382
throw new Error(`[select-filter] A collection with value/label (or value/labelKey when using Locale) is required to populate the Select list, for example:: { filter: model: Filters.multipleSelect, collection: [ { value: '1', label: 'One' } ]')`);
383383
}
384384
const labelKey = (option.labelKey || option[this.labelName]) as string;
385-
const selected = (searchTerms.findIndex((term) => term === option[this.valueName]) >= 0) ? 'selected' : '';
385+
const selected = (searchTerms.findIndex((term) => `${term}` === `${option[this.valueName]}`) >= 0) ? 'selected' : '';
386386
const labelText = ((option.labelKey || this.enableTranslateLabel) && labelKey && isEnableTranslate) ? this.translate && this.translate.currentLang && this.translate.instant(labelKey || ' ') : labelKey;
387387
let prefixText = option[this.labelPrefixName] || '';
388388
let suffixText = option[this.labelSuffixName] || '';

test/cypress/integration/example04.spec.js

+18-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ describe('Example 4 - Client Side Sort/Filter Grid', () => {
1515
const presetDurationValues = [98, 10];
1616
const presetUsDateShort = '04/20/25';
1717

18-
it('should have "Duration" fields within the inclusive range of the preset filters', () => {
18+
it('should have "Duration" fields within the inclusive range of the preset filters and be displayed in the Filter itself', () => {
19+
cy.get('.ms-filter.search-filter.filter-duration.filled')
20+
.find('.ms-choice')
21+
.contains('98, 10');
22+
1923
cy.get('#grid4')
2024
.find('.slick-row')
2125
.each(($row) => {
@@ -49,6 +53,16 @@ describe('Example 4 - Client Side Sort/Filter Grid', () => {
4953
});
5054
});
5155

56+
it('should have some metrics shown in the grid footer well below 1500 items', () => {
57+
cy.get('#slickGridContainer-grid4')
58+
.find('.slick-custom-footer')
59+
.find('.right-footer')
60+
.should($span => {
61+
const text = removeExtraSpaces($span.text()); // remove all white spaces
62+
expect(text).not.to.eq('1500 of 1500 items');
63+
});
64+
});
65+
5266
it('should expect the grid to be sorted by "Duration" descending and "% Complete" ascending', () => {
5367
cy.get('#grid4')
5468
.get('.slick-header-column:nth(2)')
@@ -69,9 +83,8 @@ describe('Example 4 - Client Side Sort/Filter Grid', () => {
6983
.children('.slick-cell:nth(2)')
7084
.should('contain', '98');
7185

72-
// cy.get('.slick-viewport-top.slick-viewport-left')
73-
// .scrollTo('bottom')
74-
// .wait(50);
86+
cy.get('[data-test="scroll-bottom-btn"')
87+
.click();
7588

7689
cy.get('.slick-row')
7790
.last()
@@ -156,8 +169,7 @@ describe('Example 4 - Client Side Sort/Filter Grid', () => {
156169
.should($span => {
157170
const text = removeExtraSpaces($span.text()); // remove all white spaces
158171
expect(text).to.eq('1500 of 1500 items');
159-
})
160-
// .contains('1500 of 1500 items')
172+
});
161173
});
162174

163175
it('should expect the grid to be sorted by "Duration" ascending and "Start" descending', () => {

test/cypress/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"author": "Ghislain B.",
1111
"license": "MIT",
1212
"devDependencies": {
13-
"cypress": "^6.6.0",
13+
"cypress": "^6.8.0",
1414
"mocha": "^8.3.2",
1515
"mochawesome": "^6.2.2"
1616
}

0 commit comments

Comments
 (0)