Make filters and sorts work on record page pagination (#12460)
Fixes #7929 This PR implements a system to capture and preserve the filters and sorts when navigating from an index view to a record show page. This information is stored in a context store component state. This allows users to navigate between records inside the record page while maintaining context from the index view.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { MAIN_CONTEXT_STORE_INSTANCE_ID } from '@/context-store/constants/MainContextStoreInstanceId';
|
||||
import { contextStoreRecordShowParentViewComponentState } from '@/context-store/states/contextStoreRecordShowParentViewComponentState';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { useFilterValueDependencies } from '@/object-record/record-filter/hooks/useFilterValueDependencies';
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
import { getQueryVariablesFromFiltersAndSorts } from '../utils/getQueryVariablesFromFiltersAndSorts';
|
||||
|
||||
export const useQueryVariablesFromParentView = ({
|
||||
objectMetadataItem,
|
||||
}: {
|
||||
objectMetadataItem: ObjectMetadataItem;
|
||||
}) => {
|
||||
const recordShowParentView = useRecoilComponentValueV2(
|
||||
contextStoreRecordShowParentViewComponentState,
|
||||
MAIN_CONTEXT_STORE_INSTANCE_ID,
|
||||
);
|
||||
|
||||
const { filterValueDependencies } = useFilterValueDependencies();
|
||||
|
||||
const { filter, orderBy } = getQueryVariablesFromFiltersAndSorts({
|
||||
recordFilterGroups: recordShowParentView?.parentViewFilterGroups ?? [],
|
||||
recordFilters: recordShowParentView?.parentViewFilters ?? [],
|
||||
recordSorts: recordShowParentView?.parentViewSorts ?? [],
|
||||
objectMetadataItem,
|
||||
filterValueDependencies,
|
||||
});
|
||||
|
||||
return {
|
||||
filter,
|
||||
orderBy,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user