aboutsummaryrefslogtreecommitdiff
path: root/web/app/store/DistanceUnits.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-09-15 12:24:13 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-09-15 12:24:13 +1200
commitd2139af877194952e3d49ca882188bcebbbd927e (patch)
treef5f6c81df6f04269a0f57d83e5fce17b8c98c346 /web/app/store/DistanceUnits.js
parent5cf1061cfcc5baf214bce145961512fd4f672621 (diff)
downloadtrackermap-server-d2139af877194952e3d49ca882188bcebbbd927e.tar.gz
trackermap-server-d2139af877194952e3d49ca882188bcebbbd927e.tar.bz2
trackermap-server-d2139af877194952e3d49ca882188bcebbbd927e.zip
Update and format store classes
Diffstat (limited to 'web/app/store/DistanceUnits.js')
-rw-r--r--web/app/store/DistanceUnits.js36
1 files changed, 17 insertions, 19 deletions
diff --git a/web/app/store/DistanceUnits.js b/web/app/store/DistanceUnits.js
index 653bf6efb..cedff592a 100644
--- a/web/app/store/DistanceUnits.js
+++ b/web/app/store/DistanceUnits.js
@@ -16,27 +16,25 @@
Ext.define('Traccar.store.DistanceUnits', {
extend: 'Ext.data.Store',
- fields: ['key', 'name'],
- data: [
- {'key': 'km', 'name': strings.sharedKm},
- {'key': 'mi', 'name': strings.sharedMi}
- ],
-
- convert: function(value, unit) {
- switch (unit) {
- case 'km':
- return Math.round(value * 0.1) / 100;
- case 'mi':
- return Math.round(value * 0.0621371) / 100;
- }
- return value;
- },
-
- getUnitName: function(unit) {
+ fields: ['key', 'name', 'factor'],
+
+ data: [{
+ key: 'km',
+ name: strings.sharedKm,
+ factor: 0.001
+ }, {
+ key: 'mi',
+ name: strings.sharedMi,
+ factor: 0.00621371
+ }],
+
+ formatValue: function(value, unit) {
+ var model;
if (unit) {
- return this.findRecord('key', unit).get('name');
+ model = this.findRecord('key', unit);
+ return Math.round(value * model.get('factor') * 100) / 100 + ' ' + model.get('name');
} else {
- return '';
+ return value;
}
}
});