← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11605: when locking is enabled, allow user to see form/datavalues (read-only form). Also added class='en...

 

------------------------------------------------------------
revno: 11605
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-08-07 21:18:03 +0700
message:
  when locking is enabled, allow user to see form/datavalues (read-only form). Also added class='entryType' to all input fields, makes them simpler to query (without using horrible [name=''] queries).
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java
  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/multiOrgSectionForm.vm
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm


--
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-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java	2013-05-23 10:40:52 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java	2013-08-07 14:18:03 +0000
@@ -314,7 +314,7 @@
                     inputHtml = inputHtml.replace( "input", "select" );
                     inputHtml = inputHtml.replaceAll( "value=\".*?\"", "" );
 
-                    appendCode += " name=\"entryselect\" tabindex=\"" + i++ + "\">";
+                    appendCode += " name=\"entryselect\" class=\"entryselect\" tabindex=\"" + i++ + "\">";
 
                     appendCode += "<option value=\"\">" + i18n.getString( "no_value" ) + "</option>";
                     appendCode += "<option value=\"true\">" + i18n.getString( "yes" ) + "</option>";
@@ -323,15 +323,15 @@
                 }
                 else if ( dataElement.getType().equals( DataElement.VALUE_TYPE_TRUE_ONLY ) )
                 {
-                    appendCode += " name=\"entrytrueonly\" type=\"checkbox\" tabindex=\"" + i++ + "\"" + TAG_CLOSE;
+                    appendCode += " name=\"entrytrueonly\" class=\"entrytrueonly\" type=\"checkbox\" tabindex=\"" + i++ + "\"" + TAG_CLOSE;
                 }
                 else if ( dataElement.getOptionSet() != null )
                 {
-                    appendCode += " name=\"entryoptionset\" tabindex=\"" + i++ + "\"" + TAG_CLOSE;
+                    appendCode += " name=\"entryoptionset\" class=\"entryoptionset\" tabindex=\"" + i++ + "\"" + TAG_CLOSE;
                 }
                 else
                 {
-                    appendCode += " name=\"entryfield\" tabindex=\"" + i++ + "\"" + TAG_CLOSE;
+                    appendCode += " name=\"entryfield\" class=\"entryfield\" tabindex=\"" + i++ + "\"" + TAG_CLOSE;
                 }
 
                 inputHtml = inputHtml.replace( TAG_CLOSE, appendCode );
@@ -348,11 +348,11 @@
                     return i18n.getString( "category_option_combo_with_id" ) + ": " + optionComboId + " " + i18n.getString( "does_not_exist" );
                 }
 
-                inputHtml = inputHtml.replace( TAG_CLOSE, " name=\"dyninput\" tabindex=\"" + i++ + "\"" + TAG_CLOSE );
+                inputHtml = inputHtml.replace( TAG_CLOSE, " name=\"dyninput\" class=\"dyninput\" tabindex=\"" + i++ + "\"" + TAG_CLOSE );
             }
             else if ( dynamicSelectMatcher.find() && dynamicSelectMatcher.groupCount() > 0 )
             {
-                inputHtml = inputHtml.replace( "<input", "<select name=\"dynselect\"" );
+                inputHtml = inputHtml.replace( "<input", "<select name=\"dynselect\" class=\"dynselect\"" );
                 inputHtml = inputHtml.replace( TAG_CLOSE, "</select>" );
             }
 

=== 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	2013-08-06 07:28:56 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2013-08-07 14:18:03 +0000
@@ -341,7 +341,7 @@
     var dataSetId = $( '#selectedDataSetId' ).val();
 	var formType = dataSets[dataSetId].type;
 
-    $( '[name="entryfield"]' ).each( function( i )
+    $( '.entryfield' ).each( function( i )
     {
         var id = $( this ).attr( 'id' );
 
@@ -390,7 +390,7 @@
         }
     } );
 
-    $( '[name="entryselect"]' ).each( function( i )
+    $( '.entryselect' ).each( function( i )
     {
         var id = $( this ).attr( 'id' );
         var split = splitFieldId( id );
@@ -414,7 +414,7 @@
         $( this ).css( 'margin-right', '2px' );
     } );
 
-    $( '[name="entrytrueonly"]' ).each( function( i )
+    $( 'entrytrueonly' ).each( function( i )
     {
         var id = $( this ).attr( 'id' );
         var split = splitFieldId( id );
@@ -436,7 +436,7 @@
         $( this ).css( 'width', '90%' );
     } );
 
-    $( '[name="entryoptionset"]' ).each( function( i )
+    $( '.entryoptionset' ).each( function( i )
     {
         var id = $( this ).attr( 'id' );
         var split = splitFieldId( id );
@@ -1033,20 +1033,20 @@
 
     // Clear existing values and colors, grey disabled fields
 
-    $( '[name="entryfield"]' ).val( '' );
-    $( '[name="entryselect"]' ).val( '' );
-    $( '[name="entrytrueonly"]' ).removeAttr('checked');
-    $( '[name="entryoptionset"]' ).val( '' );
+    $( '.entryfield' ).val( '' );
+    $( '.entryselect' ).val( '' );
+    $( '.entrytrueonly' ).removeAttr('checked');
+    $( '.entryoptionset' ).val( '' );
 
-    $( '[name="entryfield"]' ).css( 'background-color', COLOR_WHITE );
-    $( '[name="entryselect"]' ).css( 'background-color', COLOR_WHITE );
-    $( '[name="entrytrueonly"]' ).css( 'background-color', COLOR_WHITE );
-    $( '[name="entryoptionset"]' ).css( 'background-color', COLOR_WHITE );
+    $( '.entryfield' ).css( 'background-color', COLOR_WHITE );
+    $( '.entryselect' ).css( 'background-color', COLOR_WHITE );
+    $( '.entrytrueonly' ).css( 'background-color', COLOR_WHITE );
+    $( '.entryoptionset' ).css( 'background-color', COLOR_WHITE );
 
     $( '[name="min"]' ).html( '' );
     $( '[name="max"]' ).html( '' );
 
-    $( '[name="entryfield"]' ).filter( ':disabled' ).css( 'background-color', COLOR_GREY );
+    $( '.entryfield' ).filter( ':disabled' ).css( 'background-color', COLOR_GREY );
     
     // Disable and grey dynamic fields to start with and enable later
 
@@ -1070,14 +1070,17 @@
 	    {
 	    	if ( json.locked )
 	    	{
-	    		$( '#contentDiv' ).hide();
-	    		$( '#completenessDiv' ).hide();
+	            $('#contentDiv input').attr('disabled', 'disabled');
+	            $('.entryoptionset').autocomplete('disable');
+                $('.sectionFilter').removeAttr('disabled');
+                $( '#completenessDiv' ).hide();
 	    		setHeaderDelayMessage( i18n_dataset_is_locked );
-	    		return;
 	    	}
 	    	else
-	    	{	    		
-	    		$( '#contentDiv' ).show();
+	    	{
+                $('.entryoptionset').autocomplete('enable');
+                $('#contentDiv input').removeAttr('disabled');
+                $('#contentDiv input').css('backgroundColor', '#fff');
 	    		$( '#completenessDiv' ).show();
 	    	}
 	    	
@@ -1101,24 +1104,26 @@
 
 	        // Set min-max values and colorize violation fields
 
-	        $.safeEach( json.minMaxDataElements, function( i, value )
-	        {
-	            var minId = value.id + '-min';
-	            var maxId = value.id + '-max';
-
-	            var valFieldId = '#' + value.id + '-val';
-
-	            var dataValue = dataValueMap[value.id];
-
-	            if ( dataValue && ( ( value.min && new Number( dataValue ) < new Number(
-	            	value.min ) ) || ( value.max && new Number( dataValue ) > new Number( value.max ) ) ) )
-	            {
-	                $( valFieldId ).css( 'background-color', COLOR_ORANGE );
-	            }
-
-	            currentMinMaxValueMap[minId] = value.min;
-	            currentMinMaxValueMap[maxId] = value.max;
-	        } );
+            if(!json.locked) {
+                $.safeEach( json.minMaxDataElements, function( i, value )
+                {
+                    var minId = value.id + '-min';
+                    var maxId = value.id + '-max';
+
+                    var valFieldId = '#' + value.id + '-val';
+
+                    var dataValue = dataValueMap[value.id];
+
+                    if ( dataValue && ( ( value.min && new Number( dataValue ) < new Number(
+                        value.min ) ) || ( value.max && new Number( dataValue ) > new Number( value.max ) ) ) )
+                    {
+                        $( valFieldId ).css( 'background-color', COLOR_ORANGE );
+                    }
+
+                    currentMinMaxValueMap[minId] = value.min;
+                    currentMinMaxValueMap[maxId] = value.max;
+                } );
+            }
 
 	        // Update indicator values in form
 
@@ -1127,7 +1132,7 @@
 
 	        // Set completeness button
 
-	        if ( json.complete )
+	        if ( json.complete && !json.locked)
 	        {
 	            $( '#completeButton' ).attr( 'disabled', 'disabled' );
 	            $( '#undoButton' ).removeAttr( 'disabled' );
@@ -1147,7 +1152,12 @@
 	            $( '#undoButton' ).attr( 'disabled', 'disabled' );
 	            $( '#infoDiv' ).hide();
 	        }
-	    }
+
+            if(json.locked) {
+                $('#contentDiv input').css('backgroundColor', '#eee');
+                $('.sectionFilter').css('backgroundColor', '#fff');
+            }
+        }
 	} );
 }
 
@@ -1465,7 +1475,7 @@
     {
         var violations = false;
 
-        $( '[name="entryfield"]' ).add( '[name="entryselect"]' ).each( function( i )
+        $( '.entryfield' ).add( '[name="entryselect"]' ).each( function( i )
         {
             var id = $( this ).attr( 'id' );
 
@@ -2219,7 +2229,7 @@
 }
 
 function insertOptionSets() {
-    $( '[name="entryoptionset"]' ).each( function ( idx, item ) {
+    $( '.entryoptionset' ).each( function ( idx, item ) {
         var optionSetKey = splitFieldId( item.id );
 
         if ( multiOrganisationUnit ) {

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/multiOrgSectionForm.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/multiOrgSectionForm.vm	2013-07-11 04:19:05 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/multiOrgSectionForm.vm	2013-08-07 14:18:03 +0000
@@ -82,18 +82,18 @@
                 #set( $greyedField = false )
                 #set( $greyedField = $greyedFields.get( "$dataElement.uid:$optionCombo.uid" ) )
                 #if( $dataElement.type == "bool" )
-                <td><select name="entryselect" id="$dataEntryId" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end>
+                <td><select name="entryselect" class="entryselect" id="$dataEntryId" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end>
                   <option value="">[$i18n.getString( "no_value" )]</option>
                   <option value="true">$i18n.getString( "yes" )</option>
                   <option value="false">$i18n.getString( "no" )</option>
                 </select></td>
                 #elseif( $dataElement.type == 'trueOnly' )
-                    <td><input name="entrytrueonly" id="$dataEntryId" type="checkbox" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+                    <td><input name="entrytrueonly" class="entrytrueonly" id="$dataEntryId" type="checkbox" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
                 #else
                     #if( $dataElement.optionSet )
-                        <td><input name="entryoptionset" id="$dataEntryId" type="text" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+                        <td><input name="entryoptionset" class="entryoptionset" id="$dataEntryId" type="text" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
                     #else
-                        <td><input name="entryfield" id="$dataEntryId" type="text" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+                        <td><input name="entryfield" class="entryfield" id="$dataEntryId" type="text" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
                     #end
                 #end
                 </td>
@@ -163,18 +163,18 @@
                     #set( $greyedField = false )
                     #set( $greyedField = $greyedFields.get( "$dataElement.uid:$optionCombo.uid" ) )
                     #if( $dataElement.type == "bool" )
-                    <td><select name="entryselect" id="$dataEntryId" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end>
+                    <td><select name="entryselect" class="entryselect" id="$dataEntryId" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end>
                       <option value="">[$i18n.getString( "no_value" )]</option>
                       <option value="true">$i18n.getString( "yes" )</option>
                       <option value="false">$i18n.getString( "no" )</option>
                     </select></td>
                     #elseif( $dataElement.type == 'trueOnly' )
-                        <td><input name="entrytrueonly" id="$dataEntryId" type="checkbox" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+                        <td><input name="entrytrueonly" class="entrytrueonly" id="$dataEntryId" type="checkbox" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
                     #else
                         #if( $dataElement.optionSet )
-                            <td><input name="entryoptionset" id="$dataEntryId" type="text" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+                            <td><input name="entryoptionset" class="entryoptionset" id="$dataEntryId" type="text" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
                         #else
-                            <td><input name="entryfield" id="$dataEntryId" type="text" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+                            <td><input name="entryfield" class="entryfield" id="$dataEntryId" type="text" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
                         #end
                     #end
                     </td>
@@ -212,18 +212,18 @@
                 #set( $greyedField = false )
                 #set( $greyedField = $greyedFields.get( "$dataElement.uid:$optionCombo.uid" ) )
                 #if( $dataElement.type == "bool" )
-                <td><select name="entryselect" id="$dataEntryId" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end>
+                <td><select name="entryselect" class="entryselect" id="$dataEntryId" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end>
                   <option value="">[$i18n.getString( "no_value" )]</option>
                   <option value="true">$i18n.getString( "yes" )</option>
                   <option value="false">$i18n.getString( "no" )</option>
                 </select></td>
                 #elseif( $dataElement.type == 'trueOnly' )
-                    <td><input name="entrytrueonly" id="$dataEntryId" type="checkbox" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+                    <td><input name="entrytrueonly" class="entrytrueonly" id="$dataEntryId" type="checkbox" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
                 #else
                     #if( $dataElement.optionSet )
-                        <td><input name="entryoptionset" id="$dataEntryId" type="text" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+                        <td><input name="entryoptionset" class="entryoptionset" id="$dataEntryId" type="text" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
                     #else
-                        <td><input name="entryfield" id="$dataEntryId" type="text" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+                        <td><input name="entryfield" class="entryfield" id="$dataEntryId" type="text" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
                     #end
                 #end
                 </td>

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm	2013-07-08 04:59:58 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm	2013-08-07 14:18:03 +0000
@@ -85,18 +85,18 @@
     #set( $greyedField = false )
     #set( $greyedField = $greyedFields.get( "${dataElement.uid}:${optionCombo.uid}" ) )
     #if( $dataElement.type == "bool" )
-    <td><select name="entryselect" id="$dataEntryId" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end>
+    <td><select name="entryselect" class="entryselect" id="$dataEntryId" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end>
       <option value="">[$i18n.getString( "no_value" )]</option>
       <option value="true">$i18n.getString( "yes" )</option>
       <option value="false">$i18n.getString( "no" )</option>
     </select><img name="commentlink" id="${commentId}"></td>
     #elseif( $dataElement.type == "trueOnly" )
-        <td><input name="entrytrueonly" id="${dataEntryId}" type="checkbox" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+        <td><input name="entrytrueonly" class="entrytrueonly" id="${dataEntryId}" type="checkbox" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
     #else
         #if( $dataElement.optionSet )
-          <td><input name="entryoptionset" id="${dataEntryId}" type="text" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+          <td><input name="entryoptionset" class="entryoptionset" id="${dataEntryId}" type="text" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
         #else
-          <td><input name="entryfield" id="${dataEntryId}" type="text" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+          <td><input name="entryfield" class="entryfield" id="${dataEntryId}" type="text" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
         #end
     #end
     </td>