Skip to content

Commit f1047b8

Browse files
authored
Merge pull request #431 from UiPath/feat/uigrid_custom_search
feat(ui-grid): add support for using a custom search
2 parents f988dd2 + e4d907a commit f1047b8

File tree

5 files changed

+47
-11
lines changed

5 files changed

+47
-11
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {
2+
ContentChild,
3+
Directive,
4+
TemplateRef,
5+
} from '@angular/core';
6+
7+
@Directive({
8+
selector: '[uiGridCustomSearch], ui-grid-custom-search',
9+
})
10+
export class UiGridCustomSearchDirective {
11+
@ContentChild(TemplateRef, {
12+
static: true,
13+
})
14+
html?: TemplateRef<any>;
15+
}

projects/angular/components/ui-grid/src/public_api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export { UiGridRowCardViewDirective } from './body/ui-grid-row-card-view.directi
1919
export { UiGridLoadingDirective } from './body/ui-grid-loading.directive';
2020
export { UiGridNoContentDirective } from './body/ui-grid-no-content.directive';
2121
export { UiGridSearchComponent } from './components/ui-grid-search/ui-grid-search.component';
22+
export { UiGridCustomSearchDirective } from './components/ui-grid-search/ui-grid-custom-search.directive';
2223
export { UiGridSearchModule } from './components/ui-grid-search/ui-grid-search.module';
2324
export { UiGridToggleColumnsModule } from './components/ui-grid-toggle-columns/ui-grid-toggle-columns.module';
2425
export { UiGridToggleColumnsComponent } from './components/ui-grid-toggle-columns/ui-grid-toggle-columns.component';

projects/angular/components/ui-grid/src/ui-grid.component.html

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,23 @@
2626
<ng-container>
2727
<ng-container *ngIf="!(hasSelection$ | async) ||
2828
!header?.actionButtons?.length">
29-
<ui-grid-search *ngIf="header?.search"
30-
[debounce]="header!.searchDebounce"
31-
[maxLength]="header!.searchMaxLength"
32-
[placeholder]="intl.searchPlaceholder"
33-
[searchTooltip]="intl.searchTooltip"
34-
[clearTooltip]="intl.clearTooltip"
35-
[tooltipDisabled]="resizeManager.isResizing"
36-
[value]="header!.searchValue!"
37-
(searchChange)="filterManager.searchChange($event, header!, footer)"
38-
class="ui-grid-search ui-grid-filter-option">
39-
</ui-grid-search>
29+
<ng-container *ngIf="!!search; else defaultSearch">
30+
<ng-container *ngTemplateOutlet="search.html ?? null"></ng-container>
31+
</ng-container>
32+
33+
<ng-template #defaultSearch>
34+
<ui-grid-search *ngIf="header?.search"
35+
[debounce]="header!.searchDebounce"
36+
[maxLength]="header!.searchMaxLength"
37+
[placeholder]="intl.searchPlaceholder"
38+
[searchTooltip]="intl.searchTooltip"
39+
[clearTooltip]="intl.clearTooltip"
40+
[tooltipDisabled]="resizeManager.isResizing"
41+
[value]="header!.searchValue!"
42+
(searchChange)="filterManager.searchChange($event, header!, footer)"
43+
class="ui-grid-search ui-grid-filter-option">
44+
</ui-grid-search>
45+
</ng-template>
4046

4147
<ng-container *ngTemplateOutlet="toggleColumnsTmpl"></ng-container>
4248

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import { UiGridNoContentDirective } from './body/ui-grid-no-content.directive';
7676
import { UiGridRowActionDirective } from './body/ui-grid-row-action.directive';
7777
import { UiGridRowCardViewDirective } from './body/ui-grid-row-card-view.directive';
7878
import { UiGridRowConfigDirective } from './body/ui-grid-row-config.directive';
79+
import { UiGridCustomSearchDirective } from './components/ui-grid-search/ui-grid-custom-search.directive';
7980
import { ISuggestDropdownValueData } from './filters/ui-grid-dropdown-filter.directive';
8081
import { UiGridSearchFilterDirective } from './filters/ui-grid-search-filter.directive';
8182
import { UiGridFooterDirective } from './footer/ui-grid-footer.directive';
@@ -548,6 +549,16 @@ export class UiGridComponent<T extends IGridDataEntry>
548549
})
549550
header?: UiGridHeaderDirective<T>;
550551

552+
/**
553+
* Custom search directive reference.
554+
*
555+
* @ignore
556+
*/
557+
@ContentChild(UiGridCustomSearchDirective, {
558+
static: true,
559+
})
560+
search?: UiGridCustomSearchDirective;
561+
551562
/**
552563
* Column directive reference list.
553564
*

projects/angular/components/ui-grid/src/ui-grid.module.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { UiSuggestModule } from '@uipath/angular/components/ui-suggest';
1616
import { UiNgLetModule } from '@uipath/angular/directives/ui-ng-let';
1717
import { UiVirtualScrollViewportResizeModule } from '@uipath/angular/directives/ui-virtual-scroll-viewport-resize';
1818

19+
import { UiGridCustomSearchDirective } from './components/ui-grid-search/ui-grid-custom-search.directive';
1920
import { UiGridColumnDirective } from './body/ui-grid-column.directive';
2021
import { UiGridExpandedRowDirective } from './body/ui-grid-expanded-row.directive';
2122
import { UiGridLoadingDirective } from './body/ui-grid-loading.directive';
@@ -69,6 +70,7 @@ import { UiGridComponent } from './ui-grid.component';
6970
UiGridNoContentDirective,
7071
UiGridLoadingDirective,
7172
UiGridRowCardViewDirective,
73+
UiGridCustomSearchDirective,
7274
],
7375
exports: [
7476
UiGridComponent,
@@ -84,6 +86,7 @@ import { UiGridComponent } from './ui-grid.component';
8486
UiGridNoContentDirective,
8587
UiGridLoadingDirective,
8688
UiGridRowCardViewDirective,
89+
UiGridCustomSearchDirective,
8790
],
8891
})
8992
export class UiGridModule { }

0 commit comments

Comments
 (0)