Skip to content

Commit

Permalink
Metadata workflow: update edit button to use in the link the metadata…
Browse files Browse the repository at this point in the history
… identifier of the working copy when a metadata has a working copy (#6321)

* Update edit button to use the working copy metadata identifier when a metadata has a working copy

* Update edit button to use the working copy metadata identifier when a metadata has a working copy - refactor

* Fix the metadata detail page code to display the non-draft version when the results include the approved and the working copy (draft) versions, and  it is requested the non-draft version
  • Loading branch information
josegar74 committed May 19, 2022
1 parent 9ee84ee commit 90c25b6
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions core/src/main/java/org/fao/geonet/constants/Geonet.java
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ public static class IndexFieldNames {
public static final String IS_PUBLISHED_TO_ALL = "isPublishedToAll";
public static final String FEEDBACKCOUNT = "feedbackCount";
public static final String DRAFT = "draft";
public static final String DRAFT_ID = "draftId";
public static final String RESOURCETITLE = "resourceTitle";
public static final String RESOURCEABSTRACT = "resourceAbstract";
public static final String PARENTUUID = "parentUuid";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ protected Multimap<String, Object> addExtraFields(AbstractMetadata fullMd) {
Log.trace(Geonet.DATA_MANAGER,
"We are indexing a record with a draft associated with uuid " + fullMd.getUuid());
extraFields.put(Geonet.IndexFieldNames.DRAFT, "e");
extraFields.put(Geonet.IndexFieldNames.DRAFT_ID, metadataDraft.getId());

String status = "";
String statusDraft = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
'topic*',
'inspire*',
'resource*',
'draft',
'draft*',
'overview.*',
'owner*',
'link*',
Expand Down Expand Up @@ -95,7 +95,7 @@
'creat*',
'group*',
'resource*',
'draft',
'draft*',
'owner*',
'recordOwner',
'status*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,16 @@
return deferred.promise;
};

this.getMetadataIdToEdit = function(md) {
if (!md) return;

if (md.draftId) {
return md.draftId;
} else {
return md.id;
}

};
this.openPrivilegesPanel = function(md, scope) {
gnUtilityService.openModal({
title: $translate.instant('privileges') + ' - ' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@
'gnESClient',
'gnESFacet',
'gnGlobalSettings',
'gnMetadataActions',
'$http',
'$filter',
function(gnSearchLocation, $rootScope, gnMdFormatter, Metadata,
gnMdViewObj, gnSearchManagerService, gnSearchSettings,
gnUrlUtils, gnUtilityService, gnESService, gnESClient,
gnESFacet, gnGlobalSettings, $http, $filter) {
gnESFacet, gnGlobalSettings, gnMetadataActions, $http, $filter) {

// Keep where the metadataview come from to get back on close
var initFromConfig = function() {
Expand Down Expand Up @@ -282,17 +283,24 @@

//If returned more than one, maybe we are looking for the draft
var i = 0;

r.data.hits.hits.forEach(function (md, index) {
if(getDraft
if (getDraft
&& md._source.draft == 'y') {
//This will only happen if the draft exists
//and the user can see it
i = index;
} else if (!getDraft
&& md._source.draft != 'y') {
// This use the non-draft version when the results include the
// approved and the working copy (draft) versions
i = index;
}
});

var metadata = [];
metadata.push(new Metadata(r.data.hits.hits[i]));

data = {metadata: metadata};
//Keep the search results (gnMdViewObj.records)
// that.feedMd(0, undefined, data.metadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<a class="btn btn-default"
data-ng-show="user.canEditRecord(md) && md.isTemplate != 's'
&& (user.isReviewerOrMore() || md.mdStatus != 4 || !isMdWorkflowEnable)"
data-ng-href="#/metadata/{{md.id}}?redirectUrl=catalog.edit"
data-ng-href="#/metadata/{{mdService.getMetadataIdToEdit(md)}}?redirectUrl=catalog.edit"
title="{{'edit' | translate}}">
<i class="fa fa-pencil"></i>
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<div class="btn-group pull-left" role="group">
<a class="btn btn-default gn-md-edit-btn"
data-ng-show="user.canEditRecord(mdView.current.record) && (user.isReviewerOrMore() || mdView.current.record.mdStatus != 4 || !isMdWorkflowEnable)"
data-ng-href="catalog.edit#/metadata/{{mdView.current.record.id}}?redirectUrl=catalog.search%23%2Fmetadata%2F{{mdView.current.record.uuid}}"
data-ng-href="catalog.edit#/metadata/{{gnMetadataActions.getMetadataIdToEdit(mdView.current.record)}}?redirectUrl=catalog.search%23%2Fmetadata%2F{{mdView.current.record.uuid}}"
title="{{'edit' | translate}}">
<span class="fa fa-fw fa-pencil"></span>
<span data-translate="" class="hidden-sm hidden-xs">edit</span>
Expand Down

0 comments on commit 90c25b6

Please sign in to comment.