Local search (#220)
* Version Bump * local search skeleton * Added WaitService middleware * Return matching queries * wait action middleware rename/refactor * bigger debounce time * Fix: Initialize state using Immutable * Local Search without integrations * Local Search refactor: Keep state in closure, recurse * “string” should be treated as the default widget by the inference. Closes #199
This commit is contained in:
@ -37,7 +37,7 @@ class RelationControl extends Component {
|
||||
const { value, field } = this.props;
|
||||
if (value) {
|
||||
const collection = field.get('collection');
|
||||
const searchFields = field.get('searchFields').map(f => `data.${ f }`).toJS();
|
||||
const searchFields = field.get('searchFields').toJS();
|
||||
this.props.query(this.controlID, collection, searchFields, value);
|
||||
}
|
||||
}
|
||||
@ -67,32 +67,14 @@ class RelationControl extends Component {
|
||||
if (value.length < 2) return;
|
||||
const { field } = this.props;
|
||||
const collection = field.get('collection');
|
||||
const searchFields = field.get('searchFields').map(f => `data.${ f }`).toJS();
|
||||
const searchFields = field.get('searchFields').toJS();
|
||||
this.props.query(this.controlID, collection, searchFields, value);
|
||||
}, 80);
|
||||
}, 100);
|
||||
|
||||
onSuggestionsClearRequested = () => {
|
||||
this.props.clearSearch();
|
||||
};
|
||||
|
||||
getMatchingHits = (value) => {
|
||||
const { field, queryHits } = this.props;
|
||||
const searchFields = field.get('searchFields').toJS();
|
||||
const escapedValue = escapeRegexCharacters(value.trim());
|
||||
const regex = new RegExp(`^ ${ escapedValue }`, 'i');
|
||||
|
||||
if (escapedValue === '') {
|
||||
return [];
|
||||
}
|
||||
return queryHits.get(this.controlID).filter((hit) => {
|
||||
let testResult = false;
|
||||
searchFields.forEach((f) => {
|
||||
testResult = testResult || regex.test(hit.data[f]);
|
||||
});
|
||||
return testResult;
|
||||
});
|
||||
};
|
||||
|
||||
getSuggestionValue = (suggestion) => {
|
||||
const { field } = this.props;
|
||||
const valueField = field.get('valueField');
|
||||
|
Reference in New Issue
Block a user