Implemented - DELETE relation" operation allowed only in DRAFT phase

[#25104]
This commit is contained in:
Francesco Mangiacrapa 2023-05-11 16:24:16 +02:00
parent 79e0e366f1
commit 4762ad4f35
4 changed files with 42 additions and 6 deletions

View File

@ -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

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>geoportal-data-entry-app</artifactId>
<packaging>war</packaging>
<version>3.2.0</version>
<version>3.2.0-SNAPSHOT</version>
<name>GeoPortal Data Entry App</name>
<description>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</description>
<scm>

View File

@ -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.

View File

@ -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));
}
}
});