diff options
author | Abyss777 <abyss@fox5.ru> | 2017-09-04 09:44:54 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-09-04 09:44:54 +0500 |
commit | 44806acd0e4fa1618e66ac61f2cc6e0505dc9c92 (patch) | |
tree | 65d0be5bc4746457727b18c8c9490d018b814483 /web/app/view/CustomNumberField.js | |
parent | 6a9bbe6624bf65fafe11378caf485ba5612f407c (diff) | |
download | trackermap-web-44806acd0e4fa1618e66ac61f2cc6e0505dc9c92.tar.gz trackermap-web-44806acd0e4fa1618e66ac61f2cc6e0505dc9c92.tar.bz2 trackermap-web-44806acd0e4fa1618e66ac61f2cc6e0505dc9c92.zip |
Improve commands
Diffstat (limited to 'web/app/view/CustomNumberField.js')
-rw-r--r-- | web/app/view/CustomNumberField.js | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/web/app/view/CustomNumberField.js b/web/app/view/CustomNumberField.js index 887e5c9c..9144b524 100644 --- a/web/app/view/CustomNumberField.js +++ b/web/app/view/CustomNumberField.js @@ -20,7 +20,7 @@ Ext.define('Traccar.view.CustomNumberField', { xtype: 'customNumberField', beforeEl: '<div style="width:100%;display:inline-table;">', - unitEl: '<div style="display:table-cell;padding-left:10px;vertical-align:middle;">', + unitEl: '<div id="unitEl" style="display:table-cell;padding-left:10px;vertical-align:middle;width:30%">', constructor: function (config) { var unit; @@ -44,6 +44,38 @@ Ext.define('Traccar.view.CustomNumberField', { config.valueToRaw = function (value) { return Ext.getStore('DistanceUnits').convertValue(value, Traccar.app.getPreference('distanceUnit', 'km')); }; + } else if (config.dataType === 'frequency') { + config.beforeSubTpl = this.beforeEl; + config.afterSubTpl = this.unitEl + '</div></div>'; + config.listeners = { + afterrender: function (numberField) { + if (!numberField.timeUnits) { + numberField.timeUnits = Ext.create({ + xtype: 'combobox', + renderTo: 'unitEl', + store: 'TimeUnits', + displayField: 'name', + valueField: 'factor', + value: 1, + width: 70 + }); + } + } + }; + config.rawToValue = function (rawValue) { + if (this.timeUnits) { + return rawValue * this.timeUnits.getValue(); + } else { + return rawValue; + } + }; + config.valueToRaw = function (value) { + if (this.timeUnits) { + return value / this.timeUnits.getValue(); + } else { + return value; + } + }; } this.callParent(arguments); } |