← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18711: minor fix, update datepicker value from form.js

 

------------------------------------------------------------
revno: 18711
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-03-27 21:46:32 +0700
message:
  minor fix, update datepicker value from form.js
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js
  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-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js	2014-11-26 08:53:22 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js	2015-03-27 14:46:32 +0000
@@ -102,15 +102,6 @@
       id: isoFieldId
     }));
 
-  $(document).on('dhis2.de.event.dataValuesLoaded', function() {
-    var $isoField = $('#' + isoFieldId);
-
-    var date = self.calendar.parseDate('yyyy-mm-dd', $isoField.val());
-    var localDate = self.calendar.formatDate(self.format, date);
-
-    $el.val(localDate);
-  });
-
   if (options) {
 	  options.altField = '#' + isoFieldId;
   }
@@ -119,6 +110,21 @@
 };
 
 /**
+ * Formats and sets the formatted date value.
+ *
+ * @param {String} fieldId field id
+ */
+dhis2.period.DatePicker.prototype.updateDate = function( fieldId ) {
+  var $isoField = $(fieldId);
+  var $el = $(fieldId + '-dp');
+
+  var date = this.calendar.parseDate('yyyy-mm-dd', $isoField.val());
+  var localDate = this.calendar.formatDate(this.format, date);
+
+  $el.val(localDate);
+};
+
+/**
  * Creates a ranged date picker, keeping two fields in sync.
  *
  * @param {jQuery|String|Object} fromEl From element to select on, can be any kind of jQuery selector, or a jqEl

=== 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	2015-03-26 18:16:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2015-03-27 14:46:32 +0000
@@ -1649,6 +1649,8 @@
         }
         
         dataValueMap[value.id] = value.val;
+
+        dhis2.period.picker.updateDate(fieldId);
     } );
 
     // Set min-max values and colorize violation fields