Mercurial > lada > lada-client
changeset 1054:7e801af49eeb
Use exponential notation for messwerte and zusatzwerte.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 02 Mar 2016 12:59:15 +0100 |
parents | d2165ba7e8f1 |
children | 65ea1c2a8c98 |
files | app/model/Messwert.js app/model/Zusatzwert.js app/view/grid/Messwert.js app/view/grid/Probenzusatzwert.js |
diffstat | 4 files changed, 151 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- 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' }, {
--- 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'
--- 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',
--- 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',