Commit 076a804b authored by Matija Obreza's avatar Matija Obreza

Merge branch '290-stringarrfilter-copy-paste'

* 290-stringarrfilter-copy-paste:
  Handle pasting of multiple values to filters
parents 7c1f424f 7a55a75b
...@@ -377,7 +377,7 @@ ...@@ -377,7 +377,7 @@
"f": { "f": {
"_text": "Full-text query", "_text": "Full-text query",
"_textPlaceholder": "\"IRGC 1000\"", "_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.", "_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), asterisk to match a prefix (IRGC*) and parentheses for grouping. For more information click the ? icon above.",
"crop": "Crop", "crop": "Crop",
"filtersTitle": "Filter accessions", "filtersTitle": "Filter accessions",
"seqNumber": "Sequential number", "seqNumber": "Sequential number",
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"f": { "f": {
"_text": "Full-text query", "_text": "Full-text query",
"_textPlaceholder": "\"IRGC 1000\"", "_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.", "_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), asterisk to match a prefix (IRGC*) and parentheses for grouping. For more information click the ? icon above.",
"crop": "Crop", "crop": "Crop",
"filtersTitle": "Filter accessions", "filtersTitle": "Filter accessions",
"seqNumber": "Sequential number", "seqNumber": "Sequential number",
......
...@@ -243,6 +243,17 @@ class AutocompleteFilterInternal extends React.Component<IAutocompleteFilterInte ...@@ -243,6 +243,17 @@ class AutocompleteFilterInternal extends React.Component<IAutocompleteFilterInte
} }
} }
private dataPasted = (e) => {
const data = e.clipboardData.getData('text/plain');
const dataArr = data.split(/[,\n;]/).map((item) => item.trim());
if (dataArr && dataArr.length > 1) {
e.preventDefault();
const values = this.maybeAdd(...dataArr);
const { input } = _.get(this.props, this.props.names[0]);
input.onChange(values);
}
}
private onSuggestionSelected = (e, data, autocompleteInput, that) => { private onSuggestionSelected = (e, data, autocompleteInput, that) => {
autocompleteInput.onChange.call(that, ''); autocompleteInput.onChange.call(that, '');
const { input } = _.get(this.props, this.props.names[0]); const { input } = _.get(this.props, this.props.names[0]);
...@@ -262,6 +273,7 @@ class AutocompleteFilterInternal extends React.Component<IAutocompleteFilterInte ...@@ -262,6 +273,7 @@ class AutocompleteFilterInternal extends React.Component<IAutocompleteFilterInte
component={ MaterialAutosuggest } component={ MaterialAutosuggest }
label={ label } label={ label }
placeholder={ placeholder } placeholder={ placeholder }
onPaste={ this.dataPasted }
onChange={ debounce(this.onInputChange, 1000) } onChange={ debounce(this.onInputChange, 1000) }
suggestions={ this.state.autocompleteObj } suggestions={ this.state.autocompleteObj }
onSuggestionSelected={ this.onSuggestionSelected } onSuggestionSelected={ this.onSuggestionSelected }
......
...@@ -261,6 +261,17 @@ class InternalStringArrField extends React.Component<IStringArrFilterInternal & ...@@ -261,6 +261,17 @@ class InternalStringArrField extends React.Component<IStringArrFilterInternal &
input.onChange(values); input.onChange(values);
} }
private dataPasted = (e) => {
const data = e.clipboardData.getData('text/plain');
const dataArr = data.split(/[,\n;]/).map((item) => item.trim());
if (dataArr && dataArr.length > 1) {
e.preventDefault();
const values = this.maybeAdd(...dataArr);
const { input } = _.get(this.props, this.props.names[0]);
input.onChange(values);
}
}
private handleCheckbox = (event) => { private handleCheckbox = (event) => {
const { input } = _.get(this.props, this.props.names[0]); const { input } = _.get(this.props, this.props.names[0]);
const value = event.target.value; const value = event.target.value;
...@@ -386,6 +397,7 @@ class InternalStringArrField extends React.Component<IStringArrFilterInternal & ...@@ -386,6 +397,7 @@ class InternalStringArrField extends React.Component<IStringArrFilterInternal &
placeholder={ placeholder ? t(`${placeholder}`) : '' } placeholder={ placeholder ? t(`${placeholder}`) : '' }
onKeyPress={ this.handleKeyPres } onKeyPress={ this.handleKeyPres }
onBlur={ this.handleAddCurrent } onBlur={ this.handleAddCurrent }
onPaste={ this.dataPasted }
endAdornment={ endAdornment={
<InputAdornment position="end"> <InputAdornment position="end">
<IconButton type="button" onClick={ this.handleAddCurrent }> <IconButton type="button" onClick={ this.handleAddCurrent }>
......
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