Skip to content

Commit 1cb45bd

Browse files
authored
Merge pull request #108 from AtlasOfLivingAustralia/107-timecontrols
#107 fix for time controls
2 parents c1c430f + 5d24ca9 commit 1cb45bd

File tree

5 files changed

+51
-32
lines changed

5 files changed

+51
-32
lines changed

.travis.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
language: groovy
22
jdk:
33
- openjdk11
4-
sudo: false
54
branches:
65
only:
76
- master
87
- develop
9-
- feature/grails5
10-
- Leaflet-migration
11-
- hotfix
128
before_cache:
139
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
1410
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
@@ -17,6 +13,11 @@ cache:
1713
- $HOME/.m2
1814
- $HOME/.gradle/caches/
1915
- $HOME/.gradle/wrapper/
16+
17+
install:
18+
- 'travis_wait 30 ./gradlew clean'
19+
- './gradlew assemble'
20+
2021
after_success:
2122
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && travis_retry ./gradlew publish -x test'
2223

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ plugins {
1515
}
1616

1717

18-
version "4.0.0-SNAPSHOT"
18+
version "4.1.0-SNAPSHOT"
1919
group "au.org.ala"
2020

2121
publishing {

grails-app/assets/javascripts/region_page.js

+33-16
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ var region = {
9090
* @returns [*]
9191
*/
9292
buildBiocacheQuery: function (customParams, start, forChartValue) {
93-
forChart = forChartValue || $("#taxonomyTab").attr('aria-expanded') === 'true';
94-
9593
var currentState = regionWidget.getCurrentState();
9694

95+
forChart = forChartValue || regionWidget.getCurrentState().tab === 'taxonomyTab';
96+
9797
var params = customParams || [];
9898

9999
//q= must be first
@@ -138,7 +138,7 @@ var region = {
138138
params.push("start=" + start);
139139
}
140140

141-
if (timeFacet && !forChart) {
141+
if (timeFacet) {
142142
params.push("fq=" + timeFacet);
143143
}
144144

@@ -263,10 +263,17 @@ var RegionWidget = function (config) {
263263
*
264264
*/
265265
var initializeTabs = function () {
266-
// Initialize tabs
267-
$('#explorerTabs').find('a').on('show', function (e) {
268-
var tabId = $(e.target).attr('id');
269-
updateState({tab: tabId, group: 'ALL_SPECIES', fq: '', subgroup: '', guid: ''});
266+
267+
$('#speciesTab').on('click', function(event) {
268+
// reset species tab to all species, updating the map
269+
if (regionWidget) regionWidget.getTimeControls().stop();
270+
updateState({tab: 'speciesTab'});
271+
$('#ALL_SPECIES-row i').click();
272+
});
273+
$('#taxonomyTab').on('click', function(event) {
274+
if (regionWidget) regionWidget.getTimeControls().stop();
275+
updateState({tab: 'taxonomyTab', group: 'ALL_SPECIES', fq: '', subgroup: '', guid: ''});
276+
taxonomyChart.reset();
270277
});
271278
$('#' + state.tab).click();
272279

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

341349
$('.group-row').removeClass('groupSelected');
342-
$("tr[parent]").hide();
350+
351+
if (toggleExpansion) {
352+
$("tr[parent]").hide();
353+
}
354+
343355
if (group !== state.group) {
344356
$('#' + state.group + '-row i').removeClass('fa-chevron-down').addClass('fa-chevron-right');
345357
}
346358
var groupId = group.replace(/[^A-Za-z0-9\\d_]/g, "") + '-row';
347359

348360
var grp = $('#' + groupId + ' i');
349361
var isAlreadyExpanded = grp.hasClass('fa-chevron-down');
350-
if (isAlreadyExpanded) {
351-
$("tr[parent='" + groupId + "']").hide();
352-
grp.removeClass('fa-chevron-down').addClass('fa-chevron-right');
353-
} else {
354-
$("tr[parent='" + groupId + "']").show();
355-
grp.removeClass('fa-chevron-right').addClass('fa-chevron-down');
362+
if (toggleExpansion) {
363+
if (isAlreadyExpanded) {
364+
$("tr[parent='" + groupId + "']").hide();
365+
grp.removeClass('fa-chevron-down').addClass('fa-chevron-right');
366+
} else {
367+
$("tr[parent='" + groupId + "']").show();
368+
grp.removeClass('fa-chevron-right').addClass('fa-chevron-down');
369+
}
356370
}
357371

358372
// Update widget state
@@ -652,7 +666,7 @@ var RegionTimeControls = function (config) {
652666
$('#timeSlider').slider('values', [regionWidget.getDefaultFromYear(), regionWidget.getDefaultToYear()]);
653667
stop();
654668
regionWidget.updateDateRange(regionWidget.getDefaultFromYear(), regionWidget.getDefaultToYear());
655-
taxonomyChart.reset();
669+
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
656670
};
657671

658672
var updateTimeRange = function (values) {
@@ -663,6 +677,9 @@ var RegionTimeControls = function (config) {
663677
var _public = {
664678
isRunning: function () {
665679
return state === CONTROL_STATES.PLAYING;
680+
},
681+
stop: function() {
682+
stop();
666683
}
667684
};
668685

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

680-
var query = '';
697+
query = '';
681698
$.each(region.buildBiocacheQuery([], 0, true), function (i, v) {
682699
if (query.length === 0) {
683700
query = v

grails-app/assets/javascripts/regions/charts2.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ function buildGenericFacetChart(name, data, query, chartsDiv, chartOptions) {
154154
var individualOptions = individualChartOptions[name] ? individualChartOptions[name] : {};
155155
// merge generic, individual and user options
156156
opts = $.extend(true, {}, opts, individualOptions, chartOptions[name]);
157-
//Dumper.alert(opts);
158157

159158
// optionally transform the data
160159
var xformedData = data;
@@ -292,7 +291,7 @@ function lookupEntityName(chart, table, opts, entity) {
292291
chart.draw(table, opts);
293292
},
294293
error: function (d, msg) {
295-
alert(msg);
294+
296295
}
297296
});
298297
}
@@ -372,16 +371,18 @@ var taxonomyChart = {
372371
if (textStatus == 'timeout') {
373372
alert('Sorry - the request was taking too long so it has been cancelled.');
374373
}
375-
if (textStatus == 'error') {
376-
alert('Sorry - the chart cannot be redrawn due to an error.');
377-
}
378374
if (textStatus != 'success') {
379375
thisChart.cleanUp();
380376
}
381377
},
382378
success: function (data) {
383379
// check for errors
384380
if (data != undefined && data.taxa.length > 0) {
381+
// remove any data.taxa array elements with label == ''
382+
data.taxa = $.grep(data.taxa, function (obj) {
383+
return obj.label !== '';
384+
});
385+
385386
// draw the chart
386387
thisChart.draw(data);
387388
} else {
@@ -476,7 +477,7 @@ var taxonomyChart = {
476477
}
477478
else {
478479
// show the instruction
479-
$backLink.html($.i18n.prop("charts.click.slice")).removeClass('link');
480+
$backLink.html($.i18n.prop("charts.click.slice")).removeClass('lnk');
480481
}
481482

482483
// draw records link
@@ -636,7 +637,7 @@ function initTaxonTree(treeOptions) {
636637
return nodes;
637638
},
638639
error: function (xhr, text_status) {
639-
//alert(text_status);
640+
640641
}
641642
}
642643
},

grails-app/assets/stylesheets/regions.css

+4-4
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,13 @@ li.regionLink {
289289
}
290290

291291
tr.groupSelected, tr.groupSelected:hover td {
292-
/*background-color: #C44D34 !important;*/
293-
/*color: white;*/
292+
background-color: #C44D34 !important;
293+
color: white;
294294
}
295295

296296
tr.speciesSelected, tr.speciesSelected:hover td {
297-
/*background-color: #C44D34 !important;*/
298-
/*color: white;*/
297+
background-color: #C44D34 !important;
298+
color: white;
299299
}
300300

301301
#showMoreSpeciesButton {

0 commit comments

Comments
 (0)