← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10613: minor change for autocompletes in data entry

 

------------------------------------------------------------
revno: 10613
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-04-18 15:47:00 +0700
message:
  minor change for autocompletes in data entry
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.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-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java	2013-04-17 08:45:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java	2013-04-18 08:47:00 +0000
@@ -47,7 +47,6 @@
 public class SaveValueAction
     implements Action
 {
-
     private static final Log LOG = LogFactory.getLog( SaveValueAction.class );
 
     // -------------------------------------------------------------------------

=== 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	2013-04-17 06:46:31 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-04-18 08:47:00 +0000
@@ -815,6 +815,22 @@
 		});
 }
 
+function searchOptionSet( uid, query, success ) {
+    $.ajax({
+        url: "getOptions.action?id=" + uid + "&query=" + query,
+        dataType: "json",
+        cache: true,
+        success: function(data) {
+            success($.map(data.options, function(item) {
+                return {
+                    label: item.o,
+                    id: item.o
+                };
+            }));
+        }
+    });
+}
+
 function autocompletedField( idField )
 {
 	var input = jQuery( "#" +  idField );
@@ -825,19 +841,7 @@
 		delay: 0,
 		minLength: 0,
 		source: function( request, response ){
-			$.ajax({
-				url: "getOptions.action?id=" + dataElementUid + "&query=" + input.val(),
-				dataType: "json",
-				cache: true,
-				success: function(data) {
-					response($.map(data.options, function(item) {
-						return {
-							label: item.o,
-							id: item.o
-						};
-					}));
-				}
-			});
+            searchOptionSet( dataElementUid, input.val(), response );
 		},
 		minLength: 0,
 		select: function( event, ui ) {
@@ -903,6 +907,22 @@
 		});
 }
 
+function searchUsername( query, success ) {
+    $.ajax({
+        url: "getUsernameList.action?query=" + query,
+        dataType: "json",
+        cache: true,
+        success: function(data) {
+            success($.map(data.usernames, function(item) {
+                return {
+                    label: item.u,
+                    id: item.u
+                };
+            }));
+        }
+    });
+}
+
 function autocompletedUsernameField( idField )
 {
 	var input = jQuery( "#" +  idField );
@@ -913,19 +933,7 @@
 		delay: 0,
 		minLength: 0,
 		source: function( request, response ){
-			$.ajax({
-				url: "getUsernameList.action?query=" + input.val(),
-				dataType: "json",
-				cache: true,
-				success: function(data) {
-					response($.map(data.usernames, function(item) {
-						return {
-							label: item.u,
-							id: item.u
-						};
-					}));
-				}
-			});
+            searchUsername( input.val(), response );
 		},
 		minLength: 0,
 		select: function( event, ui ) {