Skip to content

Commit 84863ab

Browse files
authored
Merge pull request #3047 from AtlasOfLivingAustralia/feature/issue3040
Add the ability to identify sites created by Monitor #3040
2 parents a5d24bb + b4bbbe6 commit 84863ab

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
lines changed

grails-app/assets/javascripts/projects.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ function ProjectPageViewModel(project, sites, activities, organisations, userRol
10471047
};
10481048
sitesViewModel.typeFilter.subscribe(function(filterValue) {
10491049

1050-
if (filterValue == 'Both') {
1050+
if (filterValue == 'All') {
10511051
filterValue = ""; // Clear the search.
10521052
}
10531053
$sitesTable.DataTable().column(2).search(filterValue).draw();

grails-app/assets/javascripts/sites.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,17 @@ var SitesViewModel = function(sites, map, mapFeatures, isUserEditor, projectId)
994994
if (!site.type) {
995995
site.type = 'worksArea';
996996
}
997+
site.filterType = 'P';
998+
site.filterTypeLabel = 'Planning site';
999+
if (site.type === 'compound') {
1000+
site.filterType = 'R';
1001+
site.filterTypeLabel = 'Reporting site';
1002+
}
1003+
else if (site.externalIds && site.externalIds[0] && site.externalIds[0].idType == 'MONITOR_PLOT_GUID') {
1004+
site.filterType = 'E';
1005+
site.filterTypeLabel = 'Site created via EMSA protocol using the Monitor App';
1006+
}
1007+
9971008
site.readOnly = site.type == 'compound' || PublicationStatus.isReadOnly(site.publicationStatus);
9981009
return site;
9991010
});
@@ -1029,7 +1040,7 @@ var SitesViewModel = function(sites, map, mapFeatures, isUserEditor, projectId)
10291040
}
10301041
return '';
10311042
};
1032-
self.typeOptions = ['Both', 'P', 'R'];
1043+
self.typeOptions = ['All', 'P', 'R', 'E'];
10331044
self.typeFilter = ko.observable(self.typeOptions[0]);
10341045

10351046
// Animation callbacks for the lists
@@ -1187,7 +1198,7 @@ var SitesViewModel = function(sites, map, mapFeatures, isUserEditor, projectId)
11871198
this.viewSite = function (site) {
11881199
var url = fcConfig.siteViewUrl + '/' + site.siteId;
11891200
if (projectId) {
1190-
url += '&projectId='+projectId;
1201+
url += '?projectId='+projectId;
11911202
}
11921203
document.location.href = url;
11931204
};

grails-app/controllers/au/org/ala/merit/ProjectController.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class ProjectController {
206206
else if (template == RLP_TEMPLATE) {
207207

208208
// The RLP Project Template doesn't need site details or activities.
209-
project.sites = new JSONArray(project.sites?.collect{new JSONObject([name:it.name, siteId:it.siteId, lastUpdated:it.lastUpdated, type:it.type, extent:[:], publicationStatus:it.publicationStatus])} ?: [])
209+
project.sites = new JSONArray(project.sites?.collect{new JSONObject([name:it.name, siteId:it.siteId, lastUpdated:it.lastUpdated, type:it.type, extent:[:], publicationStatus:it.publicationStatus, externalIds:it.externalIds])} ?: [])
210210
project.remove('activities')
211211
model.overview.template = 'rlpOverview'
212212

grails-app/views/site/_sitesList.gsp

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<tr>
3030
<th><input type="checkbox" id="select-all-sites"></th>
3131
<th></th>
32-
<th>Type <fc:iconHelp html="true">Planning site (P) or Reporting site (R)</fc:iconHelp><br/>
32+
<th>Type <fc:iconHelp html="true">Planning site (P), Reporting site (R) or EMSA site created with the Monitor app (E)</fc:iconHelp><br/>
3333
<select data-bind="value:typeFilter, options:typeOptions">
3434

3535
</select>
@@ -52,7 +52,7 @@
5252
</span>
5353
</g:if>
5454
</td>
55-
<td data-bind="text:type == 'compound' ? 'R' : 'P', title:type == 'compound' ? 'Reporting site' : 'Planning site'">
55+
<td data-bind="text:filterType, title:filterTypeTitle">
5656
</td>
5757

5858
<td>

src/main/scripts/releases/3.1/fixSiteExternalIds.js

+10
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,15 @@ while (sites.hasNext()) {
1616
site.externalId = null;
1717
db.site.replaceOne({_id:site._id}, site);
1818

19+
audit(site, site.siteId, 'au.org.ala.ecodata.Site', adminUserId);
20+
}
21+
22+
sites = db.site.find({externalId:{$ne:null}});
23+
while (sites.hasNext()) {
24+
let site = sites.next();
25+
site.externalIds = [{idType:'UNSPECIFIED', externalId: site.externalId}];
26+
delete site.externalId;
27+
db.site.replaceOne({_id:site._id}, site);
28+
1929
audit(site, site.siteId, 'au.org.ala.ecodata.Site', adminUserId);
2030
}

0 commit comments

Comments
 (0)