← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7528: Only view top 30 data elements in the Add and Update Query Builder.

 

------------------------------------------------------------
revno: 7528
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-07-06 22:37:11 +0700
message:
  Only view top 30 data elements in the Add and Update Query Builder.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseAggerateDataElement.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.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-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java	2012-05-06 18:55:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java	2012-07-06 15:37:11 +0000
@@ -427,7 +427,9 @@
     int getDataElementGroupCount();
 
     int getDataElementGroupCountByName( String name );
-
+    
+    Collection<DataElement> getDataElements( DataSet dataSet, String key, Integer max );
+    
     // -------------------------------------------------------------------------
     // DataElementGroupSet
     // -------------------------------------------------------------------------
@@ -485,5 +487,5 @@
      * @return a collection of all Operands.
      */
     Collection<DataElementOperand> getAllGeneratedOperands( Collection<DataElement> dataElements );
-
+    
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java	2012-04-03 10:24:37 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java	2012-07-06 15:37:11 +0000
@@ -172,6 +172,8 @@
 
     Map<Integer, Set<Integer>> getDataElementCategoryOptionCombos();
     
+    Collection<DataElement> get( DataSet dataSet, String key, Integer max );
+    
     // -------------------------------------------------------------------------
     // DataElementOperand
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2012-05-06 18:55:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2012-07-06 15:37:11 +0000
@@ -344,6 +344,11 @@
         return dataElementStore.getDataElementCategoryOptionCombos();
     }
     
+    public Collection<DataElement> getDataElements( DataSet dataSet, String key, Integer max )
+    {
+        return dataElementStore.get( dataSet, key, max );
+    }
+    
     // -------------------------------------------------------------------------
     // DataElementGroup
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java	2012-02-06 09:32:02 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java	2012-07-06 15:37:11 +0000
@@ -271,7 +271,23 @@
         
         return sets;
     }
-
+    
+    @SuppressWarnings( "unchecked" )
+    public Collection<DataElement> get( DataSet dataSet, String key, Integer max )
+    {
+        String hql = "select dataElement from DataSet dataSet inner join dataSet.dataElements as dataElement where dataSet.id = :dataSetId ";
+        if( key != null )
+        {
+            hql += " and lower(dataElement.name) like lower('%" + key + "%') ";
+        }
+        
+        Query query = getQuery( hql );
+        query.setInteger( "dataSetId", dataSet.getId() );
+        query.setMaxResults( max );
+        
+        return query.list();
+    }
+    
     // -------------------------------------------------------------------------
     // DataElementOperand
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2012-06-13 03:59:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2012-07-06 15:37:11 +0000
@@ -565,7 +565,6 @@
 			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
 	</bean>
 
-
 	<bean
 		id="org.hisp.dhis.patient.action.caseaggregation.GetAggPSDataElementsAction"
 		class="org.hisp.dhis.patient.action.caseaggregation.GetAggPSDataElementsAction"
@@ -666,6 +665,14 @@
 			<ref bean="org.hisp.dhis.caseaggregation.CaseAggregationConditionService" />
 		</property>
 	</bean>
+	
+	<bean
+		id="org.hisp.dhis.patient.action.caseaggregation.GetDataElementsByDataSetAction"
+		class="org.hisp.dhis.patient.action.caseaggregation.GetDataElementsByDataSetAction"
+		scope="prototype">
+		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+	</bean>
 
 	<!-- Validation - PatientValidationCriteria -->
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2012-06-13 03:59:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2012-07-06 15:37:11 +0000
@@ -593,7 +593,7 @@
 				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
 		</action>
 
-		<action name="getDataElementsByDataset" class="org.hisp.dhis.commons.action.GetDataSetAction">
+		<action name="getDataElementsByDataset" class="org.hisp.dhis.patient.action.caseaggregation.GetDataElementsByDataSetAction">
 			<result name="success" type="velocity-json">
 				/dhis-web-maintenance-patient/responseAggerateDataElement.vm
 			</result>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm	2012-06-04 04:06:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm	2012-07-06 15:37:11 +0000
@@ -35,9 +35,9 @@
     <tr>
 		<td><label for="dataElement">$i18n.getString( "dataelement" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
 		<td>			
-			<select id="aggregationDataElementId" name="aggregationDataElementId" class="{validate:{required:true}} hidden" ></select>
-			<input id="aggregationDataElementInput" name="aggregationDataElementInput" style='width:303px'>
-			<button type='button' id='dataElementsButton' class='arrow-down' disabled>&nbsp;</button>
+			<input type='hidden' id="aggregationDataElementId" name="aggregationDataElementId" class="{validate:{required:true}}" >
+			<input id="aggregationDataElementInput" name="aggregationDataElementInput" style='width:290px'>
+			<button type='button' id='dataElementsButton' class='ui-icon-triangle-1-s' disabled>&nbsp;</button>
 		</td>
 	</tr>
 	

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js	2012-06-04 04:06:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js	2012-07-06 15:37:11 +0000
@@ -7,67 +7,43 @@
 {
 	var dataSets = document.getElementById( 'dataSets' );
 	var dataSetId = dataSets.options[ dataSets.selectedIndex ].value;
-	clearListById('aggregationDataElementId');
+	setFieldValue('aggregationDataElementId','');
 	
 	if( dataSetId == "" ){
 		disable( 'dataElementsButton' );
 		setFieldValue( 'aggregationDataElementInput','');
 		return;
 	}
-
-	jQuery.getJSON( 'getDataElementsByDataset.action', 
-		{ 
-			id:dataSetId 
-		}, function( json )
-        {
-			var de = byId( 'aggregationDataElementId' );
-			clearListById( 'aggregationDataElementId' );
-		  
-			for ( i in json.dataElements ) 
-			{ 
-				var id = json.dataElements[i].id;
-				var name = json.dataElements[i].name;
-
-				var option = document.createElement("option");
-				option.value = id;
-				option.text = name;
-				option.title = name;
-				
-				de.add(option, null);  			
-			}
-			
-			autoCompletedField();
-		});
+	autoCompletedField();
 }
 
 function autoCompletedField()
 {
-	var select = jQuery( "#aggregationDataElementId" );
 	$( "#dataElementsButton" ).unbind('click');
 	enable( 'dataElementsButton' );
-	var selected = select.children( ":selected" );
-	var value = selected.val() ? selected.text() : "";
 	
 	var input = jQuery( "#aggregationDataElementInput" )
-		.insertAfter( select )
-		.val( value )
 		.autocomplete({
 			delay: 0,
 			minLength: 0,
-			source: function( request, response ) {
-				var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
-				response( select.children( "option" ).map(function() {
-					var text = $( this ).text();
-					if ( this.value && ( !request.term || matcher.test(text) ) )
-						return {
-							label: text,
-							value: text,
-							option: this
-						};
-				}) );
+			source: function( request, response ){
+				$.ajax({
+					url: "getDataElementsByDataset.action?id=" + getFieldValue('dataSets') + "&query=" + input.val(),
+					dataType: "json",
+					success: function(data) {
+						response($.map(data.dataElements, function(item) {
+							return {
+								label: item.name,
+								id: item.id
+							};
+						}));
+					}
+				});
 			},
 			select: function( event, ui ) {
-				ui.item.option.selected = true;
+				input.val(ui.item.value);
+				setFieldValue('aggregationDataElementId',ui.item.id);
+				input.autocomplete( "close" );
 			},
 			change: function( event, ui ) {
 				if ( !ui.item ) {
@@ -88,17 +64,16 @@
 					}
 				}
 			}
-		});
-
-	input.data( "autocomplete" )._renderItem = function( ul, item ) {
-		return $( "<li></li>" )
-			.data( "item.autocomplete", item )
-			.append( "<a>" + item.label + "</a>" )
-			.appendTo( ul );
-	};
-
-	/* var button = $( "#dataElementsButton" )
+		}).addClass( "ui-widget" );
+
+	var button = $( "#dataElementsButton" )
 		.attr( "title", i18n_show_all_items )
+		.button({
+			icons: {
+				primary: "ui-icon-triangle-1-s"
+			},
+			text: false
+		})
 		.click(function() {
 			// close if already visible
 			if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
@@ -112,7 +87,7 @@
 			// pass empty string as value to search for, displaying all results
 			input.autocomplete( "search", "" );
 			input.focus();
-		}); */
+		});
 }
 
 //------------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseAggerateDataElement.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseAggerateDataElement.vm	2012-03-13 08:24:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/responseAggerateDataElement.vm	2012-07-06 15:37:11 +0000
@@ -1,7 +1,7 @@
-#set( $size = $dataSet.dataElements.size() )
+#set( $size = $dataElements.size() )
 { 
 	"dataElements": [
-		#foreach( $dataElement in $dataSet.dataElements )
+		#foreach( $dataElement in $dataElements )
 			#set( $subSize = $dataElement.categoryCombo.optionCombos.size() )
 			#foreach ( $optionCombo in $dataElement.categoryCombo.optionCombos )
 			{

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm	2012-06-04 04:06:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm	2012-07-06 15:37:11 +0000
@@ -34,11 +34,9 @@
     <tr>
 		<td><label for="dataElement">$i18n.getString( "dataelement" )<em title="$i18n.getString( "required" )" class="required">*</em></label></td>
 		<td>
-			<select id="aggregationDataElementId" name="aggregationDataElementId" class="{validate:{required:true}} hidden" >
-				<option value="$caseAggregation.aggregationDataElement.id.$caseAggregation.optionCombo.id">$caseAggregation.aggregationDataElement.name $caseAggregation.optionCombo.name</option>
-			</select>
+			<input id="aggregationDataElementId" name="aggregationDataElementId" value="$caseAggregation.aggregationDataElement.id.$caseAggregation.optionCombo.id" class="{validate:{required:true}} hidden" >
 			<input id="aggregationDataElementInput" name="aggregationDataElementInput" value='$caseAggregation.aggregationDataElement.name $caseAggregation.optionCombo.name' style='width:303px'>
-			<button type='button' id='dataElementsButton' class='arrow-down' disabled>&nbsp;</button>
+			<button type='button' id='dataElementsButton' disabled>&nbsp;</button>
 		</td>				
 	</tr>
 	<tr>