@@ -364,6 +364,67 @@ export function getCommonSuggests({ context, suggestStyle, rootPredicate }) {
364364 </ div >
365365 }
366366 } ,
367+ taxonKeyVernacular : {
368+ //What placeholder to show
369+ // placeholder: 'Search by scientific name',
370+ placeholder : 'search.placeholders.default' ,
371+ // how to get the list of suggestion data
372+ getSuggestions : ( { q, localeContext } ) => {
373+ const language = localeContext ?. localeMap ?. iso3LetterCode ?? 'eng' ;
374+ const SEARCH = `
375+ query($q: String, $language: Language){
376+ taxonSuggestions( q: $q, language: $language) {
377+ key
378+ scientificName
379+ vernacularName
380+ taxonomicStatus
381+ acceptedNameOf
382+ classification {
383+ name
384+ }
385+ }
386+ }
387+ ` ;
388+ const { promise, cancel } = client . query ( { query : SEARCH , variables : { q, language : language } } ) ;
389+ return {
390+ promise : promise . then ( response => {
391+ return {
392+ data : response . data ?. taxonSuggestions . map ( i => i ) ,
393+ }
394+ } ) ,
395+ cancel
396+ }
397+ } ,
398+ // how to map the results to a single string value
399+ getValue : suggestion => suggestion . scientificName ,
400+ // how to display the individual suggestions in the list
401+ render : function ScientificNameSuggestItem ( suggestion ) {
402+ const ranks = suggestion . classification . map ( ( rank , i ) => < span key = { i } > { rank . name } </ span > ) ;
403+
404+ const commonNameTranslation = formatMessage ( { id : `filterSupport.commonName` } ) ;
405+ const acceptedNameOfTranslation = formatMessage ( { id : `filterSupport.acceptedNameOf` } ) ;
406+
407+ return < div style = { { maxWidth : '100%' } } >
408+ < div style = { suggestStyle } >
409+ { suggestion . taxonomicStatus !== 'ACCEPTED' && < Tooltip title = { < span > < FormattedMessage id = { `enums.taxonomicStatus.${ suggestion . taxonomicStatus } ` } /> </ span > } >
410+ < span style = { { display : 'inline-block' , marginRight : 8 , width : 8 , height : 8 , borderRadius : 4 , background : 'orange' } } > </ span >
411+ </ Tooltip > }
412+ { suggestion . scientificName }
413+ </ div >
414+ { suggestion . vernacularName && < div style = { { marginBottom : 8 , color : '#888' , fontSize : '0.85em' , lineHeight : 1.2 } } >
415+ < div > { commonNameTranslation } : < span style = { { color : '#555' } } > { suggestion . vernacularName } </ span > </ div >
416+ </ div > }
417+ { ! suggestion . vernacularName && suggestion . acceptedNameOf && < div style = { { marginBottom : 8 , color : '#888' , fontSize : '0.85em' , lineHeight : 1.2 } } >
418+ < div > { acceptedNameOfTranslation } : < span style = { { color : '#555' } } > { suggestion . acceptedNameOf } </ span > </ div >
419+ </ div > }
420+ < div style = { { color : '#aaa' , fontSize : '0.85em' } } >
421+ < Classification >
422+ { ranks }
423+ </ Classification >
424+ </ div >
425+ </ div >
426+ }
427+ } ,
367428 eventTaxonKey : {
368429 //What placeholder to show
369430 // placeholder: 'Search by scientific name',
0 commit comments