Skip to content

Commit a8880e4

Browse files
Release 6.8
Release 6.8
2 parents d7ec361 + 09140f7 commit a8880e4

23 files changed

+387
-111
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ dependencies {
154154

155155
if (!Boolean.valueOf(inplace)) {
156156
implementation "org.grails.plugins:ala-map-plugin:3.0.1"
157-
implementation "org.grails.plugins:ecodata-client-plugin:6.1.3"
157+
implementation "org.grails.plugins:ecodata-client-plugin:6.2"
158158
}
159159

160160
testCompileOnly "org.grails:grails-test-mixins:3.3.0"

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
biocollectVersion=6.6.6
1+
biocollectVersion=6.8
22
grailsVersion=5.1.9
33
grailsGradlePluginVersion=5.1.5
44
assetPipelineVersion=3.3.4

grails-app/assets/javascripts/document.js

+1
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ function attachViewModelToFileUpload(uploadUrl, documentViewModel, uiSelector, p
283283
$(uiSelector).fileupload({
284284
url:uploadUrl,
285285
pasteZone: null,
286+
dropZone: null,
286287
formData:function(form) {
287288
return [{name:'document', value:documentViewModel.toJSONString()}]
288289
},

grails-app/assets/javascripts/i18n.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (C) 2019 Atlas of Living Australia
3+
* All Rights Reserved.
4+
*
5+
* The contents of this file are subject to the Mozilla Public
6+
* License Version 1.1 (the "License"); you may not use this file
7+
* except in compliance with the License. You may obtain a copy of
8+
* the License at http://www.mozilla.org/MPL/
9+
*
10+
* Software distributed under the License is distributed on an "AS
11+
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
12+
* implied. See the License for the specific language governing
13+
* rights and limitations under the License.
14+
*
15+
* Created by Temi on 15/11/19.
16+
*/
17+
18+
(function() {
19+
var messages = {},
20+
deffer = $.Deferred();
21+
$.get({
22+
url: fcConfig.i18nURL,
23+
cache: true
24+
}).done(function (data) {
25+
messages = data;
26+
deffer.resolve();
27+
}).fail(function () {
28+
deffer.reject();
29+
});
30+
31+
$i18n = function(key, defaultValue) {
32+
if (messages[key] !== undefined) {
33+
return messages[key];
34+
} else {
35+
return defaultValue || key;
36+
}
37+
};
38+
39+
$i18nAsync = function(key, defaultValue, callback) {
40+
if (callback) {
41+
deffer.done(function () {
42+
callback($i18n(key, defaultValue));
43+
}).fail(function () {
44+
callback($i18n(key, defaultValue));
45+
})
46+
}
47+
}
48+
49+
})();

grails-app/assets/javascripts/knockout-custom-bindings.js

+50-4
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ ko.bindingHandlers.stagedImageUpload = {
281281
$(element).fileupload({
282282
url: config.url,
283283
pasteZone: null,
284+
dropZone: null,
284285
autoUpload: true
285286
}).on('fileuploadadd', function (e, data) {
286287
complete(false);
@@ -703,11 +704,11 @@ ko.bindingHandlers.fileUploadNoImage = {
703704

704705
var defaults = {autoUpload: true};
705706
var settings = {
706-
pasteZone: null
707+
pasteZone: null,
708+
dropZone: null
707709
};
708710
$.extend(settings, defaults, options());
709-
$(element).fileupload(settings
710-
).on('fileuploadadd', function (e, data) {
711+
$(element).fileupload(settings).on('fileuploadadd', function (e, data) {
711712
window.incrementAsyncCounter && window.incrementAsyncCounter();
712713
}).on('fileuploaddone', function (e, data) {
713714
window.decreaseAsyncCounter && window.decreaseAsyncCounter();
@@ -1148,4 +1149,49 @@ ko.bindingHandlers.debug = {
11481149
console.log(element);
11491150
console.log(ko.toJS(valueAccessor()));
11501151
}
1151-
};
1152+
};
1153+
1154+
1155+
/**
1156+
* This binding requires i18n.js to be loaded. It also requires fcConfig.i18nURL to be set.
1157+
* Params can be a string or an object. If string, it is treated as key and translated to text. Object parameter has the
1158+
* following properties:
1159+
* @contentType can be 'text' or 'html' (default is 'text')
1160+
* @key is the key to be translated
1161+
* @defaultValue is the default value to be used if the key is not found
1162+
*
1163+
* Usage examples:
1164+
* <div data-bind="i18n: 'g.cancel'"></div>
1165+
* <div data-bind="i18n: {key: 'record.edit.verificationStatusTypes.help', contentType: 'html', defaultValue: '<b>simple help</b>'}"></div>
1166+
*
1167+
*/
1168+
ko.bindingHandlers.i18n = {
1169+
init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
1170+
var value = valueAccessor();
1171+
value = ko.unwrap(value);
1172+
var contentType = value && value.contentType || 'text'
1173+
1174+
// $i18nAsync is required to be defined
1175+
if(typeof $i18nAsync === 'undefined')
1176+
return
1177+
1178+
if( typeof value === 'string') {
1179+
$i18nAsync(value, '',function(text) {
1180+
$(element).text(text);
1181+
});
1182+
}
1183+
else if (typeof value === 'object') {
1184+
$i18nAsync(value.key, value.defaultValue,function(text) {
1185+
switch (contentType) {
1186+
default:
1187+
case 'text':
1188+
$(element).text(text);
1189+
break;
1190+
case 'html':
1191+
$(element).html(text);
1192+
break;
1193+
}
1194+
});
1195+
}
1196+
}
1197+
}

grails-app/assets/javascripts/outputs.js

+2
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ ko.bindingHandlers.photoPointUpload = {
152152
$(element).fileupload({
153153
url:config.url,
154154
pasteZone: null,
155+
dropZone: null,
155156
autoUpload:true
156157
}).on('fileuploadadd', function(e, data) {
157158
complete(false);
@@ -360,6 +361,7 @@ ko.bindingHandlers.fileUploadWithProgress = {
360361
$(element).fileupload({
361362
url: config.url,
362363
pasteZone: null,
364+
dropZone: null,
363365
autoUpload: true
364366
}).on('fileuploadadd', function (e, data) {
365367
complete(false);

grails-app/conf/application.groovy

+10-11
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ environments {
2727
temp.dir = "/data/biocollect/temp"
2828
// system level config
2929
server.port = 8087
30-
serverURL = "http://devt.ala.org.au:8087"
30+
serverURL = "http://localhost:8087"
3131
biocollect.system.email.replyTo = "biocollect-dev<no-reply>@ala.org.au"
3232
sender = "biocollect-dev@ala.org.au"
3333
debugUI = true
@@ -36,11 +36,10 @@ environments {
3636
}
3737

3838
test {
39-
spring.autoconfigure.exclude="au.org.ala.ws.security.AlaWsSecurityConfiguration"
4039
debugUI = false
4140
loggerLevel = "DEBUG"
4241
server.port = "8087"
43-
grails.host = "http://devt.ala.org.au"
42+
grails.host = "http://localhost"
4443
serverName = "${grails.host}:${server.port}"
4544
grails.serverURL = serverName
4645
server.serverURL = serverName
@@ -51,8 +50,8 @@ environments {
5150
grails.config.locations = []
5251
security.oidc.discoveryUri = "http://localhost:${wiremock.port}/cas/oidc/.well-known"
5352
security.oidc.allowUnsignedIdTokens = true
54-
def casBaseUrl = "http://devt.ala.org.au:${wiremock.port}"
55-
53+
def casBaseUrl = "http://localhost:${wiremock.port}"
54+
ehcache.directory = './ehcache'
5655
security.cas.appServerName=serverName
5756
security.cas.contextPath=
5857
security.cas.casServerName="${casBaseUrl}"
@@ -61,17 +60,17 @@ environments {
6160
security.cas.loginUrl="${security.cas.casServerUrlPrefix}/login"
6261
security.cas.casLoginUrl="${security.cas.casServerUrlPrefix}/login"
6362
security.cas.logoutUrl="${security.cas.casServerUrlPrefix}/logout"
63+
userDetails.api.url = "${casBaseUrl}/userdetails/userDetails/"
6464
security.jwt.discoveryUri="${casBaseUrl}/cas/oidc/.well-known"
6565
userDetails.url = "${casBaseUrl}/userdetails/userDetails/"
66-
userDetailsSingleUrl = "${userDetails.Url}getUserDetails"
67-
userDetailsUrl = "${userDetatails.url}getUserListFull"
66+
userDetailsSingleUrl = "${userDetails.url}getUserDetails"
6867
logging.dir = '.'
6968
upload.images.path = '/tmp'
7069
upload.images.url = grails.serverURL+'/image/'
71-
ecodata.baseUrl = 'http://devt.ala.org.au:8080/'
72-
ecodata.baseURL = 'http://devt.ala.org.au:8080'
73-
ecodata.service.url = 'http://devt.ala.org.au:8080/ws'
74-
pdfgen.baseURL = "http://devt.ala.org.au:${wiremock.port}/"
70+
ecodata.baseUrl = 'http://localhost:8080/'
71+
ecodata.baseURL = 'http://localhost:8080'
72+
ecodata.service.url = 'http://localhost:8080/ws'
73+
pdfgen.baseURL = "http://localhost:${wiremock.port}/"
7574
api_key='testapikey'
7675
grails.cache.config = {
7776
diskStore {

grails-app/controllers/au/org/ala/biocollect/merit/HomeController.groovy

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class HomeController {
1414
def settingService
1515
def metadataService
1616
def userService
17+
CommonService commonService
1718

1819
@PreAuthorise(accessLevel = 'alaAdmin', redirectController = "admin")
1920
@SSO
@@ -61,6 +62,13 @@ class HomeController {
6162
def works() {
6263
}
6364

65+
def i18n() {
66+
if (request.isGet()) {
67+
Map props = commonService.i18n(request.locale)
68+
render props as JSON
69+
}
70+
}
71+
6472
/**
6573
* The purpose of this method is to enable the display of the spatial object corresponding to a selected
6674
* value from a geographic facet (e.g. to display the polygon representing NSW on the map if the user has

grails-app/services/au/org/ala/biocollect/merit/ActivityService.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ class ActivityService {
116116
webService.doDelete(grailsApplication.config.ecodata.service.url + '/activity/' + id)
117117
}
118118

119-
def bulkDelete(List ids, boolean destory) {
119+
def bulkDelete(List ids, boolean destroy = false) {
120120
String url = grailsApplication.config.ecodata.service.url + '/activityBulkDelete'
121-
if(destory)
121+
if(destroy)
122122
url += '?destroy=true'
123123
webService.doPost(url, [ids: ids])
124124
}

grails-app/services/au/org/ala/biocollect/merit/CommonService.groovy

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package au.org.ala.biocollect.merit
33
import grails.converters.JSON
44
import grails.web.mapping.LinkGenerator
55
import grails.web.servlet.mvc.GrailsParameterMap
6+
import org.springframework.context.MessageSource
67

78
import javax.servlet.http.HttpServletRequest
89
import javax.xml.bind.DatatypeConverter
@@ -13,6 +14,7 @@ class CommonService {
1314
UserService userService
1415

1516
LinkGenerator grailsLinkGenerator
17+
MessageSource messageSource
1618

1719
List ignores = ["action","controller"]
1820

@@ -92,4 +94,7 @@ class CommonService {
9294
queryParams
9395
}
9496

97+
def i18n(Locale locale) {
98+
messageSource.getMergedProperties(locale)?.properties
99+
}
95100
}

grails-app/services/au/org/ala/biocollect/merit/SettingService.groovy

+7-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ class SettingService {
100100
}
101101

102102
def loadHubConfig(hub) {
103-
103+
def defaultHub = grailsApplication.config.getProperty('app.default.hub', String, 'default')
104104
if (!hub) {
105-
hub = grailsApplication.config.app.default.hub?:'default'
105+
hub = cookieService.getCookie(LAST_ACCESSED_HUB)
106+
hub = hub ?: defaultHub
106107
}
107108
else {
108109
// Hub value in multiple places like url path and in parameter causes Array to be passed instead of String.
@@ -131,7 +132,10 @@ class SettingService {
131132
)
132133
}
133134

134-
cookieService.setCookie(LAST_ACCESSED_HUB, settings?.urlPath, -1 /* -1 means the cookie expires when the browser is closed */)
135+
// Do not set cookie value to default hub since it overwrites genuine hub selection when calls are made with default hub.
136+
// This usually happens when calls are made without hub parameter like downloading images.
137+
if (settings?.urlPath != defaultHub)
138+
cookieService.setCookie(LAST_ACCESSED_HUB, settings?.urlPath, -1 /* -1 means the cookie expires when the browser is closed */, '/')
135139
GrailsWebRequest.lookup().params.hub = settings?.urlPath
136140
SettingService.setHubConfig(settings)
137141
}

0 commit comments

Comments
 (0)