=== 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-09-30 03:34:44 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js 2014-10-17 08:04:54 +0000 @@ -70,7 +70,8 @@ dateFormat: format, showAnim: '', maxDate: calendar.today(), - yearRange: 'c-100:c+100' + yearRange: 'c-100:c+100', + altFormat: 'yyyy-mm-dd' } }); }; @@ -79,10 +80,11 @@ * Creates a date picker. * * @param {jQuery|String|Object} el Element to select on, can be any kind of jQuery selector, or a jqEl - * @param {*} [fromIso] Convert field from ISO 8601 to local calendar - * @param {*} [options] Additional options, will be merged with the defaults + * @param {boolean} [fromIso] Convert field from ISO 8601 to local calendar + * @param {Object} [options] Additional options, will be merged with the defaults */ dhis2.period.DatePicker.prototype.createInstance = function( el, fromIso, options ) { + var self = this; var $el = $(el); if( fromIso ) { @@ -92,6 +94,25 @@ $el.val(this.calendar.formatDate(this.format, cDateIsoDate)); } + var isoFieldId = $el.attr('id'); + $el.attr('id', isoFieldId + '-dp'); + + $el.before($('') + .attr({ + 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); + }); + + options.altField = '#' + isoFieldId; + $el.calendarsPicker($.extend({}, this.defaults, options)); }; === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2014-10-11 19:29:38 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2014-10-17 08:04:54 +0000 @@ -148,9 +148,10 @@ return expression; } -function saveVal( dataElementId, optionComboId, fieldId ) +function saveVal( dataElementId, optionComboId, fieldId, target ) { var fieldIds = fieldId.split( "-" ); + var feedbackId = '#' + (target || fieldId); if ( fieldIds.length > 3 ) { @@ -163,7 +164,7 @@ var value = $( fieldId ).val(); var type = getDataElementType( dataElementId ); - $( fieldId ).css( 'background-color', dhis2.de.cst.colorYellow ); + $( feedbackId ).css( 'background-color', dhis2.de.cst.colorYellow ); var periodId = $( '#selectedPeriodId' ).val(); @@ -248,7 +249,7 @@ var color = warning ? dhis2.de.cst.colorOrange : dhis2.de.cst.colorGreen; - var valueSaver = new ValueSaver( dataElementId, periodId, optionComboId, value, fieldId, color ); + var valueSaver = new ValueSaver( dataElementId, periodId, optionComboId, value, feedbackId, color ); valueSaver.save(); dhis2.de.updateIndicators(); // Update indicators for custom form === 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-15 05:43:36 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2014-10-17 08:04:54 +0000 @@ -454,13 +454,13 @@ // fake event, needed for valueBlur / valueFocus when using date-picker (it doesn't send the event object through). var fakeEvent = { target: { - id: id + id: id + '-dp' } }; dhis2.period.picker.createInstance( '#' + id, false, { onSelect: function() { - saveVal( dataElementId, optionComboId, id ); + saveVal( dataElementId, optionComboId, id, fakeEvent.target.id ); }, onClose: function() { valueBlur(fakeEvent);