This repository has been archived by the owner on Jan 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PLF-7947 Connect button is no longer present on the profile card (#314)
- Loading branch information
Showing
7 changed files
with
224 additions
and
2 deletions.
There are no files selected for viewing
118 changes: 118 additions & 0 deletions
118
...formNavigation/src/main/java/org/exoplatform/platform/component/UIRelationshipAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
* Copyright (C) 2018 eXo Platform SAS. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.exoplatform.platform.component; | ||
|
||
import org.exoplatform.social.core.relationship.model.Relationship; | ||
import org.exoplatform.social.core.relationship.model.Relationship.Type; | ||
import org.exoplatform.social.webui.Utils; | ||
import org.exoplatform.web.application.ApplicationMessage; | ||
import org.exoplatform.webui.config.annotation.ComponentConfig; | ||
import org.exoplatform.webui.config.annotation.EventConfig; | ||
import org.exoplatform.webui.core.UIComponent; | ||
import org.exoplatform.webui.core.UIPortletApplication; | ||
import org.exoplatform.webui.event.Event; | ||
import org.exoplatform.webui.event.EventListener; | ||
|
||
@ComponentConfig( | ||
template = "app:/groovy/platformNavigation/portlet/UIUserNavigationPortlet/UIRelationshipAction.gtmpl", | ||
events = { | ||
@EventConfig(listeners = UIRelationshipAction.ConnectActionListener.class), | ||
@EventConfig(listeners = UIRelationshipAction.CancelActionListener.class), | ||
@EventConfig(listeners = UIRelationshipAction.AcceptActionListener.class), | ||
@EventConfig(listeners = UIRelationshipAction.DenyActionListener.class), | ||
@EventConfig(listeners = UIRelationshipAction.DisconnectActionListener.class) | ||
} | ||
) | ||
public class UIRelationshipAction extends UIComponent { | ||
|
||
public UIRelationshipAction() { | ||
} | ||
|
||
public static abstract class AbstractActionListener extends EventListener<UIRelationshipAction> { | ||
protected Relationship relationship = null; | ||
protected String msgKey = "UIRelationshipAction.label.ConnectNotExisting"; | ||
@Override | ||
public void execute(Event<UIRelationshipAction> event) { | ||
UIRelationshipAction uiAction = event.getSource(); | ||
relationship = Utils.getRelationshipManager().get(Utils.getOwnerIdentity(), Utils.getViewerIdentity()); | ||
if (isValid(event)) { | ||
doAction(event); | ||
} else { | ||
uiAction.getAncestorOfType(UIPortletApplication.class).addMessage(new ApplicationMessage(msgKey, new String[]{}, ApplicationMessage.WARNING)); | ||
} | ||
// | ||
event.getRequestContext().addUIComponentToUpdateByAjax(uiAction.getParent()); | ||
} | ||
protected boolean isValid(Event<UIRelationshipAction> event) { | ||
return (relationship != null); | ||
} | ||
protected abstract void doAction(Event<UIRelationshipAction> event); | ||
} | ||
|
||
public static class ConnectActionListener extends AbstractActionListener { | ||
@Override | ||
protected boolean isValid(Event<UIRelationshipAction> event) { | ||
msgKey = "UIRelationshipAction.label.ConnectionExisted"; | ||
return (relationship == null); | ||
} | ||
@Override | ||
protected void doAction(Event<UIRelationshipAction> event) {// sender --> owner | ||
Utils.getRelationshipManager().inviteToConnect(Utils.getViewerIdentity(), Utils.getOwnerIdentity()); | ||
} | ||
} | ||
|
||
public static class CancelActionListener extends AbstractActionListener { | ||
@Override | ||
protected void doAction(Event<UIRelationshipAction> event) { | ||
Utils.getRelationshipManager().deny(relationship.getReceiver(), relationship.getSender()); | ||
} | ||
} | ||
|
||
public static class AcceptActionListener extends AbstractActionListener { | ||
@Override | ||
protected boolean isValid(Event<UIRelationshipAction> event) { | ||
return super.isValid(event) && (relationship.getStatus() != Type.IGNORED); | ||
} | ||
|
||
@Override | ||
protected void doAction(Event<UIRelationshipAction> event) { | ||
Utils.getRelationshipManager().confirm(relationship.getReceiver(), relationship.getSender()); | ||
Utils.updateWorkingWorkSpace(); | ||
} | ||
} | ||
|
||
public static class DenyActionListener extends AbstractActionListener { | ||
@Override | ||
protected boolean isValid(Event<UIRelationshipAction> event) { | ||
return super.isValid(event); | ||
} | ||
|
||
@Override | ||
protected void doAction(Event<UIRelationshipAction> event) { | ||
Utils.getRelationshipManager().deny(relationship.getReceiver(), relationship.getSender()); | ||
Utils.updateWorkingWorkSpace(); | ||
} | ||
} | ||
|
||
public static class DisconnectActionListener extends AbstractActionListener { | ||
@Override | ||
protected void doAction(Event<UIRelationshipAction> event) { | ||
Utils.getRelationshipManager().delete(relationship); | ||
Utils.updateWorkingWorkSpace(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...bapp/groovy/platformNavigation/portlet/UIUserNavigationPortlet/UIRelationshipAction.gtmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<% | ||
import org.exoplatform.social.webui.Utils; | ||
import org.exoplatform.social.core.relationship.model.Relationship.Type; | ||
|
||
def viewerIdentity = Utils.getViewerIdentity();// current login user | ||
def ownerIdentity = Utils.getOwnerIdentity(); | ||
|
||
_ctx.getRequestContext().getJavascriptManager().require("SHARED/bts_modal"); | ||
%> | ||
<div class="uiRelationshipAction" id="<%=uicomponent.getId();%>"> | ||
<div class="user-actions pull-right"> | ||
<% | ||
if (!ownerIdentity.equals(viewerIdentity)) { | ||
def relationship = Utils.getRelationshipManager().get(viewerIdentity, ownerIdentity); | ||
def status = (relationship != null) ? relationship.getStatus() : null; | ||
|
||
if(status == null) { | ||
%> | ||
<button type="button" class="btn btn-default" onclick="<%=uicomponent.event("Connect")%>"> | ||
<i class="uiIconSocConnectUser"></i> | ||
<span><%=_ctx.appRes("UIRelationshipAction.label.Connect")%></span> | ||
</button> | ||
<% | ||
} else if(status == Type.PENDING) {//PENDING | ||
if(relationship.getSender().equals(viewerIdentity)) { | ||
%> | ||
<button type="button" class="btn" onclick="<%=uicomponent.event("Cancel")%>"> | ||
<i class="uiIconClose"></i> | ||
<span><%=_ctx.appRes("UIRelationshipAction.action.CancelRequest")%></span> | ||
</button> | ||
<% | ||
} else { | ||
%> | ||
<div class="btn-group btnStatusAnswer"> | ||
<button type="button" class="btn btn-default" onclick="<%=uicomponent.event("Accept")%>"> | ||
<%=_ctx.appRes("UIRelationshipAction.action.AcceptRequest")%> | ||
</button> | ||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> | ||
<span class="caret"></span> | ||
</button> | ||
<ul class="dropdown-menu" role="menu"> | ||
<li><a href="javascript: void(0)" onclick="<%=uicomponent.event("Deny")%>"> | ||
<%=_ctx.appRes("UIRelationshipAction.action.Deny")%> | ||
</a></li> | ||
</ul> | ||
</div> | ||
<div class="btn statusAnswer" data-toggle="modal" data-target="#popStatusAnswer"> | ||
<i class="uiIconClock"></i> | ||
<div id="popStatusAnswer" class="popStatusAnswer modal" tabindex="-1" role="dialog"> | ||
<div onclick="<%=uicomponent.event("Accept")%>"><%=_ctx.appRes("UIRelationshipAction.action.AcceptRequest")%></div> | ||
<hr/> | ||
<div onclick="<%=uicomponent.event("Deny")%>"><%=_ctx.appRes("UIRelationshipAction.action.Deny")%></div> | ||
</div> | ||
</div> | ||
<% | ||
} | ||
} | ||
} | ||
%> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters