1

Handle null return value from request

This commit is contained in:
Alex Yatskov 2015-08-24 16:29:28 +09:00
parent 56259e1c58
commit 90522c0f50

View File

@ -141,6 +141,8 @@
} }
function outputSnapshot(results, omitValues) { function outputSnapshot(results, omitValues) {
var records = results.records || [];
_ctx.query.minScore = results.minScore; _ctx.query.minScore = results.minScore;
$('#minScore').val(results.minScore); $('#minScore').val(results.minScore);
@ -153,8 +155,8 @@
_ctx.grapher.setColumns(columns); _ctx.grapher.setColumns(columns);
var searchResultCnt = String(results.records.length); var searchResultCnt = String(records.length);
if (results.records.length < results.count) { if (records.length < results.count) {
searchResultCnt += ' of ' + results.count; searchResultCnt += ' of ' + results.count;
} }
$('#resultCount').text(searchResultCnt); $('#resultCount').text(searchResultCnt);
@ -162,7 +164,7 @@
var template = Handlebars.compile($('#template').html()); var template = Handlebars.compile($('#template').html());
$('#records').empty(); $('#records').empty();
$('#records').append(template({records: results.records})); $('#records').append(template({records: records}));
$('span.sort-icon').css('visibility', 'hidden'); $('span.sort-icon').css('visibility', 'hidden');
var currentColumn = $('span.sort-icon[data-sort="' + _ctx.sortKey + '"]').css('visibility', 'visible'); var currentColumn = $('span.sort-icon[data-sort="' + _ctx.sortKey + '"]').css('visibility', 'visible');
@ -173,7 +175,7 @@
currentColumn.removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down'); currentColumn.removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');
} }
if (results.records.length === 0) { if (records.length === 0) {
$('#resultPanel').slideUp(); $('#resultPanel').slideUp();
} }
else { else {