11import { useContext , useCallback , useReducer } from 'react' ;
22
3+ import { getAdminUiConfig } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper' ;
4+
35import { findLocationsBySearchQuery } from '../services/universal.discovery.service' ;
46import { RestInfoContext , LoadedLocationsMapContext } from '../universal.discovery.module' ;
57
@@ -21,6 +23,7 @@ const searchByQueryReducer = (state, action) => {
2123} ;
2224
2325export const useSearchByQueryFetch = ( ) => {
26+ const { damWidget : damWidgetConfig } = getAdminUiConfig ( ) ;
2427 const restInfo = useContext ( RestInfoContext ) ;
2528 const [ , dispatchLoadedLocationsAction ] = useContext ( LoadedLocationsMapContext ) ;
2629 const [ { isLoading, data } , dispatch ] = useReducer ( searchByQueryReducer , { isLoading : false , data : { } } ) ;
@@ -75,12 +78,20 @@ export const useSearchByQueryFetch = () => {
7578 const isImageCriterionDataEmpty = ! imageCriterionData || Object . keys ( imageCriterionData ) . length === 0 ;
7679
7780 if ( ! isImageCriterionDataEmpty ) {
78- const imageCriterion = {
79- fieldDefIdentifier : 'image' ,
80- ...imageCriterionData ,
81+ const imagesCriterion = damWidgetConfig . image . fieldDefinitionIdentifiers . reduce (
82+ ( criterions , fieldDefinitionIdentifier ) => [
83+ ...criterions ,
84+ {
85+ fieldDefIdentifier : fieldDefinitionIdentifier ,
86+ ...imageCriterionData ,
87+ } ,
88+ ] ,
89+ [ ] ,
90+ ) ;
91+
92+ query . OR = {
93+ ImageCriterion : imagesCriterion ,
8194 } ;
82-
83- query . ImageCriterion = imageCriterion ;
8495 }
8596
8697 dispatch ( { type : SEARCH_START } ) ;
0 commit comments