When the current user is visiting his profile in a vre, an alert message appears and the profile itself is not editable
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/social-profile@130538 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a3f07223b4
commit
9f9f88590b
|
@ -18,6 +18,7 @@ import com.google.gwt.core.client.EntryPoint;
|
|||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.Cookies;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.Window.Location;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.RootPanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
@ -57,6 +58,8 @@ public class SocialProfile implements EntryPoint {
|
|||
displayProfile();
|
||||
//result contain the publicProfileLinkedInUrl
|
||||
sendRefreshClientEvent(result);
|
||||
// force refresh to reload updated content
|
||||
setUrlBase();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
|
@ -109,6 +112,17 @@ public class SocialProfile implements EntryPoint {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes any get parameter (such as code, state)
|
||||
*/
|
||||
private void setUrlBase() {
|
||||
|
||||
String baseUrl = Window.Location.getHref().split("\\?")[0];
|
||||
GWT.log(baseUrl);
|
||||
Location.assign(baseUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the token if everything goers ok, null otherwise
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.gcube.portlets.user.socialprofile.client.SocialServiceAsync;
|
|||
import org.gcube.portlets.user.socialprofile.shared.UserContext;
|
||||
import org.gcube.portlets.widgets.wsmail.client.forms.MailForm;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Alert;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.RunAsyncCallback;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
|
@ -74,6 +75,7 @@ public class DisplayProfile extends Composite {
|
|||
@UiField Button messageButton;
|
||||
@UiField Button editButton;
|
||||
@UiField Button importButton;
|
||||
@UiField Alert ownerSeeingProfileAsVreMemberAlert;
|
||||
|
||||
|
||||
private String currHeadLine;
|
||||
|
@ -98,7 +100,13 @@ public class DisplayProfile extends Composite {
|
|||
avatarImage.setUrl(myUserInfo.getAvatarId());
|
||||
userFullName.setText(myUserInfo.getFullName());
|
||||
|
||||
if (SocialProfile.getUserToShowId() == null || result.isOwner()) { //its him seeing his profile
|
||||
/*
|
||||
* Here we check that:
|
||||
* 1) the user is the owner of the profile;
|
||||
* 2) if the current user to show is null or not (that is, the parameter GCubeSocialNetworking.USER_PROFILE_OID within the url);
|
||||
* 3) if such parameter is equal to the current user we show the profile as if it belong to someone else
|
||||
*/
|
||||
if (showAsOwner(result)) {
|
||||
|
||||
String head = (result.getHeadline() == null || result.getHeadline().compareTo("") == 0) ? HEADLINE_TEXT : result.getHeadline();
|
||||
String isti = (result.getInstitution() == null ||result.getInstitution().compareTo("") == 0) ? ISTI_TEXT : result.getInstitution();
|
||||
|
@ -162,8 +170,28 @@ public class DisplayProfile extends Composite {
|
|||
avatarImage.getElement().getParentElement().setAttribute("href", "");
|
||||
avatarImage.setTitle(myUserInfo.getFullName());
|
||||
messageButton.setVisible(true);
|
||||
|
||||
// check if the current user is the owner but he is looking at his own profile as if it was the profile of another vre member
|
||||
if(result.isOwner()){
|
||||
// TODO get the address of the My Profile page and add a link to redirect the user
|
||||
ownerSeeingProfileAsVreMemberAlert.setText("You are looking your profile as the other vre members see it.");
|
||||
ownerSeeingProfileAsVreMemberAlert.setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the profile must be shown as belonging to the user or not
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
private boolean showAsOwner(UserContext result) {
|
||||
|
||||
if((SocialProfile.getUserToShowId() == null && result.isOwner()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return the redirect uri when authorized (or not) by LinkedIn via oAuth2
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||
xmlns:g="urn:import:com.google.gwt.user.client.ui">
|
||||
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
|
||||
<g:HTMLPanel ui:field="mainPanel">
|
||||
<b:Alert visible="false" animation="true" ui:field="ownerSeeingProfileAsVreMemberAlert"></b:Alert>
|
||||
<table class="">
|
||||
<tr>
|
||||
<td width="110px;" align="middle">
|
||||
|
|
|
@ -473,6 +473,7 @@ public class SocialServiceImpl extends RemoteServiceServlet implements SocialSer
|
|||
}
|
||||
|
||||
//update the location/industry
|
||||
if(locationOrIndustry != null)
|
||||
new LiferayUserManager().saveCustomAttr(user.getUserId(), CustomAttributeKeys.USER_LOCATION_INDUSTRY.getKeyName(), locationOrIndustry);
|
||||
if (toReturn)
|
||||
return publicProfileURL;
|
||||
|
|
|
@ -14,8 +14,10 @@
|
|||
<inherits name="org.jsonmaker.gwt.Gwt_jsonmaker" />
|
||||
<inherits
|
||||
name="net.eliasbalasis.tibcopagebus4gwt.testsubscriber.TestSubscriber" />
|
||||
|
||||
<!-- Bootstrap import -->
|
||||
<inherits name="com.github.gwtbootstrap.Bootstrap" />
|
||||
|
||||
<!-- Specify the app entry point class. -->
|
||||
<entry-point
|
||||
class='org.gcube.portlets.user.socialprofile.client.SocialProfile' />
|
||||
|
|
Loading…
Reference in New Issue