Skip to content

Commit df72066

Browse files
committed
Merge branch 'feature/filters-visability-handling' of https://github.com/devforth/adminforth into feature/filters-visability-handling
2 parents 5a3386e + c567845 commit df72066

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

adminforth/documentation/docs/tutorial/03-Customization/08-pageInjections.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ Now create file `ApartsPie.vue` in the `custom` folder of your project:
3737
:options="{
3838
chart: {
3939
height: 250,
40+
events: {
41+
dataPointSelection: function (event, chartContext, config) {
42+
if (config.selectedDataPoints[0].length) {
43+
const selectedRoomsCount = data[config.dataPointIndex].rooms;
44+
adminforth.list.updateFilter({field: 'number_of_rooms', operator: 'eq', value: selectedRoomsCount});
45+
} else {
46+
// clear filter
47+
adminforth.list.updateFilter({field: 'number_of_rooms', value: undefined});
48+
}
49+
}
50+
}
4051
},
4152
dataLabels: {
4253
enabled: true,

adminforth/spa/src/afcl/Table.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<table class="afcl-table w-full text-sm text-left rtl:text-right text-lightTableText dark:text-darkTableText overflow-x-auto">
55
<thead class="afcl-table-thread text-xs text-lightTableHeadingText uppercase bg-lightTableHeadingBackground dark:bg-darkTableHeadingBackground dark:text-darkTableHeadingText">
66
<tr>
7-
<th scope="col" class="px-6 py-3" ref="headerRefs"
7+
<th scope="col" class="px-6 py-3" ref="headerRefs" :key="`header-${column.fieldName}`"
88
v-for="column in columns"
99
>
1010
<slot v-if="$slots[`header:${column.fieldName}`]" :name="`header:${column.fieldName}`" :column="column" />
@@ -34,13 +34,14 @@
3434
<tr
3535
v-else="!isLoading"
3636
v-for="(item, index) in dataPage"
37+
:key="`row-${index}`"
3738
ref="rowRefs"
3839
:class="{
3940
'afcl-table-body odd:bg-lightTableOddBackground odd:dark:bg-darkTableOddBackground even:bg-lightTableEvenBackground even:dark:bg-darkTableEvenBackground': evenHighlights,
4041
'border-b border-lightTableBorder dark:border-darkTableBorder': index !== dataPage.length - 1 || totalPages > 1,
4142
}"
4243
>
43-
<td class="px-6 py-4"
44+
<td class="px-6 py-4" :key="`cell-${index}-${column.fieldName}`"
4445
v-for="column in props.columns"
4546
>
4647
<slot v-if="$slots[`cell:${column.fieldName}`]"

adminforth/types/FrontendAPI.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@ export interface FrontendAPIInterface {
8282
*/
8383
closeThreeDotsDropdown(): void;
8484

85-
8685
/**
87-
* Set a filter in the list
88-
* Works only when user located on the list page.
86+
* Set a filter in the list.
87+
* Works only when user located on the list page. If filter already exists, it will be replaced with the new one.
8988
* Can be used to set filter from charts or other components in pageInjections.
9089
*
9190
* Filters are automatically marked as hidden (won't count in badge) if:
@@ -103,11 +102,15 @@ export interface FrontendAPIInterface {
103102
* adminforth.list.setFilter({field: 'internal_status', operator: 'eq', value: 'active'})
104103
* ```
105104
*
105+
* Please note that you can set/update filter even for fields which have showIn.filter=false in resource configuration.
106+
* Also you can set filter for virtual columns. For example Universal search plugin calls updateFilter for virtual column which has showIn.filter=false (because we dont want to show this column in filter dropdown, plugin renders its own filter UI)
107+
*
106108
* @param filter - The filter to set
107109
*/
108110
setFilter(filter: FilterParams): void;
109111

110112
/**
113+
* DEPRECATED: does the same as setFilter, kept for backward compatibility
111114
* Update a filter in the list
112115
*
113116
* Filters visibility in badge is automatically determined by column configuration:

0 commit comments

Comments
 (0)