diff --git a/grails-app/assets/javascripts/profileEditor/controllers/AttachmentController.js b/grails-app/assets/javascripts/profileEditor/controllers/AttachmentController.js
index 61795fec..5ab2a83a 100644
--- a/grails-app/assets/javascripts/profileEditor/controllers/AttachmentController.js
+++ b/grails-app/assets/javascripts/profileEditor/controllers/AttachmentController.js
@@ -91,6 +91,12 @@ profileEditor.controller("AttachmentUploadController", function (profileService,
var pdfType = {key: "PDF", title: "PDF Document"};
self.types = [pdfType, urlType];
+ if (self.categories == null) {
+ profileService.getCategories().then(function (data) {
+ self.categories = data.resp;
+ });
+ }
+
self.metadata = angular.isDefined(attachment) ? _.clone(attachment) : {};
self.files = null;
self.error = null;
diff --git a/grails-app/assets/javascripts/profileEditor/services/ProfileService.js b/grails-app/assets/javascripts/profileEditor/services/ProfileService.js
index a90a57ac..3e5dd931 100644
--- a/grails-app/assets/javascripts/profileEditor/services/ProfileService.js
+++ b/grails-app/assets/javascripts/profileEditor/services/ProfileService.js
@@ -1094,6 +1094,11 @@ profileEditor.service('profileService', function ($http, util, $cacheFactory, co
return util.toStandardPromise(future);
},
+ getCategories: function () {
+ var future = $http.get(util.contextRoot() + "/attachment/categories", {cache: true});
+ return util.toStandardPromise(future);
+ },
+
getLicences: function () {
var future = $http.get(util.contextRoot() + "/licences", {cache: true});
return util.toStandardPromise(future);
diff --git a/grails-app/assets/javascripts/profileEditor/templates/attachmentUpload.tpl.htm b/grails-app/assets/javascripts/profileEditor/templates/attachmentUpload.tpl.htm
index 6fd1d553..2bda87b4 100644
--- a/grails-app/assets/javascripts/profileEditor/templates/attachmentUpload.tpl.htm
+++ b/grails-app/assets/javascripts/profileEditor/templates/attachmentUpload.tpl.htm
@@ -82,10 +82,9 @@
Add an attachment
-
diff --git a/grails-app/controllers/au/org/ala/profile/hub/OpusController.groovy b/grails-app/controllers/au/org/ala/profile/hub/OpusController.groovy
index c5119a20..025b35a0 100644
--- a/grails-app/controllers/au/org/ala/profile/hub/OpusController.groovy
+++ b/grails-app/controllers/au/org/ala/profile/hub/OpusController.groovy
@@ -359,6 +359,11 @@ class OpusController extends OpusBaseController {
}
}
+ def getCategories() {
+ def result = profileService.getCategories()
+ render result as JSON
+ }
+
@Secured(role = ROLE_PROFILE_ADMIN)
def saveAttachment() {
if (!params.opusId || !(request instanceof MultipartHttpServletRequest) || !request.getParameter("data")) {
diff --git a/grails-app/controllers/au/org/ala/profile/hub/UrlMappings.groovy b/grails-app/controllers/au/org/ala/profile/hub/UrlMappings.groovy
index c3f0986a..aa65e764 100644
--- a/grails-app/controllers/au/org/ala/profile/hub/UrlMappings.groovy
+++ b/grails-app/controllers/au/org/ala/profile/hub/UrlMappings.groovy
@@ -112,6 +112,7 @@ class UrlMappings {
"/opus/$opusId/attachment/$attachmentId" controller: "opus", action: [GET: "getAttachmentMetadata", DELETE: "deleteAttachment"]
"/opus/$opusId/attachment/$attachmentId/download" controller: "opus", action: [GET: "proxyAttachmentDownload"]
"/opus/$opusId/attachment/" controller: "opus", action: [GET: "getAttachmentMetadata", POST: "saveAttachment"]
+ "/attachment/categories/" controller: "opus", action: [GET: "getCategories"]
"/opus/$opusId/florulaList" controller: "opus", action: [POST: "updateFlorulaList"]
"/opus/$opusId/users/update" controller: "opus", action: [POST: "updateUsers"]
diff --git a/grails-app/services/au/org/ala/profile/hub/ProfileService.groovy b/grails-app/services/au/org/ala/profile/hub/ProfileService.groovy
index 05af8a67..0cfa02c5 100644
--- a/grails-app/services/au/org/ala/profile/hub/ProfileService.groovy
+++ b/grails-app/services/au/org/ala/profile/hub/ProfileService.groovy
@@ -220,6 +220,10 @@ class ProfileService {
}
}
+ def getCategories() {
+ webServiceWrapperService.get("${grailsApplication.config.profile.service.url}/attachment/categories", [:], ContentType.APPLICATION_JSON, true, false, getCustomHeaderWithUserId())
+ }
+
def deleteAttachment(String opusId, String profileId, String attachmentId) {
if (profileId) {
webService.delete("${grailsApplication.config.profile.service.url}/opus/${encPath(opusId)}/profile/${encPath(profileId)}/attachment/${encPath(attachmentId)}?latest=true", [:], ContentType.APPLICATION_JSON, true, false, getCustomHeaderWithUserId())
diff --git a/src/test/groovy/au/org/ala/profile/api/ApiControllerSpec.groovy b/src/test/groovy/au/org/ala/profile/api/ApiControllerSpec.groovy
index 86d17a98..13784a1a 100644
--- a/src/test/groovy/au/org/ala/profile/api/ApiControllerSpec.groovy
+++ b/src/test/groovy/au/org/ala/profile/api/ApiControllerSpec.groovy
@@ -179,7 +179,8 @@ class ApiControllerSpec extends Specification implements ControllerUnitTest> [[key: 'key1', title: 'title1'],[key: 'key2', title: 'title2'],[key: 'key3', title: 'title3']]
+
+ when:
+ controller.getCategories()
+
+ then:
+ assert response.json.size() == 3
+ assert response.json.toString().contains("key1")
+ assert response.json.toString().contains("key2")
+ assert response.json.toString().contains("key3")
+ }
}