← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10912: support multiorg units for optionsets

 

------------------------------------------------------------
revno: 10912
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-05-21 13:54:08 +0700
message:
  support multiorg units for optionsets
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm
  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-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm	2013-02-05 13:30:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm	2013-05-21 06:54:08 +0000
@@ -48,7 +48,11 @@
   </select>
   <img name="commentlink" id="${commentId}"></td>
   #else
-  <td><input name="entryfield" id="${dataEntryId}" maxlength="255" type="text"#if( !$hasAccess ) disabled="disabled"#end tabindex="$tabIndex"></td>
+      #if( $dataElement.optionSet )
+        <td><input name="entryoptionset" id="${dataEntryId}" maxlength="255" type="text"#if( !$hasAccess ) disabled="disabled"#end tabindex="$tabIndex"></td>
+      #else
+        <td><input name="entryfield" id="${dataEntryId}" maxlength="255" type="text"#if( !$hasAccess ) disabled="disabled"#end tabindex="$tabIndex"></td>
+      #end
   #end
   </td>
   #set( $tabIndex = $tabIndex + 1 )

=== 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-05-21 06:03:05 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2013-05-21 06:54:08 +0000
@@ -412,7 +412,32 @@
 
         $( this ).css( 'width', '90%' );
     } );
-    
+
+    $( '[name="entryoptionset"]' ).each( function( i )
+    {
+        var id = $( this ).attr( 'id' );
+        var split = splitFieldId( id );
+
+        var dataElementId = split.dataElementId;
+        var optionComboId = split.optionComboId;
+
+        $( this ).unbind( 'focus' );
+        $( this ).unbind( 'change' );
+
+        $( this ).focus( valueFocus );
+        $( this ).blur( valueBlur );
+
+        $( this ).change( function()
+        {
+            saveVal( dataElementId, optionComboId, id );
+        } );
+
+        if ( formType != FORMTYPE_CUSTOM ) {
+            $( this ).css( 'width', '80%' );
+            $( this ).css( 'text-align', 'center' );
+        }
+    } );
+
     $( '[name="commentlink"]' ).each( function( i )
     {
         var id = $( this ).attr( 'id' );
@@ -546,8 +571,8 @@
                 $( '#currentOrganisationUnit' ).html( i18n_no_organisationunit_selected );
             }
 
-            loadDataValues();
             insertOptionSets();
+            loadDataValues();
         } );
     }
 }
@@ -1076,11 +1101,13 @@
 
     $( '[name="entryfield"]' ).val( '' );
     $( '[name="entryselect"]' ).val( '' );
+    $( '[name="entryoptionset"]' ).val( '' );
     $( '[name="dyninput"]' ).val( '' );
     $( '[name="dynselect"]' ).val( '' );
 
     $( '[name="entryfield"]' ).css( 'background-color', COLOR_WHITE );
     $( '[name="entryselect"]' ).css( 'background-color', COLOR_WHITE );
+    $( '[name="entryoptionset"]' ).css( 'background-color', COLOR_WHITE );
     $( '[name="dyninput"]' ).css( 'background-color', COLOR_WHITE );
 
     $( '[name="min"]' ).html( '' );
@@ -1536,7 +1563,7 @@
     if ( fieldCombinationRequired )
     {
         var violations = false;
-		
+
         $( '[name="entryfield"]' ).add( '[name="entryselect"]' ).each( function( i )
         {
             var id = $( this ).attr( 'id' );
@@ -2277,13 +2304,29 @@
 }
 
 function insertOptionSets() {
-    $.each( _.keys(optionSets), function(idx, item) {
-        autocompleteOptionSetField( item + '-val', optionSets[item] );
-    });
+    $( '[name="entryoptionset"]' ).each( function ( idx, item ) {
+        var optionSetKey = splitFieldId( item.id );
+
+        if ( multiOrganisationUnit ) {
+            item = optionSetKey.organisationUnitId + '-' + optionSetKey.dataElementId + '-' + optionSetKey.optionComboId;
+        } else {
+            item = optionSetKey.dataElementId + '-' + optionSetKey.optionComboId;
+        }
+
+        item = item + '-val';
+        optionSetKey = optionSetKey.dataElementId + '-' + optionSetKey.optionComboId;
+
+        autocompleteOptionSetField( item, optionSets[optionSetKey] );
+    } );
 }
 
 function autocompleteOptionSetField( idField, optionSetUid ) {
     var input = jQuery( "#" + idField );
+
+    if ( !input ) {
+        return;
+    }
+
     input.css( "width", "85%" );
     input.autocomplete( {
         delay: 0,

=== 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-03-20 10:36:37 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/multiOrgSectionForm.vm	2013-05-21 06:54:08 +0000
@@ -87,7 +87,11 @@
                   <option value="false">$i18n.getString( "no" )</option>
                 </select></td>
                 #else
-                <td><input name="entryfield" id="$dataEntryId" type="text" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+                    #if( $dataElement.optionSet )
+                        <td><input name="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>
+                    #end
                 #end
                 </td>
                 #set( $tabIndex = $tabIndex + 1 )

=== 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-03-20 08:29:43 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm	2013-05-21 06:54:08 +0000
@@ -67,7 +67,11 @@
       <option value="false">$i18n.getString( "no" )</option>
     </select><img name="commentlink" id="${commentId}"></td>
     #else
-    <td><input name="entryfield" id="${dataEntryId}" type="text" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+        #if( $dataElement.optionSet )
+          <td><input name="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>
+        #end
     #end
     </td>
     #set( $tabIndex = $tabIndex + 1 )