Fix filter displayed value from query params (#9693)
Filter displayed value that use query params was broken. Recently we
added a new type of filters using the schema `{ selectedRecordIds:
string[] }` while before we were using `string[]` directly.
In that case, when fetching relation record name, we need to fix the
findManyRecord query.
Before
<img width="1512" alt="Capture d’écran 2025-01-16 à 16 10 33"
src="https://github.com/user-attachments/assets/36dc8c4f-91a4-438f-8480-bc237745a59e"
/>
After
<img width="1512" alt="Capture d’écran 2025-01-16 à 16 04 43"
src="https://github.com/user-attachments/assets/544512a3-0ef9-4d3e-993b-a4416737ab53"
/>
This commit is contained in:
@ -112,12 +112,18 @@ export const useViewFromQueryParams = () => {
|
|||||||
.getValue()
|
.getValue()
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
const satisfiesRelationFilterSchema =
|
||||||
|
relationFilterValueSchemaObject.safeParse(
|
||||||
|
filterValueFromURL,
|
||||||
|
)?.success;
|
||||||
|
|
||||||
const relationRecordNames = [];
|
const relationRecordNames = [];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
isNonEmptyString(relationObjectMetadataNamePlural) &&
|
isNonEmptyString(relationObjectMetadataNamePlural) &&
|
||||||
isDefined(relationObjectMetadataItem) &&
|
isDefined(relationObjectMetadataItem) &&
|
||||||
Array.isArray(filterValueFromURL)
|
(Array.isArray(filterValueFromURL) ||
|
||||||
|
satisfiesRelationFilterSchema)
|
||||||
) {
|
) {
|
||||||
const queryResult = await apolloClient.query<
|
const queryResult = await apolloClient.query<
|
||||||
Record<string, { edges: { node: ObjectRecord }[] }>
|
Record<string, { edges: { node: ObjectRecord }[] }>
|
||||||
@ -127,7 +133,17 @@ export const useViewFromQueryParams = () => {
|
|||||||
objectMetadataItems,
|
objectMetadataItems,
|
||||||
}),
|
}),
|
||||||
variables: {
|
variables: {
|
||||||
filter: { id: { in: filterValueFromURL } },
|
filter: {
|
||||||
|
id: {
|
||||||
|
in: satisfiesRelationFilterSchema
|
||||||
|
? (
|
||||||
|
filterValueFromURL as {
|
||||||
|
selectedRecordIds: string[];
|
||||||
|
}
|
||||||
|
)?.selectedRecordIds
|
||||||
|
: filterValueFromURL,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -5,15 +5,15 @@ import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSi
|
|||||||
import { modifyRecordFromCache } from '@/object-record/cache/utils/modifyRecordFromCache';
|
import { modifyRecordFromCache } from '@/object-record/cache/utils/modifyRecordFromCache';
|
||||||
import { DEACTIVATE_WORKFLOW_VERSION } from '@/workflow/graphql/mutations/deactivateWorkflowVersion';
|
import { DEACTIVATE_WORKFLOW_VERSION } from '@/workflow/graphql/mutations/deactivateWorkflowVersion';
|
||||||
import {
|
import {
|
||||||
ActivateWorkflowVersionMutation,
|
DeactivateWorkflowVersionMutation,
|
||||||
ActivateWorkflowVersionMutationVariables,
|
DeactivateWorkflowVersionMutationVariables,
|
||||||
} from '~/generated/graphql';
|
} from '~/generated/graphql';
|
||||||
|
|
||||||
export const useDeactivateWorkflowVersion = () => {
|
export const useDeactivateWorkflowVersion = () => {
|
||||||
const apolloClient = useApolloClient();
|
const apolloClient = useApolloClient();
|
||||||
const [mutate] = useMutation<
|
const [mutate] = useMutation<
|
||||||
ActivateWorkflowVersionMutation,
|
DeactivateWorkflowVersionMutation,
|
||||||
ActivateWorkflowVersionMutationVariables
|
DeactivateWorkflowVersionMutationVariables
|
||||||
>(DEACTIVATE_WORKFLOW_VERSION, {
|
>(DEACTIVATE_WORKFLOW_VERSION, {
|
||||||
client: apolloClient,
|
client: apolloClient,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user