This is an automated email from the ASF dual-hosted git repository.

nmalin pushed a commit to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/release18.12 by this push:
     new 076c1e2  Fixed: Link request-confirmation not generated on menus 
(OFBIZ-12278)
076c1e2 is described below

commit 076c1e254cd6afdce6e642c04faf30aa8e0e8aed
Author: Nicolas Malin <nicolas.ma...@nereide.fr>
AuthorDate: Fri Jul 9 20:31:56 2021 +0200

    Fixed: Link request-confirmation not generated on menus (OFBIZ-12278)
    
    Menus link with request-confirmation and confirmation message do not 
generate the script that open confirmation
    
    When you activate the following menu item :
          <menu-item name="statusToCancelled" 
title="${uiLabelMap.AccountingPaymentTabStatusToCancelled}">
              <link target="setPaymentStatus" request-confirmation="true" 
confirmation-message="You want to cancel this payment number 
${payment.paymentId}?">
                  ....
             </link>
          </menu-item>
    
    OFBiz to not generate the js code link to the request-confirmation 
attribute because this functionality has been never implemented on java code 
for MenuRenderer
    
    Thanks to Leila Mekika for raised this issue and solved it
---
 .../apache/ofbiz/widget/renderer/macro/MacroMenuRenderer.java | 11 +++++++++++
 themes/common-theme/template/macro/HtmlMenuMacroLibrary.ftl   |  4 ++--
 themes/rainbowstone/template/macro/HtmlMenuMacroLibrary.ftl   |  4 ++--
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git 
a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroMenuRenderer.java
 
b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroMenuRenderer.java
index 089f167..81cbd3b 100644
--- 
a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroMenuRenderer.java
+++ 
b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroMenuRenderer.java
@@ -35,7 +35,9 @@ import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.base.util.StringUtil;
 import org.apache.ofbiz.base.util.UtilCodec;
 import org.apache.ofbiz.base.util.UtilMisc;
+import org.apache.ofbiz.base.util.UtilProperties;
 import org.apache.ofbiz.base.util.UtilValidate;
+import org.apache.ofbiz.base.util.string.FlexibleStringExpander;
 import org.apache.ofbiz.base.util.template.FreeMarkerWorker;
 import org.apache.ofbiz.webapp.control.RequestHandler;
 import org.apache.ofbiz.webapp.taglib.ContentUrlTag;
@@ -233,6 +235,15 @@ public class MacroMenuRenderer implements 
MenuStringRenderer {
         String linkUrl = "";
         String actionUrl = "";
         StringBuilder targetParameters = new StringBuilder();
+
+        String confirmationMessage = 
link.getLink().getConfirmationMsg(context);
+        if (link.getLink().getRequestConfirmation() && 
UtilValidate.isEmpty(confirmationMessage)) {
+            String defaultMessage = UtilProperties.getPropertyValue("general", 
"default.confirmation.message",
+                    "${uiLabelMap.CommonConfirm}");
+            confirmationMessage = 
FlexibleStringExpander.expandString(defaultMessage, context);
+        }
+        parameters.put("confirmation", confirmationMessage);
+
         if ("hidden-form".equals(linkType) || 
"layered-modal".equals(linkType)) {
             StringBuilder sb = new StringBuilder();
             WidgetWorker.buildHyperlinkUrl(sb, target, link.getUrlMode(), 
null, link.getPrefix(context), link.getFullPath(), link.getSecure(), 
link.getEncode(), request, response, context);
diff --git a/themes/common-theme/template/macro/HtmlMenuMacroLibrary.ftl 
b/themes/common-theme/template/macro/HtmlMenuMacroLibrary.ftl
index a440739..d61fa73 100644
--- a/themes/common-theme/template/macro/HtmlMenuMacroLibrary.ftl
+++ b/themes/common-theme/template/macro/HtmlMenuMacroLibrary.ftl
@@ -46,7 +46,7 @@ under the License.
 <img src="${src}"<#if id?has_content> id="${id}"</#if><#if style?has_content> 
class="${style}"</#if><#if width?has_content> width="${width}"</#if><#if 
height?has_content> height="${height}"</#if><#if border?has_content> 
border="${border}"</#if> />
 </#macro>
 
-<#macro renderLink linkUrl parameterList targetWindow uniqueItemName actionUrl 
linkType="" id="" style="" name="" height="600" width="800" text="" imgStr="">
+<#macro renderLink linkUrl parameterList targetWindow uniqueItemName actionUrl 
confirmation="" linkType="" id="" style="" name="" height="600" width="800" 
text="" imgStr="">
   <#if linkType?has_content && "hidden-form" == linkType>
 <form method="post" action="${actionUrl}"<#if targetWindow?has_content> 
target="${targetWindow}"</#if> 
onsubmit="javascript:submitFormDisableSubmits(this)" 
name="${uniqueItemName}"><#rt/>
     <#list parameterList as parameter>
@@ -72,7 +72,7 @@ under the License.
     <#if text?has_content>${text}</#if></a>
   <#else>
 <#if (linkType?has_content && "hidden-form" == linkType) || 
linkUrl?has_content>
-<a<#if id?has_content> id="${id}"</#if><#if style?has_content> 
class="${style}"</#if><#if name?has_content> name="${name}"</#if><#if 
targetWindow?has_content> target="${targetWindow}"</#if> href="<#if 
"hidden-form"==linkType>javascript:document.${uniqueItemName}.submit()<#else>${linkUrl}</#if>"><#rt/>
+<a<#if id?has_content> id="${id}"</#if><#if style?has_content> 
class="${style}"</#if><#if name?has_content> name="${name}"</#if><#if 
confirmation?has_content> onclick="return 
confirm('${confirmation?js_string}');"</#if><#if targetWindow?has_content> 
target="${targetWindow}"</#if> href="<#if 
"hidden-form"==linkType>javascript:document.${uniqueItemName}.submit()<#else>${linkUrl}</#if>"><#rt/>
 </#if>
 <#if imgStr?has_content>${imgStr}</#if> <#if 
text?has_content>${text}</#if><#rt/>
 <#if (linkType?has_content && "hidden-form" == linkType) || 
linkUrl?has_content></a><#rt/></#if>
diff --git a/themes/rainbowstone/template/macro/HtmlMenuMacroLibrary.ftl 
b/themes/rainbowstone/template/macro/HtmlMenuMacroLibrary.ftl
index d0233fc..038ddfe 100644
--- a/themes/rainbowstone/template/macro/HtmlMenuMacroLibrary.ftl
+++ b/themes/rainbowstone/template/macro/HtmlMenuMacroLibrary.ftl
@@ -19,7 +19,7 @@ under the License.
 
 <#include "component://common-theme/template/macro/HtmlMenuMacroLibrary.ftl"/>
 
-<#macro renderLink linkUrl parameterList targetWindow uniqueItemName actionUrl 
linkType="" id="" style="" name="" height="600" width="800" text="" imgStr="">
+<#macro renderLink linkUrl parameterList targetWindow uniqueItemName actionUrl 
confirmation="" linkType="" id="" style="" name="" height="600" width="800" 
text="" imgStr="">
     <#if linkType?has_content && "hidden-form" == linkType>
     <form method="post" action="${actionUrl}"<#if targetWindow?has_content> 
target="${targetWindow}"</#if> 
onsubmit="javascript:submitFormDisableSubmits(this)" 
name="${uniqueItemName}"><#rt/>
         <#list parameterList as parameter>
@@ -45,7 +45,7 @@ under the License.
         <#if text?has_content>${text}</#if></a>
     <#else>
         <#if (linkType?has_content && "hidden-form" == linkType) || 
linkUrl?has_content>
-        <a<#if id?has_content> id="${id}"</#if><#if style?has_content> 
class="${style}"</#if><#if name?has_content> name="${name}"</#if><#if 
targetWindow?has_content> target="${targetWindow}"</#if> href="<#if 
"hidden-form"==linkType>javascript:document.${uniqueItemName}.submit()<#else>${linkUrl}</#if>"><#rt/>
+        <a<#if id?has_content> id="${id}"</#if><#if style?has_content> 
class="${style}"</#if><#if name?has_content> name="${name}"</#if><#if 
confirmation?has_content> onclick="return 
confirm('${confirmation?js_string}');"</#if><#if targetWindow?has_content> 
target="${targetWindow}"</#if> href="<#if 
"hidden-form"==linkType>javascript:document.${uniqueItemName}.submit()<#else>${linkUrl}</#if>"><#rt/>
         </#if>
         <#if imgStr?has_content>${imgStr}</#if><#if 
text?has_content>${text}</#if><#rt/>
         <#if (linkType?has_content && "hidden-form" == linkType) || 
linkUrl?has_content></a><#rt/></#if>

Reply via email to