=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html 2015-03-04 12:38:52 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html 2015-03-05 15:48:50 +0000 @@ -13,6 +13,7 @@ + === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css 2015-03-04 11:34:55 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css 2015-03-05 15:48:50 +0000 @@ -907,6 +907,15 @@ pointer-events: none; } +.disabled-context-menu-item { + pointer-events: none; + color: #dddddd; + cursor: none; +} +.enable-context-menu-item { + cursor:pointer; +} + @media print { #header, #leftBar, .not-printable { display: none; === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties 2015-02-12 10:51:40 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties 2015-03-05 15:48:50 +0000 @@ -275,4 +275,9 @@ value_must_be_between=Value must be between locate_organisation_unit_by_name=Locate organisation unit by name dashboard_layout_not_saved=Dashboard layout not saved -ou_search_scope=Orgunit scope to use \ No newline at end of file +ou_search_scope=Orgunit scope to use +zoom_map=Zoom map +zoom_in=Zoom in +zoom_out=Zoom out +center_map=Center map +capture_coordinate=Capture coordinate \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html 2015-03-04 11:34:55 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html 2015-03-05 15:48:50 +0000 @@ -14,6 +14,7 @@ + @@ -94,7 +95,7 @@ - + === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css 2015-03-03 16:55:58 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css 2015-03-05 15:48:50 +0000 @@ -859,7 +859,6 @@ } } - .org-unit-tree { margin-left: -5px; color: #000; @@ -947,4 +946,31 @@ padding: 5px; font-size: 15px; position: absolute; +} + +.map_context_menu{ + background-color:white; + border:1px solid gray; + z-index: 1000; +} +.map_context_menu_item{ + padding:3px 6px; +} +.map_context_menu_item:hover{ + background-color:#CCCCCC; +} +.map_context_menu_separator{ + background-color:gray; + height:1px; + margin:0; + padding:0; +} + +.disabled-context-menu-item { + pointer-events: none; + color: #dddddd; + cursor: none; +} +.enable-context-menu-item { + cursor:pointer; } \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/coordinatecapture/map.html' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/coordinatecapture/map.html 2015-03-04 11:34:55 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/coordinatecapture/map.html 2015-03-05 15:48:50 +0000 @@ -11,5 +11,5 @@ \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js 2015-03-04 11:34:55 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js 2015-03-05 15:48:50 +0000 @@ -253,21 +253,6 @@ }; }) -/*.directive('d2Sortable', function() { - - return { - restrict: 'A', - link: function(scope, element, attrs){ - element.sortable({ - connectWith: ".connectedSortable", - placeholder: "ui-state-highlight", - tolerance: "pointer", - handle: '.handle' - }); - } - }; -})*/ - .directive('d2Sortable', function($timeout) { return { @@ -340,7 +325,7 @@ }; }) -.directive('d2GoogleMap', function ($parse, $http, CurrentSelection) { +.directive('d2GoogleMap', function ($parse, $http, $translate, CurrentSelection) { return { restrict: 'E', replace: true, @@ -350,7 +335,7 @@ var ouLevels = CurrentSelection.getOuLevels(); //remove angular bootstrap ui modal draggable - $(".modal-content").draggable({ disabled: true }); + $(".modal-content").draggable({ disabled: true }); //get a default center var latCenter = 12.31, lngCenter = 51.48; @@ -365,7 +350,7 @@ //default map configurations var mapOptions = { - zoom: 3, + zoom: 4, center: new google.maps.LatLng(latCenter, lngCenter), mapTypeId: google.maps.MapTypeId.ROADMAP }, @@ -388,20 +373,40 @@ } } - var currentLayer, currentGeojson, currentGeojsonFeatures; - - function getGeoJsonByOuLevel(initialize, event){ - + var currentLayer = 0, currentGeojson, currentGeojsonFeatures; + + var contextMenuOptions={}; + contextMenuOptions.classNames={menu:'map_context_menu', menuSeparator:'map_context_menu_separator'}; + + //create an array of MapContextMenuItem objects + var menuItems=[]; + menuItems.push({className: 'map_context_menu_item', eventName: 'zoom_in', id: 'zoomIn', label: ' ' + $translate('zoom_in')}); + menuItems.push({className: 'map_context_menu_item', eventName: 'zoom_out', id: 'zoomOut', label: ' ' + $translate('zoom_out')}); + menuItems.push({}); + menuItems.push({className: 'map_context_menu_item', eventName: 'centerMap', label: ' ' + $translate('center_map')}); + menuItems.push({}); + menuItems.push({className: 'map_context_menu_item', eventName: 'captureCoordinate', label: ' ' + $translate('capture_coordinate')}); + contextMenuOptions.menuItems=menuItems; + var mapContextMenu = new MapContextMenu(map, contextMenuOptions); + + function getGeoJsonByOuLevel(initialize, event, mode){ var url = ''; - if(currentLayer >= ouLevels.length-1 || initialize){ + if(initialize){ currentLayer = 0; url = '../api/organisationUnits.geojson?level=' + ouLevels[currentLayer].level; } else{ - currentLayer++; - url = '../api/organisationUnits.geojson?level=' + ouLevels[currentLayer].level + '&parent=' + event.feature.D; + if(mode === 'IN'){ + currentLayer++; + url = '../api/organisationUnits.geojson?level=' + ouLevels[currentLayer].level + '&parent=' + event.feature.D; + } + if(mode === 'OUT'){ + currentLayer--; + var parents = event.feature.k.parentGraph.substring(1,event.feature.k.parentGraph.length-1).split('/'); + url = '../api/organisationUnits.geojson?level=' + ouLevels[currentLayer].level + '&parent=' + parents[parents.length-2]; + } } - + $http.get( url ).then(function(response){ currentGeojson = response.data; currentGeojsonFeatures = map.data.addGeoJson(currentGeojson); @@ -434,11 +439,11 @@ }); } - function centerMap(){ + function centerMap(){ if(currentGeojson && currentGeojson.features){ var latLngBounds = getMapCenter(currentGeojson); map.fitBounds(latLngBounds); - map.panToBounds(latLngBounds); + map.panToBounds(latLngBounds); } } @@ -476,6 +481,41 @@ getGeoJsonByOuLevel(true, null); } + function zoomMap(event, mode){ + + for(var i = 0; i < currentGeojsonFeatures.length; i++){ + map.data.remove(currentGeojsonFeatures[i]); + } + + for(var i=0; i= ouLevels.length-1){ + $("#zoomIn").addClass('disabled-context-menu-item'); + $("#zoomIn").removeClass('enable-context-menu-item'); + $('#zoomIn').attr('disabled', "disabled"); + }else{ + $("#zoomIn").removeClass('disabled-context-menu-item'); + $("#zoomIn").addClass('enable-context-menu-item'); + $('#zoomIn').attr('disabled', ""); + } + if(currentLayer === 0){ + $("#zoomOut").addClass('disabled-context-menu-item'); + $("#zoomOut").removeClass('enable-context-menu-item'); + $('#zoomOut').attr('disabled', "disabled"); + } + else{ + $("#zoomOut").removeClass('disabled-context-menu-item'); + $("#zoomOut").addClass('enable-context-menu-item'); + $('#zoomIn').attr('disabled', ""); + } + } + //get lable for current polygon map.data.addListener('mouseover', function(e) { $("#polygon-label").text( e.feature.k.name ); @@ -490,28 +530,61 @@ }); //drill-down based on polygons assigned to orgunits - map.data.addListener('rightclick', function(e){ - for(var i = 0; i < currentGeojsonFeatures.length; i++){ - map.data.remove(currentGeojsonFeatures[i]); - } - - for(var i=0; i. +*/ + +function MapContextMenu(map, options){ + options=options || {}; + + this.setMap(map); + + this.classNames_=options.classNames || {}; + this.map_=map; + this.mapDiv_=map.getDiv(); + this.menuItems_=options.menuItems || []; + this.pixelOffset=options.pixelOffset || new google.maps.Point(10, -5); +} + +MapContextMenu.prototype=new google.maps.OverlayView(); + +MapContextMenu.prototype.draw=function(){ + if(this.isVisible_){ + var mapSize=new google.maps.Size(this.mapDiv_.offsetWidth, this.mapDiv_.offsetHeight); + var menuSize=new google.maps.Size(this.menu_.offsetWidth, this.menu_.offsetHeight); + var mousePosition=this.getProjection().fromLatLngToDivPixel(this.position_); + + var left=mousePosition.x; + var top=mousePosition.y; + + if(mousePosition.x>mapSize.width-menuSize.width-this.pixelOffset.x){ + left=left-menuSize.width-this.pixelOffset.x; + } else { + left+=this.pixelOffset.x; + } + + if(mousePosition.y>mapSize.height-menuSize.height-this.pixelOffset.y){ + top=top-menuSize.height-this.pixelOffset.y; + } else { + top+=this.pixelOffset.y; + } + + this.menu_.style.left=left+'px'; + this.menu_.style.top=top+'px'; + } +}; + +MapContextMenu.prototype.getVisible=function(){ + return this.isVisible_; +}; + +MapContextMenu.prototype.hide=function(){ + if(this.isVisible_){ + this.menu_.style.display='none'; + this.isVisible_=false; + } +}; + +MapContextMenu.prototype.onAdd=function(){ + function createMenuItem(values){ + var menuItem=document.createElement('div'); + menuItem.innerHTML=values.label; + if(values.className){ + menuItem.className=values.className; + } + if(values.id){ + menuItem.id=values.id; + } + menuItem.style.cssText='white-space:nowrap; font-size: 12pt;'; + menuItem.onclick=function(){ + google.maps.event.trigger($this, 'menu_item_selected', $this.event_, $this.position_, values.eventName); + }; + return menuItem; + } + function createMenuSeparator(){ + var menuSeparator=document.createElement('div'); + if($this.classNames_.menuSeparator){ + menuSeparator.className=$this.classNames_.menuSeparator; + } + return menuSeparator; + } + var $this=this; // used for closures + + var menu=document.createElement('div'); + if(this.classNames_.menu){ + menu.className=this.classNames_.menu; + } + menu.style.cssText='display:none; position:absolute'; + + for(var i=0, j=this.menuItems_.length; i