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') 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