← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3573: first version of select (multiple) filter

 

------------------------------------------------------------
revno: 3573
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-05-11 10:39:58 +0200
message:
  first version of select (multiple) filter
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.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-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js	2011-05-10 20:24:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js	2011-05-11 08:39:58 +0000
@@ -18,21 +18,38 @@
 function localFilterSelectList( filter )
 {
 	if( jQuery("#dataElementsTab").is(":visible") ) {
-		filterSelectList( "#dataElementSelector", filter )
+		filterSelectList( "dataElementSelector", filter )
 	} else {
-		filterSelectList( "#indicatorSelector", filter )
+		filterSelectList( "indicatorSelector", filter )
 	}
 }
 
-function filterSelectList( selector, filter )
+function filterSelectList( select_id, filter )
 {
-	$(selector).find("option").each(function() {
-		var val = $(this).val().toLowerCase();
-		
+	var select_selector = "#" + select_id;
+	var select_hidden_id = select_id + "_ghost"
+	var select_hidden_selector = "#" + select_hidden_id;
+
+	if( $(select_hidden_selector).length === 0 ) {
+		var $element = $("<select multiple=\"multiple\" id=\"" + select_hidden_id + "\" style=\"display: none\"></select>");
+		$element.appendTo( "body" );
+	}
+
+	$(select_selector).find("option").each(function() {
+		var val = $(this).val().toLowerCase();
+
+		if(val.indexOf( filter ) == -1) {
+			var $option = $(this).detach();
+			$option.appendTo( select_hidden_selector );
+		}
+	});
+
+	$(select_hidden_selector).find("option").each(function() {
+		var val = $(this).val().toLowerCase();
+
 		if(val.indexOf( filter ) != -1) {
-			$(this).removeAttr("disabled");
-		} else {
-			$(this).attr("disabled", "true");
+			var $option = $(this).detach();
+			$option.appendTo( select_selector );
 		}
 	});
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm	2011-05-11 08:00:21 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm	2011-05-11 08:39:58 +0000
@@ -185,6 +185,7 @@
 					<select id="dataElementSelector" multiple="multiple" style="height: 150px; width: 100%; margin: 1px;">
 					#foreach( $operand in $operands )
 						<option class="dataElementSelectorOption"
+								data-idx="${velocityCount}"
 								data-dataelement-id="$operand.dataElement.id" data-dataelement-name="$operand.dataElement.name" data-dataelement-type="$operand.dataElement.type"
 								data-optioncombo-id="$operand.categoryOptionCombo.id" data-optioncombo-name="$operand.categoryOptionCombo.name" ondblclick="insertDataElement()">
 							$encoder.htmlEncode( $operand.operandName )
@@ -199,7 +200,7 @@
 					<select id="indicatorSelector" multiple="multiple" style="height: 150px; width: 100%; margin: 1px;">
 					#foreach( $indicator in $indicators )
 						<option class="indicatorSelectorOption"
-								data-id="${indicator.id}" ondblclick="insertIndicator()">$encoder.htmlEncode( $indicator.name )</option>
+								data-idx="${velocityCount}" data-id="${indicator.id}" ondblclick="insertIndicator()">$encoder.htmlEncode( $indicator.name )</option>
 					#end
 					</select>
 				</td>