← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17117: bugfix for date picker in date-entry

 

------------------------------------------------------------
revno: 17117
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-10-15 12:17:39 +0700
message:
  bugfix for date picker in date-entry
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.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-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-10-13 10:23:17 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-10-15 05:17:39 +0000
@@ -415,6 +415,7 @@
 {
     $( '.entryfield' ).each( function( i )
     {
+        var self = this;
         var id = $( this ).attr( 'id' );
 
         var split = splitFieldId( id );
@@ -451,7 +452,24 @@
 
         if ( type == 'date' )
         {
-            dhis2.period.picker.createInstance( '#' + id );
+            // fake event, needed for valueBlur / valueFocus when using date-picker (it doesn't send the event object through).
+            var fakeEvent = {
+                target: {
+                    id: id
+                }
+            };
+
+            dhis2.period.picker.createInstance( '#' + id, false, {
+                onSelect: function() {
+                    saveVal( dataElementId, optionComboId, id );
+                },
+                onClose: function() {
+                    valueBlur(fakeEvent);
+                },
+                onShow: function() {
+                    valueFocus(fakeEvent);
+                }
+            } );
         }
     } );