=== 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-02-02 13:42:37 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html 2015-03-04 11:34:55 +0000 @@ -7,6 +7,13 @@ + + + + + @@ -73,7 +80,7 @@ - + === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2015-02-02 13:42:37 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2015-03-04 11:34:55 +0000 @@ -10,6 +10,7 @@ $timeout, $translate, $anchorScroll, + orderByFilter, storage, Paginator, OptionSetService, @@ -23,7 +24,9 @@ CalendarService, GridColumnService, CustomFormService, + ECStorageService, ErrorMessageService, + CurrentSelection, ModalService, DialogService) { //selected org unit @@ -49,7 +52,7 @@ $scope.currentElement = {id: '', update: false}; $scope.optionSets = []; $scope.proceedSelection = true; - $scope.formUnsaved = false; + $scope.formUnsaved = false; //notes $scope.note = {}; @@ -58,13 +61,22 @@ var userAccount = storage.get('USER_PROFILE'); var storedBy = userAccount ? userAccount.userName : ''; $scope.noteExists = false; - storage.remove('SELECTED_OU'); + storage.remove('SELECTED_OU'); //watch for selection of org unit from tree $scope.$watch('selectedOrgUnit', function() { if(angular.isObject($scope.selectedOrgUnit)){ storage.set('SELECTED_OU', $scope.selectedOrgUnit); + + //get ouLevels + ECStorageService.currentStore.open().done(function(){ + ECStorageService.currentStore.getAll('ouLevels').done(function(response){ + var ouLevels = angular.isObject(response) ? orderByFilter(response, '-level').reverse() : []; + CurrentSelection.setOuLevels(orderByFilter(ouLevels, '-level').reverse()); + }); + }); + if($scope.optionSets.length < 1){ $scope.optionSets = []; OptionSetService.getAll().then(function(optionSets){ @@ -785,15 +797,12 @@ $scope.showMap = function(event){ var modalInstance = $modal.open({ - templateUrl: 'views/map.html', + templateUrl: '../dhis-web-commons/coordinatecapture/map.html', controller: 'MapController', windowClass: 'modal-full-window', resolve: { location: function () { return {lat: event.coordinate.latitude, lng: event.coordinate.longitude}; - }, - geoJsons: function(){ - return $scope.geoJsons; } } }); === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js 2015-01-29 17:13:36 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js 2015-03-04 11:34:55 +0000 @@ -29,7 +29,7 @@ dhis2.ec.store = new dhis2.storage.Store({ name: 'dhis2ec', adapters: [dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter], - objectStores: ['programs', 'programStages', 'geoJsons', 'optionSets', 'events', 'programValidations'] + objectStores: ['programs', 'programStages', 'geoJsons', 'optionSets', 'events', 'programValidations', 'ouLevels'] }); (function($) { @@ -143,8 +143,7 @@ promise = promise.then( dhis2.ec.store.open ); promise = promise.then( getCalendarSetting ); - promise = promise.then( getOrgUnitLevels ); - //promise = promise.then( getGeoJsonsByLevel ); + promise = promise.then( getOrgUnitLevels ); promise = promise.then( getMetaPrograms ); promise = promise.then( getPrograms ); promise = promise.then( getProgramStages ); @@ -183,88 +182,27 @@ function getOrgUnitLevels() { - var def = $.Deferred(); - - $.ajax({ - url: '../api/organisationUnitLevels.json', - type: 'GET', - data:'filter=level:gt:1&fields=id,name,level&paging=false' - }).done( function(response) { - var ouLevels = []; - if(response.organisationUnitLevels){ - ouLevels = _.sortBy(response.organisationUnitLevels, function(ouLevel){ - return ouLevel.level; - }); + dhis2.ec.store.getKeys( 'ouLevels').done(function(res){ + if(res.length > 0){ + return; } - def.resolve( ouLevels ); - }).fail(function(){ - def.resolve(null); - }); - - return def.promise(); -} - -function getGeoJsonsByLevel( ouLevels ) -{ - if( !ouLevels ){ - return; - } - - var mainDef = $.Deferred(); - var mainPromise = mainDef.promise(); - - var def = $.Deferred(); - var promise = def.promise(); - - var builder = $.Deferred(); - var build = builder.promise(); - - _.each( _.values( ouLevels ), function ( ouLevel ) { - if(ouLevel.level){ - build = build.then(function() { - var d = $.Deferred(); - var p = d.promise(); - dhis2.ec.store.get('geoJsons', ouLevel.level).done(function(obj) { - if(!obj) { - promise = promise.then( getGeoJson( ouLevel.level ) ); - } - d.resolve(); - }); - - return p; - }); - } - }); - - build.done(function() { - def.resolve(); - promise = promise.done( function () { - mainDef.resolve(); - }); - }).fail(function(){ - mainDef.resolve(); - }); - - builder.resolve(); - - return mainPromise; -} - -function getGeoJson( level ) -{ - return function() { - return $.ajax( { - url: '../api/organisationUnits.geojson', + var def = $.Deferred(); + + $.ajax({ + url: '../api/organisationUnitLevels.json', type: 'GET', - data: 'level=' + level - }).done( function( response ){ - - var geojson = {}; - geojson = response; - geojson.id = level; - dhis2.ec.store.set( 'geoJsons', geojson ); + data:'filter=level:gt:1&fields=id,name,level&paging=false' + }).done(function(response) { + if(response.organisationUnitLevels){ + dhis2.ec.store.setAll( 'ouLevels', response.organisationUnitLevels ); + } + def.resolve(); + }).fail(function(){ + def.resolve(); }); - }; + + return def.promise(); + }); } function getMetaPrograms() === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js 2015-01-29 17:13:36 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js 2015-03-04 11:34:55 +0000 @@ -8,7 +8,7 @@ var store = new dhis2.storage.Store({ name: 'dhis2ec', adapters: [dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter], - objectStores: ['programs', 'programStages', 'geoJsons', 'optionSets', 'events', 'programValidations'] + objectStores: ['programs', 'programStages', 'geoJsons', 'optionSets', 'events', 'programValidations', 'ouLevels'] }); return{ currentStore: store @@ -58,6 +58,19 @@ }; }) +/* current selections */ +.service('CurrentSelection', function(){ + + this.ouLevels = null; + + this.setOuLevels = function(ouLevels){ + this.ouLevels = ouLevels; + }; + this.getOuLevels = function(){ + return this.ouLevels; + }; +}) + /* Factory to fetch optionSets */ .factory('OptionSetService', function($q, $rootScope, ECStorageService) { return { === 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 2014-12-18 11:50:32 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css 2015-03-04 11:34:55 +0000 @@ -251,9 +251,15 @@ } #polygon-label { - background-color: #000000; - color: #fff; - font-size: 12px; + text-align: center; + padding: 5px; + font-size: 15px; +} + +.polygon-name { + padding: 5px; + font-size: 15px; + position: absolute; } .contextmenu{ @@ -947,4 +953,4 @@ { padding: 11px 0 10px 5px; } -} \ No newline at end of file +} === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html 2015-01-26 17:47:09 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html 2015-03-04 11:34:55 +0000 @@ -50,6 +50,9 @@ ng-required="false" style="width:99%;"/> {{'int_required'| translate}} [-90 ... 90] + + + @@ -65,11 +68,12 @@ ng-required="false" style="width:99%;"/> {{'int_required'| translate}}[-180 ... 180] - + + + + - + {{eventGridColumn.name}}* === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/ec-custom-form.html' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/ec-custom-form.html 2015-01-26 17:47:09 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/ec-custom-form.html 2015-03-04 11:34:55 +0000 @@ -51,9 +51,9 @@ style="min-width:128px"/> {{'int_required'| translate}}[-180 ... 180] - + === removed file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/map.html' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/map.html 2014-11-03 11:11:25 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/map.html 1970-01-01 00:00:00 +0000 @@ -1,13 +0,0 @@ - - - \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2015-03-03 16:55:58 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2015-03-04 11:34:55 +0000 @@ -27,7 +27,7 @@ //get ouLevels TCStorageService.currentStore.open().done(function(){ TCStorageService.currentStore.getAll('ouLevels').done(function(response){ - var ouLevels = response; + var ouLevels = angular.isObject(response) ? orderByFilter(response, '-level').reverse() : []; CurrentSelection.setOuLevels(orderByFilter(ouLevels, '-level').reverse()); }); }); === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2015-03-03 16:55:58 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2015-03-04 11:34:55 +0000 @@ -675,15 +675,12 @@ $scope.showMap = function(event){ var modalInstance = $modal.open({ - templateUrl: 'views/map.html', + templateUrl: '../dhis-web-commons/coordinatecapture/map.html', controller: 'MapController', windowClass: 'modal-full-window', resolve: { location: function () { return {lat: event.coordinate.latitude, lng: event.coordinate.longitude}; - }, - geoJsons: function(){ - return $scope.geoJsons; } } }); === 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-03 16:55:58 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html 2015-03-04 11:34:55 +0000 @@ -13,7 +13,7 @@ - + === removed file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/custom-overlay.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/custom-overlay.js 2015-03-03 16:55:58 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/custom-overlay.js 1970-01-01 00:00:00 +0000 @@ -1,101 +0,0 @@ -//adapded from this example http://code.google.com/apis/maps/documentation/javascript/overlays.html#CustomOverlays -//text overlays -function TxtOverlay(pos, txt, cls, map) { - - // Now initialize all properties. - this.pos = pos; - this.txt_ = txt; - this.cls_ = cls; - this.map_ = map; - - // We define a property to hold the image's - // div. We'll actually create this div - // upon receipt of the add() method so we'll - // leave it null for now. - this.div_ = null; - - // Explicitly call setMap() on this overlay - this.setMap(map); -} - -TxtOverlay.prototype = new google.maps.OverlayView(); - - - -TxtOverlay.prototype.onAdd = function () { - - // Note: an overlay's receipt of onAdd() indicates that - // the map's panes are now available for attaching - // the overlay to the map via the DOM. - - // Create the DIV and set some basic attributes. - var div = document.createElement('DIV'); - div.className = this.cls_; - - div.innerHTML = this.txt_; - - // Set the overlay's div_ property to this DIV - this.div_ = div; - var overlayProjection = this.getProjection(); - var position = overlayProjection.fromLatLngToDivPixel(this.pos); - div.style.left = position.x + 'px'; - div.style.top = position.y + 'px'; - // We add an overlay to a map via one of the map's panes. - - var panes = this.getPanes(); - panes.floatPane.appendChild(div); -} -TxtOverlay.prototype.draw = function () { - - - var overlayProjection = this.getProjection(); - - // Retrieve the southwest and northeast coordinates of this overlay - // in latlngs and convert them to pixels coordinates. - // We'll use these coordinates to resize the DIV. - var position = overlayProjection.fromLatLngToDivPixel(this.pos); - - - var div = this.div_; - div.style.left = position.x + 'px'; - div.style.top = position.y + 'px'; - - - -} -//Optional: helper methods for removing and toggling the text overlay. -TxtOverlay.prototype.onRemove = function () { - this.div_.parentNode.removeChild(this.div_); - this.div_ = null; -} -TxtOverlay.prototype.hide = function () { - if (this.div_) { - this.div_.style.visibility = "hidden"; - } -} - -TxtOverlay.prototype.show = function () { - if (this.div_) { - this.div_.style.visibility = "visible"; - } -} - -TxtOverlay.prototype.toggle = function () { - if (this.div_) { - if (this.div_.style.visibility == "hidden") { - this.show(); - } - else { - this.hide(); - } - } -} - -TxtOverlay.prototype.toggleDOM = function () { - if (this.getMap()) { - this.setMap(null); - } - else { - this.setMap(this.map_); - } -} === removed file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/map.html' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/map.html 2015-03-03 16:55:58 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/map.html 1970-01-01 00:00:00 +0000 @@ -1,15 +0,0 @@ - - - \ No newline at end of file === added directory 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/coordinatecapture' === added 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 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/coordinatecapture/map.html 2015-03-04 11:34:55 +0000 @@ -0,0 +1,15 @@ + + + \ 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.controllers.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.controllers.js 2015-02-02 13:42:37 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.controllers.js 2015-03-04 11:34:55 +0000 @@ -32,8 +32,7 @@ .controller('MapController', function($scope, $modalInstance, - DHIS2URL, - geoJsons, + DHIS2URL, location) { $scope.home = function(){ @@ -41,7 +40,6 @@ }; $scope.location = location; - $scope.geoJsons = geoJsons; $scope.close = function () { $modalInstance.close(); === 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-03 16:55:58 +0000 +++ 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 @@ -346,7 +346,7 @@ replace: true, template: '
', link: function(scope, element, attrs){ - + var ouLevels = CurrentSelection.getOuLevels(); //remove angular bootstrap ui modal draggable @@ -459,12 +459,12 @@ latLngBounds.extend(new google.maps.LatLng(coordinate[1],coordinate[0])); polygonPoints.extend(new google.maps.LatLng(coordinate[1],coordinate[0])); }); - var txt = new TxtOverlay(polygonPoints.getCenter(), customTxt, "polygon-name", map); + var txt = new Dhis2TextOverlay(polygonPoints.getCenter(), customTxt, "polygon-name", map); overLays.push(txt); } else if(feature.geometry.type === 'Point'){ latLngBounds.extend(new google.maps.LatLng(feature.geometry.coordinates[1],feature.geometry.coordinates[0])); - var txt = new TxtOverlay(new google.maps.LatLng(feature.geometry.coordinates[1],feature.geometry.coordinates[0]),customTxt, "polygon-name",map ); + var txt = new Dhis2TextOverlay(new google.maps.LatLng(feature.geometry.coordinates[1],feature.geometry.coordinates[0]),customTxt, "polygon-name",map ); overLays.push(txt); } }); === added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.map.textoverlay.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.map.textoverlay.js 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.map.textoverlay.js 2015-03-04 11:34:55 +0000 @@ -0,0 +1,103 @@ +// https://developers.google.com/maps/documentation/javascript/customoverlays +/** @constructor */ +function Dhis2TextOverlay(pos, txt, cls, map) { + + // Initialize properties. + this.pos = pos; + this.txt_ = txt; + this.cls_ = cls; + this.map_ = map; + + // Div to contain text + this.div_ = null; + + // Explicitly call setMap() on this overlay + this.setMap(map); +} + +Dhis2TextOverlay.prototype = new google.maps.OverlayView(); + + +/** + * onAdd is called when the map's panes are ready and the overlay has been + * added to the map. + */ +Dhis2TextOverlay.prototype.onAdd = function () { + + // Create the DIV and set some basic attributes. + var div = document.createElement('DIV'); + div.className = this.cls_; + div.innerHTML = this.txt_; + + // Set the overlay's div_ property to this DIV + this.div_ = div; + var overlayProjection = this.getProjection(); + var position = overlayProjection.fromLatLngToDivPixel(this.pos); + div.style.left = position.x + 'px'; + div.style.top = position.y + 'px'; + + // Add the element to the "overlayLayer" pane. + var panes = this.getPanes(); + panes.floatPane.appendChild(div); +}; + +Dhis2TextOverlay.prototype.draw = function () { + + // We use the south-west and north-east + // coordinates of the overlay to peg it to the correct position and size. + // To do this, we need to retrieve the projection from the overlay. + var overlayProjection = this.getProjection(); + + // Retrieve the southwest and northeast coordinates of this overlay + // in latlngs and convert them to pixels coordinates. + // We'll use these coordinates to resize the DIV. + var position = overlayProjection.fromLatLngToDivPixel(this.pos); + + // Resize the div to fit the indicated dimensions. + var div = this.div_; + div.style.left = position.x + 'px'; + div.style.top = position.y + 'px'; +}; + +// The onRemove() method will be called automatically from the API if +// we ever set the overlay's map property to 'null' +Dhis2TextOverlay.prototype.onRemove = function () { + this.div_.parentNode.removeChild(this.div_); + this.div_ = null; +}; + +// Set the visibility to 'hidden' or 'visible'. +Dhis2TextOverlay.prototype.hide = function () { + if (this.div_) { + this.div_.style.visibility = "hidden"; + } +}; + +Dhis2TextOverlay.prototype.show = function () { + if (this.div_) { + this.div_.style.visibility = "visible"; + } +}; + +Dhis2TextOverlay.prototype.toggle = function () { + if (this.div_) { + if (this.div_.style.visibility === "hidden") { + this.show(); + } + else { + this.hide(); + } + } +}; + +// Detach the map from the DOM via toggleDOM(). +// Note that if we later reattach the map, it will be visible again, +// because the containing
is recreated in the overlay's onAdd() method. +Dhis2TextOverlay.prototype.toggleDOM = function () { + if (this.getMap()) { + this.setMap(null); + } + else { + this.setMap(this.map_); + } +};