[Lada-commits] [PATCH] Use exponential notation for messwerte and zusatzwerte

Wald Commits scm-commit at wald.intevation.org
Wed Mar 2 12:59:36 CET 2016


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1456919955 -3600
# Node ID 7e801af49eeb584f1034172c947eef45edefa18e
# Parent  d2165ba7e8f15eeab93efe63a4558f98e0958327
Use exponential notation for messwerte and zusatzwerte.

diff -r d2165ba7e8f1 -r 7e801af49eeb app/model/Messwert.js
--- a/app/model/Messwert.js	Tue Mar 01 14:20:49 2016 +0100
+++ b/app/model/Messwert.js	Wed Mar 02 12:59:15 2016 +0100
@@ -27,7 +27,42 @@
         name: 'messgroesseId'
     }, {
         name: 'messwert',
-        type: 'float'
+        serialize: function(v) {
+            if (!v || v === '') {
+                return v;
+            }
+            if (v.indexOf(',') > 0) {
+                v = v.replace(',', '.');
+                return v;
+            }
+            return v;
+        },
+        convert: function(value) {
+            if (!value || value === '') {
+                return value;
+            }
+            var valueString = value.toString();
+            if (valueString.indexOf('E') > 0) {
+                valueString = valueString.replace('E', 'e');
+            }
+            var tmp;
+            if (valueString.indexOf('e') > 0) {
+                tmp = valueString;
+            }
+            else {
+                // Currently not locale friendly...
+                if (valueString.indexOf(',') > 0) {
+                    valueString = valueString.replace(',', '.');
+                }
+                tmp = parseFloat(valueString).toExponential();
+            }
+            var parts = tmp.split('e');
+            if (parts[0].indexOf('.') > 0) {
+                var floatPart = parseFloat(parts[0]);
+                parts[0] = floatPart.toLocaleString();
+            }
+            return parts[0] + 'e' + parts[1];
+        }
     }, {
         name: 'messwertNwg',
         convert: function(v) {
@@ -42,7 +77,42 @@
         type: 'float'
     }, {
         name: 'nwgZuMesswert',
-        type: 'float'
+        serialize: function(v) {
+            if (!v || v === '') {
+                return v;
+            }
+            if (v.indexOf(',') > 0) {
+                v = v.replace(',', '.');
+                return v;
+            }
+            return v;
+        },
+        convert: function(value) {
+            if (!value || value === '') {
+                return value;
+            }
+            var valueString = value.toString();
+            if (valueString.indexOf('E') > 0) {
+                valueString = valueString.replace('E', 'e');
+            }
+            var tmp;
+            if (valueString.indexOf('e') > 0) {
+                tmp = valueString;
+            }
+            else {
+                // Currently not locale friendly...
+                if (valueString.indexOf(',') > 0) {
+                    valueString = valueString.replace(',', '.');
+                }
+                tmp = parseFloat(valueString).toExponential();
+            }
+            var parts = tmp.split('e');
+            if (parts[0].indexOf('.') > 0) {
+                var floatPart = parseFloat(parts[0]);
+                parts[0] = floatPart.toLocaleString();
+            }
+            return parts[0] + 'e' + parts[1];
+        }
     }, {
         name: 'mehId'
     }, {
diff -r d2165ba7e8f1 -r 7e801af49eeb app/model/Zusatzwert.js
--- a/app/model/Zusatzwert.js	Tue Mar 01 14:20:49 2016 +0100
+++ b/app/model/Zusatzwert.js	Wed Mar 02 12:59:15 2016 +0100
@@ -27,10 +27,74 @@
         name: 'pzsId'
     }, {
         name: 'nwgZuMesswert',
-        type: 'float'
+        serialize: function(v) {
+            if (v.indexOf(',') > 0) {
+                v = v.replace(',', '.');
+                return v;
+            }
+            return v;
+        },
+        convert: function(value) {
+            if (!value || value === '') {
+                return value;
+            }
+            var valueString = value.toString();
+            if (valueString.indexOf('E') > 0) {
+                valueString = valueString.replace('E', 'e');
+            }
+            var tmp;
+            if (valueString.indexOf('e') > 0) {
+                tmp = valueString;
+            }
+            else {
+                // Currently not locale friendly...
+                if (valueString.indexOf(',') > 0) {
+                    valueString = valueString.replace(',', '.');
+                }
+                tmp = parseFloat(valueString).toExponential();
+            }
+            var parts = tmp.split('e');
+            if (parts[0].indexOf('.') > 0) {
+                var floatPart = parseFloat(parts[0]);
+                parts[0] = floatPart.toLocaleString();
+            }
+            return parts[0] + 'e' + parts[1];
+        }
     }, {
         name: 'messwertPzs',
-        type: 'float'
+        serialize: function(v) {
+            if (v.indexOf(',') > 0) {
+                v = v.replace(',', '.');
+                return v;
+            }
+            return v;
+        },
+        convert: function(value) {
+            if (!value || value === '') {
+                return value;
+            }
+            var valueString = value.toString();
+            if (valueString.indexOf('E') > 0) {
+                valueString = valueString.replace('E', 'e');
+            }
+            var tmp;
+            if (valueString.indexOf('e') > 0) {
+                tmp = valueString;
+            }
+            else {
+                // Currently not locale friendly...
+                if (valueString.indexOf(',') > 0) {
+                    valueString = valueString.replace(',', '.');
+                }
+                tmp = parseFloat(valueString).toExponential();
+            }
+            var parts = tmp.split('e');
+            if (parts[0].indexOf('.') > 0) {
+                var floatPart = parseFloat(parts[0]);
+                parts[0] = floatPart.toLocaleString();
+            }
+            return parts[0] + 'e' + parts[1];
+        }
     }, {
         name: 'messfehler',
         type: 'float'
diff -r d2165ba7e8f1 -r 7e801af49eeb app/view/grid/Messwert.js
--- a/app/view/grid/Messwert.js	Tue Mar 01 14:20:49 2016 +0100
+++ b/app/view/grid/Messwert.js	Wed Mar 02 12:59:15 2016 +0100
@@ -100,25 +100,17 @@
             dataIndex: 'messwertNwg',
             editor: {
                 xtype: 'checkbox',
-     	        inputValue: '<'
+                inputValue: '<'
             }
         }, {
             header: 'Messwert',
             dataIndex: 'messwert',
-            xtype: 'numbercolumn',
             width: 80,
-            renderer: function(value) {
-              return value.toExponential(2);
-            },
             editor: {
-                xtype: 'numberfield',
+                xtype: 'textfield',
                 allowBlank: false,
-                maxLength: 10,
-                allowExponential: true,
-                enforceMaxLength: true,
-                hideTrigger: true,
-                keyNavEnabled: false,
-                mouseWheelEnabled: false
+                regex: /^[+\-]?(?:(?:0|[1-9]\d*)(?:[\.\,][0-9]\d*)?(?:[eE][+\-]?\d+)|(\d+[\.\,]?\d*)?)$/,
+                regexText: 'Keine Zahl'
             }
         }, {
             header: 'Messeinheit',
@@ -159,25 +151,13 @@
             }
         }, {
             header: 'Nachweisgrenze',
-            xtype: 'numbercolumn',
             dataIndex: 'nwgZuMesswert',
             width: 80,
-            renderer: function(value) {
-              if (!value) {
-                return null;
-              } else {
-                return value.toExponential(2);
-              }
-            },
             editor: {
-                xtype: 'numberfield',
+                xtype: 'textfield',
                 allowBlank: true,
-                maxLength: 10,
-                allowExponential: true,
-                enforceMaxLength: true,
-                hideTrigger: true,
-                keyNavEnabled: false,
-                mouseWheelEnabled: false
+                regex: /^[+\-]?(?:(?:0|[1-9]\d*)(?:[\.\,][0-9]\d*)?(?:[eE][+\-]?\d+)|(\d+[\.\,]?\d*)?)$/,
+                regexText: 'Keine Zahl'
             }
         }, {
             header: 'Grenzwertüberschreitung',
diff -r d2165ba7e8f1 -r 7e801af49eeb app/view/grid/Probenzusatzwert.js
--- a/app/view/grid/Probenzusatzwert.js	Tue Mar 01 14:20:49 2016 +0100
+++ b/app/view/grid/Probenzusatzwert.js	Wed Mar 02 12:59:15 2016 +0100
@@ -90,14 +90,12 @@
         }, {
             header: 'Messwert',
             dataIndex: 'messwertPzs',
-            xtype: 'numbercolumn',
             flex: 1,
             editor: {
-                xtype: 'numberfield',
+                xtype: 'textfield',
                 allowBlank: false,
-                maxLength: 10,
-                enforceMaxLength: true,
-                allowExponential: false
+                regex: /^[+\-]?(?:(?:0|[1-9]\d*)(?:[\.\,][0-9]\d*)?(?:[eE][+\-]?\d+)|(\d+[\.\,]?\d*)?)$/,
+                regexText: 'Keine Zahl'
             }
         }, {
             header: '< NWG',
@@ -114,14 +112,12 @@
             header: 'Nachweisgrenze',
             dataIndex: 'nwgZuMesswert',
             xtype: 'numbercolumn',
-            format: '0',
             flex: 1,
             editor: {
-                xtype: 'numberfield',
+                xtype: 'textfield',
                 allowBlank: false,
-                maxLength: 10,
-                enforceMaxLength: true,
-                allowExponential: false
+                regex: /^[+\-]?(?:(?:0|[1-9]\d*)(?:[\.\,][0-9]\d*)?(?:[eE][+\-]?\d+)|(\d+[\.\,]?\d*)?)$/,
+                regexText: 'Keine Zahl'
             }
         }, {
             header: 'Maßeinheit',


More information about the Lada-commits mailing list