From 5433c47155452951b8c75587725bf6c92f8ff11d Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 1 Dec 2016 17:45:19 +0500 Subject: Handle 'showsingleevent' only in one place --- web/app/view/MapMarkerController.js | 11 +---------- web/app/view/ReportController.js | 6 ++++++ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/web/app/view/MapMarkerController.js b/web/app/view/MapMarkerController.js index 596cffb3..a526d912 100644 --- a/web/app/view/MapMarkerController.js +++ b/web/app/view/MapMarkerController.js @@ -31,8 +31,7 @@ Ext.define('Traccar.view.MapMarkerController', { controller: { '*': { selectdevice: 'selectDevice', - selectreport: 'selectReport', - showsingleevent: 'showSingleEvent' + selectreport: 'selectReport' } }, store: { @@ -66,10 +65,6 @@ Ext.define('Traccar.view.MapMarkerController', { this.liveRouteLength = Traccar.app.getAttributePreference('web.liveRouteLength', 10); }, - showSingleEvent: function () { - this.singleEvent = true; - }, - getDeviceColor: function (device) { switch (device.get('status')) { case 'online': @@ -253,10 +248,6 @@ Ext.define('Traccar.view.MapMarkerController', { } else if (geometry) { this.getView().getMapView().fit(geometry, this.getView().getMap().getSize()); } - if (this.singleEvent) { - this.singleEvent = false; - this.fireEvent('selectreport', data[0], false); - } }, clearReport: function () { diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index e1a64e69..97407e23 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -210,9 +210,14 @@ Ext.define('Traccar.view.ReportController', { params: { id: positionIds }, + scope: this, callback: function (records, operation, success) { if (success) { Ext.getStore('ReportRoute').add(records); + if (this.singleEvent) { + this.singleEvent = false; + this.fireEvent('selectreport', records[0], false); + } } } }); @@ -220,6 +225,7 @@ Ext.define('Traccar.view.ReportController', { }, showSingleEvent: function (eventId) { + this.singleEvent = true; this.lookupReference('reportTypeField').setValue('events'); Ext.getStore('Events').load({ id: eventId, -- cgit v1.2.3