Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
johnvanbreda committed Nov 7, 2019
2 parents d92de51 + da1f7af commit fb7bc42
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 840 deletions.
4 changes: 4 additions & 0 deletions js/indicia.datacomponents/idc.esDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ var IdcEsDataSource;
source.hideAllSpinners(source);
alert('Elasticsearch query failed');
} else {
// Convert hits.total to Elasticsearch 7 style.
if (response.hits.total && indiciaData.esVersion === 6) {
response.hits.total = { value: response.hits.total, relation: 'eq' };
}
// Build any configured output tables.
source.buildTableXY(response);
$.each(indiciaData.outputPluginClasses, function eachPluginClass(i, pluginClass) {
Expand Down
8 changes: 5 additions & 3 deletions js/indicia.datacomponents/jquery.idc.dataGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,17 +638,19 @@
*/
function drawTableFooter(el, response, data, afterKey) {
var fromRowIndex = typeof data.from === 'undefined' ? 1 : (data.from + 1);
var ofLabel;
// Set up the count info in the footer.
if (!el.settings.aggregation) {
if (response.hits.hits.length > 0) {
ofLabel = response.hits.total.relation === 'gte' ? 'at least ' : '';
$(el).find('tfoot .showing').html('Showing ' + fromRowIndex +
' to ' + (fromRowIndex + (response.hits.hits.length - 1)) + ' of ' + response.hits.total);
' to ' + (fromRowIndex + (response.hits.hits.length - 1)) + ' of ' + ofLabel + response.hits.total.value);
} else {
$(el).find('tfoot .showing').html('No hits');
}
// Enable or disable the paging buttons.
$(el).find('.pager-row .prev').prop('disabled', fromRowIndex <= 1);
$(el).find('.pager-row .next').prop('disabled', fromRowIndex + response.hits.hits.length >= response.hits.total);
$(el).find('.pager-row .next').prop('disabled', fromRowIndex + response.hits.hits.length >= response.hits.total.value);
} else if (el.settings.aggregation === 'composite') {
if (afterKey) {
el.settings.compositeInfo.pageAfterKeys[el.settings.compositeInfo.page + 1] = afterKey;
Expand Down Expand Up @@ -970,7 +972,7 @@
if (el.settings.responsive) {
$(el).find('table').trigger('footable_redraw');
}
el.settings.totalRowCount = el.settings.aggregation ? null : response.hits.total;
el.settings.totalRowCount = el.settings.aggregation ? null : response.hits.total.value;
drawTableFooter(el, response, data, afterKey);
fireAfterPopulationCallbacks(el);
setColWidths(el, maxCharsPerCol);
Expand Down
13 changes: 9 additions & 4 deletions js/indicia.datacomponents/jquery.idc.esDownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
* Response body from the ES proxy containing progress data.
*/
function updateProgress(el, response) {
$(el).find('.progress-text').text(response.done + ' of ' + response.total);
animateTo(el, response.done / response.total);
$(el).find('.progress-text').text(response.done + ' of ' + response.total.value);
animateTo(el, response.done / response.total.value);
}

/**
Expand Down Expand Up @@ -112,7 +112,7 @@
var data = {
scroll_id: lastResponse.scroll_id
};
if (lastResponse.done < lastResponse.total) {
if (lastResponse.done < lastResponse.total.value) {
$.extend(data, getColumnSettings(el));
// Post to the ES proxy. Pass scroll_id parameter to request the next
// chunk of the dataset.
Expand All @@ -122,6 +122,11 @@
dataType: 'json',
data: data,
success: function success(response) {
// Patch response from V6 to behave like V7.
if (indiciaData.esVersion === 6) {
response.total = { value: response.total, relation: 'eq' };
}
response.done = Math.min(response.done, response.total.value);
updateProgress(el, response);
doPages(el, response);
}
Expand All @@ -137,7 +142,7 @@
$(el).find('.idc-download-files').append('<div><a href="' + lastResponse.filename + '">' +
'<span class="fas fa-file-archive fa-2x"></span>' +
'Download .zip file</a><br/>' +
'File containing ' + lastResponse.total + ' occurrences. Available until ' + hours + ':' + minutes + '</div>');
'File containing ' + lastResponse.total.value + ' occurrences. Available until ' + hours + ':' + minutes + '</div>');
$(el).find('.idc-download-files').fadeIn('med');
}
}
Expand Down
6 changes: 2 additions & 4 deletions js/indicia.datacomponents/jquery.idc.verificationButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,8 @@
setTimeout(function doPopulate() {
indiciaFns.populateDataSources();
}, 500);
} else {
if (response !== 'OK') {
alert('Indicia records update failed');
}
} else if (response !== 'OK') {
alert('Indicia records update failed');
}
}
).always(function cleanup() {
Expand Down
16 changes: 8 additions & 8 deletions js/indicia.locks.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
*/

/**
* @requires jquery.js, jquery.cookie.js, json2.js
* @requires jquery.js, jquery.cookie.js
*/

/**
* indicia.locks
*
*
* This is a library of support code for the indicia project. It implements the
* javascript for lockable form controls. These allow users to lock controls so
* the set values are reset as the control value when the form is redisplayed.
Expand All @@ -43,10 +43,10 @@

// 'constant' for the base cookie name for locks
var COOKIE_NAME = 'indicia_locked_controls';

// variable to indicate if locking initialised.
var initialised = false;

// variables to hold the tool-tips pumped in from PHP. This has to be done to
// support I18n.
var lockedTip = '';
Expand All @@ -60,7 +60,7 @@

// variables to hold reference to map div and spatial ref input
var mapDiv, srefId;

// variable to hold user name, or empty string for anonymous
var user = '';

Expand Down Expand Up @@ -320,9 +320,9 @@
if (srefId!==null && mapDiv!==null && escControlId===srefId) {
$(mapDiv).before('<div id="mapLockMask" style="position: absolute;"/>');
$('#mapLockMask').css({"opacity": "0.25", "background-color": "white",
"left":$(mapDiv).position().left + "px",
"top":$(mapDiv).position().top + "px",
"z-index":9999})
"left":$(mapDiv).position().left + "px",
"top":$(mapDiv).position().top + "px",
"z-index":9999})
.width($(mapDiv).width())
.height($(mapDiv).height());
}
Expand Down
2 changes: 1 addition & 1 deletion js/jquery.indiciaMapPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2358,7 +2358,7 @@ var destroyAllFeatures;
}
});
// Hide the Google layer if it is not the current base layer.
if (map.baseLayer !== olLayer) {
if (typeof olLayer !== 'undefined' && map.baseLayer !== olLayer) {
olLayer.display(false);
}
}
Expand Down
Loading

0 comments on commit fb7bc42

Please sign in to comment.