details:   https://code.openbravo.com/erp/devel/pi/rev/7a0dcbb151a5
changeset: 25747:7a0dcbb151a5
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Fri Jan 23 15:00:12 2015 +0100
summary:   Fixes issue 28427: Numbers are always rounded on blur

The blur function of the OBNumberItems only did the rounding when the getValue 
function of the item returned a string. This worked in most of the cases (i.e. 
standard grids and forms, d
ue to the edit form of the grid having a setTextualValue function, see [1]), 
but not in the parameter windows. In those windows, both numeric parameters and 
numeric columns in grid para
meters did not round the entered numbers before saving them.

To fix this, now the numbers are rounded on blur even if the value entered is 
already a number. To found the number these two functions are invoked:

  value = OB.Utilities.Number.JSToOBMasked(this.getValue(), 
this.typeInstance.maskNumeric, this.typeInstance.decSeparator, 
this.typeInstance.groupSeparator);
  this.setValue(OB.Utilities.Number.OBMaskedToJS(value,  
this.typeInstance.decSeparator, this.typeInstance.groupSeparator));

The first one converts the number to a string representation of the rounded 
number. The second one converts the rounded string number to a javascript 
number.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js
 |  3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diffs (13 lines):

diff -r 825bc261f63c -r 7a0dcbb151a5 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js
      Fri Jan 23 12:21:36 2015 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-number.js
      Fri Jan 23 15:00:12 2015 +0100
@@ -443,6 +443,9 @@
       if (this.form.setTextualValue) {
         this.form.setTextualValue(this.name, value, this.typeInstance);
       }
+    } else {
+      value = OB.Utilities.Number.JSToOBMasked(this.getValue(), 
this.typeInstance.maskNumeric, this.typeInstance.decSeparator, 
this.typeInstance.groupSeparator);
+      this.setValue(OB.Utilities.Number.OBMaskedToJS(value,  
this.typeInstance.decSeparator, this.typeInstance.groupSeparator));
     }
 
     if (this.grid && this.grid.isEditing && this.grid.isEditing()) {

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to