Author: thomas.heute(a)jboss.com
Date: 2010-09-23 06:28:53 -0400 (Thu, 23 Sep 2010)
New Revision: 4337
Modified:
epp/portal/branches/EPP_5_1_Branch/web/eXoResources/src/main/webapp/javascript/eXo/core/UIMaskLayer.js
epp/portal/branches/EPP_5_1_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIPopupWindow.js
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposer.gtmpl
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/webui/core/UIConfirmation.gtmpl
epp/portal/branches/EPP_5_1_Branch/webui/core/src/main/java/org/exoplatform/webui/core/UIConfirmation.java
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIEditInlineWorkspace.java
Log:
JBEPP-494: Add confirmation message when leaving page edition page without saving
Modified:
epp/portal/branches/EPP_5_1_Branch/web/eXoResources/src/main/webapp/javascript/eXo/core/UIMaskLayer.js
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/web/eXoResources/src/main/webapp/javascript/eXo/core/UIMaskLayer.js 2010-09-23
10:28:45 UTC (rev 4336)
+++
epp/portal/branches/EPP_5_1_Branch/web/eXoResources/src/main/webapp/javascript/eXo/core/UIMaskLayer.js 2010-09-23
10:28:53 UTC (rev 4337)
@@ -126,7 +126,7 @@
blockContainer.appendChild(maskLayer) ;
maskLayer.className = "MaskLayer" ;
maskLayer.id = "MaskLayer" ;
- maskLayer.maxZIndex = 4; //3 ;
+ maskLayer.maxZIndex = eXo.webui.UIPopup.zIndex + 1; //3 ;
maskLayer.style.width = Browser.getBrowserWidth() + "px";
maskLayer.style.height = Browser.getBrowserHeight() + "px";
maskLayer.style.top = "0px" ;
Modified:
epp/portal/branches/EPP_5_1_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIPopupWindow.js
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIPopupWindow.js 2010-09-23
10:28:45 UTC (rev 4336)
+++
epp/portal/branches/EPP_5_1_Branch/web/eXoResources/src/main/webapp/javascript/eXo/webui/UIPopupWindow.js 2010-09-23
10:28:53 UTC (rev 4337)
@@ -71,7 +71,7 @@
var mask = popup.previousSibling;
if(isShowPopup) {
//Modal if popup is portal component
- if (popup.parentNode.id == "UIPortalApplication") {
+ if (eXo.core.DOMUtil.findAncestorByClass(popup, "PORTLET-FRAGMENT") == null)
{
eXo.core.UIMaskLayer.createMask(popup.parentNode, popup, 1) ;
} else {
//If popup is portlet's component, modal with just its parent
Modified:
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties 2010-09-23
10:28:45 UTC (rev 4336)
+++
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties 2010-09-23
10:28:53 UTC (rev 4337)
@@ -485,6 +485,14 @@
UIPageEditor.action.SwitchMode=Switch View mode
#############################################################################
+ # org.exoplatform.portal.webui.workspace.UIEditInlineWorkspace #
+ #############################################################################
+
+UIEditInlineWorkspace.confirm.close=Modifications have been made. Are you sure you want
to close without saving ?
+UIEditInlineWorkspace.confirm.yes=Yes
+UIEditInlineWorkspace.confirm.no=No
+
+ #############################################################################
# org.exoplatform.portal.component.customization.UIPageForm #
#############################################################################
Modified:
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposer.gtmpl
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposer.gtmpl 2010-09-23
10:28:45 UTC (rev 4336)
+++
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/portal/UIPortalComposer.gtmpl 2010-09-23
10:28:53 UTC (rev 4337)
@@ -14,7 +14,7 @@
<div class="OverflowContainer">
<div class="<%=uicomponent.isCollapsed ? "CollapseIcon" :
"ExpandIcon"%>"
onclick="eXo.portal.UIPortal.toggleComposer(this)"><span></span></div>
<% if(uicomponent.isShowControl) { %>
- <a class="CloseButton"
title="<%=_ctx.appRes("word.abort")%>"
href="<%=uicomponent.event("Abort")%>"><span></span></a>
+ <a class="CloseButton"
title="<%=_ctx.appRes("word.abort")%>"
href="<%=uicomponent.event("CloseComposer")%>"><span></span></a>
<% if (uicomponent.isUsedInWizard()) { %>
<a class="<%= isEditted ? "EdittedSaveButton" :
"SaveButton" %>"
title="<%=_ctx.appRes("word.finish")%>"
href="<%=uicomponent.url("Finish")%>"
onclick="eXo.core.DOMUtil.disableOnClick(this);"
><span></span></a>
<a class="BackButton""
title="<%=_ctx.appRes("word.back")%>"
href="<%=uicomponent.event("Back")%>">
Modified:
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/webui/core/UIConfirmation.gtmpl
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/webui/core/UIConfirmation.gtmpl 2010-09-23
10:28:45 UTC (rev 4336)
+++
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/webui/core/UIConfirmation.gtmpl 2010-09-23
10:28:53 UTC (rev 4337)
@@ -41,7 +41,7 @@
void printMessage(String message, String messageType)
{
- println "<div class=\"UITabContent\"";
+ println "<div class=\"UITabContent\">";
println " <div class=\"PopupMessageBox\">";
println " <div class=\"$messageType\">";
println " <div class=\"PopupMessageContainer\">";
@@ -76,7 +76,7 @@
}
}
%>
- <div class="UIPopupWindow" id="$popupId" style="width:
550px; display: none;">
+ <div class="UIPopupWindow UIDragObject" id="$popupId"
style="width: 550px; display: none;">
<div class="ExoMessageDecorator">
<div class="TopLeftCornerDecorator">
<div class="TopRightCornerDecorator">
@@ -136,9 +136,9 @@
</div>
<%
- rcontext.getJavascriptManager().addJavascript("eXo.webui.UIPopupWindow.init('$popupId',
false);");
+ rcontext.getJavascriptManager().addJavascript("eXo.webui.UIPopupWindow.init('$popupId',
false, null, null, $uicomponent.showMask);");
if(uicomponent.hasMessage()){
- rcontext.getJavascriptManager().addJavascript("eXo.webui.UIPopupWindow.show('$popupId');");
+ rcontext.getJavascriptManager().addJavascript("eXo.webui.UIPopupWindow.show('$popupId',
$uicomponent.showMask);");
rcontext.getJavascriptManager().addJavascript("window.setTimeout(\"eXo.webui.UIPopupWindow.increasezIndex('$popupId')\",
100);");
}
%>
\ No newline at end of file
Modified:
epp/portal/branches/EPP_5_1_Branch/webui/core/src/main/java/org/exoplatform/webui/core/UIConfirmation.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/webui/core/src/main/java/org/exoplatform/webui/core/UIConfirmation.java 2010-09-23
10:28:45 UTC (rev 4336)
+++
epp/portal/branches/EPP_5_1_Branch/webui/core/src/main/java/org/exoplatform/webui/core/UIConfirmation.java 2010-09-23
10:28:53 UTC (rev 4337)
@@ -24,7 +24,6 @@
import org.exoplatform.webui.config.annotation.EventConfig;
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.EventListener;
-import org.exoplatform.webui.form.UIFormInputWithActions.ActionData;
/**
* Created by The eXo Platform SAS
@@ -56,6 +55,7 @@
{
this.message_ = "";
this.caller_ = new Object();
+ setShowMask(true);
setShow(true);
}
@@ -63,6 +63,7 @@
{
this.message_ = message;
this.caller_ = caller;
+ setShowMask(true);
setShow(true);
}
@@ -116,19 +117,16 @@
return (message_!=null) && (!message_.equals(""));
}
- private void hidePopup(WebuiRequestContext context)
+ private void hidePopup(Event<UIConfirmation> event) throws Exception
{
+ WebuiRequestContext context = event.getRequestContext();
this.clearMessage();
- if(this.getParent() == null)
- {
- context.addUIComponentToUpdateByAjax(this);
- return;
- }
-
- if(!this.isShow())
- {
- return;
- }
+ context.addUIComponentToUpdateByAjax(this);
+ UIComponent uiParent = getParent();
+ Event<UIComponent> pEvent =
+ uiParent.createEvent("ClosePopup", event.getExecutionPhase(),
event.getRequestContext());
+ if (pEvent != null)
+ pEvent.broadcast();
}
public static class CloseActionListener extends EventListener<UIConfirmation>
@@ -137,8 +135,7 @@
public void execute(Event<UIConfirmation> event) throws Exception
{
UIConfirmation uiConfirmation = event.getSource();
- WebuiRequestContext context = event.getRequestContext();
- uiConfirmation.hidePopup(context);
+ uiConfirmation.hidePopup(event);
}
}
@@ -158,7 +155,7 @@
xEvent.broadcast();
}
- uiConfirmation.hidePopup(context);
+ uiConfirmation.hidePopup(event);
}
}
Modified:
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2010-09-23
10:28:45 UTC (rev 4336)
+++
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2010-09-23
10:28:53 UTC (rev 4337)
@@ -60,6 +60,7 @@
import org.exoplatform.webui.event.Event.Phase;
import java.util.List;
+import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest;
@@ -67,6 +68,7 @@
@ComponentConfigs({
@ComponentConfig(template =
"app:/groovy/portal/webui/portal/UIPortalComposer.gtmpl", events = {
@EventConfig(listeners = UIPortalComposer.ViewPropertiesActionListener.class),
+ @EventConfig(listeners = UIPortalComposer.CloseComposerActionListener.class),
@EventConfig(listeners = UIPortalComposer.AbortActionListener.class),
@EventConfig(listeners = UIPortalComposer.FinishActionListener.class),
@EventConfig(listeners = UIPortalComposer.SwitchModeActionListener.class),
@@ -74,6 +76,7 @@
@EventConfig(listeners = UIPortalComposer.ToggleActionListener.class)}),
@ComponentConfig(id = "UIPageEditor", template =
"app:/groovy/portal/webui/portal/UIPortalComposer.gtmpl", events = {
@EventConfig(name = "ViewProperties", listeners =
UIPortalComposer.ViewProperties2ActionListener.class),
+ @EventConfig(listeners = UIPortalComposer.CloseComposerActionListener.class),
@EventConfig(name = "Abort", listeners =
UIPortalComposer.Abort2ActionListener.class),
@EventConfig(name = "Finish", listeners =
UIPortalComposer.Finish2ActionListener.class),
@EventConfig(name = "Back", listeners =
UIPortalComposer.BackActionListener.class),
@@ -95,7 +98,7 @@
UITabPane uiTabPane = addChild(UITabPane.class, "UIPortalComposerTab",
null);
uiTabPane.addChild(UIApplicationList.class, null, null).setRendered(true);
uiTabPane.addChild(UIContainerList.class, null, null);
- uiTabPane.setSelectedTab(1);
+ uiTabPane.setSelectedTab(1);
}
public int getPortalMode()
@@ -619,6 +622,27 @@
event.getRequestContext().addUIComponentToUpdateByAjax(uiMaskWS);
}
}
+
+ static public class CloseComposerActionListener extends
EventListener<UIPortalComposer>
+ {
+ public void execute(Event<UIPortalComposer> event) throws Exception
+ {
+ UIPortalComposer uiPortalComposer = event.getSource();
+ UIEditInlineWorkspace uiEditInlineWorkspace =
uiPortalComposer.getAncestorOfType(UIEditInlineWorkspace.class);
+ if (uiPortalComposer.isEditted())
+ {
+ ResourceBundle resourceBundle =
event.getRequestContext().getApplicationResourceBundle();
+ String closeMessage =
resourceBundle.getString("UIEditInlineWorkspace.confirm.close");
+
+ uiEditInlineWorkspace.showConfirmWindow(closeMessage);
+ }
+ else
+ {
+ Event<UIComponent> abortEvent =
uiPortalComposer.createEvent("Abort", event.getExecutionPhase(),
event.getRequestContext());
+ abortEvent.broadcast();
+ }
+ }
+ }
static public class Abort2ActionListener extends
EventListener<UIPortalComposer>
{
Modified:
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIEditInlineWorkspace.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIEditInlineWorkspace.java 2010-09-23
10:28:45 UTC (rev 4336)
+++
epp/portal/branches/EPP_5_1_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIEditInlineWorkspace.java 2010-09-23
10:28:53 UTC (rev 4337)
@@ -19,19 +19,29 @@
package org.exoplatform.portal.webui.workspace;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ResourceBundle;
+
import org.exoplatform.portal.webui.portal.UIPortalComposer;
+import org.exoplatform.webui.application.WebuiRequestContext;
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.UIConfirmation;
import org.exoplatform.webui.core.UIContainer;
+import org.exoplatform.webui.core.UIConfirmation.ActionConfirm;
import org.exoplatform.webui.core.lifecycle.UIContainerLifecycle;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
/**
- * Created by The eXo Platform SAS
- * Author : Tan Pham Dinh
- * pdtanit(a)gmail.com
- * Aug 27, 2009
+ * Created by The eXo Platform SAS Author : Tan Pham Dinh pdtanit(a)gmail.com Aug
+ * 27, 2009
*/
-@ComponentConfig(lifecycle = UIContainerLifecycle.class)
+@ComponentConfig(lifecycle = UIContainerLifecycle.class, events = {
+ @EventConfig(listeners = UIEditInlineWorkspace.ConfirmCloseActionListener.class),
+ @EventConfig(listeners = UIEditInlineWorkspace.AbortCloseActionListener.class)})
public class UIEditInlineWorkspace extends UIContainer
{
@@ -39,6 +49,17 @@
{
addChild(UIPortalComposer.class, null, null);
addChild(UIPortalToolPanel.class, null, null);
+
+ ResourceBundle resourceBundle =
WebuiRequestContext.getCurrentInstance().getApplicationResourceBundle();
+ String yes =
resourceBundle.getString("UIEditInlineWorkspace.confirm.yes");
+ String no =
resourceBundle.getString("UIEditInlineWorkspace.confirm.no");
+
+ List<ActionConfirm> actionConfirms = new ArrayList<ActionConfirm>();
+ actionConfirms.add(new ActionConfirm("ConfirmClose", yes));
+ actionConfirms.add(new ActionConfirm("AbortClose", no));
+ UIConfirmation uiConfirmation = addChild(UIConfirmation.class, null, null);
+ uiConfirmation.setCaller(this);
+ uiConfirmation.setActions(actionConfirms);
}
public void setUIComponent(UIComponent uiComp)
@@ -55,4 +76,41 @@
{
return getChild(UIPortalComposer.class);
}
+
+ public void showConfirmWindow(String message)
+ {
+ UIConfirmation uiConfirmation = getChild(UIConfirmation.class);
+ uiConfirmation.setMessage(message);
+
((WebuiRequestContext)WebuiRequestContext.getCurrentInstance()).addUIComponentToUpdateByAjax(uiConfirmation);
+ }
+
+ static public class ConfirmCloseActionListener extends
EventListener<UIEditInlineWorkspace>
+ {
+
+ @Override
+ public void execute(Event<UIEditInlineWorkspace> event) throws Exception
+ {
+ UIEditInlineWorkspace uiEditInlineWorkspace = event.getSource();
+
+ UIConfirmation uiConfirmation =
uiEditInlineWorkspace.getChild(UIConfirmation.class);
+ uiConfirmation.createEvent("Close", event.getExecutionPhase(),
event.getRequestContext()).broadcast();
+
+ UIPortalComposer uiPortalComposer =
uiEditInlineWorkspace.getChild(UIPortalComposer.class);
+ Event<UIComponent> abortEvent =
+ uiPortalComposer.createEvent("Abort", event.getExecutionPhase(),
event.getRequestContext());
+ abortEvent.broadcast();
+ }
+ }
+
+ static public class AbortCloseActionListener extends
EventListener<UIEditInlineWorkspace>
+ {
+
+ @Override
+ public void execute(Event<UIEditInlineWorkspace> event) throws Exception
+ {
+ UIEditInlineWorkspace uiEditInlineWorkspace = event.getSource();
+ UIConfirmation uiConfirmation =
uiEditInlineWorkspace.getChild(UIConfirmation.class);
+ uiConfirmation.createEvent("Close", event.getExecutionPhase(),
event.getRequestContext()).broadcast();
+ }
+ }
}