From d9be85d9928a9c511335a3a2eb231dcfd1fb1d5a Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 29 Dec 2016 16:31:11 +0500 Subject: Deselect markers --- web/app/view/BaseMap.js | 13 ++++++++++--- web/app/view/DevicesController.js | 9 +++++++-- web/app/view/Map.js | 1 + web/app/view/MapMarkerController.js | 8 +++++++- web/app/view/ReportController.js | 9 ++++++++- web/app/view/StateController.js | 9 ++++++++- 6 files changed, 41 insertions(+), 8 deletions(-) diff --git a/web/app/view/BaseMap.js b/web/app/view/BaseMap.js index f0d51d5..d7309e7 100644 --- a/web/app/view/BaseMap.js +++ b/web/app/view/BaseMap.js @@ -120,9 +120,16 @@ Ext.define('Traccar.view.BaseMap', { }); this.map.on('click', function (e) { - this.map.forEachFeatureAtPixel(e.pixel, function (feature, layer) { - this.fireEvent('selectfeature', feature); - }.bind(this)); + if (this.map.hasFeatureAtPixel(e.pixel, { + layerFilter: function (layer) { + return layer.get('name') !== 'geofencesLayer'; + }})) { + this.map.forEachFeatureAtPixel(e.pixel, function (feature, layer) { + this.fireEvent('selectfeature', feature); + }.bind(this)); + } else { + this.fireEvent('deselectfeature'); + } }, this); }, diff --git a/web/app/view/DevicesController.js b/web/app/view/DevicesController.js index f09950b..20b90b3 100644 --- a/web/app/view/DevicesController.js +++ b/web/app/view/DevicesController.js @@ -32,7 +32,8 @@ Ext.define('Traccar.view.DevicesController', { listen: { controller: { '*': { - selectreport: 'selectReport' + selectreport: 'selectReport', + deselectfeature: 'deselectFeature' }, 'map': { selectdevice: 'selectDevice' @@ -143,11 +144,15 @@ Ext.define('Traccar.view.DevicesController', { selectReport: function (position) { if (position !== undefined) { - this.getView().getSelectionModel().deselectAll(); + this.deselectFeature(); } }, onUpdateDevice: function (store, data) { this.updateButtons(this.getView().getSelectionModel()); + }, + + deselectFeature: function () { + this.getView().getSelectionModel().deselectAll(); } }); diff --git a/web/app/view/Map.js b/web/app/view/Map.js index 2cc37ec..062bf4c 100644 --- a/web/app/view/Map.js +++ b/web/app/view/Map.js @@ -114,6 +114,7 @@ Ext.define('Traccar.view.Map', { this.geofencesSource = new ol.source.Vector({}); this.map.addLayer(new ol.layer.Vector({ + name: 'geofencesLayer', source: this.geofencesSource })); diff --git a/web/app/view/MapMarkerController.js b/web/app/view/MapMarkerController.js index f8f0e43..e4e3979 100644 --- a/web/app/view/MapMarkerController.js +++ b/web/app/view/MapMarkerController.js @@ -52,7 +52,8 @@ Ext.define('Traccar.view.MapMarkerController', { }, component: { '#': { - selectfeature: 'selectFeature' + selectfeature: 'selectFeature', + deselectfeature: 'deselectFeature' } } } @@ -379,5 +380,10 @@ Ext.define('Traccar.view.MapMarkerController', { this.fireEvent('selectreport', record, false); } } + }, + + deselectFeature: function () { + this.selectMarker(null, false); + this.fireEvent('deselectfeature'); } }); diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 383b38b..0064c5b 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -33,7 +33,8 @@ Ext.define('Traccar.view.ReportController', { controller: { '*': { selectdevice: 'selectDevice', - showsingleevent: 'showSingleEvent' + showsingleevent: 'showSingleEvent', + deselectfeature: 'deselectFeature' }, 'map': { selectreport: 'selectReport' @@ -195,6 +196,12 @@ Ext.define('Traccar.view.ReportController', { } }, + deselectFeature: function () { + if (this.lookupReference('reportTypeField').getValue() !== 'trips') { + this.getGrid().getSelectionModel().deselectAll(); + } + }, + selectTrip: function (trip) { var from, to; from = new Date(trip.get('startTime')); diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js index 3835697..bef54d2 100644 --- a/web/app/view/StateController.js +++ b/web/app/view/StateController.js @@ -34,7 +34,8 @@ Ext.define('Traccar.view.StateController', { '*': { selectdevice: 'selectDevice', selectreport: 'selectReport', - updatealiases: 'updateAliases' + updatealiases: 'updateAliases', + deselectfeature: 'deselectFeature' } }, store: { @@ -157,6 +158,12 @@ Ext.define('Traccar.view.StateController', { } }, + deselectFeature: function () { + this.deviceId = null; + this.position = null; + Ext.getStore('Attributes').removeAll(); + }, + clearReport: function (store) { this.position = null; Ext.getStore('Attributes').removeAll(); -- cgit v1.2.3