← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17157: event capture now respects calendar and date settings

 

------------------------------------------------------------
revno: 17157
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-10-17 16:33:27 +0200
message:
  event capture now respects calendar and date settings
modified:
  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/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/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


--
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/index.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html	2014-09-23 10:48:24 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html	2014-10-17 14:33:27 +0000
@@ -1,5 +1,6 @@
 <!DOCTYPE html>
-<html manifest="event-capture.appcache" ng-app="eventCapture">
+<html ng-app="eventCapture">
+<!--<html manifest="event-capture.appcache" ng-app="eventCapture">-->
     <head>
         <title>Event Capture</title>
 
@@ -8,9 +9,23 @@
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
         
         <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.tmpl.js"></script>      
-        <link rel="stylesheet" type="text/css" href="../dhis-web-commons/javascripts/jQuery/ui/css/redmond/jquery-ui.css">    
+        <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>
+        
+        <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendars/jquery.calendars.min.js"></script>
+        <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendars/jquery.calendars.picker.min.js"></script>
+        <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendars/jquery.calendars.plus.min.js"></script>
+        <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendars/jquery.calendars.picker.ext.js"></script>
+        
+        <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendars/jquery.calendars.coptic.min.js"></script>
+        <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendars/jquery.calendars.ethiopian.min.js"></script>
+        <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendars/jquery.calendars.islamic.min.js"></script>
+        <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendars/jquery.calendars.julian.min.js"></script>
+        <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendars/jquery.calendars.nepali.min.js"></script>
+        <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/calendars/jquery.calendars.thai.min.js"></script>      
+
+        <link type="text/css" rel="stylesheet" href="../dhis-web-commons/javascripts/jQuery/ui/css/redmond/jquery-ui.css">
+        <link type="text/css" rel="stylesheet" href="../dhis-web-commons/javascripts/jQuery/calendars/css/ui-redmond.calendars.picker.css">    
         
         <script type="text/javascript" src="../dhis-web-commons/bootstrap/js/bootstrap.min.js"></script>        
                 

=== 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 13:22:28 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js	2014-10-17 14:33:27 +0000
@@ -43,9 +43,7 @@
     
     //notes
     $scope.note = {};
-    var today = moment();
-    today = Date.parse(today);
-    today = $filter('date')(today, 'yyyy-MM-dd');
+    $scope.today = DateUtils.getToday();
     
     var loginDetails = storage.get('LOGIN_DETAILS');
     var storedBy = '';
@@ -230,7 +228,7 @@
                                             if(angular.isObject($scope.prStDes[dataValue.dataElement].dataElement)){                               
 
                                                 //converting int string value to integer for proper sorting.
-                                                if($scope.prStDes[dataValue.dataElement].dataElement.type == 'int'){
+                                                if($scope.prStDes[dataValue.dataElement].dataElement.type === 'int'){
                                                     if( !isNaN(parseInt(val)) ){
                                                         val = parseInt(val);
                                                     }
@@ -238,12 +236,15 @@
                                                         val = '';
                                                     }                                        
                                                 }
-                                                if($scope.prStDes[dataValue.dataElement].dataElement.type == 'string'){
+                                                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.type == 'trueOnly'){
+                                                if($scope.prStDes[dataValue.dataElement].dataElement.type === 'date'){
+                                                    val = DateUtils.formatFromApiToUser(val);                                               
+                                                }
+                                                if( $scope.prStDes[dataValue.dataElement].dataElement.type === 'trueOnly'){
                                                     if(val == 'true'){
                                                         val = true;
                                                     }
@@ -258,7 +259,7 @@
                                     });
 
                                     $scope.dhis2Events[i]['uid'] = $scope.dhis2Events[i].event;                                
-                                    $scope.dhis2Events[i].eventDate = DateUtils.format($scope.dhis2Events[i].eventDate);                                
+                                    $scope.dhis2Events[i].eventDate = DateUtils.formatFromApiToUser($scope.dhis2Events[i].eventDate);                                
                                     $scope.dhis2Events[i]['event_date'] = $scope.dhis2Events[i].eventDate;
 
                                     delete $scope.dhis2Events[i].dataValues;
@@ -437,13 +438,17 @@
             var val = $scope.currentEvent[dataElement];
             if(val){
                 valueExists = true;            
-                if($scope.prStDes[dataElement].dataElement.type == 'string'){
+                if($scope.prStDes[dataElement].dataElement.type === 'string'){
                     if($scope.prStDes[dataElement].dataElement.optionSet){
                         if($scope.optionCodesByName[  '"' + val + '"']){
                             val = $scope.optionCodesByName[  '"' + val + '"'];
                         }
                     }
-                }            
+                }
+
+                if($scope.prStDes[dataElement].dataElement.type === 'date'){
+                    val = DateUtils.formatFromUserToApi(val);
+                }
             }
             dataValues.push({dataElement: dataElement, value: val});
         }
@@ -466,7 +471,7 @@
                 programStage: $scope.selectedProgramStage.id,
                 orgUnit: $scope.selectedOrgUnit.id,
                 status: 'ACTIVE',            
-                eventDate: $filter('date')(newEvent.eventDate, 'yyyy-MM-dd'),
+                eventDate: DateUtils.formatFromUserToApi(newEvent.eventDate),
                 dataValues: dataValues
         }; 
         
@@ -477,7 +482,7 @@
         if(!angular.isUndefined($scope.note.value) && $scope.note.value != ''){
             dhis2Event.notes = [{value: $scope.note.value}];
             
-            newEvent.notes = [{value: $scope.note.value, storedDate: today, storedBy: storedBy}];
+            newEvent.notes = [{value: $scope.note.value, storedDate: $scope.today, storedBy: storedBy}];
             
             $scope.noteExists = true;
         }
@@ -486,7 +491,7 @@
             dhis2Event.coordinate = {latitude: $scope.currentEvent.coordinate.latitude ? $scope.currentEvent.coordinate.latitude : '',
                                      longitude: $scope.currentEvent.coordinate.longitude ? $scope.currentEvent.coordinate.longitude : ''};             
         }
-
+        
         //send the new event to server
         DHIS2EventFactory.create(dhis2Event).then(function(data) {
             if (data.importSummaries[0].status === 'ERROR') {
@@ -505,7 +510,7 @@
                     $scope.dhis2Events = [];                   
                 }
                 newEvent['uid'] = newEvent.event;
-                newEvent['event_date'] = DateUtils.format(newEvent.eventDate); 
+                newEvent['event_date'] = newEvent.eventDate; 
                 $scope.dhis2Events.splice(0,0,newEvent);
                 
                 $scope.eventLength++;
@@ -548,13 +553,16 @@
         for(var dataElement in $scope.prStDes){
             var val = $scope.currentEvent[dataElement];
             
-            if(val && $scope.prStDes[dataElement].dataElement.type == 'string'){
+            if(val && $scope.prStDes[dataElement].dataElement.type === 'string'){
                 if($scope.prStDes[dataElement].dataElement.optionSet){                        
                     if($scope.optionCodesByName[  '"' + val + '"']){
                         val = $scope.optionCodesByName[  '"' + val + '"'];
                     }                                            
                 }    
             }
+            if(val && $scope.prStDes[dataElement].dataElement.type === 'date'){
+                val = DateUtils.formatFromUserToApi(val);    
+            }
             dataValues.push({dataElement: dataElement, value: val});
         }
         
@@ -563,12 +571,11 @@
                             programStage: $scope.currentEvent.programStage,
                             orgUnit: $scope.currentEvent.orgUnit,
                             status: 'ACTIVE',                                        
-                            eventDate: $scope.currentEvent.eventDate,
+                            eventDate: DateUtils.formatFromUserToApi($scope.currentEvent.eventDate),
                             event: $scope.currentEvent.event, 
                             dataValues: dataValues
                         };
 
-        updatedEvent.eventDate = DateUtils.format(updatedEvent.eventDate);
         
         if($scope.selectedProgramStage.captureCoordinates){
             updatedEvent.coordinate = {latitude: $scope.currentEvent.coordinate.latitude ? $scope.currentEvent.coordinate.latitude : '',
@@ -580,10 +587,10 @@
             updatedEvent.notes = [{value: $scope.note.value}];
             
             if($scope.currentEvent.notes){
-                $scope.currentEvent.notes.splice(0,0,{value: $scope.note.value, storedDate: today, storedBy: storedBy});
+                $scope.currentEvent.notes.splice(0,0,{value: $scope.note.value, storedDate: $scope.today, storedBy: storedBy});
             }
             else{
-                $scope.currentEvent.notes = [{value: $scope.note.value, storedDate: today, storedBy: storedBy}];
+                $scope.currentEvent.notes = [{value: $scope.note.value, storedDate: $scope.today, storedBy: storedBy}];
             }   
             
             $scope.noteExists = true;
@@ -640,6 +647,9 @@
                         newValue = $scope.optionCodesByName[  '"' + newValue + '"'];
                     }
                 }
+            }            
+            if($scope.prStDes[dataElement].dataElement.type === 'date'){
+                newValue = DateUtils.formatFromUserToApi(newValue);
             }
             
             var updatedSingleValueEvent = {event: currentEvent.event, dataValues: [{value: newValue, dataElement: dataElement}]};

=== 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 13:22:28 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/directives.js	2014-10-17 14:33:27 +0000
@@ -191,10 +191,62 @@
     };   
 })
 
+.directive('d2Date', function(DateUtils, CalendarService, storage, $parse) {
+    return {
+        restrict: 'A',
+        require: 'ngModel',        
+        link: function(scope, element, attrs, ctrl) {    
+            
+            var calendarSetting = CalendarService.getSetting();            
+            var dateFormat = 'yyyy-mm-dd';
+            if(calendarSetting.keyDateFormat === 'dd-MM-yyyy'){
+                dateFormat = 'dd-mm-yyyy';
+            }            
+            
+            var minDate = $parse(attrs.minDate)(scope), 
+                maxDate = $parse(attrs.maxDate)(scope),
+                calendar = $.calendars.instance(calendarSetting.keyCalendar);
+            
+            element.calendarsPicker({
+                changeMonth: true,
+                dateFormat: dateFormat,
+                yearRange: '-120:+30',
+                minDate: minDate,
+                maxDate: maxDate,
+                calendar: calendar, 
+                renderer: $.calendars.picker.themeRollerRenderer,
+                onSelect: function(date) {
+                    //scope.date = date;
+                    ctrl.$setViewValue(date);
+                    $(this).change();                    
+                    scope.$apply();
+                }
+            })
+            .change(function() {                
+                var rawDate = this.value;
+                var convertedDate = DateUtils.format(this.value);
+
+                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('blurOrChange', function() {
     
     return function( scope, elem, attrs) {
-        elem.datepicker({
+        elem.calendarsPicker({
             onSelect: function() {
                 scope.$apply(attrs.blurOrChange);
                 $(this).change();                                        

=== 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-01 08:08:35 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js	2014-10-17 14:33:27 +0000
@@ -60,6 +60,7 @@
         
         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 );     
@@ -166,6 +167,21 @@
     return def.promise(); 
 }
 
+function getCalendarSetting()
+{
+    var def = $.Deferred();
+
+    $.ajax({
+        url: '../api/systemSettings?key=keyCalendar&key=keyDateFormat',
+        type: 'GET'
+    }).done(function(response) {
+        localStorage['CALENDAR_SETTING'] = JSON.stringify(response);
+        def.resolve();
+    });
+
+    return def.promise();
+}
+
 function getLoginDetails()
 {
     var def = $.Deferred();
@@ -334,7 +350,7 @@
 {
     return function() {
         return $.ajax( {
-            url: '../api/programStages.json?filter=id:eq:' + id +'&fields=id,name,version,description,reportDateDescription,captureCoordinates,dataEntryForm,minDaysFromStart,repeatable,preGenerateUID,programStageSections[id,name,programStageDataElements[dataElement[id]]],programStageDataElements[displayInReports,allowProvidedElsewhere,allowDateInFuture,compulsory,dataElement[id,name,type,formName,optionSet[id]]]',
+            url: '../api/programStages.json?filter=id:eq:' + id +'&fields=id,name,version,description,reportDateDescription,captureCoordinates,dataEntryForm,minDaysFromStart,repeatable,preGenerateUID,programStageSections[id,name,programStageDataElements[dataElement[id]]],programStageDataElements[displayInReports,sortOrder,allowProvidedElsewhere,allowFutureDate,compulsory,dataElement[id,name,type,formName,optionSet[id]]]',
             type: 'GET'
         }).done( function( response ){            
             _.each( _.values( response.programStages ), function( programStage ) {                

=== 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-17 13:22:28 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js	2014-10-17 14:33:27 +0000
@@ -16,16 +16,54 @@
     };
 })
 
-.service('DateUtils', function($filter){
+.service('DateUtils', function($filter, CalendarService){
     
     return {
         format: function(dateValue) {            
+            if(!dateValue){
+                return;
+            }            
+            var calendarSetting = CalendarService.getSetting();
+            dateValue = $filter('date')(dateValue, calendarSetting.keyDateFormat);            
+            return dateValue;
+        },
+        formatToHrsMins: function(dateValue) {
+            var calendarSetting = CalendarService.getSetting();
+            var dateFormat = 'YYYY-MM-DD @ hh:mm A';
+            if(calendarSetting.keyDateFormat === 'dd-MM-yyyy'){
+                dateFormat = 'DD-MM-YYYY @ hh:mm A';
+            }            
+            return moment(dateValue).format(dateFormat);
+        },
+        getToday: function(){  
+            var calendarSetting = CalendarService.getSetting();
+            var tdy = $.calendars.instance(calendarSetting.keyCalendar).newDate();            
+            var today = moment(tdy._year + '-' + tdy._month + '-' + tdy._day, 'YYYY-MM-DD')._d;            
+            today = Date.parse(today);     
+            today = $filter('date')(today,  calendarSetting.keyDateFormat);
+            return today;
+        },
+        formatFromUserToApi: function(dateValue){            
+            if(!dateValue){
+                return;
+            }
+            var calendarSetting = CalendarService.getSetting();            
+            dateValue = moment(dateValue, calendarSetting.momentFormat)._d;
+            dateValue = Date.parse(dateValue);     
+            dateValue = $filter('date')(dateValue, 'yyyy-MM-dd'); 
+            return dateValue;            
+        },
+        formatFromApiToUser: function(dateValue){            
+            if(!dateValue){
+                return;
+            }            
+            var calendarSetting = CalendarService.getSetting();
             dateValue = moment(dateValue, 'YYYY-MM-DD')._d;
-            dateValue = Date.parse(dateValue);
-            dateValue = $filter('date')(dateValue, 'yyyy-MM-dd');
+            dateValue = Date.parse(dateValue);     
+            dateValue = $filter('date')(dateValue, calendarSetting.keyDateFormat); 
             return dateValue;
         }
-    };            
+    };
 })
 
 /* factory for loading logged in user profiles from DHIS2 */
@@ -286,6 +324,8 @@
                             attributes['name'] = deId;
                         }
                         
+                        var maxDate = programStageDataElements[deId].allowFutureDate ? '' : 0;
+                        
                         //check data element type and generate corresponding angular input field
                         if(programStageDataElements[deId].dataElement.type == "int"){
                             newInputField = '<input type="number" ' +
@@ -327,7 +367,8 @@
                             newInputField = '<input type="text" ' +
                                             this.getAttributesAsString(attributes) +
                                             ' ng-model="currentEvent.' + deId + '"' +
-                                            ' ng-date' +
+                                            ' d2-date ' +
+                                            ' max-date="' + maxDate + '"' + '\'' +
                                             ' ng-required="prStDes.' + deId + '.compulsory">';
                         }
                         if(programStageDataElements[deId].dataElement.type == "trueOnly"){
@@ -568,4 +609,30 @@
         }
     };
             
+})
+
+/* service for getting calendar setting */
+.service('CalendarService', function(storage, $rootScope){    
+
+    return {
+        getSetting: function() {
+            
+            var dhis2CalendarFormat = {keyDateFormat: 'yyyy-MM-dd', keyCalendar: 'gregorian', momentFormat: 'YYYY-MM-DD'};                
+            var storedFormat = storage.get('CALENDAR_SETTING');
+            if(angular.isObject(storedFormat) && storedFormat.keyDateFormat && storedFormat.keyCalendar){
+                if(storedFormat.keyCalendar === 'iso8601'){
+                    storedFormat.keyCalendar = 'gregorian';
+                }
+
+                if(storedFormat.keyDateFormat === 'dd-MM-yyyy'){
+                    dhis2CalendarFormat.momentFormat = 'DD-MM-YYYY';
+                }
+                
+                dhis2CalendarFormat.keyCalendar = storedFormat.keyCalendar;
+                dhis2CalendarFormat.keyDateFormat = storedFormat.keyDateFormat;
+            }
+            $rootScope.dhis2CalendarFormat = dhis2CalendarFormat;
+            return dhis2CalendarFormat;
+        }
+    };            
 });

=== 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-08-21 16:30:01 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/customForm.html	2014-10-17 14:33:27 +0000
@@ -13,8 +13,9 @@
         </td>
         <td>
             <input type="text"                                                   
-                   placeholder="yyyy-mm-dd" 
-                   ng-date 
+                   placeholder="{{dhis2CalendarFormat.keyDateFormat}}"
+                   d2-date
+                   max-date='0'
                    ng-model="currentEvent.eventDate"
                    ng-disabled="editingEventInFull"    
                    ng-required="true" 

=== 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-17 13:22:28 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html	2014-10-17 14:33:27 +0000
@@ -25,13 +25,14 @@
                 </td>
                 <td>
                     <input type="text"                                                   
-                           placeholder="yyyy-mm-dd" 
-                           ng-date 
+                           placeholder="{{dhis2CalendarFormat.keyDateFormat}}"
+                           d2-date
+                           max-date='0'
                            ng-model="currentEvent.eventDate"
                            ng-disabled="editingEventInFull"    
                            ng-required="true" 
                            name="eventDate" 
-                           style="width:99%;">
+                           style="width:99%;">{{dhis2CalendarFormat.keyDateFormat}}
                     <span ng-show="outerForm.submitted && outerForm.eventDate.$invalid" class="required">{{'required'| translate}}</span>
                 </td>
             </tr>
@@ -133,8 +134,9 @@
                             </div>
                             <div ng-switch-when="date">
                                 <input type="text"                                                                
-                                       placeholder="yyyy-mm-dd" 
-                                       ng-date 
+                                       placeholder="{{dhis2CalendarFormat.keyDateFormat}}"
+                                       d2-date
+                                       max-date="prStDes[eventGridColumn.id].allowFutureDate ? '' : 0"
                                        ng-model="currentEvent[eventGridColumn.id]"                                                               
                                        ng-required={{eventGridColumn.compulsory}}
                                        name="foo" 
@@ -182,8 +184,9 @@
                 </td>
                 <td>
                     <input type="text"                                                   
-                           placeholder="yyyy-mm-dd" 
-                           ng-date 
+                           placeholder="{{dhis2CalendarFormat.keyDateFormat}}"
+                           d2-date
+                           max-date='0'
                            ng-model="currentEvent.eventDate"
                            ng-disabled="editingEventInFull"    
                            ng-required="true" 
@@ -307,8 +310,9 @@
                                     </div>
                                     <div ng-switch-when="date">
                                         <input type="text"                                                                
-                                               placeholder="yyyy-mm-dd" 
-                                               ng-date 
+                                               placeholder="{{dhis2CalendarFormat.keyDateFormat}}"
+                                               d2-date
+                                               max-date="prStDes[de.dataElement.id].allowFutureDate ? '' : 0"
                                                ng-model="currentEvent[de.dataElement.id]"                                                               
                                                ng-required={{prStDes[de.dataElement.id].compulsory}}
                                                name="foo" 

=== 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 13:22:28 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html	2014-10-17 14:33:27 +0000
@@ -72,11 +72,11 @@
                                                 <input style="width: 45%;" placeholder="{{'upper_limit' | translate}}" type="number" ng-model="filterText[eventGridColumn.id].end" ng-blur="searchInGrid(eventGridColumn)">
                                             </span>
                                             <span ng-switch-when="date">
-                                                <input style="width: 70%;" placeholder="{{'start_date' | translate}}" type="text" ng-model="filterText[eventGridColumn.id].start" data-ng-date readonly="readonly">
+                                                <input style="width: 70%;" placeholder="{{'start_date' | translate}}" type="text" ng-model="filterText[eventGridColumn.id].start" d2-date readonly="readonly">
                                                 <span ng-hide="filterText[eventGridColumn.id].start == undefined || filterText[eventGridColumn.id].start == ''">
                                                     <a href ng-click='removeStartFilterText(eventGridColumn.id)'><span class='black'><i class="fa fa-trash-o"></i></span></a>                                                        
                                                 </span>
-                                                <input style="width: 70%;" placeholder="{{'end_date' | translate}}" type="text" ng-model="filterText[eventGridColumn.id].end" data-ng-date readonly="readonly">
+                                                <input style="width: 70%;" placeholder="{{'end_date' | translate}}" type="text" ng-model="filterText[eventGridColumn.id].end" d2-date readonly="readonly">
                                                 <span ng-hide="filterText[eventGridColumn.id].end == undefined || filterText[eventGridColumn.id].end == ''">
                                                     <a href ng-click='removeEndFilterText(eventGridColumn.id)'><span class='black'><i class="fa fa-trash-o"></i></span></a>                                                        
                                                 </span> 
@@ -213,8 +213,9 @@
                                         </div>
                                         <div ng-switch-when="date">
                                             <input type="text" 
-                                                   placeholder="yyyy-mm-dd" 
-                                                   ng-date 
+                                                   placeholder="{{dhis2CalendarFormat.keyDateFormat}}"
+                                                   d2-date
+                                                   max-date="prStDes[eventGridColumn.id].allowFutureDate ? '' : 0" 
                                                    ng-model="dhis2Event[eventGridColumn.id]"
                                                    blur-or-change="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
                                                    ng-required={{eventGridColumn.compulsory}}