dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33858
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17344: bug fix in Indexeddb; capturing coordinates through google map - WIP
------------------------------------------------------------
revno: 17344
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-11-03 11:34:14 +0100
message:
bug fix in Indexeddb; capturing coordinates through google map - WIP
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/en.json
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/scripts/app.js
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/directives.js
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/services.js
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/views/customForm.html
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/eventList.html
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/index.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/en.json'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/en.json 2014-09-23 10:48:24 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/en.json 2014-11-03 10:34:14 +0000
@@ -91,6 +91,10 @@
"online_nofification": "You are online",
"latitude": "Latitude",
"longitude": "Longitude",
+ "lat_lng": "[Latitude Longitude]",
+ "get_from_map": "Get from map",
+ "capture": "Capture",
+ "point_and_click_for_coordinate": "Point and click for coordinate",
"profile": "Profile",
"applications": "Apps",
"more_applications": "More apps",
=== 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 2014-10-17 14:33:57 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html 2014-11-03 10:34:14 +0000
@@ -7,6 +7,12 @@
<meta name="keywords" content="DHIS 2">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <script type="text/javascript">
+ window.google = null;
+ </script>
+
+ <script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false&libraries=geometry"></script>
+
<script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/jquery.min.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/jquery.plugin.min.js"></script>
@@ -33,7 +39,7 @@
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/angular-route.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/angular-cookies.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/angular-animate.js"></script>
- <script type="text/javascript" src="../dhis-web-commons/javascripts/angular/ui-bootstrap-tpls-0.10.0-draggable-modal.js"></script>
+ <script type="text/javascript" src="../dhis-web-commons/javascripts/angular/ui-bootstrap-tpls-0.10.0-draggable-modal.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/moment/moment-with-langs.min.js"></script>
@@ -60,18 +66,22 @@
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.appcache.js"></script>
- <script type="text/javascript" src="../dhis-web-commons/ouwt/ouwt.js"></script>
+ <!--<script type="text/javascript" src="../dhis-web-commons/ouwt/ouwt.js"></script>-->
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angularLocalStorage.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angular-translate.min.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angular-translate-loader-static-files.min.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angular-translate-loader-url.min.js"></script>
- <script type="text/javascript" src="scripts/event-capture.js"></script>
+ <!--<script type="text/javascript" src="scripts/event-capture.js"></script>-->
<script type="text/javascript" src="scripts/app.js"></script>
<script type="text/javascript" src="scripts/services.js"></script>
<script type="text/javascript" src="scripts/directives.js"></script>
- <script type="text/javascript" src="scripts/controllers.js"></script>
+ <script type="text/javascript" src="scripts/controllers.js"></script>
+ <script type="text/javascript" src="scripts/column-display-controller.js"></script>
+ <script type="text/javascript" src="scripts/header-controller.js"></script>
+ <script type="text/javascript" src="scripts/map-controller.js"></script>
+ <script type="text/javascript" src="scripts/notes-controller.js"></script>
<script type="text/javascript" src="scripts/filters.js"></script>
<script type="text/javascript" src="scripts/orgunitTreeSearch.js"></script>
@@ -98,108 +108,9 @@
<div d2-menu></div>
- </div>
-
- <div ng-controller="MainController">
-
- <div id="leftBar">
-
- <div style="margin-top:20px">
-
-
- <img id="searchIcon" src="../images/search.png" style="cursor: pointer" title="{{ 'locate_organisation_unit_by_name' | translate}}">
-
- <span id="searchSpan" style="width:100%;display:none;">
- <input type="text" id="searchField" name="key" style="width:160px" />
- <input type="button" value="Find" onclick="selection.findByName()" />
- </span>
- </div>
-
- <div id="orgUnitTree">
- <ul>
- </ul>
- </div>
- <img id="ouwt_loader" src="../images/ajax-loader-bar.gif"/>
- </div>
-
- <div class="page" id="mainPage" ng-show="selectedOrgUnit">
- <h3>
- {{'event_capture'| translate}}
- </h3>
-
- <!-- selection begins-->
- <div>
- <table>
- <tr>
- <td><label>{{'registering_unit'| translate}}</label></td>
- <td><input type="text" class="fixed-width-text" selected-org-unit ng-model="selectedOrgUnit.name" value="{{selectedOrgUnit.name || 'please_select'| translate}}" disabled="" style="height:14px"></td>
- </tr>
- <tr>
- <td><label>{{'program'| translate}}</label></td>
- <td>
- <select id="programId"
- class="fixed-width-select"
- name="programId"
- ng-model="selectedProgram"
- ng-options="program as program.name for program in programs | orderBy: 'name'"
- ng-change="loadEvents()"
- ng-disabled="eventRegistration || editingEventInFull || editingEventInGrid">
- <option value="">{{'please_select'| translate}}</option>
- </select>
- </td>
- <td style='padding-left: 10px;'>
- <button class="button button-std not-printable"
- ng-show="selectedProgramStage"
- ng-click="showEventRegistration()"
- ng-disabled="eventRegistration || editingEventInFull || editingEventInGrid">
- {{'register_event'| translate}}
- </button>
- </td>
- <td ng-if="(editingEventInFull || eventRegistration) && customForm" style='padding-left: 10px;'>
- <button class="button button-std not-printable"
- ng-click="switchDataEntryForm()">
- {{displayCustomForm ? 'use_default_form' : 'use_custom_form'| translate}}
- </button>
- </td>
- <td ng-if="dhis2Events.length > 0" style='padding-left: 10px;'>
- <button class="button button-std not-printable"
- onclick="javascript:window.print()">
- <span ng-if="!eventRegistration && !editingEventInFull">{{'print_list'| translate}}</span>
- <span ng-if="eventRegistration">{{'print_form'| translate}}</span>
- <span ng-if="editingEventInFull">{{'print_details'| translate}}</span>
- </button>
- </td>
- </tr>
- </table>
- </div>
- <!-- selection ends -->
- <div id="hideTypeAheadPopUp" ng-hide="true"></div>
- <!-- event grid begins -->
- <div ng-include="'views/eventList.html'"></div>
- <!-- event grid ends -->
-
- <!-- event update in full / registration begins-->
- <div>
- <form name="outerForm" novalidate>
- <div ng-if="editingEventInFull || eventRegistration">
- <h3>
- <span ng-if="editingEventInFull">{{'event_details'| translate}}</span>
- <span ng-if="eventRegistration">{{'new_event'| translate}}</span>
- </h3>
-
- <div class="bordered-div" ng-if="displayCustomForm">
- <div ng-include="'views/customForm.html'"></div>
- </div>
-
- <div class="bordered-div container-default-form" ng-if="!displayCustomForm">
- <div ng-include="'views/defaultForm.html'"></div>
- </div>
-
- </div>
- </form>
- </div>
- <!-- event update / registration ends -->
- </div>
</div>
+
+ <div ng-view></div>
+
</body>
</html>
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/app.js 2014-06-12 23:12:59 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/app.js 2014-11-03 10:34:14 +0000
@@ -16,16 +16,27 @@
.value('DHIS2URL', '..')
-.config(function($httpProvider, $translateProvider) {
+.config(function($httpProvider, $routeProvider, $translateProvider) {
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
+ $routeProvider.when('/', {
+ templateUrl: 'views/home.html',
+ controller: 'MainController'/*,
+ resolve: {
+ geoJsons: function(GeoJsonFactory){
+ return GeoJsonFactory.getAll();
+ }
+ }*/
+ }).otherwise({
+ redirectTo : '/'
+ });
+
$translateProvider.useStaticFilesLoader({
prefix: 'i18n/',
suffix: '.json'
});
- $translateProvider.preferredLanguage('en');
-
+ $translateProvider.preferredLanguage('en');
});
\ No newline at end of file
=== 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 2014-10-17 14:33:27 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2014-11-03 10:34:14 +0000
@@ -6,17 +6,17 @@
//Controller for settings page
.controller('MainController',
function($scope,
- $filter,
$modal,
$timeout,
storage,
Paginator,
TranslationService,
- OptionSetFactory,
+ OptionSetService,
ProgramFactory,
- ProgramStageFactory,
- DHIS2EventFactory,
+ ProgramStageFactory,
+ DHIS2EventFactory,
DHIS2EventService,
+ GeoJsonFactory,
ContextMenuSelectedItem,
DateUtils,
ModalService,
@@ -57,18 +57,21 @@
$scope.dhis2Events = [];
if( angular.isObject($scope.selectedOrgUnit)){
-
//apply translation - by now user's profile is fetched from server.
- TranslationService.translate();
-
+ TranslationService.translate();
$scope.loadPrograms();
-
}
});
+ GeoJsonFactory.getAll().then(function(geoJsons){
+ $scope.geoJsons = geoJsons;
+ });
+
+
+
//load programs associated with the selected org unit.
- $scope.loadPrograms = function() {
-
+ $scope.loadPrograms = function() {
+
//$scope.selectedOrgUnit = orgUnit;
$scope.selectedProgram = null;
$scope.selectedProgramStage = null;
@@ -121,19 +124,10 @@
if( $scope.selectedProgram && $scope.selectedProgram.programStages[0].id){
$scope.optionSets = [];
- $scope.optionNamesByCode = new Object();
- $scope.optionCodesByName = new Object();
- OptionSetFactory.getAll().then(function(optionSets){
+ OptionSetService.getAll().then(function(optionSets){
angular.forEach(optionSets, function(optionSet){
- //$scope.optionSets[optionSet.id] = optionSet;
- angular.forEach(optionSet.options, function(option){
- if(option.name && option.code){
- $scope.optionNamesByCode[ '"' + option.code + '"'] = option.name;
- $scope.optionCodesByName[ '"' + option.name + '"'] = option.code;
- }
- });
- $scope.optionSets[optionSet.id] = optionSet;
+ $scope.optionSets[optionSet.id] = optionSet;
});
//because this is single event, take the first program stage
@@ -155,7 +149,7 @@
$scope.newDhis2Event = {dataValues: []};
$scope.currentEvent = {dataValues: []};
- $scope.eventGridColumns.push({name: 'form_id', id: 'uid', type: 'string', compulsory: false, showFilter: false, show: true});
+ $scope.eventGridColumns.push({name: 'form_id', id: 'uid', type: 'string', compulsory: false, showFilter: false, show: false});
$scope.filterTypes['uid'] = 'string';
$scope.eventGridColumns.push({name: $scope.selectedProgramStage.reportDateDescription ? $scope.selectedProgramStage.reportDateDescription : 'incident_date', id: 'event_date', type: 'date', compulsory: false, showFilter: false, show: true});
@@ -237,8 +231,8 @@
}
}
if($scope.prStDes[dataValue.dataElement].dataElement.type === 'string'){
- if($scope.prStDes[dataValue.dataElement].dataElement.optionSet && $scope.optionNamesByCode[ '"' + val + '"']){
- val = $scope.optionNamesByCode[ '"' + val + '"'];
+ if($scope.prStDes[dataValue.dataElement].dataElement.optionSet ){
+ val = OptionSetService.getNameOrCode($scope.optionSets[$scope.prStDes[dataValue.dataElement].dataElement.optionSet.id].options, val);
}
}
if($scope.prStDes[dataValue.dataElement].dataElement.type === 'date'){
@@ -440,9 +434,10 @@
valueExists = true;
if($scope.prStDes[dataElement].dataElement.type === 'string'){
if($scope.prStDes[dataElement].dataElement.optionSet){
- if($scope.optionCodesByName[ '"' + val + '"']){
+ /*if($scope.optionCodesByName[ '"' + val + '"']){
val = $scope.optionCodesByName[ '"' + val + '"'];
- }
+ }*/
+ val = OptionSetService.getNameOrCode($scope.optionSets[$scope.prStDes[dataElement].dataElement.optionSet.id].options,val); //$scope.optionSets[].options$scope.optionCodesByName[ '"' + val + '"'];
}
}
@@ -555,9 +550,10 @@
if(val && $scope.prStDes[dataElement].dataElement.type === 'string'){
if($scope.prStDes[dataElement].dataElement.optionSet){
- if($scope.optionCodesByName[ '"' + val + '"']){
+ /*if($scope.optionCodesByName[ '"' + val + '"']){
val = $scope.optionCodesByName[ '"' + val + '"'];
- }
+ }*/
+ val = OptionSetService.getNameOrCode($scope.optionSets[$scope.prStDes[dataElement].dataElement.optionSet.id].options,val);
}
}
if(val && $scope.prStDes[dataElement].dataElement.type === 'date'){
@@ -643,9 +639,10 @@
if($scope.prStDes[dataElement].dataElement.type === 'string'){
if($scope.prStDes[dataElement].dataElement.optionSet){
- if($scope.optionCodesByName[ '"' + newValue + '"']){
+ /*if($scope.optionCodesByName[ '"' + newValue + '"']){
newValue = $scope.optionCodesByName[ '"' + newValue + '"'];
- }
+ }*/
+ newValue = OptionSetService.getNameOrCode($scope.optionSets[$scope.prStDes[dataElement].dataElement.optionSet.id].options, newValue);//$scope.optionCodesByName[ '"' + newValue + '"'];
}
}
if($scope.prStDes[dataElement].dataElement.type === 'date'){
@@ -702,15 +699,7 @@
});
});
};
-
- $scope.printForm = function(){
- var printContents = document.getElementById('printableForm').innerHTML;
- var originalContents = document.body.innerHTML;
- document.body.innerHTML = printContents;
- window.print();
- document.body.innerHTML = originalContents;
- };
-
+
$scope.showNotes = function(dhis2Event){
var modalInstance = $modal.open({
@@ -729,56 +718,28 @@
$scope.getHelpContent = function(){
};
-})
-
-//Controller for notes
-.controller('NotesController',
- function($scope,
- $modalInstance,
- dhis2Event){
-
- $scope.dhis2Event = dhis2Event;
-
- $scope.close = function () {
- $modalInstance.close();
- };
-})
-
-//Controller for the header section
-.controller('HeaderController',
- function($scope,
- DHIS2URL,
- TranslationService) {
-
- TranslationService.translate();
-
- $scope.home = function(){
- window.location = DHIS2URL;
- };
-
-})
-
-//Controller for column show/hide
-.controller('ColumnDisplayController',
- function($scope,
- $modalInstance,
- hiddenGridColumns,
- eventGridColumns){
-
- $scope.eventGridColumns = eventGridColumns;
- $scope.hiddenGridColumns = hiddenGridColumns;
-
- $scope.close = function () {
- $modalInstance.close($scope.eventGridColumns);
- };
-
- $scope.showHideColumns = function(gridColumn){
-
- if(gridColumn.show){
- $scope.hiddenGridColumns--;
- }
- else{
- $scope.hiddenGridColumns++;
- }
- };
-});
+
+ $scope.showMap = function(event){
+ var modalInstance = $modal.open({
+ templateUrl: 'views/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;
+ }
+ }
+ });
+
+ modalInstance.result.then(function (location) {
+ if(angular.isObject(location)){
+ event.coordinate.latitude = location.lat;
+ event.coordinate.longitude = location.lng;
+ }
+ }, function () {
+ });
+ };
+});
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/directives.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/directives.js 2014-10-17 14:33:27 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/directives.js 2014-11-03 10:34:14 +0000
@@ -21,13 +21,7 @@
return {
restrict: 'A',
- link: function(scope, element, attrs){
-
- dhis2.ec.store = new dhis2.storage.Store({
- name: EC_STORE_NAME,
- adapters: [dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter],
- objectStores: ['eventCapturePrograms', 'programStages', 'optionSets']
- });
+ link: function(scope, element, attrs){
//when tree has loaded, get selected orgunit - if there is any - and inform angular
$(function() {
@@ -73,7 +67,7 @@
});
//listen to user selection, and inform angular
- selection.setListenerFunction( organisationUnitSelected, true );
+ selection.setListenerFunction( organisationUnitSelected );
selection.responseReceived();
function organisationUnitSelected( orgUnits, orgUnitNames ) {
@@ -84,7 +78,7 @@
};
})
-.directive('dhisCustomForm', function($compile, $parse, CustomFormService) {
+.directive('d2CustomForm', function($compile, $parse, CustomFormService) {
return{
restrict: 'E',
link: function(scope, elm, attrs){
@@ -101,7 +95,7 @@
};
})
-.directive('dhisContextMenu', function(ContextMenuSelectedItem) {
+.directive('d2ContextMenu', function(ContextMenuSelectedItem) {
return {
restrict: 'A',
@@ -153,44 +147,6 @@
};
})
-.directive('ngDate', function($filter) {
- return {
- restrict: 'A',
- require: 'ngModel',
- link: function(scope, element, attrs, ctrl) {
- element.datepicker({
- changeYear: true,
- changeMonth: true,
- maxDate: new Date(),
- dateFormat: 'yy-mm-dd',
- onSelect: function(date) {
- ctrl.$setViewValue(date);
- $(this).change();
- scope.$apply();
- }
- })
- .change(function() {
- var rawDate = this.value;
- var convertedDate = moment(this.value, 'YYYY-MM-DD')._d;
- convertedDate = $filter('date')(convertedDate, 'yyyy-MM-dd');
-
- if(rawDate != convertedDate){
- scope.invalidDate = true;
- ctrl.$setViewValue(this.value);
- ctrl.$setValidity('foo', false);
- scope.$apply();
- }
- else{
- scope.invalidDate = false;
- ctrl.$setViewValue(this.value);
- ctrl.$setValidity('foo', true);
- scope.$apply();
- }
- });
- }
- };
-})
-
.directive('d2Date', function(DateUtils, CalendarService, storage, $parse) {
return {
restrict: 'A',
@@ -274,15 +230,6 @@
};
})
-.directive('draggableModal', function(){
- return {
- restrict: 'EA',
- link: function(scope, element) {
- element.draggable();
- }
- };
-})
-
.directive('d2PopOver', function($compile, $templateCache){
return {
restrict: 'EA',
@@ -306,6 +253,155 @@
};
})
+.directive('d2GoogleMap', function ($parse, $compile, storage) {
+ return {
+ restrict: 'E',
+ replace: true,
+ template: '<div></div>',
+ link: function(scope, element, attrs){
+
+ //remove angular bootstrap ui modal draggable
+ $(".modal-content").draggable({ disabled: true });
+
+ //get a default center
+ var latCenter = 12.31, lngCenter = 51.48;
+
+ //if there is any marker already - use it as center
+ if(angular.isObject(scope.location)){
+ if(scope.location.lat && scope.location.lng){
+ latCenter = scope.location.lat;
+ lngCenter = scope.location.lng;
+ }
+ }
+
+ //default map configurations
+ var mapOptions = {
+ zoom: 3,
+ center: new google.maps.LatLng(latCenter, lngCenter),
+ mapTypeId: google.maps.MapTypeId.ROADMAP
+ },featureStyle = {
+ strokeWeight: 2,
+ strokeOpacity: 0.4,
+ fillOpacity: 0.4,
+ fillColor: 'green'
+ };
+
+ var geojsons = $parse(attrs.geojsons)(scope);
+ var currentLayer = 0, currentGeojson = geojsons[0];
+
+ var map = new google.maps.Map(document.getElementById(attrs.id), mapOptions);
+ var currentGeojsonFeatures = map.data.addGeoJson(currentGeojson);
+
+ var marker = new google.maps.Marker({
+ map: map
+ });
+
+ if(angular.isObject(scope.location)){
+ if(scope.location.lat && scope.location.lng){
+ addMarker({lat: scope.location.lat, lng: scope.location.lng});
+ }
+ }
+
+ function addMarker(loc){
+ var latLng = new google.maps.LatLng(loc.lat, loc.lng);
+ marker.setPosition(latLng);
+ }
+
+ function centerMap(){
+
+ if(currentGeojson && currentGeojson.features){
+ var latLngBounds = new google.maps.LatLngBounds();
+ angular.forEach(currentGeojson.features, function(feature){
+ if(feature.geometry.type === 'MultiPolygon'){
+ angular.forEach(feature.geometry.coordinates[0][0], function(coordinate){
+ latLngBounds.extend(new google.maps.LatLng(coordinate[1],coordinate[0]));
+ });
+ }
+ else if(feature.geometry.type === 'Point'){
+ latLngBounds.extend(new google.maps.LatLng(feature.geometry.coordinates[1],feature.geometry.coordinates[0]));
+ }
+ });
+
+ map.fitBounds(latLngBounds);
+ map.panToBounds(latLngBounds);
+ }
+ }
+
+ function initializeMap(){
+ google.maps.event.addListenerOnce(map, 'idle', function(){
+ google.maps.event.trigger(map, 'resize');
+ map.data.setStyle(featureStyle);
+ centerMap();
+ });
+ }
+
+ map.data.addListener('mouseover', function(e) {
+ $("#polygon-label").text( e.feature.k.name );
+ map.data.revertStyle();
+ map.data.overrideStyle(e.feature, {fillOpacity: 0.8});
+ });
+
+ map.data.addListener('mouseout', function() {
+ $("#polygon-label").text( '' );
+ map.data.revertStyle();
+ });
+
+ //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]);
+ }
+
+ if(currentLayer >= geojsons.length-1){
+ currentLayer = 0;
+ currentGeojson = angular.copy(geojsons[currentLayer]);
+ }
+ else{
+ currentLayer++;
+ currentGeojson = angular.copy(geojsons[currentLayer]);
+ currentGeojson.features = [];
+ var selectedFeatures = [];
+ angular.forEach(geojsons[currentLayer].features, function(feature){
+ if(feature.properties.parent === e.feature.B){
+ selectedFeatures.push(feature);
+ }
+ });
+
+ if(selectedFeatures.length){
+ currentGeojson.features = selectedFeatures;
+ }
+ }
+ currentGeojsonFeatures = map.data.addGeoJson(currentGeojson);
+ centerMap();
+ });
+
+ //capturing coordinate from defined polygons
+ map.data.addListener('click', function(e) {
+ scope.$apply(function(){
+ addMarker({
+ lat: e.latLng.lat(),
+ lng: e.latLng.lng()
+ });
+ $parse(attrs.location).assign(scope.$parent, {lat: e.latLng.lat(), lng: e.latLng.lng()});
+ });
+ });
+
+ //capturing coordinate from anywhere in the map - incase no polygons are defined
+ google.maps.event.addListener(map, 'click', function(e){
+ scope.$apply(function(){
+ addMarker({
+ lat: e.latLng.lat(),
+ lng: e.latLng.lng()
+ });
+ $parse(attrs.location).assign(scope.$parent, {lat: e.latLng.lat(), lng: e.latLng.lng()});
+ });
+ });
+
+ initializeMap();
+ }
+ };
+})
+
.directive('serversidePaginator', function factory() {
return {
restrict: 'E',
=== 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 2014-10-22 11:43:51 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js 2014-11-03 10:34:14 +0000
@@ -7,7 +7,7 @@
// Instance of the StorageManager
dhis2.ec.storageManager = new StorageManager();
-var EC_STORE_NAME = "dhis2";
+var EC_STORE_NAME = "dhis2ec";
var i18n_no_orgunits = 'No organisation unit attached to current user, no data entry possible';
var i18n_offline_notification = 'You are offline, data will be stored locally';
var i18n_online_notification = 'You are online';
@@ -21,11 +21,10 @@
var EVENT_VALUES = 'EVENT_VALUES';
-dhis2.ec.store = new dhis2.storage.Store({
- name: EC_STORE_NAME,
- adapters: [dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter],
- objectStores: ['eventCapturePrograms', 'programStages', 'optionSets']
-});
+//var ecDAO = {};
+
+dhis2.ec.store = null;
+dhis2.ec.memoryOnly = $('html').hasClass('ie7') || $('html').hasClass('ie8');
(function($) {
$.safeEach = function(arr, fn)
@@ -54,26 +53,11 @@
$('#loaderSpan').show();
$('#orgUnitTree').one('ouwtLoaded', function()
- {
- var def = $.Deferred();
- var promise = def.promise();
-
- promise = promise.then( dhis2.ec.store.open );
- promise = promise.then( getUserProfile );
- promise = promise.then( getCalendarSetting );
- promise = promise.then( getLoginDetails );
- promise = promise.then( getMetaPrograms );
- promise = promise.then( getPrograms );
- promise = promise.then( getProgramStages );
- promise = promise.then( getOptionSets );
- promise.done( function() {
- selection.responseReceived();
- });
-
- def.resolve();
+ {
+ downloadMetaData();
});
-
+
$(document).bind('dhis2.online', function(event, loggedIn)
{
if (loggedIn)
@@ -151,6 +135,56 @@
});
}
+function downloadMetaData(){
+ var adapters = [];
+ if( dhis2.ec.memoryOnly ) {
+ adapters = [ dhis2.storage.InMemoryAdapter ];
+ } else {
+ adapters = [ dhis2.storage.IndexedDBAdapter, dhis2.storage.DomLocalStorageAdapter, dhis2.storage.InMemoryAdapter ];
+ }
+
+
+ dhis2.ec.store = new dhis2.storage.Store({
+ name: EC_STORE_NAME,
+ objectStores: [
+ {
+ name: 'ecPrograms',
+ adapters: adapters
+ },
+ {
+ name: 'programStages',
+ adapters: adapters
+ },
+ {
+ name: 'geoJsons',
+ adapters: adapters
+ },
+ {
+ name: 'optionSets',
+ adapters: adapters
+ }
+ ]
+ });
+
+ var def = $.Deferred();
+ var promise = def.promise();
+
+ promise = promise.then( dhis2.ec.store.open );
+ promise = promise.then( getUserProfile );
+ promise = promise.then( getCalendarSetting );
+ promise = promise.then( getLoginDetails );
+ promise = promise.then( getOrgUnitLevels );
+ promise = promise.then( getGeoJsonsByLevel );
+ promise = promise.then( getMetaPrograms );
+ promise = promise.then( getPrograms );
+ promise = promise.then( getProgramStages );
+ promise = promise.then( getOptionSets );
+ promise.done( function() {
+ selection.responseReceived();
+ });
+
+ def.resolve();
+}
function getUserProfile()
{
@@ -197,6 +231,89 @@
return def.promise();
}
+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;
+ });
+ }
+ def.resolve( ouLevels );
+ });
+
+ 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();
+ } );
+ });
+
+ builder.resolve();
+
+ return mainPromise;
+}
+
+function getGeoJson( level )
+{
+ return function() {
+ return $.ajax( {
+ url: '../api/organisationUnits.geojson',
+ type: 'GET',
+ data: 'level=' + level
+ }).done( function( response ){
+
+ var geojson = {};
+ geojson = response;
+ geojson.id = level;
+ dhis2.ec.store.set( 'geoJsons', geojson );
+ });
+ };
+}
+
function getMetaPrograms()
{
var def = $.Deferred();
@@ -208,15 +325,7 @@
}).done( function(response) {
var programs = [];
_.each( _.values( response.programs ), function ( program ) {
- programs.push(program);
- /*if( program.programStages &&
- program.programStages.length &&
- program.programStages[0].programStageDataElements &&
- program.programStages[0].programStageDataElements.length ) {
-
- programs.push(program);
- } */
-
+ programs.push(program);
});
def.resolve( programs );
@@ -244,7 +353,7 @@
build = build.then(function() {
var d = $.Deferred();
var p = d.promise();
- dhis2.ec.store.get('eventCapturePrograms', program.id).done(function(obj) {
+ dhis2.ec.store.get('ecPrograms', program.id).done(function(obj) {
if(!obj || obj.version !== program.version) {
promise = promise.then( getProgram( program.id ) );
}
@@ -293,7 +402,7 @@
program.userRoles = ur;
- dhis2.ec.store.set( 'eventCapturePrograms', program );
+ dhis2.ec.store.set( 'ecPrograms', program );
});
});
=== 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 2014-10-22 11:43:51 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js 2014-11-03 10:34:14 +0000
@@ -7,9 +7,9 @@
.factory('StorageService', function(){
var store = new dhis2.storage.Store({
- name: 'dhis2',
+ name: 'dhis2ec',
adapters: [dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter],
- objectStores: ['eventCapturePrograms', 'programStages', 'optionSets']
+ objectStores: ['ecPrograms', 'programStages', 'geoJsons', 'optionSets']
});
return{
currentStore: store
@@ -84,8 +84,60 @@
})
+/* factory for fetching selected orgunit's coordinate */
+.factory('OrgUnitService', function($http) {
+
+ var orgUnitId, promise;
+ return {
+ get: function(id) {
+ if( !promise && id !== orgUnitId){
+ promise = $http.get('../api/me/profile').then(function(response){
+ orgUnitId = id;
+ return response.data;;
+ });
+ }
+ return promise;
+ }
+ };
+})
+
+
+/* Factory to fetch geojsons */
+.factory('GeoJsonFactory', function($q, $rootScope, StorageService) {
+ return {
+ getAll: function(){
+
+ //console.log('I am trying to fetch geojsons');
+ var def = $q.defer();
+
+ StorageService.currentStore.open().done(function(){
+ StorageService.currentStore.getAll('geoJsons').done(function(geoJsons){
+ $rootScope.$apply(function(){
+ def.resolve(geoJsons);
+ });
+ });
+ });
+
+ return def.promise;
+ },
+ get: function(level){
+
+ var def = $q.defer();
+
+ StorageService.currentStore.open().done(function(){
+ StorageService.currentStore.get('geoJsons', level).done(function(geoJson){
+ $rootScope.$apply(function(){
+ def.resolve(geoJson);
+ });
+ });
+ });
+ return def.promise;
+ }
+ };
+})
+
/* Factory to fetch optioSets */
-.factory('OptionSetFactory', function($q, $rootScope, StorageService) {
+.factory('OptionSetService', function($q, $rootScope, StorageService) {
return {
getAll: function(){
@@ -113,18 +165,29 @@
});
});
return def.promise;
+ },
+ getNameOrCode: function(options, key){
+ var val = key;
+
+ if(options){
+ for(var i=0; i<options.length; i++){
+ if( key === options[i].name){
+ val = options[i].code;
+ break;
+ }
+ if( key === options[i].code){
+ val = options[i].name;
+ break;
+ }
+ }
+ }
+ return val;
}
};
})
/* Factory to fetch programs */
.factory('ProgramFactory', function($q, $rootScope, StorageService) {
-
- /*dhis2.ec.store = new dhis2.storage.Store({
- name: EC_STORE_NAME,
- adapters: [dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter],
- objectStores: ['eventCapturePrograms', 'programStages', 'optionSets']
- });*/
return {
@@ -133,7 +196,7 @@
var def = $q.defer();
StorageService.currentStore.open().done(function(){
- StorageService.currentStore.getAll('eventCapturePrograms').done(function(programs){
+ StorageService.currentStore.getAll('ecPrograms').done(function(programs){
$rootScope.$apply(function(){
def.resolve(programs);
});
@@ -146,12 +209,6 @@
/* Factory to fetch programStages */
.factory('ProgramStageFactory', function($q, $rootScope, StorageService) {
-
- /*dhis2.ec.store = new dhis2.storage.Store({
- name: EC_STORE_NAME,
- adapters: [dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter],
- objectStores: ['eventCapturePrograms', 'programStages', 'optionSets']
- });*/
return {
get: function(uid){
@@ -160,16 +217,6 @@
StorageService.currentStore.open().done(function(){
StorageService.currentStore.get('programStages', uid).done(function(pst){
- /*angular.forEach(pst.programStageDataElements, function(pstDe){
- if(pstDe.dataElement.optionSet){
- dhis2.ec.store.get('optionSets', pstDe.dataElement.optionSet.id).done(function(optionSet){
- pstDe.dataElement.optionSet = optionSet;
- });
- }
- $rootScope.$apply(function(){
- def.resolve(pst);
- });
- });*/
$rootScope.$apply(function(){
def.resolve(pst);
});
=== 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-08-21 16:30:01 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css 2014-11-03 10:34:14 +0000
@@ -45,6 +45,11 @@
margin-top: 1em;
}
+.container-1-2 {
+ width: 50%;
+ float: left;
+}
+
div.paging a.active
{
text-decoration: none;
@@ -197,6 +202,9 @@
display:none;
}
+.pull-center {
+ text-align: center;
+}
.filter-with-content {
float: right !important;
color: red;
@@ -215,6 +223,39 @@
width: 130px;
}
+.coordinate-container{
+ width: 50%;
+ float: left;
+}
+
+.modal-full-window .modal-dialog {
+ width: 99%;
+ height: 99%;
+}
+
+#map-container {
+ height: 800px;
+ width: 100%;
+}
+
+#polygon-label {
+ background-color: #000000;
+ color: #fff;
+ font-size: 12px;
+}
+
+.contextmenu{
+ visibility:hidden;
+ background:#ffffff;
+ border:1px solid #8888FF;
+ z-index: 10;
+ position: relative;
+ width: 140px;
+}
+.contextmenu div{
+ padding-left: 5px
+}
+
/*----------------------------------------------------------------------------*/
/* Bootstrap modal and panel style
/*----------------------------------------------------------------------------*/
@@ -251,7 +292,7 @@
position: relative;
z-index: 1050;
width: auto;
- padding: 10px;
+ padding: 5px;
margin-right: auto;
margin-left: auto
}
@@ -285,7 +326,7 @@
}
.modal-header {
min-height: 16.428571429px;
- padding: 0 15px;
+ padding: 0 5px;
border-bottom: 1px solid #e5e5e5
}
.modal-header .close {
@@ -297,10 +338,10 @@
}
.modal-body {
position: relative;
- margin: 10px;
+ margin: 5px;
}
.modal-footer {
- padding: 19px 20px 20px;
+ padding: 10px;
text-align: right;
border-top: 1px solid #e5e5e5
}
@@ -531,209 +572,209 @@
}
.panel {
- margin-bottom: 20px;
- background-color: #fff;
- border: 1px solid transparent;
- border-radius: 4px;
- -webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.05);
- box-shadow: 0 1px 1px rgba(0,0,0,0.05)
+ margin-bottom: 20px;
+ background-color: #fff;
+ border: 1px solid transparent;
+ border-radius: 4px;
+ -webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.05);
+ box-shadow: 0 1px 1px rgba(0,0,0,0.05)
}
.panel-body {
- padding: 0;
-}
-.panel-body:before, .panel-body:after {
- display: table;
- content: " "
-}
-.panel-body:after {
- clear: both
-}
-.panel-body:before, .panel-body:after {
- display: table;
- content: " "
-}
-.panel-body:after {
- clear: both
+ padding: 0;
+}
+.panel-body:before, .panel-body:after {
+ display: table;
+ content: " "
+}
+.panel-body:after {
+ clear: both
+}
+.panel-body:before, .panel-body:after {
+ display: table;
+ content: " "
+}
+.panel-body:after {
+ clear: both
}
.panel > .list-group {
- margin-bottom: 0
+ margin-bottom: 0
}
.panel > .list-group .list-group-item {
- border-width: 1px 0
+ border-width: 1px 0
}
.panel > .list-group .list-group-item:first-child {
- border-top-right-radius: 0;
- border-top-left-radius: 0
+ border-top-right-radius: 0;
+ border-top-left-radius: 0
}
.panel > .list-group .list-group-item:last-child {
- border-bottom: 0
+ border-bottom: 0
}
.panel-heading+ .list-group .list-group-item:first-child {
- border-top-width: 0
+ border-top-width: 0
}
.panel > .table, .panel > .table-responsive {
- margin-bottom: 0
+ margin-bottom: 0
}
.panel > .panel-body+ .table, .panel > .panel-body+ .table-responsive {
- border-top: 1px solid #ddd
+ border-top: 1px solid #ddd
}
.panel > .table-bordered, .panel > .table-responsive > .table-bordered {
- border: 0
+ border: 0
}
.panel > .table-bordered > thead > tr > th:first-child, .panel > .table-responsive > .table-bordered > thead > tr > th:first-child, .panel > .table-bordered > tbody > tr > th:first-child, .panel > .table-responsive > .table-bordered > tbody > tr > th:first-child, .panel > .table-bordered > tfoot > tr > th:first-child, .panel > .table-responsive > .table-bordered > tfoot > tr > th:first-child, .panel > .table-bordered > thead > tr > td:first-child, .panel > .table-responsive > .table-bordered > thead > tr > td:first-child, .panel > .table-bordered > tbody > tr > td:first-child, .panel > .table-responsive > .table-bordered > tbody > tr > td:first-child, .panel > .table-bordered > tfoot > tr > td:first-child, .panel > .table-responsive > .table-bordered > tfoot > tr > td:first-child {
- border-left: 0
+ border-left: 0
}
.panel > .table-bordered > thead > tr > th:last-child, .panel > .table-responsive > .table-bordered > thead > tr > th:last-child, .panel > .table-bordered > tbody > tr > th:last-child, .panel > .table-responsive > .table-bordered > tbody > tr > th:last-child, .panel > .table-bordered > tfoot > tr > th:last-child, .panel > .table-responsive > .table-bordered > tfoot > tr > th:last-child, .panel > .table-bordered > thead > tr > td:last-child, .panel > .table-responsive > .table-bordered > thead > tr > td:last-child, .panel > .table-bordered > tbody > tr > td:last-child, .panel > .table-responsive > .table-bordered > tbody > tr > td:last-child, .panel > .table-bordered > tfoot > tr > td:last-child, .panel > .table-responsive > .table-bordered > tfoot > tr > td:last-child {
- border-right: 0
+ border-right: 0
}
.panel > .table-bordered > thead > tr:last-child > th, .panel > .table-responsive > .table-bordered > thead > tr:last-child > th, .panel > .table-bordered > tbody > tr:last-child > th, .panel > .table-responsive > .table-bordered > tbody > tr:last-child > th, .panel > .table-bordered > tfoot > tr:last-child > th, .panel > .table-responsive > .table-bordered > tfoot > tr:last-child > th, .panel > .table-bordered > thead > tr:last-child > td, .panel > .table-responsive > .table-bordered > thead > tr:last-child > td, .panel > .table-bordered > tbody > tr:last-child > td, .panel > .table-responsive > .table-bordered > tbody > tr:last-child > td, .panel > .table-bordered > tfoot > tr:last-child > td, .panel > .table-responsive > .table-bordered > tfoot > tr:last-child > td {
- border-bottom: 0
+ border-bottom: 0
}
.panel-heading {
- padding: 5px;
- border-bottom: 1px solid transparent;
- border-top-right-radius: 3px;
- border-top-left-radius: 3px
+ padding: 5px;
+ border-bottom: 1px solid transparent;
+ border-top-right-radius: 3px;
+ border-top-left-radius: 3px
}
.panel-heading > .dropdown .dropdown-toggle {
- color: inherit
+ color: inherit
}
.panel-title {
- margin-top: 0;
- margin-bottom: 0;
- font-size: 16px
+ margin-top: 0;
+ margin-bottom: 0;
+ font-size: 16px
}
.panel-title > a {
- color: inherit
+ color: inherit
}
.panel-footer {
- padding: 10px 15px;
- background-color: #f5f5f5;
- border-top: 1px solid #ddd;
- border-bottom-right-radius: 3px;
- border-bottom-left-radius: 3px
+ padding: 10px 15px;
+ background-color: #f5f5f5;
+ border-top: 1px solid #ddd;
+ border-bottom-right-radius: 3px;
+ border-bottom-left-radius: 3px
}
.panel-group .panel {
- margin-bottom: 0;
- overflow: hidden;
- border-radius: 4px
+ margin-bottom: 0;
+ overflow: hidden;
+ border-radius: 4px
}
.panel-group .panel+ .panel {
- margin-top: 5px
+ margin-top: 5px
}
.panel-group .panel-heading {
- border-bottom: 0
+ border-bottom: 0
}
.panel-group .panel-heading+ .panel-collapse .panel-body {
- border-top: 1px solid #ddd
+ border-top: 1px solid #ddd
}
.panel-group .panel-footer {
- border-top: 0
+ border-top: 0
}
.panel-group .panel-footer+ .panel-collapse .panel-body {
- border-bottom: 1px solid #ddd
+ border-bottom: 1px solid #ddd
}
.panel-default {
- border-color: #ddd
+ border-color: #ddd
}
.panel-default > .panel-heading {
- color: #333;
- background-color: #f5f5f5;
- border-color: #ddd
+ color: #333;
+ background-color: #f5f5f5;
+ border-color: #ddd
}
.panel-default > .panel-heading+ .panel-collapse .panel-body {
- border-top-color: #ddd
+ border-top-color: #ddd
}
.panel-default > .panel-heading > .dropdown .caret {
- border-color: #333 transparent
+ border-color: #333 transparent
}
.panel-default > .panel-footer+ .panel-collapse .panel-body {
- border-bottom-color: #ddd
+ border-bottom-color: #ddd
}
.panel-primary {
- border-color: #428bca
+ border-color: #428bca
}
.panel-primary > .panel-heading {
- color: #fff;
- background-color: #428bca;
- border-color: #428bca
+ color: #fff;
+ background-color: #428bca;
+ border-color: #428bca
}
.panel-primary > .panel-heading+ .panel-collapse .panel-body {
- border-top-color: #428bca
+ border-top-color: #428bca
}
.panel-primary > .panel-heading > .dropdown .caret {
- border-color: #fff transparent
+ border-color: #fff transparent
}
.panel-primary > .panel-footer+ .panel-collapse .panel-body {
- border-bottom-color: #428bca
+ border-bottom-color: #428bca
}
.panel-success {
- border-color: #d6e9c6
+ border-color: #d6e9c6
}
.panel-success > .panel-heading {
- color: #468847;
- background-color: #dff0d8;
- border-color: #d6e9c6
+ color: #468847;
+ background-color: #dff0d8;
+ border-color: #d6e9c6
}
.panel-success > .panel-heading+ .panel-collapse .panel-body {
- border-top-color: #d6e9c6
+ border-top-color: #d6e9c6
}
.panel-success > .panel-heading > .dropdown .caret {
- border-color: #468847 transparent
+ border-color: #468847 transparent
}
.panel-success > .panel-footer+ .panel-collapse .panel-body {
- border-bottom-color: #d6e9c6
+ border-bottom-color: #d6e9c6
}
.panel-warning {
- border-color: #faebcc
+ border-color: #faebcc
}
.panel-warning > .panel-heading {
- color: #c09853;
- background-color: #fcf8e3;
- border-color: #faebcc
+ color: #c09853;
+ background-color: #fcf8e3;
+ border-color: #faebcc
}
.panel-warning > .panel-heading+ .panel-collapse .panel-body {
- border-top-color: #faebcc
+ border-top-color: #faebcc
}
.panel-warning > .panel-heading > .dropdown .caret {
- border-color: #c09853 transparent
+ border-color: #c09853 transparent
}
.panel-warning > .panel-footer+ .panel-collapse .panel-body {
- border-bottom-color: #faebcc
+ border-bottom-color: #faebcc
}
.panel-danger {
- border-color: #ebccd1
+ border-color: #ebccd1
}
.panel-danger > .panel-heading {
- color: #b94a48;
- background-color: #f2dede;
- border-color: #ebccd1
+ color: #b94a48;
+ background-color: #f2dede;
+ border-color: #ebccd1
}
.panel-danger > .panel-heading+ .panel-collapse .panel-body {
- border-top-color: #ebccd1
+ border-top-color: #ebccd1
}
.panel-danger > .panel-heading > .dropdown .caret {
- border-color: #b94a48 transparent
+ border-color: #b94a48 transparent
}
.panel-danger > .panel-footer+ .panel-collapse .panel-body {
- border-bottom-color: #ebccd1
+ border-bottom-color: #ebccd1
}
.panel-info {
- border-color: #bce8f1
+ border-color: #bce8f1
}
.panel-info > .panel-heading {
- color: #3a87ad;
- background-color: #d9edf7;
- border-color: #bce8f1
+ color: #3a87ad;
+ background-color: #d9edf7;
+ border-color: #bce8f1
}
.panel-info > .panel-heading+ .panel-collapse .panel-body {
- border-top-color: #bce8f1
+ border-top-color: #bce8f1
}
.panel-info > .panel-heading > .dropdown .caret {
- border-color: #3a87ad transparent
+ border-color: #3a87ad transparent
}
.panel-info > .panel-footer+ .panel-collapse .panel-body {
- border-bottom-color: #bce8f1
+ border-bottom-color: #bce8f1
}
.dropdown {
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/customForm.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/customForm.html 2014-10-17 14:33:27 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/customForm.html 2014-11-03 10:34:14 +0000
@@ -26,36 +26,38 @@
</tr>
<tr ng-if="selectedProgramStage.captureCoordinates">
<td>
- {{'latitude'| translate}}
+ {{'lat_lng' | translate}}
</td>
<td>
- <input type="number"
- ng-model="currentEvent.coordinate.latitude"
+ <span class="coordinate-container">
+ <input type="number"
+ ng-model="currentEvent.coordinate.latitude"
+ placeholder="{{'latitude' | translate}}"
name="latitude"
min="-90"
max="90"
ng-required="false"
- style="width:99%;"/>
- <span ng-show="outerForm.submitted && outerForm.latitude.$invalid" class="required">{{'number_required'| translate}} [-90 ... 90]</span>
- </td>
- </tr>
- <tr ng-if="selectedProgramStage.captureCoordinates">
- <td>
- {{'longitude'| translate}}
- </td>
- <td>
- <input type="number"
+ style="width:100%;"/>
+ <span ng-show="outerForm.submitted && outerForm.latitude.$invalid" class="required">{{'number_required'| translate}} [-90 ... 90]</span>
+ </span>
+ <span class="coordinate-container">
+ <input type="number"
ng-model="currentEvent.coordinate.longitude"
+ placeholder="{{'longitude' | translate}}"
name="longitude"
min="-180"
max="180"
ng-required="false"
- style="width:99%;"/>
- <span ng-show="outerForm.submitted && outerForm.longitude.$invalid" class="required">{{'number_required'| translate}}[-180 ... 180]</span>
- </td>
+ style="width:100%;"/>
+ <span ng-show="outerForm.submitted && outerForm.longitude.$invalid" class="required">{{'number_required'| translate}}[-180 ... 180]</span>
+ </span>
+ <!--<span class='pull-right'>
+ <a href ng-click="showMap(currentEvent)" title="{{'get_from_map'| translate}}"><i class="fa fa-map-marker fa-2x"></i></a>
+ </span>-->
+ </td>
</tr>
</table>
-<dhis-custom-form custom-form-type="PROGRAM_STAGE" custom-form-object="selectedProgramStage"></dhis-custom-form>
+<d2-custom-form custom-form-type="PROGRAM_STAGE" custom-form-object="selectedProgramStage"></d2-custom-form>
<div class="clear">
<hr>
<h4>
=== 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 2014-10-21 07:53:37 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html 2014-11-03 10:34:14 +0000
@@ -38,34 +38,36 @@
</tr>
<tr ng-if="selectedProgramStage.captureCoordinates">
<td>
- {{'latitude'| translate}}
+ {{'lat_lng' | translate}}
</td>
<td>
- <input type="number"
- ng-model="currentEvent.coordinate.latitude"
+ <span class="coordinate-container">
+ <input type="number"
+ ng-model="currentEvent.coordinate.latitude"
+ placeholder="{{'latitude' | translate}}"
name="latitude"
min="-90"
max="90"
ng-required="false"
- style="width:99%;"/>
- <span ng-show="outerForm.submitted && outerForm.latitude.$invalid" class="required">{{'number_required'| translate}} [-90 ... 90]</span>
- </td>
- </tr>
- <tr ng-if="selectedProgramStage.captureCoordinates">
- <td>
- {{'longitude'| translate}}
- </td>
- <td>
- <input type="number"
+ style="width:100%;"/>
+ <span ng-show="outerForm.submitted && outerForm.latitude.$invalid" class="required">{{'number_required'| translate}} [-90 ... 90]</span>
+ </span>
+ <span class="coordinate-container">
+ <input type="number"
ng-model="currentEvent.coordinate.longitude"
+ placeholder="{{'longitude' | translate}}"
name="longitude"
min="-180"
max="180"
ng-required="false"
- style="width:99%;"/>
- <span ng-show="outerForm.submitted && outerForm.longitude.$invalid" class="required">{{'number_required'| translate}}[-180 ... 180]</span>
- </td>
- </tr>
+ style="width:100%;"/>
+ <span ng-show="outerForm.submitted && outerForm.longitude.$invalid" class="required">{{'number_required'| translate}}[-180 ... 180]</span>
+ </span>
+ <!--<span class='pull-right'>
+ <a href ng-click="showMap(currentEvent)" title="{{'get_from_map'| translate}}"><i class="fa fa-map-marker fa-2x"></i></a>
+ </span>-->
+ </td>
+ </tr>
<tr ng-repeat="eventGridColumn in eventGridColumns" ng-if="eventGridColumn.id !== 'comment' && eventGridColumn.id !== 'uid' && eventGridColumn.id !== 'event_date'">
<td >
{{eventGridColumn.name}}
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html 2014-10-17 14:33:27 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html 2014-11-03 10:34:14 +0000
@@ -98,7 +98,7 @@
<tr ng-repeat="dhis2Event in dhis2Events | orderBy:sortHeader:reverse | gridFilter:filterText:filterTypes">
<!-- Visible when event is not under editing -->
- <td dhis-context-menu
+ <td d2-context-menu
selected-item={{dhis2Event}}
ng-click="showEventList()"
ng-hide="(currentEvent.event == dhis2Event.event) || !eventGridColumn.show || eventGridColumn.id === 'comment'"
=== 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 2014-10-22 14:22:06 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2014-11-03 10:34:14 +0000
@@ -8,7 +8,7 @@
storage,
TEIService,
TEService,
- OptionSetFactory,
+ OptionSetService,
ProgramFactory,
CurrentSelection,
TranslationService) {
@@ -68,7 +68,7 @@
});
$scope.optionSets = {optionSets: [], optionNamesByCode: new Object(), optionCodesByName: new Object()};
- OptionSetFactory.getAll().then(function(optionSets){
+ OptionSetService.getAll().then(function(optionSets){
angular.forEach(optionSets, function(optionSet){
angular.forEach(optionSet.options, function(option){
if(option.name && option.code){
=== 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 2014-10-20 16:24:09 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html 2014-11-03 10:34:14 +0000
@@ -88,7 +88,7 @@
<script type="text/javascript" src="scripts/header-controller.js"></script>
<script type="text/javascript" src="scripts/leftbar-menu-controller.js"></script>
<script type="text/javascript" src="scripts/report-types-controller.js"></script>
- <script type="text/javascript" src="scripts/tracker-capture.js"></script>
+ <!--<script type="text/javascript" src="scripts/tracker-capture.js"></script>-->
<script type="text/javascript" src="scripts/ng-csv.js"></script>
<script type="text/javascript" src="components/dashboard/dashboard-controller.js"></script>
<script type="text/javascript" src="components/dashboard/dashboard-widgets-controller.js"></script>
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-10-23 14:40:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-11-03 10:34:14 +0000
@@ -11,7 +11,7 @@
Paginator,
TranslationService,
storage,
- OptionSetFactory,
+ OptionSetService,
OperatorFactory,
ProgramFactory,
AttributesFactory,
@@ -62,7 +62,7 @@
if(!$scope.optionSets){
$scope.optionSets = {optionSets: [], optionNamesByCode: new Object(), optionCodesByName: new Object()};
- OptionSetFactory.getAll().then(function(optionSets){
+ OptionSetService.getAll().then(function(optionSets){
angular.forEach(optionSets, function(optionSet){
angular.forEach(optionSet.options, function(option){
if(option.name && option.code){
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-10-23 16:54:30 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-11-03 10:34:14 +0000
@@ -7,9 +7,9 @@
.factory('StorageService', function(){
var store = new dhis2.storage.Store({
- name: "dhis2",
+ name: "dhis2tc",
adapters: [dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter],
- objectStores: ['trackerCapturePrograms', 'programStages', 'trackedEntities', 'trackedEntityForms', 'attributes','optionSets']
+ objectStores: ['tcPrograms', 'programStages', 'trackedEntities', 'trackedEntityForms', 'attributes','optionSets']
});
return{
currentStore: store
@@ -17,7 +17,7 @@
})
/* Factory to fetch optioSets */
-.factory('OptionSetFactory', function($q, $rootScope, StorageService) {
+.factory('OptionSetService', function($q, $rootScope, StorageService) {
return {
getAll: function(){
@@ -107,7 +107,7 @@
var def = $q.defer();
StorageService.currentStore.open().done(function(){
- StorageService.currentStore.getAll('trackerCapturePrograms').done(function(programs){
+ StorageService.currentStore.getAll('tcPrograms').done(function(programs){
$rootScope.$apply(function(){
def.resolve(programs);
});
@@ -121,7 +121,7 @@
var def = $q.defer();
StorageService.currentStore.open().done(function(){
- StorageService.currentStore.get('trackerCapturePrograms', uid).done(function(pr){
+ StorageService.currentStore.get('tcPrograms', uid).done(function(pr){
$rootScope.$apply(function(){
def.resolve(pr);
});
@@ -1230,8 +1230,8 @@
var columns = attributes ? angular.copy(attributes) : [];
//also add extra columns which are not part of attributes (orgunit for example)
- columns.push({id: 'orgUnitName', name: $translate('registering_unit'), type: 'string', displayInListNoProgram: false});
- columns.push({id: 'created', name: $translate('registration_date'), type: 'date', displayInListNoProgram: false});
+ columns.push({id: 'orgUnitName', name: $translate('registering_unit'), valueType: 'string', displayInListNoProgram: false});
+ columns.push({id: 'created', name: $translate('registration_date'), valueType: 'date', displayInListNoProgram: false});
//generate grid column for the selected program/attributes
angular.forEach(columns, function(column){
@@ -1467,4 +1467,4 @@
return dhis2CalendarFormat;
}
};
-});
\ No newline at end of file
+});
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js 2014-10-23 14:40:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js 2014-11-03 10:34:14 +0000
@@ -6,7 +6,7 @@
// Instance of the StorageManager
dhis2.tc.storageManager = new StorageManager();
-var TC_STORE_NAME = "dhis2";
+var TC_STORE_NAME = "dhis2tc";
var i18n_no_orgunits = 'No organisation unit attached to current user, no data entry possible';
var i18n_offline_notification = 'You are offline, data will be stored locally';
var i18n_online_notification = 'You are online';
@@ -22,11 +22,8 @@
var optionSetsInPromise = [];
-dhis2.tc.store = new dhis2.storage.Store({
- name: TC_STORE_NAME,
- adapters: [dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter],
- objectStores: ['trackerCapturePrograms', 'programStages', 'trackedEntities', 'trackedEntityForms', 'attributes', 'relationshipTypes', 'optionSets']
-});
+dhis2.tc.store = null;
+dhis2.tc.memoryOnly = $('html').hasClass('ie7') || $('html').hasClass('ie8');
(function($) {
$.safeEach = function(arr, fn)
@@ -55,28 +52,7 @@
$('#orgUnitTree').one('ouwtLoaded', function()
{
- var def = $.Deferred();
- var promise = def.promise();
-
- promise = promise.then( dhis2.tc.store.open );
- promise = promise.then( getUserProfile );
- promise = promise.then( getCalendarSetting );
- promise = promise.then( getLoginDetails );
- promise = promise.then( getRelationships );
- promise = promise.then( getAttributes );
- promise = promise.then( getOptionSetsForAttributes );
- promise = promise.then( getTrackedEntities );
- promise = promise.then( getMetaPrograms );
- promise = promise.then( getPrograms );
- promise = promise.then( getProgramStages );
- promise = promise.then( getOptionSetsForPrograms );
- promise = promise.then( getMetaTrackedEntityForms );
- promise = promise.then( getTrackedEntityForms );
- promise.done(function() {
- selection.responseReceived();
- });
-
- def.resolve();
+ loadMetaData();
});
@@ -185,6 +161,80 @@
});
}
+function loadMetaData()
+{
+ /*dhis2.tc.store = new dhis2.storage.Store({
+ name: TC_STORE_NAME,
+ adapters: [dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter],
+ objectStores: ['tcPrograms', 'programStages', 'trackedEntities', 'trackedEntityForms', 'attributes', 'relationshipTypes', 'optionSets']
+ });*/
+
+ var adapters = [];
+ if( dhis2.tc.memoryOnly ) {
+ adapters = [ dhis2.storage.InMemoryAdapter ];
+ } else {
+ adapters = [ dhis2.storage.IndexedDBAdapter, dhis2.storage.DomLocalStorageAdapter, dhis2.storage.InMemoryAdapter ];
+ }
+
+ dhis2.tc.store = new dhis2.storage.Store({
+ name: TC_STORE_NAME,
+ objectStores: [
+ {
+ name: 'tcPrograms',
+ adapters: adapters
+ },
+ {
+ name: 'programStages',
+ adapters: adapters
+ },
+ {
+ name: 'trackedEntities',
+ adapters: adapters
+ },
+ {
+ name: 'trackedEntityForms',
+ adapters: adapters
+ },
+ {
+ name: 'attributes',
+ adapters: adapters
+ },
+ {
+ name: 'relationshipTypes',
+ adapters: adapters
+ },
+ {
+ name: 'optionSets',
+ adapters: adapters
+ }
+ ]
+ });
+
+
+ var def = $.Deferred();
+ var promise = def.promise();
+
+ promise = promise.then( dhis2.tc.store.open );
+ promise = promise.then( getUserProfile );
+ promise = promise.then( getCalendarSetting );
+ promise = promise.then( getLoginDetails );
+ promise = promise.then( getRelationships );
+ promise = promise.then( getAttributes );
+ promise = promise.then( getOptionSetsForAttributes );
+ promise = promise.then( getTrackedEntities );
+ promise = promise.then( getMetaPrograms );
+ promise = promise.then( getPrograms );
+ promise = promise.then( getProgramStages );
+ promise = promise.then( getOptionSetsForPrograms );
+ promise = promise.then( getMetaTrackedEntityForms );
+ promise = promise.then( getTrackedEntityForms );
+ promise.done(function() {
+ selection.responseReceived();
+ });
+
+ def.resolve();
+}
+
function getUserProfile()
{
var def = $.Deferred();
@@ -369,7 +419,7 @@
build = build.then(function() {
var d = $.Deferred();
var p = d.promise();
- dhis2.tc.store.get('trackerCapturePrograms', program.id).done(function(obj) {
+ dhis2.tc.store.get('tcPrograms', program.id).done(function(obj) {
if(!obj || obj.version !== program.version) {
promise = promise.then( getProgram( program.id ) );
}
@@ -419,7 +469,7 @@
program.userRoles = ur;
- dhis2.tc.store.set( 'trackerCapturePrograms', program );
+ dhis2.tc.store.set( 'tcPrograms', program );
});
});