From aa0b4fdaa2763ae1efcefc8c257b6112b5988829 Mon Sep 17 00:00:00 2001 From: "costantino.perciante" Date: Thu, 7 Apr 2016 10:37:57 +0000 Subject: [PATCH] The portlet now open the settings dialog automatically if the actual url ends with showsettings=true git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/notifications@126852 82a268e6-3cf1-43bd-a215-b396298e98cf --- pom.xml | 6 ++++ .../client/view/NotificationsPanel.java | 29 +++++++++++++++++-- .../templates/SingleNotificationView.java | 8 ++++- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 803fa96..69c680c 100644 --- a/pom.xml +++ b/pom.xml @@ -87,6 +87,12 @@ aslcore provided + + org.gcube.common.portal + portal-manager + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + provided + com.google gwt-jsonmaker diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/NotificationsPanel.java b/src/main/java/org/gcube/portlets/user/notifications/client/view/NotificationsPanel.java index c3f5dbb..4c4b6e9 100644 --- a/src/main/java/org/gcube/portlets/user/notifications/client/view/NotificationsPanel.java +++ b/src/main/java/org/gcube/portlets/user/notifications/client/view/NotificationsPanel.java @@ -17,12 +17,14 @@ import org.gcube.portlets.user.notifications.shared.NotificationConstants; import org.gcube.portlets.user.notifications.shared.NotificationPreference; import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Style.Position; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.Window.Location; import com.google.gwt.user.client.Window.ScrollEvent; import com.google.gwt.user.client.Window.ScrollHandler; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -125,9 +127,30 @@ public class NotificationsPanel extends Composite { } } }); - } - + // if the url ends with "showsettings=true" open the settings modal automatically + if(Location.getHref().endsWith("showsettings=true")){ + + Timer t = new Timer() { + + @Override + public void run() { + clickElement(notificationSettings.getElement()); + + } + }; + t.schedule(1000); + + } + } + + /** + * Simulate click event + * @param elem + */ + private static native void clickElement(Element elem) /*-{ + elem.click(); + }-*/; private void showUserNotifications() { showLoader(); @@ -196,7 +219,7 @@ public class NotificationsPanel extends Composite { int from = (fromStartingPoint == 0) ? NotificationConstants.NOTIFICATION_NUMBER_PRE+1 : fromStartingPoint; fromStartingPoint = from; final int quantity = NotificationConstants.NOTIFICATION_NUMBER_PER_REQUEST; - + notificationService.getUserNotificationsByRange(from, quantity, new AsyncCallback>>() { @Override public void onSuccess(HashMap> notificationsPerDay) { diff --git a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/SingleNotificationView.java b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/SingleNotificationView.java index 43857c7..5b1741f 100644 --- a/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/SingleNotificationView.java +++ b/src/main/java/org/gcube/portlets/user/notifications/client/view/templates/SingleNotificationView.java @@ -1,9 +1,11 @@ package org.gcube.portlets.user.notifications.client.view.templates; +import org.gcube.common.portal.GCubePortalConstants; import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portal.databook.client.util.Encoder; import org.gcube.portal.databook.shared.Notification; import org.gcube.portal.databook.shared.NotificationType; +import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper; import org.gcube.portlets.user.gcubewidgets.client.elements.Span; import org.gcube.portlets.user.notifications.client.view.templates.images.NotificationImages; @@ -12,6 +14,7 @@ import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.resources.client.ImageResource; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.Window.Location; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; @@ -63,8 +66,11 @@ public class SingleNotificationView extends Composite { //shorten the notification text if greather than 200 chars actualHTML = actualHTML.length() > 200 ? actualHTML.substring(0, 200) + " ..." : actualHTML; + String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +"/"+GCubePortalConstants.USER_PROFILE_FRIENDLY_URL; + notificationText.setHTML( - ""+ toShow.getSenderFullName()+" " + actualHTML);