diff options
author | Abyss777 <abyss@fox5.ru> | 2017-09-04 16:16:31 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-09-04 16:16:31 +0500 |
commit | a9c3d0532db72a635f373f2dce5bc5365aed16dc (patch) | |
tree | 5795c557ac54ba9827af64e861eeddcc93845ae5 /web/app/store | |
parent | 44806acd0e4fa1618e66ac61f2cc6e0505dc9c92 (diff) | |
download | trackermap-web-a9c3d0532db72a635f373f2dce5bc5365aed16dc.tar.gz trackermap-web-a9c3d0532db72a635f373f2dce5bc5365aed16dc.tar.bz2 trackermap-web-a9c3d0532db72a635f373f2dce5bc5365aed16dc.zip |
Improve CustomNumberField
Diffstat (limited to 'web/app/store')
-rw-r--r-- | web/app/store/TimeUnits.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/web/app/store/TimeUnits.js b/web/app/store/TimeUnits.js index 6afeb935..0d16c4bb 100644 --- a/web/app/store/TimeUnits.js +++ b/web/app/store/TimeUnits.js @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,16 +17,28 @@ Ext.define('Traccar.store.TimeUnits', { extend: 'Ext.data.Store', - fields: ['name', 'factor'], + fields: ['key', 'name', 'factor'], data: [{ + key: 's', name: Strings.sharedSecondAbbreviation, factor: 1 }, { + key: 'm', name: Strings.sharedMinuteAbbreviation, factor: 60 }, { + key: 'h', name: Strings.sharedHourAbbreviation, factor: 3600 - }] + }], + + convertValue: function (value, unit, back) { + var model; + if (!unit) { + unit = 'kn'; + } + model = this.findRecord('key', unit); + return back ? value * model.get('factor') : value / model.get('factor'); + } }); |