aboutsummaryrefslogtreecommitdiff
path: root/web/app/store
diff options
context:
space:
mode:
Diffstat (limited to 'web/app/store')
-rw-r--r--web/app/store/TimeUnits.js18
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');
+ }
});