Skip to content

Commit

Permalink
Merge pull request #1182 from VirtualFlyBrain/feature/1179
Browse files Browse the repository at this point in the history
Feature/1179 - Fixes complicated layout and autocomplete
  • Loading branch information
ddelpiano authored Sep 24, 2021
2 parents 09fda4c + a9786ac commit 8ffdbb1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function refineResults(e) {
}

export const datasourceConfiguration = {
"url": "https://solr.virtualflybrain.org/solr/ontology/select",
"url": "https://solr-dev.virtualflybrain.org/solr/ontology/select",
"query_settings":
{
"q": "$SEARCH_TERM$ OR $SEARCH_TERM$* OR *$SEARCH_TERM$*",
Expand Down
29 changes: 13 additions & 16 deletions components/interface/VFBCircuitBrowser/Controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,45 +146,42 @@ class AutocompleteResults extends Component {
super(props);
this.state = { filteredResults: {} };
this.handleResults = this.handleResults.bind(this);
this.fieldLabel = this.props.field.label;
}

/**
* Receives SOLR results and creates an map with those results that match the input text
*/
handleResults (status, data, value){
let results = {};
console.log("Status ", status)
console.log("Data ", data)
console.log("Value ", value)
data?.map(result => {
// Match results by short_form id
if ( result?.short_form?.toLowerCase().includes(value?.toLowerCase()) ){
results[result?.label] = result;
} else if ( result?.label?.toLowerCase().includes(value?.toLowerCase()) ){
results[result?.label] = result;
}
results[result?.label] = result;
});

console.log("Results ", results)


this.setState({ filteredResults : results });
}

getFilteredResults (){
return this.state.filteredResults;
}

shouldComponentUpdate(nextProps, nextState) {
this.fieldLabel = nextProps.getLatestNeuronFields()[this.props.index].label;
return true;
}

render () {
const label = "Neuron " + (this.props.index + 1) .toString();

const options = Object.keys(this.state.filteredResults).map(option => this.state.filteredResults[option].label);

return (
<Autocomplete
fullWidth
freeSolo
disableClearable
disablePortal
autoHighlight
value={this.props.field.label}
value={this.fieldLabel}
id={this.props.index.toString()}
ListboxProps={{ style: { maxHeight: "10rem" } }}
onChange={this.props.resultSelectedChanged}
Expand Down Expand Up @@ -339,7 +336,6 @@ class Controls extends Component {
* Neuron text field has been modified.
*/
neuronTextfieldModified (event) {
console.log(event.key);
this.resultsHeight = event.target.offsetTop + 15;
// Remove old typing timeout interval
if (this.state.typingTimeout) {
Expand Down Expand Up @@ -444,7 +440,7 @@ class Controls extends Component {
const { classes } = this.props;
this.circuitQuerySelected = this.props.circuitQuerySelected;
let neuronFields = this.getUpdatedNeuronFields();

let expanded = this.state.expanded;
if ( this.props.resultsAvailable() ){
expanded = true;
Expand Down Expand Up @@ -503,6 +499,7 @@ class Controls extends Component {
field={field}
index={index}
neuronTextfieldModified={this.neuronTextfieldModified}
getLatestNeuronFields={this.getUpdatedNeuronFields}
resultSelectedChanged={(event, value) => this.resultSelectedChanged(event, value, index)}
ref={this.autocompleteRef[index.toString()]}
/>
Expand Down
4 changes: 3 additions & 1 deletion components/interface/VFBCircuitBrowser/QueryParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export function queryParser (e) {
if (allRelationships.get(parseInt(startNode)) === undefined) {
allRelationships.set(parseInt(startNode), new Array());
}
allRelationships?.get(parseInt(startNode))?.push( { target : parseInt(endNode), label : properties[e.data.params.configuration.resultsMapping.link.label], weight : properties[e.data.params.configuration.resultsMapping.link.weight] });
if ( data[0]?.row[3].includes(parseInt(id)) ) {
allRelationships?.get(parseInt(startNode))?.push( { target : parseInt(endNode), label : properties[e.data.params.configuration.resultsMapping.link.label], weight : properties[e.data.params.configuration.resultsMapping.link.weight] });
}
});
});

Expand Down

0 comments on commit 8ffdbb1

Please sign in to comment.