Skip to content

Commit

Permalink
Add num results
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jul 13, 2018
1 parent 770eb04 commit a10f2a9
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/JBrowse/View/Dialog/Search.js
Expand Up @@ -92,6 +92,7 @@ function (
onClick: dojo.hitch(dialog, 'hide')
}).placeAt(this.actionBar);

this.numResults = dojo.create('div', { id: 'numResults', style: {margin: '10px'} }, container);
this.errResults = dojo.create('div', { id: 'errResults', style: {margin: '10px', color: 'red'} }, container);
dialog.set('content', [ container, this.actionBar ]);

Expand All @@ -111,9 +112,18 @@ function (
},
searchBoxProcess: function() {
var loc = this.searchBox.get('value');
this.numResults.innerHTML = '';
if (!this.exactCheckbox.checked) {
loc += "*";
}
function handleError() {
console.error(error);
var g = this.locationListView.grid;
(g.store || g.collection).setData([]);
g.refresh();
this.errResults.innerHTML = 'Error: ' + err;
this.numResults.innerHTML = '';
}
this.browser.nameStore.query({ name: loc }).then((nameMatches) => {
var promises = nameMatches.map((match) => this.browser.nameStore.query({ name: match.name }));
Promise.all(promises).then((res) => {
Expand Down Expand Up @@ -145,18 +155,13 @@ function (
}
}
}
this.numResults.innerHTML = "Num. results: " + grid.length;
var g = this.locationListView.grid;
(g.store || g.collection).setData(grid);
g.refresh();
this.errResults.innerHTML = '';
});
}, (err) => {
console.error(err);
var g = this.locationListView.grid;
(g.store || g.collection).setData([]);
g.refresh();
this.errResults.innerHTML = 'Error: ' + err;
});
}, dojo.hitch(this, handleError));
}, dojo.hitch(this, handleError));
}
});
});

0 comments on commit a10f2a9

Please sign in to comment.