Skip to content

Commit 6c48348

Browse files
committed
Merge branch 'hotfix/5.0.5'
2 parents faa5fb5 + c00e516 commit 6c48348

File tree

6 files changed

+39
-11
lines changed

6 files changed

+39
-11
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ plugins {
1717
id 'war'
1818
}
1919

20-
version "5.0.4"
20+
version "5.0.5"
2121
group "au.org.ala"
2222

2323
apply plugin:"eclipse"

grails-app/assets/javascripts/activity.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ var ActivityRecordViewModel = function (activity) {
911911
if (activity.endDate) {
912912
projectActivityOpen = moment(activity.endDate).isAfter(moment());
913913
}
914-
self.showAdd = ko.observable(projectActivityOpen);
914+
self.showAdd = ko.observable( self.isWorksProject() ? false : projectActivityOpen);
915915
self.readOnly = ko.observable((fcConfig.version || '' ).length > 0)//183,238,252
916916

917917
var allRecords = $.map(activity.records ? activity.records : [], function (record, index) {

grails-app/assets/javascripts/mapWithFeatures.js

+18-7
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,11 @@
141141
self.allLocationsLoaded();
142142
}
143143
},
144-
loadFeature: function(loc, iw){
144+
loadFeature: function(loc, iw, ignoreDefaultArea){
145145
var self = this, f;
146146
var loaded = false;
147+
ignoreDefaultArea = ignoreDefaultArea || false;
148+
147149
if(loc != null && loc.type != null){
148150
if (loc.type.toLowerCase() === 'point') {
149151
var ll = new google.maps.LatLng(Number(loc.coordinates[1]), Number(loc.coordinates[0]));
@@ -152,7 +154,7 @@
152154
position: ll,
153155
title: loc.name
154156
});
155-
if (!self.defaultZoomArea || self.defaultZoomArea == loc.id) {
157+
if ((!self.defaultZoomArea || self.defaultZoomArea == loc.id) || ignoreDefaultArea) {
156158
self.featureBounds.extend(ll);
157159
}
158160
self.addFeature(f, loc);
@@ -183,7 +185,7 @@
183185
this.allMarkers.push(markerMap);
184186
}
185187

186-
if (!self.defaultZoomArea || self.defaultZoomArea == loc.id) {
188+
if ((!self.defaultZoomArea || self.defaultZoomArea == loc.id) || ignoreDefaultArea) {
187189
self.featureBounds.extend(ll);
188190
}
189191

@@ -199,7 +201,7 @@
199201
});
200202
//set the extend of the map
201203
//console.log("f.getBounds()",f.getBounds());
202-
if (!self.defaultZoomArea || self.defaultZoomArea == loc.id) {
204+
if ((!self.defaultZoomArea || self.defaultZoomArea == loc.id) || ignoreDefaultArea) {
203205
self.featureBounds.extend(f.getBounds().getNorthEast());
204206
self.featureBounds.extend(f.getBounds().getSouthWest());
205207
}
@@ -219,7 +221,7 @@
219221
// flatten arrays to array of points
220222
points = [].concat.apply([], paths);
221223
// extend bounds by each point
222-
if (!self.defaultZoomArea || self.defaultZoomArea == loc.id) {
224+
if ((!self.defaultZoomArea || self.defaultZoomArea == loc.id) || ignoreDefaultArea) {
223225
$.each(points, function (i,obj) {self.featureBounds.extend(obj);});
224226
}
225227

@@ -242,7 +244,7 @@
242244
// The bounding box of a point is a linestring with two points
243245
pointArray = [pointArray[0], pointArray[1], pointArray[0], pointArray[1]];
244246
}
245-
if (!self.defaultZoomArea || self.defaultZoomArea == loc.id) {
247+
if ((!self.defaultZoomArea || self.defaultZoomArea == loc.id) || ignoreDefaultArea) {
246248
self.featureBounds.extend(new google.maps.LatLng(pointArray[1].split(" ")[1], pointArray[1].split(" ")[0]));
247249
self.featureBounds.extend(new google.maps.LatLng(pointArray[3].split(" ")[1], pointArray[3].split(" ")[0]));
248250
}
@@ -276,11 +278,20 @@
276278
iw = new google.maps.InfoWindow({maxWidth: 360});
277279
}
278280

281+
// List of features sometimes does not contain default zoom area. Hence map zoom to an extent not containing
282+
// sites. The below setting tells loadFeature to ignore the default zoom area check and add site to extent
283+
// calculation.
284+
var defaultArea = $.grep(features, function (loc) {
285+
return loc.id == self.defaultZoomArea;
286+
}),
287+
ignoreDefaultArea = defaultArea.length === 0;
288+
289+
279290
$.each(features, function (i,loc) {
280291
//console.log('Loading feature with type:' + loc.type + "|" + loc.latitude);
281292
if(loc != null){
282293

283-
self.loadFeature(loc, iw);
294+
self.loadFeature(loc, iw, ignoreDefaultArea);
284295
//self.locationLoaded();
285296
}
286297
});

grails-app/views/site/index.gsp

+4-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
activityDeleteUrl: "${createLink(controller: 'bioActivity', action: 'delete')}",
3838
activityAddUrl: "${createLink(controller: 'bioActivity', action: 'create')}",
3939
activityListUrl: "${createLink(controller: 'bioActivity', action: 'ajaxList')}",
40+
worksActivityEditUrl: "${createLink(controller: 'activity', action: 'enterData')}",
41+
worksActivityViewUrl: "${createLink(controller: 'activity', action: 'index')}",
4042
searchProjectActivitiesUrl: "${createLink(controller: 'bioActivity', action: 'searchProjectActivities')}",
4143
downloadProjectDataUrl: "${createLink(controller: 'bioActivity', action: 'downloadProjectData')}",
4244
getRecordsForMapping: "${createLink(controller: 'bioActivity', action: 'getProjectActivitiesRecordsForMapping')}",
@@ -67,7 +69,7 @@
6769
<button type="button" class="close" data-dismiss="alert">&times;</button>
6870
<strong>Heads up!</strong> You can only edit the site if you have at least 'editor' privilege on all projects associated with the site. Check the projects this site is associated with on the 'Projects' tab below.
6971
</div>
70-
<ul class="breadcrumb pull-right">
72+
<ul class="breadcrumb pull-right margin-top-10">
7173
<li>
7274
<g:set var="disabled">${(!user) ? "disabled='disabled' title='login required'" : ''}</g:set>
7375
%{--Favourite functionality only available to authenticated users --}%
@@ -296,7 +298,7 @@
296298
<a data-bind="attr:{'href': transients.editUrl}"><i
297299
class="fa fa-edit" title="Edit survey"></i></a>
298300
</span>
299-
<span class="margin-left-1">
301+
<span class="margin-left-1" data-bind="visible: false">
300302
<a href="#" data-bind="click: $parent.remove"><i
301303
class="fa fa-remove" title="Delete survey"></i></a>
302304
</span>

karma.conf.js

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module.exports = function (config) {
3535
'grails-app/assets/javascripts/organisation.js',
3636
'grails-app/assets/javascripts/pagination.js',
3737
'grails-app/assets/javascripts/sites.js',
38+
'grails-app/assets/javascripts/activity.js',
3839
'node_modules/leaflet/dist/leaflet.js',
3940
'grails-app/assets/vendor/leaflet-plugins-2.0.0/layer/tile/Google.js',
4041
'grails-app/assets/javascripts/MapUtilities.js',

src/test/js/spec/ActivitySpec.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
describe('Test activity view models', function () {
3+
beforeAll(function() {
4+
window.fcConfig = {
5+
}
6+
});
7+
8+
it('add button should be hidden for works projects', function () {
9+
var vm = new ActivityRecordViewModel({projectType: "works"});
10+
expect(vm.showAdd()).toBe(false);
11+
var vm = new ActivityRecordViewModel({projectType: "survey"});
12+
expect(vm.showAdd()).toBe(true);
13+
});
14+
});

0 commit comments

Comments
 (0)