Commit 9229952b authored by Matija Obreza's avatar Matija Obreza

Added full-text search to Accession Browser

parent a009e779
......@@ -41,6 +41,7 @@
"ge": "{{what}} ≥",
"lt": "{{what}} <",
"gt": "{{what}} >",
"_text": "Full-text",
"accessions": {
"crop": "Crop",
"crops": "Crops",
......@@ -374,6 +375,9 @@
}
},
"f": {
"_text": "Full-text query",
"_textPlaceholder": "\"IRGC 1000\"",
"_textHint": "Note: A full-text search query does not result in a 100% match. Double quotes may be used to specify a phrase (\"IRGC 100\"). Use | as OR operator (IRGC | TMp), asterix to match a prefix (IRGC*) and parentheses for grouping. For more information click the ? icon above.",
"crop": "Crop",
"filtersTitle": "Filter accessions",
"seqNumber": "Sequential number",
......
......@@ -11,6 +11,9 @@
}
},
"f": {
"_text": "Full-text query",
"_textPlaceholder": "\"IRGC 1000\"",
"_textHint": "Note: A full-text search query does not result in a 100% match. Double quotes may be used to specify a phrase (\"IRGC 100\"). Use | as OR operator (IRGC | TMp), asterix to match a prefix (IRGC*) and parentheses for grouping. For more information click the ? icon above.",
"crop": "Crop",
"filtersTitle": "Filter accessions",
"seqNumber": "Sequential number",
......
......@@ -16,6 +16,7 @@ import Accession from 'model/accession/Accession';
import DateFilter from 'ui/common/filter/DateFilter';
import BooleanFilter from 'ui/common/filter/BooleanFilter';
import { autocomplete } from 'accessions/actions/public';
import TextFilter from 'ui/common/filter/TextFilter';
const AccessionFilters = ({handleSubmit, initialValues, initialize, filterCode, autocomplete, terms, crops, t, ...other}) => {
// console.log('AccessionFilters', initialValues);
......@@ -29,6 +30,11 @@ const AccessionFilters = ({handleSubmit, initialValues, initialize, filterCode,
/>
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title={ t('common:f.textSearch') }>
<TextFilter name="_text"
label={ t('accessions.public.f._text') }
placeholder={ t('accessions.public.f._textPlaceholder') }
hint={ t('accessions.public.f._textHint') }
/>
<AutocompleteFilter
filterCode={ filterCode }
autocomplete={ autocomplete }
......
......@@ -10,6 +10,7 @@ import AccessionGeoFilter from './AccessionGeoFilter';
* Defined in Swagger as '#/definitions/AccessionFilter'
*/
class AccessionFilter {
public _text?: string;
public accessionNumber?: StringFilter;
public aliases?: StringFilter;
public active?: boolean;
......
......@@ -41,6 +41,7 @@
"ge": "{{what}} ≥",
"lt": "{{what}} <",
"gt": "{{what}} >",
"_text": "Full-text",
"accessions": {
"crop": "Crop",
"crops": "Crops",
......
......@@ -165,7 +165,10 @@ class AutocompleteFilterInternal extends React.Component<IAutocompleteFilterInte
private maybeAdd = (...newValues: string[]) => {
const values = [ ...this.state.values ];
const excludedValues = [ ...this.state.excludedValues ];
const excludedValues = [ ];
if (this.state.excludedValues) {
excludedValues.push(...this.state.excludedValues);
}
newValues.forEach((text) => {
if (text && text.length > 0) {
......
......@@ -2,12 +2,15 @@ import * as React from 'react';
import {translate} from 'react-i18next';
import { Field } from 'redux-form';
import FormControl from 'ui/common/forms/FormControl';
import TextField from '@material-ui/core/TextField';
import { FormHelperText } from '@material-ui/core';
interface ITextFilterInternal extends React.ClassAttributes<any> {
input: any;
label: string;
placeholder?: string;
hint?: any;
t: any;
}
......@@ -37,9 +40,9 @@ class TextFilterInternal extends React.Component<ITextFilterInternal, any> {
}
public render() {
const { label, placeholder, t } = this.props;
const { label, placeholder, t, hint } = this.props;
return (
<div>
<FormControl fullWidth>
<TextField
className="full-width"
label={ label }
......@@ -47,7 +50,10 @@ class TextFilterInternal extends React.Component<ITextFilterInternal, any> {
placeholder={ t(placeholder) }
onChange={ this.handleChange }
/>
</div>
{ hint && <FormHelperText>
<span>{ hint }</span>
</FormHelperText> }
</FormControl>
);
}
}
......
......@@ -76,7 +76,7 @@ const styles = (theme) => ({
}
},
sidebar: {
whiteSpace: 'nowrap' as 'nowrap',
// whiteSpace: 'nowrap' as 'nowrap',
minWidth: '360px',
'html[dir="rtl"] &' : {
minWidth: '420px',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment