diff options
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 efcf1d66..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: [{ - 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'); + } }); |