Commit 7a55a75b authored by Matija Obreza's avatar Matija Obreza

Handle pasting of multiple values to filters

parent 639d2e45
......@@ -377,7 +377,7 @@
"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.",
"_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",
"filtersTitle": "Filter accessions",
"seqNumber": "Sequential number",
......
......@@ -13,7 +13,7 @@
"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.",
"_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",
"filtersTitle": "Filter accessions",
"seqNumber": "Sequential number",
......
......@@ -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) => {
autocompleteInput.onChange.call(that, '');
const { input } = _.get(this.props, this.props.names[0]);
......@@ -262,6 +273,7 @@ class AutocompleteFilterInternal extends React.Component<IAutocompleteFilterInte
component={ MaterialAutosuggest }
label={ label }
placeholder={ placeholder }
onPaste={ this.dataPasted }
onChange={ debounce(this.onInputChange, 1000) }
suggestions={ this.state.autocompleteObj }
onSuggestionSelected={ this.onSuggestionSelected }
......
......@@ -261,6 +261,17 @@ class InternalStringArrField extends React.Component<IStringArrFilterInternal &
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) => {
const { input } = _.get(this.props, this.props.names[0]);
const value = event.target.value;
......@@ -386,6 +397,7 @@ class InternalStringArrField extends React.Component<IStringArrFilterInternal &
placeholder={ placeholder ? t(`${placeholder}`) : '' }
onKeyPress={ this.handleKeyPres }
onBlur={ this.handleAddCurrent }
onPaste={ this.dataPasted }
endAdornment={
<InputAdornment position="end">
<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