Skip to content

Commit cd56c7b

Browse files
Merge pull request #371 from UiPath/fix/ui-grid-filters
fix(grid): search filters initial value
2 parents e4c6d9e + c47ed36 commit cd56c7b

File tree

6 files changed

+42
-7
lines changed

6 files changed

+42
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# v14.8.5 (2023-07-10)
2+
* **grid** search filters initial value
3+
14
# v14.8.4 (2023-06-20)
25
* **grid** select by clicking the row
36

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-components",
3-
"version": "14.8.4",
3+
"version": "14.8.5",
44
"author": {
55
"name": "UiPath Inc",
66
"url": "https://uipath.com"

projects/angular/components/ui-grid/src/filters/ui-grid-search-filter.directive.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,16 @@ export class UiGridSearchFilterDirective<T> extends UiGridFilterDirective<T> imp
123123
this.filterChange.complete();
124124
}
125125

126+
private checkAlreadyExisting(value: ISuggestValue, isSelected?: boolean) {
127+
if (this.multiple) {
128+
return (isSelected && (this.value as ISuggestValue[] ?? []).find(item => item.id === value.id));
129+
}
130+
131+
return false;
132+
}
133+
126134
private handleMultiple(value?: ISuggestValue, isSelected?: boolean) {
127-
if (!value) {
135+
if (!value || this.checkAlreadyExisting(value, isSelected)) {
128136
return;
129137
}
130138

projects/angular/components/ui-grid/src/ui-grid.component.spec.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
ResizeStrategy,
3939
} from '@uipath/angular/components/ui-grid';
4040
import {
41+
ISuggestValueData,
4142
ISuggestValues,
4243
UiSuggestComponent,
4344
} from '@uipath/angular/components/ui-suggest';
@@ -1327,7 +1328,7 @@ describe('Component: UiGrid', () => {
13271328
[searchable]="true"
13281329
title="String Header"
13291330
width="50%">
1330-
<ui-grid-search-filter [searchSourceFactory]="searchFactory"></ui-grid-search-filter>
1331+
<ui-grid-search-filter [searchSourceFactory]="searchFactory" [value]="value" [multiple]="multiple"></ui-grid-search-filter>
13311332
</ui-grid-column>
13321333
</ui-grid>
13331334
`,
@@ -1343,6 +1344,9 @@ describe('Component: UiGrid', () => {
13431344
showAllOption?: boolean;
13441345
search?: boolean;
13451346

1347+
value?: ISuggestValueData<ITestEntity>[];
1348+
multiple = false;
1349+
13461350
searchFactory = (): Observable<ISuggestValues<any>> => of({
13471351
data: this.dropdownItemList
13481352
.map(
@@ -1372,7 +1376,7 @@ describe('Component: UiGrid', () => {
13721376
fixture = TestBed.createComponent(TestFixtureGridHeaderWithFilterComponent);
13731377
component = fixture.componentInstance;
13741378
grid = component.grid;
1375-
grid.data = generateListFactory(generateEntity)();
1379+
component.data = generateListFactory(generateEntity)();
13761380
});
13771381

13781382
afterEach(() => {
@@ -1614,6 +1618,26 @@ describe('Component: UiGrid', () => {
16141618

16151619
expect(searchFilter.items.length).toEqual(0);
16161620
}));
1621+
1622+
it('should correctly set the initial value', () => {
1623+
component.multiple = true;
1624+
component.value = [{
1625+
id: component.data?.[0]?.id ?? '',
1626+
text: component.data?.[0]?.myString ?? '',
1627+
}];
1628+
1629+
fixture.detectChanges();
1630+
1631+
expect(grid.filterManager.filter$.value).toEqual([{
1632+
method: undefined as any,
1633+
property: 'myString',
1634+
value: [component.data?.[0]?.id ?? ''] as any,
1635+
meta: [{
1636+
id: component.data?.[0]?.id ?? '',
1637+
text: component.data?.[0]?.myString ?? '',
1638+
}],
1639+
}]);
1640+
});
16171641
});
16181642

16191643
describe('Event: dropdown filter change', () => {

projects/angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@uipath/angular",
3-
"version": "14.8.4",
3+
"version": "14.8.5",
44
"license": "MIT",
55
"author": {
66
"name": "UiPath Inc",

0 commit comments

Comments
 (0)