Skip to content

Commit

Permalink
Merge pull request #686 from AtlasOfLivingAustralia/dev
Browse files Browse the repository at this point in the history
Merge 2.4 from dev to master
  • Loading branch information
Rita-C authored May 13, 2019
2 parents 47d0d8e + 4af4631 commit ba2f767
Show file tree
Hide file tree
Showing 41 changed files with 962 additions and 175 deletions.
2 changes: 1 addition & 1 deletion application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#Wed Dec 21 11:09:46 AEDT 2016
app.grails.version=2.5.6
app.name=profile-hub
app.version=2.3
app.version=2.4
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Controller for handling creating a new profile (via a modal popup)
*/
profileEditor.controller('CreateProfileController', function (profileService, $modalInstance, opusId, duplicateExisting) {
profileEditor.controller('CreateProfileController', function (profileService, messageService, $modalInstance, opusId, duplicateExisting) {
var self = this;

self.opusId = opusId;
Expand Down Expand Up @@ -44,14 +44,18 @@ profileEditor.controller('CreateProfileController', function (profileService, $m
};

self.searchByScientificName = function () {
var searchResult = profileService.profileSearch(self.opusId, self.profileToCopy, true);
searchResult.then(function (data) {
self.profiles = data;
},
function () {
messageService.alert("Failed to perform search for '" + self.searchTerm + "'.");
}
);
if (!self.profileToCopy || self.profileToCopy === undefined || self.profileToCopy.length <= 0) {
self.profiles = [];
} else {
var searchResult = profileService.profileSearch(self.opusId, self.profileToCopy, true);
searchResult.then(function (data) {
self.profiles = data;
},
function () {
messageService.alert("Failed to perform search for '" + self.searchTerm + "'.");
}
);
}
};

self.valid = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ profileEditor.controller('MapController', function ($scope, profileService, util
point: {
colour: self.opus.mapConfig.mapPointColour,
mapAttribution: self.opus.mapConfig.mapAttribution
}
},
facetGroupUrl: config.facetGroupUrl
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ profileEditor.controller('PublicationController', function (profileService, util
promise.then(function () {
loadPublications();
}, function () {
messageService.alert("An error occurred while creating the snapshot.");
messageService.alertStayOn("An error occurred while creating the snapshot. The error might be due to profile not having an author.");
});
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@

function checkMasterlistSyncStatus() {
$log.debug("Chceking masterlist sync status");
if (!self.opus.uuid) return;
profileService.isMasterListSyncing(self.opus.uuid)
.then(function(res) {
self.isMasterListSyncing = res.response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ profileEditor.directive('vocabularyEditor', function ($browser) {
$scope.removeVocabTerm = function (index, form) {
var promise = profileService.findUsagesOfVocabTerm($scope.opusId, $scope.vocabId, $scope.vocabulary.terms[index].termId);
promise.then(function (data) {
if (data.usageCount == 0) {
if (data.usageCount == 0 &&
$filter('filter')($scope.replacements, {'newTermName':$scope.vocabulary.terms[index].name}).length == 0) {
var deletedItemOrder = $scope.vocabulary.terms[index].order;
$scope.vocabulary.terms.splice(index, 1);

Expand Down Expand Up @@ -85,9 +86,15 @@ profileEditor.directive('vocabularyEditor', function ($browser) {
return $scope.vocabulary.terms[existingTermIndex];
},
terms: function() {
var terms = angular.copy($scope.vocabulary.terms);
var deletedItemOrder = terms[existingTermIndex].order;
terms.splice(existingTermIndex, 1);
var terms = [];
var itemToDel = $scope.vocabulary.terms[existingTermIndex];
var deletedItemOrder = $scope.vocabulary.terms[existingTermIndex].order;
angular.forEach($scope.vocabulary.terms, function(term) {
if ($filter('filter')($scope.replacements, {'existingTermId':term.termId}).length == 0 &&
term.termId != itemToDel.termId) {
terms.push(term);
}
});

angular.forEach(terms, function(term) {
if (term.order > deletedItemOrder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
</div>

<!-- config is on root scope -->
<div ng-if="config.isOpusReviewer && (config.isOpusAuthor || comment.author.userId == config.currentUserId)"
class="col-md-4">
<button class="btn btn-link fa fa-trash-o color--red" ng-click="commentCtrl.deleteComment(path)"
<div class="col-md-4">
<button ng-if="config.isALAAdmin || config.isOpusAdmin"
class="btn btn-link fa fa-trash-o color--red" ng-click="commentCtrl.deleteComment(path)"
title="Delete comment"></button>
<button class="btn btn-link fa fa-edit" ng-click="commentCtrl.editComment(path)"
<button ng-if="config.isOpusAdmin || config.isOpusEditor || config.isOpusAuthor || (config.isOpusReviewer && comment.author.userId == config.currentUserId)"
class="btn btn-link fa fa-edit" ng-click="commentCtrl.editComment(path)"
title="Edit comment"></button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

<!-- readonly view -->
<div class="col-md-12 nomenclature" ng-show="selectedReference && readonly">
<a href="" class="btn btn-link btn-sm" ng-click="toggleSynonomy()"><span class="fa" ng-class="showSynonomy ? 'fa-angle-double-up' : 'fa-angle-double-down'"></span>&nbsp;
<div class="concept" data-ng-bind-html="selectedReference.formattedName | sanitizeHtml"></div>
<a href="" class="btn btn-link btn-sm" ng-click="toggleSynonomy()"><span class="fa" ng-class="showSynonomy ? 'fa-angle-double-up' : 'fa-angle-double-down'"></span>&nbsp;
<span class="concept" data-ng-bind-html="selectedReference.formattedName | sanitizeHtml"></span>
</a>

<div class="apc" ng-show="selectedReference.apcReference"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ <h4 class="modal-title">Remove vocabulary term</h4>
</div>

<div class="modal-body">
<p>
<p ng-hide="removeTermCtrl.usageCount == '0'" >
The vocabulary term {{removeTermCtrl.existingTerm.name}} is being used in {{removeTermCtrl.usageCount}}
profile(s).
You must either select a replacement term or manually find and remove all usages before you can delete
the term.
</p>
<p ng-show="removeTermCtrl.usageCount == '0'" >
The vocabulary term {{removeTermCtrl.existingTerm.name}} is being selected as a replacement term.
You must either select another replacement term or remove all usages before you can delete the term.
</p>

<div class="form-horizontal">
<div class="form-group">
Expand Down
6 changes: 5 additions & 1 deletion grails-app/assets/stylesheets/mergedProfilesThemeColour.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,11 @@ hr.comment-divider {

.nomenclature .concept {
font-weight: bold;
display: inline-block;
}

.nomenclature .btn {
white-space: normal;
text-align: start;
}

.nomenclature a, .nomenclature a:focus, .nomenclature a:hover {
Expand Down
5 changes: 4 additions & 1 deletion grails-app/assets/thirdparty/ckeditor/ng-ckeditor-0.2.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@
onUpdateModelData(true);
});

instance.document.on('keyup', setModelData);
// This fixes a bug in ng-ckeditor that caused #627.
// Previously listener was incorrectly configured. Function setModelData was called on a keystroke
// anywhere on the page.
instance.on('key', setModelData);
});
instance.on('customConfigLoaded', function() {
configLoaderDef.resolve();
Expand Down
2 changes: 1 addition & 1 deletion grails-app/conf/BuildConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ grails.project.dependency.resolution = {
compile ":cache:1.1.8"
compile ":cors:1.1.6"
compile ":csv:0.3.1"
compile(":ala-map:2.0.4") {
compile(":ala-map:2.1.8-SNAPSHOT") {
excludes "resources"
}
compile(":ala-ws-plugin:1.6.1") {
Expand Down
1 change: 1 addition & 0 deletions grails-app/conf/UrlMappings.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ class UrlMappings {
"/opus/$opusId/profile/$profileId/image/$imageId/tile/$zoom/$x/$y" controller: "image", action: [GET: "getTile"]

"/stylesheet/$id?" controller: "stylesheet", action: "opus"
"/facets" controller: "resource", action: "facets"
if (Environment.current == Environment.DEVELOPMENT) {
"/console/$action?/$id?(.$format)?" controller: 'console'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ class AccessControlFilters {
authorised = params.isOpusAdmin
log.debug "Action ${actionFullName} requires ROLE_PROFILE_ADMIN. User ${request.userPrincipal?.name} has it? ${authorised}"
} else if (requiredRole == Role.ROLE_PROFILE_EDITOR.toString()) {
authorised = params.isOpusAdmin || params.isOpusEditor
authorised = params.isOpusAdmin || params.isOpusAuthor || params.isOpusEditor
log.debug "Action ${actionFullName} requires ${requiredRole}. User ${request.userPrincipal?.name} has it? ${authorised}"
} else if (requiredRole == Role.ROLE_PROFILE_AUTHOR.toString()) {
authorised = params.isOpusAdmin || params.isOpusAuthor || params.isOpusEditor
authorised = params.isOpusAdmin || params.isOpusAuthor
log.debug "Action ${actionFullName} requires ${requiredRole}. User ${request.userPrincipal?.name} has it? ${authorised}"
} else if (requiredRole == Role.ROLE_PROFILE_REVIEWER.toString()) {
authorised = params.isOpusAdmin || params.isOpusAuthor || params.isOpusReviewer || params.isOpusEditor
Expand Down Expand Up @@ -122,6 +122,8 @@ class AccessControlFilters {
response.status = HttpStatus.SC_FORBIDDEN
response.sendError(HttpStatus.SC_FORBIDDEN)
}

return authorised
} else {
boolean authenticated = authService.getDisplayName() != null
params.isOpusAdmin = authenticated
Expand All @@ -130,6 +132,7 @@ class AccessControlFilters {
params.isOpusReviewer = authenticated
params.isOpusUser = authenticated
log.warn "**** Authorisation has been disabled! ****"
return true
}
}
after = { Map model ->
Expand Down
115 changes: 115 additions & 0 deletions grails-app/conf/grouped_facets_ala.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
[
{
"title":"Taxon",
"facets":[
{
"sort":"index",
"field":"taxon_name"
},
{
"sort":"index",
"field":"subspecies_name"
},
{
"sort":"index",
"field":"species"
},
{
"sort":"index",
"field":"genus"
},
{
"sort":"index",
"field":"family"
},
{
"sort":"index",
"field":"order"
},
{
"sort":"index",
"field":"class"
},
{
"sort":"index",
"field":"phylum"
},
{
"sort":"index",
"field":"kingdom"
},
{
"sort":"index",
"field":"common_name"
},
{
"sort":"count",
"field":"species_subgroup"
}
]
},
{
"title":"Occurrence",
"facets":[
{
"sort":"index",
"field":"month"
},
{
"sort":"index",
"field":"year"
}
]
},
{
"title":"Location",
"facets":[
{
"sort":"index",
"field":"country"
},
{
"sort":"count",
"field":"state"
},
{
"sort":"count",
"field": "cl1048"
},
{
"sort":"count",
"field": "cl1049"
}
]
},
{
"title":"Record",
"facets":[
{
"sort":"index",
"field":"basis_of_record"
},
{
"sort":"count",
"field":"multimedia"
},
{
"sort":"index",
"field":"occurrence_status"
}
]
},
{
"title":"Attribution",
"facets":[
{
"sort":"count",
"field":"alau_user_id"
},
{
"sort":"count",
"field":"data_resource_uid"
}
]
}
]
1 change: 1 addition & 0 deletions grails-app/conf/reports/profiles/PROFILES_detail.jrxml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
<reportElement positionType="Float" x="0" y="86" width="515" height="15" uuid="6c27bf88-e8a0-4428-b155-5ec3610add41">
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<printWhenExpression><![CDATA[Boolean.valueOf($P{PROFILES_REPORT_OPTIONS}.map)]]></printWhenExpression>
</reportElement>
<subreportParameter name="REPORT_TEMPLATES">
<subreportParameterExpression><![CDATA[(java.util.Collection<net.sf.jasperreports.engine.JRTemplate>)$P{REPORT_TEMPLATES}]]></subreportParameterExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,14 @@ class CommentController extends BaseController {
}
}

@Secured(role = Role.ROLE_PROFILE_REVIEWER)
@Secured(role = Role.ROLE_PROFILE_ADMIN)
def deleteComment() {
if (!params.commentId) {
badRequest()
} else if (checkCommentPermissions(params.profileId, params.commentId)) {
} else {
def response = profileService.deleteComment(params.opusId, params.profileId, params.commentId)

handle response
} else {
notAuthorised()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.springframework.web.multipart.MultipartFile
import org.springframework.web.multipart.MultipartHttpServletRequest
import org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest

import static au.org.ala.profile.hub.Utils.encPath
import static au.org.ala.profile.hub.util.HubConstants.*
import static au.org.ala.profile.security.Role.ROLE_ADMIN
import static au.org.ala.profile.security.Role.ROLE_PROFILE_ADMIN
Expand Down Expand Up @@ -104,6 +103,7 @@ class OpusController extends OpusBaseController {
}
}

@Secured(role = ROLE_PROFILE_ADMIN)
def reports() {
def opus = profileService.getOpus(params.opusId as String)

Expand Down
Loading

0 comments on commit ba2f767

Please sign in to comment.