From 6606ad80f189da772687c6092618b19a46f83394 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 3 Jul 2016 15:30:35 +1200 Subject: Add toolbar to geozone editor --- web/app/view/GeofenceMap.js | 78 ++++++++++++++++++++--------------- web/app/view/GeofenceMapController.js | 10 ++++- 2 files changed, 53 insertions(+), 35 deletions(-) (limited to 'web/app/view') diff --git a/web/app/view/GeofenceMap.js b/web/app/view/GeofenceMap.js index 8ec5ac224..2538a8b16 100644 --- a/web/app/view/GeofenceMap.js +++ b/web/app/view/GeofenceMap.js @@ -23,61 +23,71 @@ Ext.define('Traccar.view.GeofenceMap', { ], controller: 'geofenceMap', + bodyBorder: true, + + tbar: { + items: [{ + xtype: 'combobox', + store: 'GeozoneTypes', + valueField: 'id', + displayField: 'name' + }, { + xtype: 'tbfill' + }, { + text: Strings.sharedSave, + handler: 'onSaveClick' + }, { + text: Strings.sharedCancel, + handler: 'onCancelClick' + }] + }, initMap: function () { + var map, featureOverlay; this.callParent(); - var map = this.map; + map = this.map; - var features = new ol.Collection(); - var featureOverlay = new ol.layer.Vector({ - source: new ol.source.Vector({features: features}), + this.features = new ol.Collection(); + featureOverlay = new ol.layer.Vector({ + source: new ol.source.Vector({ + features: this.features + }), style: new ol.style.Style({ fill: new ol.style.Fill({ - color: 'rgba(255, 255, 255, 0.2)' + color: Traccar.Style.mapColorOverlay }), stroke: new ol.style.Stroke({ - color: '#ffcc33', - width: 2 + color: Traccar.Style.mapColorReport, + width: Traccar.Style.mapRouteWidth }), image: new ol.style.Circle({ - radius: 7, + radius: Traccar.Style.mapRadiusNormal, fill: new ol.style.Fill({ - color: '#ffcc33' + color: Traccar.Style.mapColorReport }) }) }) }); featureOverlay.setMap(map); - var modify = new ol.interaction.Modify({ - features: features, - // the SHIFT key must be pressed to delete vertices, so - // that new vertices can be drawn at the same position - // of existing vertices + map.addInteraction(new ol.interaction.Modify({ + features: this.features, deleteCondition: function(event) { - return ol.events.condition.shiftKeyOnly(event) && - ol.events.condition.singleClick(event); + return ol.events.condition.shiftKeyOnly(event) && ol.events.condition.singleClick(event); } - }); - map.addInteraction(modify); - - var draw; // global so we can remove it later - //var typeSelect = document.getElementById('type'); + })); + }, - function addInteraction() { - draw = new ol.interaction.Draw({ - features: features, - type: 'Polygon' // (typeSelect.value) - }); - map.addInteraction(draw); - } - - /*typeSelect.onchange = function() { - map.removeInteraction(draw); - addInteraction(); - };*/ + addInteraction: function () { + this.draw = new ol.interaction.Draw({ + features: this.features, + type: 'Polygon' // (typeSelect.value) + }); + this.map.addInteraction(this.draw); + }, - addInteraction(); + removeInteraction: function () { + this.map.removeInteraction(this.draw); } }); diff --git a/web/app/view/GeofenceMapController.js b/web/app/view/GeofenceMapController.js index bc0fbfe1b..d3915fd46 100644 --- a/web/app/view/GeofenceMapController.js +++ b/web/app/view/GeofenceMapController.js @@ -16,5 +16,13 @@ Ext.define('Traccar.view.GeofenceMapController', { extend: 'Ext.app.ViewController', - alias: 'controller.geofenceMap' + alias: 'controller.geofenceMap', + + onSaveClick: function (button) { + button.up('window').close(); + }, + + onCancelClick: function (button) { + button.up('window').close(); + } }); -- cgit v1.2.3