← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10944: fix issues with slow optionset search, too many LIs was appended to the DOM which made it slow. S...

 

------------------------------------------------------------
revno: 10944
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-05-23 09:42:12 +0700
message:
  fix issues with slow optionset search, too many LIs was appended to the DOM which made it slow. Showing a maximum of 30 search hits now, to align with searchoptionsaction
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.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/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-05-21 03:27:20 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-05-23 02:42:12 +0000
@@ -933,11 +933,17 @@
                 } else {
                     query = query.toLowerCase();
 
-                    _.each(obj.optionSet.options, function(item, idx) {
+                    for ( var idx=0, len = obj.optionSet.options.length; idx < len; idx++ ) {
+                        var item = obj.optionSet.options[idx];
+
+                        if ( options.length >= MAX_DROPDOWN_DISPLAYED ) {
+                            break;
+                        }
+
                         if ( item.toLowerCase().indexOf( query ) != -1 ) {
-                            options.push(item);
+                            options.push( item );
                         }
-                    });
+                    }
                 }
 
                 success( $.map( options, function ( item ) {

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2013-05-21 06:54:08 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2013-05-23 02:42:12 +0000
@@ -2234,11 +2234,17 @@
                 } else {
                     query = query.toLowerCase();
 
-                    _.each(obj.optionSet.options, function(item, idx) {
+                    for ( var idx=0, len = obj.optionSet.options.length; idx < len; idx++ ) {
+                        var item = obj.optionSet.options[idx];
+
+                        if ( options.length >= MAX_DROPDOWN_DISPLAYED ) {
+                            break;
+                        }
+
                         if ( item.toLowerCase().indexOf( query ) != -1 ) {
-                            options.push(item);
+                            options.push( item );
                         }
-                    });
+                    }
                 }
 
                 success( $.map( options, function ( item ) {