Skip to content

Commit

Permalink
Fix publish link
Browse files Browse the repository at this point in the history
Re-apply changes for PR geonetwork#7009 that was broken when PR geonetwork#7148 was merged in commit 1021055
  • Loading branch information
ianwallen committed Nov 8, 2023
1 parent 4806aff commit 42a35e4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
25 changes: 19 additions & 6 deletions web-ui/src/main/resources/catalog/js/CatController.js
Original file line number Diff line number Diff line change
Expand Up @@ -931,11 +931,17 @@ goog.require('gn_alert');
return gnConfig["metadata.workflow.allowPublishNonApprovedMd"];
};

$scope.getPublicationOptionClass = function (md, user, isMdWorkflowEnable) {
$scope.getPublicationOptionClass = function (
md,
user,
isMdWorkflowEnable,
pubOption
) {
var publicationOptionTitle = $scope.getPublicationOptionTitle(
md,
user,
isMdWorkflowEnable
isMdWorkflowEnable,
pubOption
);
switch (publicationOptionTitle) {
case "mdnonapprovedcantpublish":
Expand All @@ -948,16 +954,22 @@ goog.require('gn_alert');
};

// Function to get the title name to be used when displaying the publish item in the menu
$scope.getPublicationOptionTitle = function (md, user, isMdWorkflowEnable) {
$scope.getPublicationOptionTitle = function (
md,
user,
isMdWorkflowEnable,
pubOption
) {
var publicationOptionTitle = "";
if (!md.isPublished()) {
if (!md.isPublished(pubOption)) {
if (md.isValid()) {
publicationOptionTitle = "mdvalid";
} else {
if (
isMdWorkflowEnable &&
md.isWorkflowEnabled() &&
$scope.allowPublishInvalidMd() === false
$scope.allowPublishInvalidMd() === false &&
pubOption.name === "default"
) {
publicationOptionTitle = "mdinvalidcantpublish";
} else {
Expand All @@ -974,7 +986,8 @@ goog.require('gn_alert');
isMdWorkflowEnable &&
md.isWorkflowEnabled() &&
md.mdStatus != 2 &&
$scope.allowPublishNonApprovedMd() === false
$scope.allowPublishNonApprovedMd() === false &&
pubOption.name === "default"
) {
publicationOptionTitle = "mdnonapprovedcantpublish";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,9 @@
data-ng-repeat="pubOption in publicationOptions"
role="menuitem"
data-ng-if="user.canEditRecord(md) && (user.isAdmin() || user.isReviewerForGroup(md.groupOwner)) && md.draft != 'y' && md.mdStatus != 3"
data-ng-class="
(md.isPublished(pubOption) || (allowPublishInvalidMd() === true) ||
(!md.isPublished(pubOption) && (allowPublishInvalidMd() === false) &&
(!md.hasValidation() || (md.hasValidation() && md.isValid())))) ? '' : 'disabled'"
title="{{(!md.isPublished(pubOption) ? (md.isValid() ? 'mdvalid' :
(!md.hasValidation() ? 'mdnovalidation':
(allowPublishInvalidMd() === false ? 'mdinvalidcantpublish' : 'mdinvalid'))) : '') | translate }}">
data-ng-class="getPublicationOptionClass(md, user, isMdWorkflowEnable, pubOption)"
title="{{getPublicationOptionTitle(md, user, isMdWorkflowEnable, pubOption) | translate}}"
>
<a href="" data-ng-click="mdService.publish(md, undefined, undefined, getCatScope(), pubOption)">
<span class="fa fa-fw"
data-ng-class="md.isPublished(pubOption) ? 'fa-lock' : 'fa-unlock'"></span>&nbsp;
Expand Down

0 comments on commit 42a35e4

Please sign in to comment.