From cb17319216da2478366d293c0897dcdb33834350 Mon Sep 17 00:00:00 2001 From: Serhii Zubkov Date: Sun, 18 Feb 2024 08:33:15 +0200 Subject: [PATCH] feat(reference): add props.searchProperty for reference fields --- src/frontend/components/property-type/reference/edit.tsx | 1 + src/frontend/components/property-type/reference/filter.tsx | 1 + src/frontend/utils/api-client.ts | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/frontend/components/property-type/reference/edit.tsx b/src/frontend/components/property-type/reference/edit.tsx index 9353ef996..e10783069 100644 --- a/src/frontend/components/property-type/reference/edit.tsx +++ b/src/frontend/components/property-type/reference/edit.tsx @@ -36,6 +36,7 @@ const Edit: FC = (props) => { const optionRecords = await api.searchRecords({ resourceId, query: inputValue, + searchProperty: property.props.searchProperty, }) return optionRecords.map((optionRecord: RecordJSON) => ({ value: optionRecord.id, diff --git a/src/frontend/components/property-type/reference/filter.tsx b/src/frontend/components/property-type/reference/filter.tsx index 167eae1e5..101031d53 100644 --- a/src/frontend/components/property-type/reference/filter.tsx +++ b/src/frontend/components/property-type/reference/filter.tsx @@ -22,6 +22,7 @@ const Filter: React.FC = (props) => { const records = await api.searchRecords({ resourceId: property.reference as string, query: inputValue, + searchProperty: property.props.searchProperty, }) const loadedOptions = records.map((r) => ({ value: r.id, label: r.title })) diff --git a/src/frontend/utils/api-client.ts b/src/frontend/utils/api-client.ts index 952d72dda..93c560653 100644 --- a/src/frontend/utils/api-client.ts +++ b/src/frontend/utils/api-client.ts @@ -143,7 +143,7 @@ class ApiClient { async searchRecords({ resourceId, query, searchProperty }: { resourceId: string; query: string; - searchProperty?: string; + searchProperty?: any; }): Promise> { if (globalAny.isOnServer) { return [] } const actionName = 'search' @@ -151,7 +151,7 @@ class ApiClient { resourceId, actionName, query, - ...(searchProperty ? { params: { searchProperty } } : undefined), + ...(searchProperty ? { params: { ...searchProperty } } : undefined), }) checkResponse(response) return response.data.records