Skip to content

Commit e750a47

Browse files
authored
feat: added filter record option when context datasource is coming from a resource (#2022)
1 parent ecb9e5c commit e750a47

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

apps/back-office/src/app/dashboard/pages/dashboard/dashboard.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ <h1 class="!m-0 overflow-hidden text-ellipsis">
140140
<ui-graphql-select
141141
[query]="recordsQuery"
142142
[formControl]="contextId"
143+
[filterable]="true"
144+
(searchChange)="onSearchChange($event)"
143145
path="records"
144146
valueField="id"
145147
textField="data.{{ dashboard.page.context.displayField }}"

apps/back-office/src/app/dashboard/pages/dashboard/dashboard.component.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,4 +846,32 @@ export class DashboardComponent
846846
subscription?.unsubscribe();
847847
});
848848
}
849+
850+
/**
851+
* Update query based on text search.
852+
*
853+
* @param search Search text from the graphql select
854+
*/
855+
public onSearchChange(search: string): void {
856+
const context = this.dashboard?.page?.context;
857+
if (!context) return;
858+
if ('resource' in context) {
859+
this.recordsQuery.refetch({
860+
variables: {
861+
first: ITEMS_PER_PAGE,
862+
id: context.resource,
863+
},
864+
filter: {
865+
logic: 'and',
866+
filters: [
867+
{
868+
field: context.displayField,
869+
operator: 'contains',
870+
value: search,
871+
},
872+
],
873+
},
874+
});
875+
}
876+
}
849877
}

0 commit comments

Comments
 (0)