From 96b30f55676a44e2569f63a9fa425bc966de9284 Mon Sep 17 00:00:00 2001 From: holivier Date: Sat, 12 Sep 2020 09:52:28 +0200 Subject: [PATCH 1/2] Fixed: link address correction on EditAgreement and EditAgreementItem documentation --- .../src/docs/asciidoc/_include/HELP_EditAgreement.adoc | 2 +- .../src/docs/asciidoc/_include/HELP_EditAgreementItem.adoc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/accounting/src/docs/asciidoc/_include/HELP_EditAgreement.adoc b/applications/accounting/src/docs/asciidoc/_include/HELP_EditAgreement.adoc index 5188d9b96b..eab892ecdc 100644 --- a/applications/accounting/src/docs/asciidoc/_include/HELP_EditAgreement.adoc +++ b/applications/accounting/src/docs/asciidoc/_include/HELP_EditAgreement.adoc @@ -38,6 +38,6 @@ It can be used to create or update the following details for an Agreement: == How do I copy an existing agreement? . Find the agreement that needs to be copied -. Click on the Agreement Id <> +. Click on the Agreement Id <<_how_do_i_edit_an_agreement, How do it?>> . The 'Edit Agreement' screen will be displayed . At the bottom of the screen press the 'Copy' in the 'Copy Agreement' window (NOTE: The default tick boxes will copy the agreement terms, products and party. If not required then click on the boxes to stop them being copied) diff --git a/applications/accounting/src/docs/asciidoc/_include/HELP_EditAgreementItem.adoc b/applications/accounting/src/docs/asciidoc/_include/HELP_EditAgreementItem.adoc index 893a46303a..b3f40ebabf 100644 --- a/applications/accounting/src/docs/asciidoc/_include/HELP_EditAgreementItem.adoc +++ b/applications/accounting/src/docs/asciidoc/_include/HELP_EditAgreementItem.adoc @@ -39,5 +39,5 @@ Currently these are limited to the following: == How do I edit an agreement item? . Select the agreement item to be updated by clicking on the Agreement Item Id -. The 'Edit Agreement Item' screen is displayed <> +. The 'Edit Agreement Item' screen is displayed <<_how_do_i_edit_an_agreement, How do it?>> . Update the fields required (NOTE: Additional details can be updated by selecting the Promotions, Terms, Product, Party or Geo sub menus) From b18dd6a9ce39a595f6d1eebdb83f1b583a812d1d Mon Sep 17 00:00:00 2001 From: James Yong Date: Sat, 12 Sep 2020 20:10:08 +0800 Subject: [PATCH 2/2] Improved: Show border and file name for content rendered from ftl (OFBIZ-12002) To reduce the need to view the page source from the browser. Activated when print.verbose=true and widget.verbose=true. Thanks: Jacques for review --- .../org/apache/ofbiz/base/util/UtilHtml.java | 35 +++++++++++++++++-- .../apache/ofbiz/widget/model/HtmlWidget.java | 19 +++++----- .../renderer/html/HtmlWidgetRenderer.java | 24 ++++++++++++- .../common-theme/webapp/common/css/info.css | 19 ++++++++++ .../webapp/common/js/util/OfbizUtil.js | 8 +++++ themes/common-theme/widget/Theme.xml | 1 + 6 files changed, 95 insertions(+), 11 deletions(-) create mode 100644 themes/common-theme/webapp/common/css/info.css diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHtml.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHtml.java index 94f72c3220..bbafaaff76 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHtml.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHtml.java @@ -18,6 +18,7 @@ *******************************************************************************/ package org.apache.ofbiz.base.util; +import org.apache.ofbiz.widget.model.ThemeFactory; import org.jsoup.parser.ParseError; import org.jsoup.parser.Parser; @@ -28,9 +29,12 @@ import javax.xml.stream.events.EndElement; import javax.xml.stream.events.StartElement; import javax.xml.stream.events.XMLEvent; import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Stack; @@ -39,6 +43,7 @@ public final class UtilHtml { private static final String MODULE = UtilHtml.class.getName(); private static final Parser JSOUP_HTML_PARSER = createJSoupHtmlParser(); private static final String[] TAG_SHOULD_CLOSE_LIST = new String[]{"div"}; + private static List visualThemeBasePathsName; private UtilHtml() { } private static Parser createJSoupHtmlParser() { @@ -110,7 +115,33 @@ public final class UtilHtml { return errorList; } - public static void logFormattedError(String content, String location, String error, String module) { - Debug.logError("[Parsing " + location + "] " + error, module); + public static List getVisualThemeFolderNamesToExempt() { + if (visualThemeBasePathsName == null) { + try { + List xmlThemes = ThemeFactory.getThemeXmlFiles(); + visualThemeBasePathsName = new ArrayList<>(); + String themePathKey = File.separator + "themes" + File.separator; + String pluginPathKey = File.separator + "plugins" + File.separator; + for (File xmlTheme : xmlThemes) { + String path = xmlTheme.toURI().toURL().toString(); + if (path.indexOf(themePathKey) > 0) { + path = path.substring(path.indexOf(themePathKey) + 8); + } else if (path.indexOf(pluginPathKey) > 0) { + path = path.substring(path.indexOf(pluginPathKey) + 9); + } + path = path.substring(0, path.indexOf(File.separator)); + if (!path.contains("common-theme") && !path.contains("ecommerce")) { + visualThemeBasePathsName.add(File.separator + path + File.separator); + } + } + } catch (IOException e) { + Debug.logError(e, MODULE); + } + } + return Collections.unmodifiableList(visualThemeBasePathsName); + } + + public static void logHtmlWarning(String content, String location, String error, String module) { + Debug.logWarning("[Parsing " + location + "] " + error, module); } } diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java index bd21c0324b..4b275dcb01 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/HtmlWidget.java @@ -269,14 +269,17 @@ public class HtmlWidget extends ModelScreenWidget { stringWriter.close(); if (Debug.verboseOn()) { - // check for unclosed tags - List errorList = UtilHtml.hasUnclosedTag(data); - if (UtilValidate.isNotEmpty(errorList)) { - errorList.forEach(a -> UtilHtml.logFormattedError(data, location, a, MODULE)); - // check with JSoup Html Parser - List errList = UtilHtml.validateHtmlFragmentWithJSoup(data); - if (UtilValidate.isNotEmpty(errList)) { - errList.forEach(a -> UtilHtml.logFormattedError(data, location, a.toString(), MODULE)); + List themeBasePathsToExempt = UtilHtml.getVisualThemeFolderNamesToExempt(); + if (!themeBasePathsToExempt.stream().anyMatch(location::contains)) { + // check for unclosed tags + List errorList = UtilHtml.hasUnclosedTag(data); + if (UtilValidate.isNotEmpty(errorList)) { + errorList.forEach(a -> UtilHtml.logHtmlWarning(data, location, a, MODULE)); + // check with JSoup Html Parser + List errList = UtilHtml.validateHtmlFragmentWithJSoup(data); + if (UtilValidate.isNotEmpty(errList)) { + errList.forEach(a -> UtilHtml.logHtmlWarning(data, location, a.toString(), MODULE)); + } } } } diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlWidgetRenderer.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlWidgetRenderer.java index 7c26716503..caa1723440 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlWidgetRenderer.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlWidgetRenderer.java @@ -18,8 +18,12 @@ *******************************************************************************/ package org.apache.ofbiz.widget.renderer.html; +import java.io.File; import java.io.IOException; +import java.util.List; +import org.apache.ofbiz.base.util.Debug; +import org.apache.ofbiz.base.util.UtilHtml; import org.apache.ofbiz.base.util.UtilHttp; import org.apache.ofbiz.widget.model.ModelWidget; @@ -73,7 +77,25 @@ public class HtmlWidgetRenderer { } public static String formatBoundaryComment(String boundaryType, String widgetType, String widgetName) { - return "" + WHITE_SPACE; + String boundaryComment = "" + WHITE_SPACE; + if (!Debug.verboseOn()) { + return boundaryComment; + } + List themeBasePathsToExempt = UtilHtml.getVisualThemeFolderNamesToExempt(); + if (!themeBasePathsToExempt.stream().anyMatch(widgetName::contains)) { + // add additional visual label for non-theme ftl + switch (boundaryType) { + case "End": + String fileName = widgetName.substring(widgetName.lastIndexOf(File.separator) + 1); + return "
" + + fileName + + "
" + boundaryComment; + default: + return boundaryComment + "
"; + } + } else { + return boundaryComment; + } } public static String formatBoundaryJsComment(String boundaryType, String widgetType, String widgetName) { diff --git a/themes/common-theme/webapp/common/css/info.css b/themes/common-theme/webapp/common/css/info.css new file mode 100644 index 0000000000..a861213859 --- /dev/null +++ b/themes/common-theme/webapp/common/css/info.css @@ -0,0 +1,19 @@ +.info-container { + display: grid; +} +.info-overlay { + color: rgb(165, 42, 42); + justify-items: center; + z-index: 10; + border: 2px dashed rgba(236, 198, 48, 0.7); + transition: .5s ease-out; +} +.info-content, +.info-overlay { + grid-area: 1 / 1; +} +.info-overlay-item { + height: 50%; + background: rgba(255, 213, 70); + border: 2px dashed rgba(236, 198, 48); +} diff --git a/themes/common-theme/webapp/common/js/util/OfbizUtil.js b/themes/common-theme/webapp/common/js/util/OfbizUtil.js index 65f1940052..9aa14bb43b 100644 --- a/themes/common-theme/webapp/common/js/util/OfbizUtil.js +++ b/themes/common-theme/webapp/common/js/util/OfbizUtil.js @@ -39,6 +39,14 @@ $(document).ready(function() { ajaxAutoCompleteDropDown(); // bindObservers will add observer on passed html section when DOM is ready. bindObservers("body"); + // fadeout info-overlay labels + setTimeout(function(){ + $('.info-overlay').fadeOut(1000, function(){ + $('.info-container').contents().unwrap(); + $('.info-content').contents().unwrap(); + $('.info-overlay').delay(1000).remove(); + }); + }, 3000); }); /* bindObservers function contains the code of adding observers and it can be called for specific section as well diff --git a/themes/common-theme/widget/Theme.xml b/themes/common-theme/widget/Theme.xml index 6730d5fbbe..400729c699 100644 --- a/themes/common-theme/widget/Theme.xml +++ b/themes/common-theme/widget/Theme.xml @@ -76,6 +76,7 @@ under the License. +