← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18543: Fixed bug - list of available DE includes already selected DE.

 

------------------------------------------------------------
revno: 18543
committer: Tran Chau<tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-03-10 14:43:30 +0700
message:
  Fixed bug - list of available DE includes already selected DE.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroupEditorView.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-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroupEditorView.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroupEditorView.js	2014-08-28 09:15:48 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroupEditorView.js	2015-03-10 07:43:30 +0000
@@ -26,9 +26,16 @@
 
         if ( text.toLowerCase().indexOf( filter_1.toLowerCase() ) != -1 )
         {
-            list_1.append( '<option value="' + id + '">' + text + '</option>' );
-            list_2.append( '<option value="' + id + '">' + text + '</option>' );
-        }
+			if( !checkSelectedDataElement( id ) )
+			{
+				list_1.append( '<option value="' + id + '">' + text + '</option>' );
+			}
+		}
+		
+		if ( text.toLowerCase().indexOf( filter_2.toLowerCase() ) != -1 )
+        {
+			list_2.append( '<option value="' + id + '">' + text + '</option>' );
+		}
     }
 
 	sortList( 'availableDataElements', 'ASC' );
@@ -37,6 +44,30 @@
     list_2.find( ":first" ).attr( "selected", "selected" );
 }
 
+function checkSelectedDataElement( deId )
+{
+	var list_selected = jQuery( "#selectedDataElements_storage" ).children();	
+	var selectedDataElements = jQuery( "#view_1 #selectedDataElements" ).children();
+
+	$.each( selectedDataElements, function( i_de, item_de )
+	{
+		list_selected.push( item_de );
+	});
+
+	var returnStatus = false;
+	
+	jQuery.each( list_selected, function( i, item )
+	{
+		if ( item.value == deId )
+		{
+			returnStatus = true;
+			return false;  // same as break;
+		}
+	} );
+	
+	return returnStatus;
+}
+
 function loadAvailableGroups()
 {
     var filter_1 = jQuery( '#view_1 #dataElementGroupsFilter' ).val();