Skip to content

Commit

Permalink
Configure advanced search on notification templates list
Browse files Browse the repository at this point in the history
  • Loading branch information
mabashian committed Dec 7, 2020
1 parent 459c8da commit 668569e
Showing 1 changed file with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,41 @@ function NotificationTemplatesList({ i18n }) {
const addUrl = `${match.url}/add`;

const {
result: { templates, count, actions },
result: {
templates,
count,
actions,
relatedSearchableKeys,
searchableKeys,
},
error: contentError,
isLoading: isTemplatesLoading,
request: fetchTemplates,
} = useRequest(
useCallback(async () => {
const params = parseQueryString(QS_CONFIG, location.search);
const responses = await Promise.all([
const [response, actionsResponse] = await Promise.all([
NotificationTemplatesAPI.read(params),
NotificationTemplatesAPI.readOptions(),
]);
return {
templates: responses[0].data.results,
count: responses[0].data.count,
actions: responses[1].data.actions,
templates: response.data.results,
count: response.data.count,
actions: actionsResponse.data.actions,
relatedSearchableKeys: (
actionsResponse.data?.related_search_fields || []
).map(val => val.slice(0, -8)),
searchableKeys: Object.keys(
actionsResponse.data.actions?.GET || {}
).filter(key => actionsResponse.data.actions?.GET[key].filterable),
};
}, [location]),
{
templates: [],
count: 0,
actions: {},
relatedSearchableKeys: [],
searchableKeys: [],
}
);

Expand Down Expand Up @@ -133,6 +147,8 @@ function NotificationTemplatesList({ i18n }) {
key: 'modified_by__username__icontains',
},
]}
toolbarSearchableKeys={searchableKeys}
toolbarRelatedSearchableKeys={relatedSearchableKeys}
toolbarSortColumns={[
{
name: i18n._(t`Name`),
Expand Down

0 comments on commit 668569e

Please sign in to comment.