← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21375: data-entry: booleans are now changed from drop-down to radio

 

------------------------------------------------------------
revno: 21375
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-12-08 14:14:21 +0100
message:
  data-entry: booleans are now changed from drop-down to radio
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/entry.js
  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/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	2015-10-19 22:23:02 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java	2015-12-08 13:14:21 +0000
@@ -346,15 +346,22 @@
 
                 if ( ValueType.BOOLEAN == valueType )
                 {
-                    inputHtml = inputHtml.replace( "input", "select" );
-                    inputHtml = inputHtml.replaceAll( "value=\".*?\"", "" );
-
-                    appendCode += " name=\"entryselect\" class=\"entryselect\" tabindex=\"" + i++ + "\">";
-
-                    appendCode += "<option value=\"\">" + i18n.getString( "no_value" ) + "</option>";
-                    appendCode += "<option value=\"true\">" + i18n.getString( "yes" ) + "</option>";
-                    appendCode += "<option value=\"false\">" + i18n.getString( "no" ) + "</option>";
-                    appendCode += "</select>";
+                    inputHtml = inputHtml.replaceAll(inputHtml, TAG_CLOSE);
+                    
+                    appendCode += "<label>";
+                    appendCode += "<input type=\"radio\" class=\"entryselect\" name=\"" + dataElementId + "-" + optionComboId + "-val\"  id=\"" + dataElementId + "-" + optionComboId + "-val\" tabindex=\"" + i++ + "\" value=\"\">";
+                    appendCode += i18n.getString( "no_value" );
+                    appendCode += "</label>";
+                    
+                    appendCode += "<label>";
+                    appendCode += "<input type=\"radio\" class=\"entryselect\" name=\"" + dataElementId + "-" + optionComboId + "-val\"  id=\"" + dataElementId + "-" + optionComboId + "-val\" tabindex=\"" + i++ + "\" value=\"true\">";
+                    appendCode += i18n.getString( "yes" );
+                    appendCode += "</label>";
+                    
+                    appendCode += "<label>";
+                    appendCode += "<input type=\"radio\" class=\"entryselect\" name=\"" + dataElementId + "-" + optionComboId + "-val\"  id=\"" + dataElementId + "-" + optionComboId + "-val\" tabindex=\"" + i++ + "\" value=\"false\">";
+                    appendCode += i18n.getString( "no" );
+                    appendCode += "</label>";
                 }
                 else if ( ValueType.TRUE_ONLY == valueType )
                 {

=== 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	2015-10-01 10:26:37 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2015-12-08 13:14:21 +0000
@@ -262,11 +262,11 @@
     }
 }
 
-function saveBoolean( dataElementId, optionComboId, fieldId )
+function saveBoolean( dataElementId, optionComboId, _fieldId )
 {
-    fieldId = '#' + fieldId;
+    var fieldId = '#' + _fieldId;
     
-    var value = $( fieldId + ' option:selected' ).val();
+    var value = $('input[id=' + _fieldId + ']:checked').val();
 
     $( fieldId ).css( 'background-color', dhis2.de.cst.colorYellow );
 

=== 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-10-19 14:07:54 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2015-12-08 13:14:21 +0000
@@ -565,12 +565,12 @@
         var dataElementId = split.dataElementId;
         var optionComboId = split.optionComboId;
 
-        $( this ).unbind( 'focus' );
+        /*$( this ).unbind( 'focus' );
         $( this ).unbind( 'change' );
 
         $( this ).focus( valueFocus );
 
-        $( this ).blur( valueBlur );
+        $( this ).blur( valueBlur );*/
 
         $( this ).change( function()
         {
@@ -1553,7 +1553,7 @@
     // Clear existing values and colors, grey disabled fields
 
     $( '.entryfield' ).val( '' );
-    $( '.entryselect' ).val( '' );
+    $( '.entryselect' ).removeAttr( 'checked' );
     $( '.entrytrueonly' ).removeAttr( 'checked' );
     $( '.entryoptionset' ).val( '' );
 
@@ -1675,6 +1675,22 @@
             {
                 dhis2.de.setOptionNameInField( fieldId, value );
             }
+            else if ( $( fieldId ).attr( 'class' ) == 'entryselect' )
+            {                
+                var fId = fieldId.substring(1, fieldId.length);
+    
+                if( value.val == 'true' )
+                {
+                    $('input[id=' + fId + ']')[1].checked = true;
+                }
+                else if ( value.val == 'false')
+                {
+                    $('input[id=' + fId + ']')[2].checked = true;
+                }
+                else{
+                    $('input[id=' + fId + ']')[0].checked = true;
+                }
+            }
             else if ( $( fieldId ).attr( 'class' ) == 'entryfileresource' )
             {
                 var $field = $( fieldId );

=== 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	2015-10-19 14:07:54 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm	2015-12-08 13:14:21 +0000
@@ -91,11 +91,24 @@
     #set( $greyedField = false )
     #set( $greyedField = $greyedFields.get( "${dataElement.uid}:${optionCombo.uid}" ) )
     #if( $dataElement.valueType == "BOOLEAN" )
-    <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 class="commentlink" id="${commentId}"></td>
+    <td>
+
+                <label>
+                        <input type="radio" name="${dataEntryId}" class="entryselect" id="${dataEntryId}" value="" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end>
+			$i18n.getString( "no_value" )		
+		</label>
+		
+		<label>
+			<input type="radio" name="${dataEntryId}" class="entryselect" id="${dataEntryId}" value="true" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end>
+			$i18n.getString( "yes" )
+		</label>		
+		
+		<label>
+			<input type="radio" name="${dataEntryId}" class="entryselect" id="${dataEntryId}" value="false" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end>
+			$i18n.getString( "no" )			
+		</label>
+    <img class="commentlink" id="${commentId}">
+    </td>
     #elseif( $dataElement.valueType == "TRUE_ONLY" )
         <td><input name="entrytrueonly" class="entrytrueonly" id="${dataEntryId}" type="checkbox" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end><img class="commentlink" id="${commentId}"></td>
     #elseif( "LONG_TEXT" == $dataElement.valueType )