Skip to content

Commit

Permalink
Merge pull request #108 from AtlasOfLivingAustralia/107-timecontrols
Browse files Browse the repository at this point in the history
#107 fix for time controls
  • Loading branch information
adam-collins authored Sep 30, 2024
2 parents c1c430f + 5d24ca9 commit 1cb45bd
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 32 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
language: groovy
jdk:
- openjdk11
sudo: false
branches:
only:
- master
- develop
- feature/grails5
- Leaflet-migration
- hotfix
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
Expand All @@ -17,6 +13,11 @@ cache:
- $HOME/.m2
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/

install:
- 'travis_wait 30 ./gradlew clean'
- './gradlew assemble'

after_success:
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && travis_retry ./gradlew publish -x test'

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ plugins {
}


version "4.0.0-SNAPSHOT"
version "4.1.0-SNAPSHOT"
group "au.org.ala"

publishing {
Expand Down
49 changes: 33 additions & 16 deletions grails-app/assets/javascripts/region_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ var region = {
* @returns [*]
*/
buildBiocacheQuery: function (customParams, start, forChartValue) {
forChart = forChartValue || $("#taxonomyTab").attr('aria-expanded') === 'true';

var currentState = regionWidget.getCurrentState();

forChart = forChartValue || regionWidget.getCurrentState().tab === 'taxonomyTab';

var params = customParams || [];

//q= must be first
Expand Down Expand Up @@ -138,7 +138,7 @@ var region = {
params.push("start=" + start);
}

if (timeFacet && !forChart) {
if (timeFacet) {
params.push("fq=" + timeFacet);
}

Expand Down Expand Up @@ -263,10 +263,17 @@ var RegionWidget = function (config) {
*
*/
var initializeTabs = function () {
// Initialize tabs
$('#explorerTabs').find('a').on('show', function (e) {
var tabId = $(e.target).attr('id');
updateState({tab: tabId, group: 'ALL_SPECIES', fq: '', subgroup: '', guid: ''});

$('#speciesTab').on('click', function(event) {
// reset species tab to all species, updating the map
if (regionWidget) regionWidget.getTimeControls().stop();
updateState({tab: 'speciesTab'});
$('#ALL_SPECIES-row i').click();
});
$('#taxonomyTab').on('click', function(event) {
if (regionWidget) regionWidget.getTimeControls().stop();
updateState({tab: 'taxonomyTab', group: 'ALL_SPECIES', fq: '', subgroup: '', guid: ''});
taxonomyChart.reset();
});
$('#' + state.tab).click();

Expand Down Expand Up @@ -337,22 +344,29 @@ var RegionWidget = function (config) {
* Code to execute when a group is selected
*/
var selectGroup = function (group, fq) {
var toggleExpansion = !regionWidget.getTimeControls().isRunning()

$('.group-row').removeClass('groupSelected');
$("tr[parent]").hide();

if (toggleExpansion) {
$("tr[parent]").hide();
}

if (group !== state.group) {
$('#' + state.group + '-row i').removeClass('fa-chevron-down').addClass('fa-chevron-right');
}
var groupId = group.replace(/[^A-Za-z0-9\\d_]/g, "") + '-row';

var grp = $('#' + groupId + ' i');
var isAlreadyExpanded = grp.hasClass('fa-chevron-down');
if (isAlreadyExpanded) {
$("tr[parent='" + groupId + "']").hide();
grp.removeClass('fa-chevron-down').addClass('fa-chevron-right');
} else {
$("tr[parent='" + groupId + "']").show();
grp.removeClass('fa-chevron-right').addClass('fa-chevron-down');
if (toggleExpansion) {
if (isAlreadyExpanded) {
$("tr[parent='" + groupId + "']").hide();
grp.removeClass('fa-chevron-down').addClass('fa-chevron-right');
} else {
$("tr[parent='" + groupId + "']").show();
grp.removeClass('fa-chevron-right').addClass('fa-chevron-down');
}
}

// Update widget state
Expand Down Expand Up @@ -652,7 +666,7 @@ var RegionTimeControls = function (config) {
$('#timeSlider').slider('values', [regionWidget.getDefaultFromYear(), regionWidget.getDefaultToYear()]);
stop();
regionWidget.updateDateRange(regionWidget.getDefaultFromYear(), regionWidget.getDefaultToYear());
taxonomyChart.reset();
regionWidget.updateDateRange(regionWidget.getDefaultFromYear(), regionWidget.getDefaultToYear()); // called for a 2nd time for the use case when a "group" is select to restore the expansion toggle state
};

var updateTimeRange = function (values) {
Expand All @@ -663,6 +677,9 @@ var RegionTimeControls = function (config) {
var _public = {
isRunning: function () {
return state === CONTROL_STATES.PLAYING;
},
stop: function() {
stop();
}
};

Expand All @@ -677,7 +694,7 @@ var TaxonomyWidget = function (config) {
var TaxonomyWidget = function (config) {
var currentState = regionWidget.getCurrentState();

var query = '';
query = '';
$.each(region.buildBiocacheQuery([], 0, true), function (i, v) {
if (query.length === 0) {
query = v
Expand Down
15 changes: 8 additions & 7 deletions grails-app/assets/javascripts/regions/charts2.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ function buildGenericFacetChart(name, data, query, chartsDiv, chartOptions) {
var individualOptions = individualChartOptions[name] ? individualChartOptions[name] : {};
// merge generic, individual and user options
opts = $.extend(true, {}, opts, individualOptions, chartOptions[name]);
//Dumper.alert(opts);

// optionally transform the data
var xformedData = data;
Expand Down Expand Up @@ -292,7 +291,7 @@ function lookupEntityName(chart, table, opts, entity) {
chart.draw(table, opts);
},
error: function (d, msg) {
alert(msg);

}
});
}
Expand Down Expand Up @@ -372,16 +371,18 @@ var taxonomyChart = {
if (textStatus == 'timeout') {
alert('Sorry - the request was taking too long so it has been cancelled.');
}
if (textStatus == 'error') {
alert('Sorry - the chart cannot be redrawn due to an error.');
}
if (textStatus != 'success') {
thisChart.cleanUp();
}
},
success: function (data) {
// check for errors
if (data != undefined && data.taxa.length > 0) {
// remove any data.taxa array elements with label == ''
data.taxa = $.grep(data.taxa, function (obj) {
return obj.label !== '';
});

// draw the chart
thisChart.draw(data);
} else {
Expand Down Expand Up @@ -476,7 +477,7 @@ var taxonomyChart = {
}
else {
// show the instruction
$backLink.html($.i18n.prop("charts.click.slice")).removeClass('link');
$backLink.html($.i18n.prop("charts.click.slice")).removeClass('lnk');
}

// draw records link
Expand Down Expand Up @@ -636,7 +637,7 @@ function initTaxonTree(treeOptions) {
return nodes;
},
error: function (xhr, text_status) {
//alert(text_status);

}
}
},
Expand Down
8 changes: 4 additions & 4 deletions grails-app/assets/stylesheets/regions.css
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,13 @@ li.regionLink {
}

tr.groupSelected, tr.groupSelected:hover td {
/*background-color: #C44D34 !important;*/
/*color: white;*/
background-color: #C44D34 !important;
color: white;
}

tr.speciesSelected, tr.speciesSelected:hover td {
/*background-color: #C44D34 !important;*/
/*color: white;*/
background-color: #C44D34 !important;
color: white;
}

#showMoreSpeciesButton {
Expand Down

0 comments on commit 1cb45bd

Please sign in to comment.