Fix attribute formatter functions

This commit is contained in:
Anton Tananaev
2015-09-16 22:27:23 +12:00
parent 37f402a3af
commit e7187ea46a
4 changed files with 12 additions and 9 deletions

View File

@@ -68,7 +68,7 @@ Ext.define('Traccar.Application', {
},
getPreference: function(key, defaultValue) {
return this.getUser().get('distanceUnit') | this.getServer().get('distanceUnit') | defaultValue;
return this.getUser().get(key) || this.getServer().get(key) || defaultValue;
}
});

View File

@@ -18,17 +18,16 @@ Ext.define('Traccar.AttributeFormatter', {
singleton: true,
coordinateFormatter: function(value) {
return value.toFixed(5);
return value.toFixed(6);
},
speedFormatter: function(value) {
return Ext.getStore('SpeedUnits').formatValue(value, Traccar.app.getPreference('speedUnit'));
},
courseValues: ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'],
courseFormatter: function(value) {
return this.courseValues[Math.floor(value / 45)];
var courseValues = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];
return courseValues[Math.floor(value / 45)];
},
distanceFormatter: function(value) {
@@ -36,8 +35,10 @@ Ext.define('Traccar.AttributeFormatter', {
},
defaultFormatter: function(value) {
if (value instanceof Number) {
if (typeof value === 'number') {
return value.toFixed(2);
} else if (typeof value === 'boolean') {
return value ? Ext.Msg.buttonText.yes : Ext.Msg.buttonText.no;
} else if (value instanceof Date) {
return Ext.Date.format(value, styles.dateTimeFormat);
}

View File

@@ -35,7 +35,7 @@ Ext.define('Traccar.view.login.Login', {
autoEl: {
tag: 'form',
method: 'POST',
action: 'blank.html',
action: 'blank',
target: 'submitTarget'
},

View File

@@ -81,7 +81,8 @@ Ext.define('Traccar.view.report.Report', {
columns: [{
text: strings.positionValid,
dataIndex: 'valid',
flex: 1
flex: 1,
renderer: Traccar.AttributeFormatter.getFormatter('valid')
}, {
text: strings.positionTime,
dataIndex: 'fixTime',
@@ -111,6 +112,7 @@ Ext.define('Traccar.view.report.Report', {
}, {
text: strings.positionAddress,
dataIndex: 'address',
flex: 1
flex: 1,
renderer: Traccar.AttributeFormatter.getFormatter('address')
}]
});