@@ -2,25 +2,37 @@ import React from 'react'
22import TextField from '@mui/material/TextField'
33import Button from '@mui/material/Button' ;
44
5- import orderBy from 'lodash/orderBy '
5+ import max from 'lodash/max '
66
77import { highlightTexts } from '../../common/utils' ;
88import SearchResults from '../search/SearchResults' ;
99import Mappings from './Mappings'
1010import Concept from './Concept'
1111
12- const SearchCandidates = ( { searchStr, setSearchStr, candidates, repo, repoVersion, rowIndex, concepts, setShowItem, showItem, isSelectedForMap, onMap} ) => {
12+ const SearchCandidates = ( { searchStr, setSearchStr, candidates, repo, repoVersion, rowIndex, concepts, setShowItem, showItem, isSelectedForMap, onMap, response, onSearch} ) => {
13+ let total = parseInt ( response ?. headers ?. num_found ) || concepts ?. length || 0
14+ const results = { total : total , pageSize : max ( [ parseInt ( response ?. headers ?. num_returned ) , 5 ] ) , page : parseInt ( response ?. headers ?. page_number ) , pages : parseInt ( response ?. headers ?. pages ) , results : response ?. data || [ ] }
15+
16+ const onKeyPress = event => {
17+ if ( event . key === 'Enter' ) {
18+ if ( searchStr )
19+ candidates ( event )
20+ }
21+ }
22+
1323 return (
1424 < div className = 'col-xs-12 padding-0' >
1525 < div className = 'col-xs-12 padding-0' style = { { display : 'flex' , alignItems : 'center' , margin : '16px 0' } } >
1626 < TextField
27+ autoFocus
1728 label = 'Search'
1829 sx = { { width : 'calc(100% - 90px)' } }
1930 required
2031 id = "search"
2132 value = { searchStr }
2233 onChange = { event => setSearchStr ( event . target . value || '' ) }
2334 size = 'small'
35+ onKeyDown = { onKeyPress }
2436 />
2537 < Button
2638 color = 'primary'
@@ -52,22 +64,20 @@ const SearchCandidates = ({searchStr, setSearchStr, candidates, repo, repoVersio
5264 renderer = { props => < Concept { ...props } onMap = { onMap } isSelectedForMap = { isSelectedForMap } noScore /> }
5365 display = 'card'
5466 nested
55- results = { {
56- results : orderBy ( concepts || [ ] , 'search_meta.search_score' , 'desc' ) ,
57- total : concepts ?. length
58- } }
67+ results = { results }
5968 resource = 'concepts'
60- noPagination
6169 noSorting
6270 noToolbar
63- resultContainerStyle = { { height : 'calc(100vh - 560px)' } }
71+ rowsPerPageOptions = { - 1 }
72+ resultContainerStyle = { { height : 'calc(100vh - 582px)' } }
6473 onShowItemSelect = { item => {
6574 setShowItem ( item )
6675 setTimeout ( ( ) => {
6776 highlightTexts ( [ item ] , null , false )
6877 } , 100 )
6978 } }
7079 selectedToShow = { showItem }
80+ onPageChange = { ( page , pageSize ) => onSearch ( null , page , pageSize ) }
7181 extraColumns = { [
7282 {
7383 sortable : false ,
0 commit comments