From b53b223a07dbba48321d42204ffbb07a33ac2caf Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 1 Dec 2016 12:00:19 +0500 Subject: - Handle eventId url parameter - Fit map view to events positions markers --- web/app/view/ReportController.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'web/app/view/ReportController.js') diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index f8a01bc6..32a44df5 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -40,12 +40,32 @@ Ext.define('Traccar.view.ReportController', { }, store: { '#ReportEvents': { + add: 'loadEvents', load: 'loadEvents' } } } }, + init: function () { + var eventId = Ext.Object.fromQueryString(window.location.search).eventId; + if (eventId) { + this.lookupReference('reportTypeField').setValue('events'); + Ext.getStore('Events').load({ + params: { + id: eventId + }, + callback: function (records, operation, success) { + if (success) { + Ext.getStore('ReportEvents').add(records); + } + } + }); + Traccar.app.hasEventId = true; + Traccar.app.removeUrlParameter('eventId'); + } + }, + hideReports: function () { Traccar.app.showReports(false); }, @@ -214,6 +234,15 @@ Ext.define('Traccar.view.ReportController', { } } }); + } else if (Traccar.app.hasEventId && data.length > 0) { + this.getView().getSelectionModel().select([data[0]], false, true); + this.getView().getView().focusRow(data[0]); + if (Traccar.app.isMobile()) { + Traccar.app.showReports(true); + } else { + this.getView().expand(); + } + Traccar.app.hasEventId = false; } }, -- cgit v1.2.3