Skip to content

Commit

Permalink
Merge pull request #210 from AtlasOfLivingAustralia/hotfix/6.1.1
Browse files Browse the repository at this point in the history
Hotfix/6.1.1
  • Loading branch information
jack-brinkman authored Sep 20, 2023
2 parents 3a0e07f + bf44ebc commit c8ea2c4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {
}


version "6.1"
version "6.1.1-SNAPSHOT"
group "org.grails.plugins"

apply plugin:"eclipse"
Expand Down
8 changes: 7 additions & 1 deletion grails-app/assets/javascripts/viewModels.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,15 @@ function enmapify(args) {
viewModel.getSiteId = function () {
return siteIdObservable();
};
viewModel.loadActivitySite = function () {
viewModel.loadActivitySite = function (data) {
var siteId = activityLevelData.activity && activityLevelData.activity.siteId;
siteId && siteIdObservable(siteId);
// if siteId is not set, then we need to create a site from lat and lon coordinates
if (edit && !siteIdObservable() && data) {
if (data.decimalLatitude && data.decimalLongitude) {
viewModel.addMarker(data);
}
}
};

function isEmpty(value){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ class ModelJSTagLib {
if (data.${mod.name} && typeof data.${mod.name} !== 'undefined') {
self.data.${mod.name}(data.${mod.name});
} else {
self.loadActivitySite();
self.loadActivitySite({decimalLatitude: data.${mod.name}Latitude, decimalLongitude: data.${mod.name}Longitude});
}
if (data.${mod.name}Accuracy){
Expand Down
18 changes: 18 additions & 0 deletions src/test/js/spec/EnmapifySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,24 @@ describe("Enmapify Spec", function () {

});

it("should create site if siteId is not provided", function () {
options.activityLevelData.activity.siteId = "";
options.activityLevelData.siteId = "";
options.container.Test = "";

var result = enmapify(options);
spyOn(result.viewModel, "addMarker").and.returnValue(true);
result.viewModel.loadActivitySite({decimalLatitude: 1, decimalLongitude: 1});
expect(result.viewModel.addMarker).toHaveBeenCalledWith({decimalLatitude: 1, decimalLongitude: 1});

// should not call when in read mode
options.edit = false;
result = enmapify(options);
spyOn(result.viewModel, "addMarker").and.returnValue(true);
result.viewModel.loadActivitySite({decimalLatitude: 0, decimalLongitude: 0});
expect(result.viewModel.addMarker).not.toHaveBeenCalled();
});

it("centroid for line should be the first coordinate", function () {
var result = enmapify(options);
var line = {
Expand Down

0 comments on commit c8ea2c4

Please sign in to comment.