diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-09-05 21:41:29 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-05 21:41:29 +1200 |
commit | 6a87e86cee0cdbcc196166f3f1b330903364931b (patch) | |
tree | bf86c8ddb2b5d0edca73175be5e1ec2b69f33633 /web/app/store/TimeUnits.js | |
parent | ca6b408cc068c1e21641d1464350beb1daef872e (diff) | |
parent | b86c09cd3266b2bac9a7a8dbf848ed14fff1e6d7 (diff) | |
download | etbsa-traccar-web-6a87e86cee0cdbcc196166f3f1b330903364931b.tar.gz etbsa-traccar-web-6a87e86cee0cdbcc196166f3f1b330903364931b.tar.bz2 etbsa-traccar-web-6a87e86cee0cdbcc196166f3f1b330903364931b.zip |
Merge pull request #571 from Abyss777/improve_commands
Improve commands
Diffstat (limited to 'web/app/store/TimeUnits.js')
-rw-r--r-- | web/app/store/TimeUnits.js | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/web/app/store/TimeUnits.js b/web/app/store/TimeUnits.js index efcf1d6..0d16c4b 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: [{ - name: Strings.sharedSecond, + key: 's', + name: Strings.sharedSecondAbbreviation, factor: 1 }, { - name: Strings.sharedMinute, + key: 'm', + name: Strings.sharedMinuteAbbreviation, factor: 60 }, { - name: Strings.sharedHour, + 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'); + } }); |