From a9c3d0532db72a635f373f2dce5bc5365aed16dc Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 4 Sep 2017 16:16:31 +0500 Subject: Improve CustomNumberField --- web/app/store/TimeUnits.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'web/app/store/TimeUnits.js') 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'); + } }); -- cgit v1.2.3