← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7317: Disable calendar of date-fields of other programstage in custom entry form.

 

------------------------------------------------------------
revno: 7317
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-06-18 09:36:01 +0700
message:
  Disable calendar of date-fields of other programstage in custom entry form.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.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-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java	2012-06-15 04:41:31 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java	2012-06-18 02:36:01 +0000
@@ -367,7 +367,7 @@
 
             String compulsory = "null";
             boolean allowProvidedElsewhere = false;
-            
+
             String dataElementCode = dataElementMatcher.group( 1 );
             Matcher identifierMatcher = IDENTIFIER_PATTERN_FIELD.matcher( dataElementCode );
             if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
@@ -511,7 +511,7 @@
                 {
                     disabled = "disabled";
                 }
-                else if ( !programStageInstance.isCompleted() && allowProvidedElsewhere)
+                else if ( !programStageInstance.isCompleted() && allowProvidedElsewhere )
                 {
                     // -----------------------------------------------------------
                     // Add ProvidedByOtherFacility checkbox
@@ -519,7 +519,7 @@
 
                     appendCode = addProvidedElsewherCheckbox( appendCode, patientDataValue, programStage );
                 }
-                
+
                 // -----------------------------------------------------------
                 // 
                 // -----------------------------------------------------------
@@ -579,7 +579,7 @@
             // -----------------------------------------------------------------
 
             String compulsory = "null";
-            boolean providedElsewhere = false;
+            boolean allowProvidedElsewhere = false;
             String dataElementCode = dataElementMatcher.group( 1 );
 
             Matcher identifierMatcher = IDENTIFIER_PATTERN_FIELD.matcher( dataElementCode );
@@ -616,7 +616,7 @@
                     ProgramStageDataElement psde = programStageDataElementService.get( programStage, dataElement );
 
                     compulsory = BooleanUtils.toStringTrueFalse( psde.isCompulsory() );
-                    providedElsewhere = psde.getAllowProvidedElsewhere();
+                    allowProvidedElsewhere = psde.getAllowProvidedElsewhere();
                 }
 
                 if ( dataElement == null )
@@ -700,8 +700,8 @@
                 }
 
                 appendCode += jsCodeForInputs;
-                
-                Boolean hasOptionSet = ( dataElement.getOptionSet() != null );
+
+                Boolean hasOptionSet = (dataElement.getOptionSet() != null);
                 appendCode = appendCode.replace( "$OPTIONS", hasOptionSet.toString() );
 
                 appendCode += " />";
@@ -713,13 +713,13 @@
                 // -----------------------------------------------------------
 
                 disabled = "";
-                
+
                 if ( programStageId != programStage.getId() )
                 {
                     disabled = "disabled=\"\"";
                 }
-                
-                else if ( !programStageInstance.isCompleted() && providedElsewhere )
+
+                else if ( !programStageInstance.isCompleted() && allowProvidedElsewhere )
                 {
                     // -----------------------------------------------------------
                     // Add ProvidedByOtherFacility checkbox
@@ -727,7 +727,7 @@
 
                     appendCode = addProvidedElsewherCheckbox( appendCode, patientDataValue, programStage );
                 }
-                
+
                 // -----------------------------------------------------------
                 // 
                 // -----------------------------------------------------------
@@ -928,18 +928,18 @@
                 {
                     disabled = "disabled=\"\"";
                 }
-
-                appendCode += jQueryCalendar;
-
-                if ( programStageId == programStage.getId() && !programStageInstance.isCompleted() && allowProvidedElsewhere )
+                else
                 {
-                    // -----------------------------------------------------------
-                    // Add ProvidedByOtherFacility checkbox
-                    // -----------------------------------------------------------
+                    appendCode += jQueryCalendar;
+                    if ( !programStageInstance.isCompleted() && allowProvidedElsewhere )
+                    {
+                        // -----------------------------------------------------------
+                        // Add ProvidedByOtherFacility checkbox
+                        // -----------------------------------------------------------
+                        appendCode = addProvidedElsewherCheckbox( appendCode, patientDataValue, programStage );
+                    }
+                }
 
-                    appendCode = addProvidedElsewherCheckbox( appendCode, patientDataValue, programStage );
-                }
-                
                 // -------------------------------------------------------------
                 // 
                 // -------------------------------------------------------------
@@ -963,25 +963,26 @@
 
         return sb.toString();
     }
-    
-    private String addProvidedElsewherCheckbox( String appendCode, PatientDataValue patientDataValue, ProgramStage programStage )
+
+    private String addProvidedElsewherCheckbox( String appendCode, PatientDataValue patientDataValue,
+        ProgramStage programStage )
     {
         appendCode += "<label for=\"$PROGRAMSTAGEID_$DATAELEMENTID_facility\" title=\"is provided by another Facility ?\" ></label><input name=\"providedByAnotherFacility\"  title=\"is provided by another Facility ?\"  id=\"$PROGRAMSTAGEID_$DATAELEMENTID_facility\"  type=\"checkbox\" style=\"display:$DISPLAY;\" ";
-        
+
         if ( patientDataValue != null && patientDataValue.getProvidedElsewhere() )
         {
             appendCode += " checked=\"checked\" ";
         }
-        
+
         appendCode += "onChange=\"updateProvidingFacility( $DATAELEMENTID, this )\"  >";
 
-        String display = ( !programStage.getProgram().isRegistration() ) ? "none" : "block";  
+        String display = (!programStage.getProgram().isRegistration()) ? "none" : "block";
         appendCode = appendCode.replace( "$DISPLAY", display );
-        
+
         return appendCode;
 
     }
-    
+
     /**
      * Returns the value of the PatientDataValue in the Collection of DataValues
      * with the given data element identifier.

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-06-14 13:19:46 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-06-18 02:36:01 +0000
@@ -267,7 +267,7 @@
 	window.location.href = url;
 }
 
-var prefixStageId = 'ps_';
+var prefixId = 'ps_';
 var COLOR_RED = "#fb4754";
 var COLOR_GREEN = "#8ffe8f";
 var COLOR_YELLOW = "#f9f95a";

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2012-06-15 06:16:17 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2012-06-18 02:36:01 +0000
@@ -1,14 +1,7 @@
-var prefixId = 'ps_';
-
-var COLOR_RED = "#fb4754";
-var COLOR_GREEN = "#8ffe8f";
-var COLOR_YELLOW = "#f9f95a";
-var COLOR_LIGHTRED = "#fb6bfb";
-var COLOR_LIGHT_RED = "#ff7676";
-var COLOR_LIGHT_YELLOW = "#ffff99";
-var COLOR_LIGHT_GREEN = "#ccffcc";
-var COLOR_LIGHT_LIGHTRED = "#ff99ff";
-
+var SUCCESS_COLOR = '#ccffcc';
+var ERROR_COLOR = '#ccccff';
+var SAVING_COLOR = '#ffffcc';
+	
 //--------------------------------------------------------------------------------------------
 // Load program-stages by the selected program
 //--------------------------------------------------------------------------------------------
@@ -181,7 +174,7 @@
 	var dataElementName = data['deName']; 
     var type = data['deType'];
  
-	field.style.backgroundColor = '#ffffcc';
+	field.style.backgroundColor = SAVING_COLOR;
     
     if( fieldValue != '' )
     {
@@ -225,7 +218,7 @@
     	
     }
     
-	var valueSaver = new ValueSaver( dataElementId, fieldValue, type, '#ccffcc'  );
+	var valueSaver = new ValueSaver( dataElementId, fieldValue, type, SUCCESS_COLOR );
     valueSaver.save();
 }
 
@@ -233,9 +226,9 @@
 {
 	var programStageId = byId('programStageId').value;
 	var field = byId( programStageId + '-' + dataElementId + '-val' );	
-	field.style.backgroundColor = '#ffffcc';
+	field.style.backgroundColor = SAVING_COLOR;
 	
-	var valueSaver = new ValueSaver( dataElementId, field.options[field.selectedIndex].value, 'bool', '#ccffcc' );
+	var valueSaver = new ValueSaver( dataElementId, field.options[field.selectedIndex].value, 'bool', SUCCESS_COLOR );
     valueSaver.save();
 }
 
@@ -243,9 +236,9 @@
 {
 	var programStageId = byId( 'programStageId' ).value;
 	var checked= checkField.checked;
-    checkField.style.backgroundColor = '#ffffcc';
+    checkField.style.backgroundColor = SAVING_COLOR;
 	
-    var facilitySaver = new FacilitySaver( dataElementId, checked, '#ccffcc' );
+    var facilitySaver = new FacilitySaver( dataElementId, checked, SUCCESS_COLOR );
     facilitySaver.save();
     
 }
@@ -254,9 +247,9 @@
 {
     var field = document.getElementById( 'executionDate' );
 	
-    field.style.backgroundColor = '#ffffcc';
+    field.style.backgroundColor = SAVING_COLOR;
 	
-    var executionDateSaver = new ExecutionDateSaver( programId, executionDateValue, '#ccffcc' );
+    var executionDateSaver = new ExecutionDateSaver( programId, executionDateValue, SUCCESS_COLOR );
     executionDateSaver.save();
 	
     if( !jQuery("#entryForm").is(":visible") )
@@ -389,9 +382,6 @@
 
 function ValueSaver( dataElementId_, value_, dataElementType_, resultColor_  )
 {
-    var SUCCESS = '#ccffcc';
-    var ERROR = '#ccccff';
-	
     var dataElementId = dataElementId_;
 	var providedElsewhereId = getFieldValue('programStageId') + "_" + dataElementId_ + "_facility";
 	var value = value_;
@@ -463,9 +453,6 @@
 
 function FacilitySaver( dataElementId_, providedElsewhere_, resultColor_ )
 {
-    var SUCCESS = 'success';
-    var ERROR = '#error';
-	
     var dataElementId = dataElementId_;
 	var providedElsewhere = providedElsewhere_;
     var resultColor = resultColor_;
@@ -494,11 +481,11 @@
         var code = parseInt( codeElement.firstChild.nodeValue );
         if ( code == 0 )
         {
-            markValue( SUCCESS );
+            markValue( SUCCESS_COLOR );
         }
         else
         {
-            markValue( ERROR );
+            markValue( ERROR_COLOR );
             window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
         }
     }
@@ -512,11 +499,11 @@
     function markValue( result )
     {
 		var programStageId = byId( 'programStageId' ).value;
-        if( result == SUCCESS )
+        if( result == 'success' )
         {
             jQuery('label[for="' + programStageId + '_facility"]').toggleClass('checked');
         }
-        else if( result == ERROR )
+        else if( result == 'error' )
         {
             jQuery('label[for="' + programStageId + '_facility"]').removeClass('checked');
             jQuery('label[for="' + programStageId + '_facility"]').addClass('error');
@@ -526,9 +513,6 @@
 
 function ExecutionDateSaver( programId_, executionDate_, resultColor_ )
 {
-    var SUCCESS = '#ccffcc';
-    var ERROR = '#ffcc00';
-	
     var programId = programId_;
     var executionDate = executionDate_;
     var resultColor = resultColor_;