From 788a499b346724d753798597fb18f8aef17e1588 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 18 May 2017 10:01:49 +0500 Subject: Implement known position attributes --- web/app/view/edit/Attributes.js | 4 ++-- web/app/view/edit/ComputedAttributes.js | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'web/app/view/edit') diff --git a/web/app/view/edit/Attributes.js b/web/app/view/edit/Attributes.js index 7788d8c..b080e56 100644 --- a/web/app/view/edit/Attributes.js +++ b/web/app/view/edit/Attributes.js @@ -57,9 +57,9 @@ Ext.define('Traccar.view.edit.Attributes', { if (this.attributesStore) { attribute = Ext.getStore(this.attributesStore).getById(record.get('name')); } - if (attribute && attribute.get('convert') === 'speed') { + if (attribute && attribute.get('dataType') === 'speed') { return Ext.getStore('SpeedUnits').formatValue(value, Traccar.app.getPreference('speedUnit', 'kn')); - } else if (attribute && attribute.get('convert') === 'distance') { + } else if (attribute && attribute.get('dataType') === 'distance') { return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getPreference('distanceUnit', 'km')); } else { return value; diff --git a/web/app/view/edit/ComputedAttributes.js b/web/app/view/edit/ComputedAttributes.js index 87d3b8d..741a104 100644 --- a/web/app/view/edit/ComputedAttributes.js +++ b/web/app/view/edit/ComputedAttributes.js @@ -46,13 +46,29 @@ Ext.define('Traccar.view.edit.ComputedAttributes', { dataIndex: 'description' }, { text: Strings.sharedAttribute, - dataIndex: 'attribute' + dataIndex: 'attribute', + renderer: function (value) { + var attribute = Ext.getStore('PositionAttributes').getById(value); + if (attribute) { + return attribute.get('name'); + } else { + return value; + } + } }, { text: Strings.sharedExpression, dataIndex: 'expression' }, { text: Strings.sharedType, - dataIndex: 'type' + dataIndex: 'type', + renderer: function (value) { + var type = Ext.getStore('AttributeValueTypes').getById(value); + if (type) { + return type.get('name'); + } else { + return value; + } + } }] } }); -- cgit v1.2.3 From 3cd2d2e792d558886e404913780116d99a443d74 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 19 May 2017 09:25:53 +0500 Subject: Position attribute name rendering optimization --- web/app/store/PositionAttributes.js | 12 ++++++++---- web/app/view/StateController.js | 2 +- web/app/view/dialog/DeviceDistance.js | 2 +- web/app/view/edit/ComputedAttributes.js | 7 +------ web/app/view/permissions/DeviceAttributes.js | 7 +------ web/app/view/permissions/GroupAttributes.js | 7 +------ web/app/view/permissions/UserAttributes.js | 7 +------ 7 files changed, 14 insertions(+), 30 deletions(-) (limited to 'web/app/view/edit') diff --git a/web/app/store/PositionAttributes.js b/web/app/store/PositionAttributes.js index 6d6c0b7..ec1cbf8 100644 --- a/web/app/store/PositionAttributes.js +++ b/web/app/store/PositionAttributes.js @@ -236,14 +236,18 @@ Ext.define('Traccar.store.PositionAttributes', { valueType: 'string' }], - getAttributeName: function (key) { + getAttributeName: function (key, capitalize) { var model = this.getById(key); if (model) { return model.get('name'); } else { - return key.replace(/^./, function (match) { - return match.toUpperCase(); - }); + if (capitalize) { + return key.replace(/^./, function (match) { + return match.toUpperCase(); + }); + } else { + return key; + } } }, diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js index 1525db2..0723dc1 100644 --- a/web/app/view/StateController.js +++ b/web/app/view/StateController.js @@ -124,7 +124,7 @@ Ext.define('Traccar.view.StateController', { if (aliasIndex !== -1) { name = this.aliasesStore.getAt(aliasIndex).get('alias'); } else { - name = Ext.getStore('PositionAttributes').getAttributeName(key); + name = Ext.getStore('PositionAttributes').getAttributeName(key, true); } store.add(Ext.create('Traccar.model.Attribute', { priority: 1024, diff --git a/web/app/view/dialog/DeviceDistance.js b/web/app/view/dialog/DeviceDistance.js index f908e45..c6ac9f2 100644 --- a/web/app/view/dialog/DeviceDistance.js +++ b/web/app/view/dialog/DeviceDistance.js @@ -39,7 +39,7 @@ Ext.define('Traccar.view.dialog.DeviceDistance', { } }, { xtype: 'customNumberField', - convert: 'distance', + dataType: 'distance', reference: 'totalDistance', fieldLabel: Strings.deviceTotalDistance }], diff --git a/web/app/view/edit/ComputedAttributes.js b/web/app/view/edit/ComputedAttributes.js index 741a104..b4699e8 100644 --- a/web/app/view/edit/ComputedAttributes.js +++ b/web/app/view/edit/ComputedAttributes.js @@ -48,12 +48,7 @@ Ext.define('Traccar.view.edit.ComputedAttributes', { text: Strings.sharedAttribute, dataIndex: 'attribute', renderer: function (value) { - var attribute = Ext.getStore('PositionAttributes').getById(value); - if (attribute) { - return attribute.get('name'); - } else { - return value; - } + return Ext.getStore('PositionAttributes').getAttributeName(value); } }, { text: Strings.sharedExpression, diff --git a/web/app/view/permissions/DeviceAttributes.js b/web/app/view/permissions/DeviceAttributes.js index baca9d3..2ce0763 100644 --- a/web/app/view/permissions/DeviceAttributes.js +++ b/web/app/view/permissions/DeviceAttributes.js @@ -32,12 +32,7 @@ Ext.define('Traccar.view.permissions.DeviceAttributes', { flex: 1, minWidth: Traccar.Style.columnWidthNormal, renderer: function (value) { - var attribute = Ext.getStore('PositionAttributes').getById(value); - if (attribute) { - return attribute.get('name'); - } else { - return value; - } + return Ext.getStore('PositionAttributes').getAttributeName(value); } }] } diff --git a/web/app/view/permissions/GroupAttributes.js b/web/app/view/permissions/GroupAttributes.js index 3972dbe..44089da 100644 --- a/web/app/view/permissions/GroupAttributes.js +++ b/web/app/view/permissions/GroupAttributes.js @@ -32,12 +32,7 @@ Ext.define('Traccar.view.permissions.GroupAttributes', { flex: 1, minWidth: Traccar.Style.columnWidthNormal, renderer: function (value) { - var attribute = Ext.getStore('PositionAttributes').getById(value); - if (attribute) { - return attribute.get('name'); - } else { - return value; - } + return Ext.getStore('PositionAttributes').getAttributeName(value); } }] } diff --git a/web/app/view/permissions/UserAttributes.js b/web/app/view/permissions/UserAttributes.js index 8a8a454..7bca622 100644 --- a/web/app/view/permissions/UserAttributes.js +++ b/web/app/view/permissions/UserAttributes.js @@ -32,12 +32,7 @@ Ext.define('Traccar.view.permissions.UserAttributes', { flex: 1, minWidth: Traccar.Style.columnWidthNormal, renderer: function (value) { - var attribute = Ext.getStore('PositionAttributes').getById(value); - if (attribute) { - return attribute.get('name'); - } else { - return value; - } + return Ext.getStore('PositionAttributes').getAttributeName(value); } }] } -- cgit v1.2.3