From a6d08249a6e55df39505a75802e246f0368d87e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacobo=20Aragunde=20P=C3=A9rez?= Date: Thu, 13 Oct 2011 19:09:22 +0200 Subject: [PATCH] [Bug #1183] Implement the replacement of decimal comma with dot in the client side. FEA: ItEr75S04BugFixing --- .../web/common/LenientDecimalBox.java | 18 ------------------ .../main/resources/metainfo/zk/lang-addon.xml | 6 ++++++ .../web/js/webcommon/LenientDecimalBox.js | 14 ++++++++++++++ .../src/main/resources/web/js/webcommon/zk.wpd | 3 +++ 4 files changed, 23 insertions(+), 18 deletions(-) create mode 100644 navalplanner-webapp/src/main/resources/web/js/webcommon/LenientDecimalBox.js create mode 100644 navalplanner-webapp/src/main/resources/web/js/webcommon/zk.wpd diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/common/LenientDecimalBox.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/common/LenientDecimalBox.java index 596afbe7b..c7bcc35c7 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/common/LenientDecimalBox.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/common/LenientDecimalBox.java @@ -43,22 +43,4 @@ public class LenientDecimalBox extends Decimalbox { super(value); } - @Override - protected Object coerceFromString(String value) throws WrongValueException { - return super - .coerceFromString(interpretCommasAndPointsAsDecimalSeparator(value)); - } - - private String interpretCommasAndPointsAsDecimalSeparator(String value) { - if (value == null) { - return null; - } - final DecimalFormatSymbols symbols = new DecimalFormatSymbols( - Locales.getCurrent()); - - char decimalSeparator = symbols.getDecimalSeparator(); - return value.replace('.', decimalSeparator).replace(',', - decimalSeparator); - } - } diff --git a/navalplanner-webapp/src/main/resources/metainfo/zk/lang-addon.xml b/navalplanner-webapp/src/main/resources/metainfo/zk/lang-addon.xml index e94bc1d0d..f49b7328d 100755 --- a/navalplanner-webapp/src/main/resources/metainfo/zk/lang-addon.xml +++ b/navalplanner-webapp/src/main/resources/metainfo/zk/lang-addon.xml @@ -88,6 +88,12 @@ /common/components/templateFinder.zul + + LenientDecimalBox + org.navalplanner.web.common.LenientDecimalBox + webcommon.LenientDecimalBox + + LimitingResourcesPanel org.navalplanner.web.limitingresources.LimitingResourcesPanel diff --git a/navalplanner-webapp/src/main/resources/web/js/webcommon/LenientDecimalBox.js b/navalplanner-webapp/src/main/resources/web/js/webcommon/LenientDecimalBox.js new file mode 100644 index 000000000..2fc932af5 --- /dev/null +++ b/navalplanner-webapp/src/main/resources/web/js/webcommon/LenientDecimalBox.js @@ -0,0 +1,14 @@ +zk.$package("webcommon"); + +webcommon.LenientDecimalBox = zk.$extends(zul.inp.Decimalbox,{ + + coerceFromString_: function (b) { + if(!b) { + return null; + } + //replace decimal comma with dot + b = b.replace(',','.'); + //process normally + return this.$supers('coerceFromString_', arguments); + } +}); diff --git a/navalplanner-webapp/src/main/resources/web/js/webcommon/zk.wpd b/navalplanner-webapp/src/main/resources/web/js/webcommon/zk.wpd new file mode 100644 index 000000000..ef9d9cff0 --- /dev/null +++ b/navalplanner-webapp/src/main/resources/web/js/webcommon/zk.wpd @@ -0,0 +1,3 @@ + + +