Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
johnvanbreda committed Jan 15, 2020
2 parents ec75fa3 + 3db7834 commit 2f7bc33
Show file tree
Hide file tree
Showing 12 changed files with 654 additions and 193 deletions.
23 changes: 14 additions & 9 deletions css/theme-bootstrap-3.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion css/theme-bootstrap-3.css.map

Large diffs are not rendered by default.

46 changes: 37 additions & 9 deletions css/theme-generic.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion css/theme-generic.css.map

Large diffs are not rendered by default.

24 changes: 21 additions & 3 deletions js/indicia.datacomponents/idc.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
*/
indiciaData.esSourceObjects = {};

/**
* List of the user filters we've used, so we can refresh cache appropriately.
*/
indiciaData.esUserFiltersLoaded = [];

/**
* Font Awesome icon and other classes for record statuses and flags.
*/
Expand Down Expand Up @@ -425,7 +430,7 @@
query = 'metadata.website.id:' + parts[0].trim();
// Search can optionally include the survey ID.
if (parts.length > 1 && parts[1].trim() !== '') {
query += 'AND metadata.survey.id:' + parts[1].trim();
query += ' AND metadata.survey.id:' + parts[1].trim();
}
return query;
}
Expand All @@ -447,6 +452,12 @@
field: 'event.year',
format: '{1}'
},
{
// yyyy format.
pattern: '(\\d{4})-(\\d{4})',
field: 'event.year',
format: '[{1} TO {2}]'
},
{
// dd/mm/yyyy format.
pattern: '(\\d{2})\\/(\\d{2})\\/(\\d{4})',
Expand Down Expand Up @@ -537,7 +548,9 @@
* Allow special fields to provide custom hints for their filter row inputs.
*/
indiciaFns.fieldConvertorQueryDescriptions = {
lat_lon: 'Enter a latitude and longitude value to filter to records in the vicinity.'
lat_lon: 'Enter a latitude and longitude value to filter to records in the vicinity.',
event_date: 'Enter a date in dd/mm/yyyy or yyyy-mm-dd format. Filtering to a year or range or years is possible ' +
'using yyyy or yyyy-yyyy format.'
};

/**
Expand Down Expand Up @@ -709,7 +722,8 @@
textFilters: {},
numericFilters: {},
bool_queries: [],
user_filters: []
user_filters: [],
refresh_user_filters: false
};
var mapToFilterTo;
var bounds;
Expand Down Expand Up @@ -796,6 +810,10 @@
$.each($('.user-filter'), function eachUserFilter() {
if ($(this).val()) {
data.user_filters.push($(this).val());
if (indiciaData.esUserFiltersLoaded.indexOf($(this).val()) === -1) {
data.refresh_user_filters = true;
indiciaData.esUserFiltersLoaded.push($(this).val());
}
}
});
}
Expand Down
7 changes: 5 additions & 2 deletions js/indicia.datacomponents/idc.esDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,12 @@ var IdcEsDataSource;
source.hideAllSpinners(source);
}
},
error: function error() {
error: function error(jqXHR) {
source.hideAllSpinners(source);
alert('Elasticsearch query failed');
if (jqXHR.readyState === 4) {
// Don't bother if not done - i.e. error because user navigated away.
alert('Elasticsearch query failed');
}
},
dataType: 'json'
});
Expand Down
62 changes: 27 additions & 35 deletions js/indicia.datacomponents/jquery.idc.dataGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,16 @@
if (indiciaFns.fieldConvertorQueryDescriptions[this.simpleFieldName()]) {
title = indiciaFns.fieldConvertorQueryDescriptions[this.simpleFieldName()];
} else {
title = 'Enter a value to find matches the ' + caption + ' column.';
title = 'Enter a value to find matches in the ' + caption + ' column.';
}
} else if (indiciaData.esMappings[this].type === 'text' || indiciaData.esMappings[this].type === 'keyword') {
title = 'Search for words which begin with this text in the ' + caption + ' column. Prefix with ! to exclude rows which contain words beginning with the text you enter.';
title = 'Search for words in the ' + caption + ' column. Prefix with ! to exclude rows which contain words ' +
'beginning with the text you enter. Use * at the end of words to find words starting with. Use ' +
'"" to group words into phrases and | between words to request either/or searches. Use - before ' +
'a word to exclude that word from the search results.';
} else {
title = 'Search for a number in the ' + caption + ' column. Prefix with ! to exclude rows which match the number you enter or separate a range with a hyphen (e.g. 123-456).';
title = 'Search for a number in the ' + caption + ' column. Prefix with ! to exclude rows which match the ' +
'number you enter or separate a range with a hyphen (e.g. 123-456).';
}
$('<input type="text" title="' + title + '">').appendTo(td);
}
Expand Down Expand Up @@ -233,6 +237,21 @@
});
}

/**
* Calculate the correct tbody height on resize, if a fixed or anchored height.
*/
function setTableHeight(el) {
var tbody = $(el).find('tbody');
if (el.settings.scrollY) {
if (el.settings.scrollY.match(/^-/)) {
tbody.css('max-height', (($(window).height() + parseInt(el.settings.scrollY.replace('px', ''), 10))
- ($(el).find('tbody').offset().top + $(el).find('tfoot').height())));
} else {
tbody.css('max-height', el.settings.scrollY);
}
}
}

/**
* Register the various user interface event handlers.
*/
Expand Down Expand Up @@ -315,8 +334,7 @@
});

$(el).find('.multiselect-switch').click(function clickMultiselectSwitch() {
var el = $(this).closest('.idc-output-dataGrid');
var table = el.find('table');
var table = $(el).find('table');
if ($(el).hasClass('multiselect-mode')) {
$(el).removeClass('multiselect-mode');
$(table).find('.multiselect-cell').remove();
Expand All @@ -336,6 +354,7 @@
$('.all-selected-buttons')
);
}
setTableHeight(el);
});

/**
Expand Down Expand Up @@ -371,32 +390,6 @@
$panel.find('ol').sortable();
});

function onFullScreenChange() {
var tbody;
var fsEl = document.fullscreenElement
|| document.webkitFullscreenElement
|| document.mozFullScreenElement;
tbody = $(el).find('tbody');
if (tbody && el.settings.scrollY) {
if (fsEl === el) {
tbody.css('max-height', $(window).height() - $(el).find('thead').height() - $(el).find('tfoot').height());
} else {
tbody.css('max-height', el.settings.scrollY + 'px');
}
}
}

document.addEventListener('fullscreenchange', onFullScreenChange);

/* Firefox */
document.addEventListener('mozfullscreenchange', onFullScreenChange);

/* Chrome, Safari and Opera */
document.addEventListener('webkitfullscreenchange', onFullScreenChange);

/* IE / Edge */
document.addEventListener('msfullscreenchange', onFullScreenChange);

$(el).find('.data-grid-fullscreen').click(function settingsIconClick() {
if (document.fullscreenElement ||
document.webkitFullscreenElement ||
Expand Down Expand Up @@ -864,10 +857,7 @@
table = $('<table class="' + tableClasses.join(' ') + '" data-sort="' + footableSort + '" />').appendTo(el);
addHeader(el, table);
// We always want a table body for the data.
tbody = $('<tbody />').appendTo(table);
if (el.settings.scrollY) {
$(tbody).css('max-height', el.settings.scrollY);
}
$('<tbody />').appendTo(table);
// Output a footer if we want a pager.
if (el.settings.includePager && !(el.settings.sourceTable || el.settings.aggregation === 'simple')) {
totalCols = el.settings.columns.length
Expand All @@ -877,6 +867,7 @@
'<span class="buttons"><button class="prev">Previous</button><button class="next">Next</button></span>' +
'</td></tr></tfoot>').appendTo(table);
}
setTableHeight(el);
// Add icons for table settings.
tools = '<span class="fas fa-wrench data-grid-show-settings" title="Click to show grid column settings"></span>';
if (document.fullscreenEnabled || document.mozFullScreenEnabled || document.webkitFullscreenEnabled) {
Expand All @@ -902,6 +893,7 @@
$(table).trigger('footable_expand_all');
});
}
window.addEventListener('resize', function resize() { setTableHeight(el); });
},

/**
Expand Down
Loading

0 comments on commit 2f7bc33

Please sign in to comment.