Make the "motivation" mandatory when someone asks to join a VRE

This commit is contained in:
Massimiliano Assante 2022-01-03 15:29:26 +01:00
parent 1e1bb2e47b
commit d56a2e6600
4 changed files with 46 additions and 38 deletions

View File

@ -4,15 +4,17 @@
All notable changes to this project will be documented in this file. 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). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v3.7.3-SNAPSHOT] - 2022-01-03
- Make the "motivation" mandatory when someone asks to join a VRE
## [v3.7.2] - 2021-04-30 ## [v3.7.2] - 2021-04-30
Removed a forgotten sysout in the code :( - Removed a forgotten sysout in the code :(
## [v3.7.1] - 2020-10-16 ## [v3.7.1] - 2020-10-16
Enhacements - No need to retrieve the user membership request status if the VRE Access policy is Open
No need to retrieve the user membership request status if the VRE Access policy is Open
## [v3.7.0] - 2020-06-03 ## [v3.7.0] - 2020-06-03

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>join-vre</artifactId> <artifactId>join-vre</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>3.7.2</version> <version>3.7.3-SNAPSHOT</version>
<name>gCube Join VRE Portlet</name> <name>gCube Join VRE Portlet</name>
<description>Display the available VRE to Join</description> <description>Display the available VRE to Join</description>
<scm> <scm>
@ -38,7 +38,7 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId> <artifactId>maven-portal-bom</artifactId>
<version>3.6.3</version> <version>3.6.3-SNAPSHOT</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>

View File

@ -17,6 +17,7 @@ import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.Window.Location; import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
@ -25,7 +26,7 @@ import com.google.gwt.user.client.ui.Widget;
public class RequestMembershipDialog extends Composite { public class RequestMembershipDialog extends Composite {
private static final String OPTIONAL_COMMENT_TEXT = "You can add an optional comment here, it will be attached to your request and read by this VRE Moderators."; private static final String MANDATORY_MOTIVATION_TEXT = "Please state your motivation here, it will be attached to your request and read by this VRE Moderators (Mandatory field).";
private final JoinServiceAsync joinService = GWT.create(JoinService.class); private final JoinServiceAsync joinService = GWT.create(JoinService.class);
@ -38,7 +39,7 @@ public class RequestMembershipDialog extends Composite {
@UiField Modal m; @UiField Modal m;
@UiField Button close; @UiField Button close;
@UiField Button confirmRequest; @UiField Button confirmRequest;
@UiField TextArea optionalText; @UiField TextArea mandatoryMotivation;
@UiField HelpBlock helpBlock; @UiField HelpBlock helpBlock;
@UiField Icon loading; @UiField Icon loading;
private VRE myVRE = null; private VRE myVRE = null;
@ -51,8 +52,8 @@ public class RequestMembershipDialog extends Composite {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
this.myVRE = myVRE; this.myVRE = myVRE;
this.responsivePanel = responsivePanel; this.responsivePanel = responsivePanel;
optionalText.setWidth("95%"); mandatoryMotivation.setWidth("95%");
optionalText.setPlaceholder(OPTIONAL_COMMENT_TEXT); mandatoryMotivation.setPlaceholder(MANDATORY_MOTIVATION_TEXT);
} }
public void show() { public void show() {
@ -100,13 +101,17 @@ public class RequestMembershipDialog extends Composite {
} }
@UiHandler("confirmRequest") @UiHandler("confirmRequest")
void confirm(ClickEvent e) { void confirm(ClickEvent e) {
String text = optionalText.getText(); String text = mandatoryMotivation.getText();
if (text.isEmpty() || text.length() < 8) {
Window.alert("The motivation is mandatory, please state your motivation appropriately.");
}
else {
confirmRequest.setEnabled(false); confirmRequest.setEnabled(false);
joinService.addMembershipRequest(myVRE, text, new AsyncCallback<Void>() { joinService.addMembershipRequest(myVRE, text, new AsyncCallback<Void>() {
@Override @Override
public void onSuccess(Void result) { public void onSuccess(Void result) {
confirmRequest.removeFromParent(); confirmRequest.removeFromParent();
optionalText.removeFromParent(); mandatoryMotivation.removeFromParent();
m.setTitle("Thank you, your request has been sent successfully"); m.setTitle("Thank you, your request has been sent successfully");
helpBlock.setText("You will receive an email as soon as your request will be processed."); helpBlock.setText("You will receive an email as soon as your request will be processed.");
responsivePanel.setPending(myVRE); responsivePanel.setPending(myVRE);
@ -116,7 +121,7 @@ public class RequestMembershipDialog extends Composite {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
confirmRequest.removeFromParent(); confirmRequest.removeFromParent();
optionalText.removeFromParent(); mandatoryMotivation.removeFromParent();
m.setTitle("An error occurred! Your request has not been sent"); m.setTitle("An error occurred! Your request has not been sent");
helpBlock.setText("An email with the cause of the error has been sent to the support team, we'll be back to you shortly."); helpBlock.setText("An email with the cause of the error has been sent to the support team, we'll be back to you shortly.");
touText.removeFromParent(); touText.removeFromParent();
@ -124,3 +129,4 @@ public class RequestMembershipDialog extends Composite {
}); });
} }
} }
}

View File

@ -8,7 +8,7 @@
visible="false" /> visible="false" />
<b:ControlGroup> <b:ControlGroup>
<b:Controls> <b:Controls>
<b:TextArea ui:field="optionalText" alternateSize="XLARGE" /> <b:TextArea ui:field="mandatoryMotivation" alternateSize="XLARGE" />
<b:HelpBlock ui:field="helpBlock">Your request will be reviewed by this VRE moderators, you will be notified via email about the result as soon as possible (tipically within a few hours).</b:HelpBlock> <b:HelpBlock ui:field="helpBlock">Your request will be reviewed by this VRE moderators, you will be notified via email about the result as soon as possible (tipically within a few hours).</b:HelpBlock>
<b:HelpBlock ui:field="touGatewayBlock" visible="false"> <b:HelpBlock ui:field="touGatewayBlock" visible="false">
By asking access to this VRE you agree to the terms indicated in By asking access to this VRE you agree to the terms indicated in