You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by nm...@apache.org on 2021/07/09 18:33:06 UTC
[ofbiz-framework] branch trunk updated: Fixed: Link
request-confirmation not generated on menus (OFBIZ-12278)
This is an automated email from the ASF dual-hosted git repository.
nmalin pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new 894408c Fixed: Link request-confirmation not generated on menus (OFBIZ-12278)
894408c is described below
commit 894408cb0d9a6f08009ff3a90ea8a92f25fabd42
Author: Nicolas Malin <ni...@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 | 10 ++++++++++
themes/common-theme/template/macro/HtmlMenuMacroLibrary.ftl | 4 ++--
themes/helveticus/template/macro/HtmlMenuMacroLibrary.ftl | 4 ++--
themes/rainbowstone/template/macro/HtmlMenuMacroLibrary.ftl | 4 ++--
4 files changed, 16 insertions(+), 6 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 d8d0838..f6a3276 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;
@@ -237,6 +239,14 @@ public class MacroMenuRenderer implements MenuStringRenderer {
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);
+
boolean isModal = "layered-modal".equals(linkType);
if ("hidden-form".equals(linkType) || isModal) {
final URI actionUri = WidgetWorker.buildHyperlinkUri(target, link.getUrlMode(), null,
diff --git a/themes/common-theme/template/macro/HtmlMenuMacroLibrary.ftl b/themes/common-theme/template/macro/HtmlMenuMacroLibrary.ftl
index 644f5ef..237ddfa 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 && "update-area" != linkType> target="${targetWindow}"</#if> href="<#if "hidden-form"==linkType><#if linkUrl?has_content>javascript:ajaxSubmitFormUpdateAreas('${uniqueItemName}', '${linkUrl}')<#else>javascript:document.${uniqueItemName}.submit()</#if><#else><#if "update-area" == linkType>javascript:ajaxUpdateAreas('${linkUrl}')<#els [...]
+<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 && "update-area" != linkType> target="${targetWindow}"</#if><#if confirmation?has_content> onclick="return confirm('${confirmation?js_string}');"</#if> href="<#if "hidden-form"==linkType><#if linkUrl?has_content>javascript:ajaxSubmitFormUpdateAreas('${uniqueItemName}', '${linkUrl}')<#else>javascript:document.${uniqueItemName}.submit [...]
</#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/helveticus/template/macro/HtmlMenuMacroLibrary.ftl b/themes/helveticus/template/macro/HtmlMenuMacroLibrary.ftl
index bc58a31..de9d05c 100644
--- a/themes/helveticus/template/macro/HtmlMenuMacroLibrary.ftl
+++ b/themes/helveticus/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 && "update-area" != linkType> target="${targetWindow}"</#if> href="<#if "hidden-form"==linkType><#if linkUrl?has_content>javascript:ajaxSubmitFormUpdateAreas('${uniqueItemName}', '${linkUrl}')<#else>javascript:document.${uniqueItemName}.submit()</#if><#else><#if "update-area" == linkType>javascript:ajaxUpdateAreas('${linkUrl [...]
+ <a<#if id?has_content> id="${id}"</#if><#if style?has_content> class="${style}"</#if><#if name?has_content> name="${name}"</#if><#if name?has_content> name="${name}"</#if><#if confirmation?has_content> onclick="return confirm('${confirmation?js_string}');"</#if><#if targetWindow?has_content && "update-area" != linkType> target="${targetWindow}"</#if> href="<#if "hidden-form"==linkType><#if linkUrl?has_content>javascript:ajaxSubmitFormUpdateAreas('${uniqueItemName}', '${linkUrl}') [...]
</#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 bc58a31..12b1f9b 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 && "update-area" != linkType> target="${targetWindow}"</#if> href="<#if "hidden-form"==linkType><#if linkUrl?has_content>javascript:ajaxSubmitFormUpdateAreas('${uniqueItemName}', '${linkUrl}')<#else>javascript:document.${uniqueItemName}.submit()</#if><#else><#if "update-area" == linkType>javascript:ajaxUpdateAreas('${linkUrl [...]
+ <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 && "update-area" != linkType> target="${targetWindow}"</#if> href="<#if "hidden-form"==linkType><#if linkUrl?has_content>javascript:ajaxSubmitFormUpdateAreas('${uniqueItemName}', '${linkUrl}')<#else>javascript:document.${uniqueItemName [...]
</#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>