From 4762ad4f35c271d4d731c88d6ac7bfc0dc91c65f Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 11 May 2023 16:24:16 +0200 Subject: [PATCH] Implemented - DELETE relation" operation allowed only in DRAFT phase [#25104] --- CHANGELOG.md | 3 +- pom.xml | 2 +- .../ConstantsGeoPortalDataEntryApp.java | 6 +++ .../ui/relation/ViewRelationshipPanel.java | 37 +++++++++++++++++-- 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbf4218..4a09919 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,13 +4,14 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [v3.2.0] - 2022-05-11 +## [v3.2.0-SNAPSHOT] - 2022-05-11 - Implemented the Update facility [#24166] - Integrated with the geoportal-data-mapper library [#24244] - Integrated the Geoportal Data-Viewer Widget [#25015] - Passed to Geoportal_Resolver service [#25031] - Provided the "View Document" and "View As JSON" facilities +- DELETE relation" operation allowed only in DRAFT phase [#25104] ## [v3.1.0] - 2023-03-06 diff --git a/pom.xml b/pom.xml index ff3129b..42bd7a4 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-entry-app war - 3.2.0 + 3.2.0-SNAPSHOT GeoPortal Data Entry App The GeoPortal Data Entry App is an application to build the web forms for data entries needed to create projects/documents (based on UCD) in the D4Science Geoportal service diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java index 513fef7..e175e9b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ConstantsGeoPortalDataEntryApp.java @@ -61,6 +61,12 @@ public class ConstantsGeoPortalDataEntryApp { + WORKFLOW_PHASE.DRAFT.name() + " phase. You need to perform the step 'Reject' or 'UnPublish' to take back the project in " + WORKFLOW_PHASE.DRAFT.name() + " phase."; + + + public static final String ALERT_MESSAGE_DELETE_RELATION_FORBIDDEN = "The Delete Relation operation can be performed only in " + + WORKFLOW_PHASE.DRAFT.name() + + " phase. You need to perform the step 'Reject' or 'UnPublish' to take back the project in " + + WORKFLOW_PHASE.DRAFT.name() + " phase."; /** * The Enum ACTION_PERFORMED_ON_ITEM. diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/ViewRelationshipPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/ViewRelationshipPanel.java index 13a0c38..5103dcc 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/ViewRelationshipPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/relation/ViewRelationshipPanel.java @@ -4,12 +4,17 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import org.gcube.application.geoportalcommon.shared.config.OPERATION_ON_ITEM; import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV; +import org.gcube.application.geoportalcommon.shared.geoportal.WORKFLOW_PHASE; import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV; +import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp; import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryServiceAsync; import org.gcube.portlets.user.geoportaldataentry.client.events.CloseCreateRelationGUIEvent; import org.gcube.portlets.user.geoportaldataentry.client.events.RelationActionHandlerEvent; +import org.gcube.portlets.user.geoportaldataentry.client.resource.Images; +import org.gcube.portlets.user.geoportaldataentry.client.ui.ModalWindow; import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil; import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; @@ -17,6 +22,7 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.Label; import com.github.gwtbootstrap.client.ui.Modal; +import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.github.gwtbootstrap.client.ui.constants.IconSize; import com.github.gwtbootstrap.client.ui.constants.IconType; @@ -35,6 +41,7 @@ import com.google.gwt.user.client.ui.FlexTable; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; +import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Widget; public class ViewRelationshipPanel extends Composite { @@ -170,7 +177,7 @@ public class ViewRelationshipPanel extends Composite { Label label = new Label(); label.setType(LabelType.INFO); label.setText(relationDV.getRelationshipName()); - + FlowPanel panelContainer = new FlowPanel(); Button deleteRelation = new Button("", IconType.TRASH); deleteRelation.setTitle("Delete this relation"); @@ -179,9 +186,31 @@ public class ViewRelationshipPanel extends Composite { @Override public void onClick(ClickEvent event) { - ResultDocumentDV toProject = mapOfTargetProjectForId.get(relationDV.getTargetUCD()); - appManagerBus.fireEvent( - new RelationActionHandlerEvent(project, relationDV.getRelationshipName(), toProject)); + + // #24571 + boolean isNotInDRAFT = false; + + if (fromTheProject.getLifecycleInfo() != null) { + String phase = fromTheProject.getLifecycleInfo().getPhase(); + // IF the project is not in DRAFT, showing an alert and the no Update Mode will + // be activated + if (phase != null && phase.compareToIgnoreCase(WORKFLOW_PHASE.DRAFT.getLabel()) != 0) { + + String msg = ConstantsGeoPortalDataEntryApp.ALERT_MESSAGE_DELETE_RELATION_FORBIDDEN; + ModalWindow modalW = new ModalWindow(new Image(Images.ICONS.accessDenied()), + "Forbidden: " + OPERATION_ON_ITEM.DELETE_RELATION, msg, AlertType.WARNING); + modalW.show(); + + isNotInDRAFT = true; + } + } + + //If the project is in DRAFT, going to delete the releation after confirm + if(!isNotInDRAFT) { + ResultDocumentDV toProject = mapOfTargetProjectForId.get(relationDV.getTargetUCD()); + appManagerBus.fireEvent( + new RelationActionHandlerEvent(project, relationDV.getRelationshipName(), toProject)); + } } });