← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16703: Data entry, fixed bug related to selection of attributes when changing data sets

 

------------------------------------------------------------
revno: 16703
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-09-12 05:40:25 -0400
message:
  Data entry, fixed bug related to selection of attributes when changing data sets
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-09-10 03:45:33 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-09-12 09:40:25 +0000
@@ -955,17 +955,21 @@
 
         var periodType = dhis2.de.dataSets[dataSetId].periodType;
 
-        if ( periodType != previousPeriodType )
+        var previousPeriodTypeValid = !!( previousPeriodType && previousPeriodType == periodType );
+        
+        if ( !previousPeriodTypeValid )
         {
             displayPeriods();
             clearSectionFilters();
         }
-
+        
         dhis2.de.currentCategories = dhis2.de.getCategories( dataSetId );
-        
+
+        dhis2.de.setAttributesMarkup();   
+
         dhis2.de.multiOrganisationUnit = !!$( '#selectedDataSetId :selected' ).data( 'multiorg' );
 
-        if ( dhis2.de.inputSelected() && previousPeriodType && previousPeriodType == periodType )
+        if ( dhis2.de.inputSelected() && previousPeriodTypeValid )
         {
             showLoader();
             loadForm();
@@ -999,10 +1003,9 @@
     var periodName = $( '#selectedPeriodId :selected' ).text();
 
     $( '#currentPeriod' ).html( periodName );
-
-    var attributeMarkup = dhis2.de.getAttributesMarkup();
-    $( '#attributeComboDiv' ).html( attributeMarkup );
-
+    
+    dhis2.de.setAttributesMarkup();
+    
     if ( dhis2.de.inputSelected() )
     {    	
         showLoader();
@@ -1200,6 +1203,15 @@
 }
 
 /**
+ * Sets the markup for attribute selections.
+ */
+dhis2.de.setAttributesMarkup = function()
+{
+    var attributeMarkup = dhis2.de.getAttributesMarkup();
+    $( '#attributeComboDiv' ).html( attributeMarkup );
+}
+
+/**
 * Returns markup for drop down boxes to be put in the selection box for the
 * given categories. The empty string is returned if no categories are given. 
 */