← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7380: Only load 10 option-values for dataelement in entry form.

 

------------------------------------------------------------
revno: 7380
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-06-25 20:20:32 +0700
message:
  Only load 10 option-values for dataelement in entry form.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/DefaultOptionService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/hibernate/HibernateOptionStore.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetOptionsByDataElementAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css


--
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/option/OptionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionService.java	2012-06-15 04:41:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionService.java	2012-06-25 13:20:32 +0000
@@ -51,5 +51,5 @@
 
     Collection<OptionSet> getAllOptionSets();
     
-    List<String> getOptions( OptionSet optionSet, String key  );
+    List<String> getOptions( OptionSet optionSet, String key, Integer max  );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionStore.java	2012-06-24 09:35:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionStore.java	2012-06-25 13:20:32 +0000
@@ -38,5 +38,6 @@
  */
 public interface OptionStore extends GenericIdentifiableObjectStore<OptionSet>
 {
-    List<String> getOptions( OptionSet optionSet, String key, int max  );
+    List<String> getOptions( OptionSet optionSet, String key, Integer max  );
 }
+

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/DefaultOptionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/DefaultOptionService.java	2012-06-24 09:35:28 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/DefaultOptionService.java	2012-06-25 13:20:32 +0000
@@ -81,8 +81,8 @@
         return optionStore.getAll();
     }
     
-    public List<String> getOptions( OptionSet optionSet, String key  )
+    public List<String> getOptions( OptionSet optionSet, String key, Integer max  )
     {
-        return optionStore.getOptions( optionSet, key, 100 );
+        return optionStore.getOptions( optionSet, key, max );
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/hibernate/HibernateOptionStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/hibernate/HibernateOptionStore.java	2012-06-24 09:35:28 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/option/hibernate/HibernateOptionStore.java	2012-06-25 13:20:32 +0000
@@ -45,12 +45,17 @@
 {
     @SuppressWarnings("unchecked")
     @Override
-    public List<String> getOptions( OptionSet optionSet, String key, int max )
+    public List<String> getOptions( OptionSet optionSet, String key, Integer max )
     {
-        String hql = "select option from OptionSet as optionset inner join optionset.options as option where optionset.id = :optionSetId and lower(option) like lower('%" + key + "%') ";
-
+        String hql = "select option from OptionSet as optionset inner join optionset.options as option where optionset.id = :optionSetId ";
+        if( key != null )
+        {
+            hql += " and lower(option) like lower('%" + key + "%') ";
+        }
+        
         Query query = getQuery( hql );
         query.setInteger( "optionSetId", optionSet.getId() );
+        query.setMaxResults( max );
         
         return query.list();
     }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetOptionsByDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetOptionsByDataElementAction.java	2012-06-20 06:32:51 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetOptionsByDataElementAction.java	2012-06-25 13:20:32 +0000
@@ -43,6 +43,8 @@
 public class GetOptionsByDataElementAction
     implements Action
 {
+    private static Integer MAX_OPTIONS_DISPLAYED = 10;
+    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -98,8 +100,8 @@
     {
         DataElement dataElement = dataElementService.getDataElement( id );
 
-        options = optionService.getOptions( dataElement.getOptionSet(), query );
-
+        options = optionService.getOptions( dataElement.getOptionSet(), query, MAX_OPTIONS_DISPLAYED );
+       
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2012-06-23 11:05:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2012-06-25 13:20:32 +0000
@@ -814,6 +814,7 @@
 {
 	var input = jQuery( "#" +  idField )
 	var dataElementId = input.attr('id').split('-')[1];
+	
 	input.autocomplete({
 		delay: 0,
 		minLength: 0,
@@ -831,7 +832,7 @@
 				}
 			});
 		},
-		minLength: 2,
+		minLength: 0,
 		select: function( event, ui ) {
 			input.val(ui.item.value);
 			saveVal( dataElementId );
@@ -852,4 +853,25 @@
 		}
 	})
 	.addClass( "ui-widget" );
+	
+	var button = $( "<button>&nbsp;</button>" )
+		.attr( "tabIndex", -1 )
+		.attr( "title", i18n_show_all_items )
+		.insertAfter( input )
+		.button({
+			icons: {
+				primary: "ui-icon-triangle-1-s"
+			},
+			text: false
+		})
+		.addClass( "small-button" )
+		.click(function() {
+			if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
+				input.autocomplete( "close" );
+				return;
+			}
+			$( this ).blur();
+			input.autocomplete( "search", "" );
+			input.focus();
+		});
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css	2012-06-25 03:19:12 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css	2012-06-25 13:20:32 +0000
@@ -167,8 +167,9 @@
 	height:20px; 
 }
 
-.optionset-small-button{
-	font-size: .8em !important;
+.ui-button{
+	max-height: 100px;
+	max-height: 100px;
 }
 
 .ui-autocomplete {