← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17524: Data entry, added a [No value] option to autocomplete drop-downs to make it simpler to remove exi...

 

------------------------------------------------------------
revno: 17524
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-11-18 15:45:40 +0100
message:
  Data entry, added a [No value] option to autocomplete drop-downs to make it simpler to remove existing values and not use backspace
modified:
  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-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	2014-11-18 14:05:39 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-11-18 14:45:40 +0000
@@ -2814,12 +2814,14 @@
  */
 dhis2.de.searchOptionSet = function( uid, query, success ) 
 {
+	var noneVal = '[No value]';
+	
     if ( window.DAO !== undefined && window.DAO.store !== undefined ) {
         DAO.store.get( 'optionSets', uid ).done( function ( obj ) {
             if ( obj && obj.optionSet ) {
                 var options = [];
 
-                if ( query == null || query == '' ) {
+                if ( query == null || query == '' || query == noneVal ) {
                     options = obj.optionSet.options.slice( 0, dhis2.de.cst.dropDownMaxItems - 1 );
                 } 
                 else {
@@ -2837,6 +2839,10 @@
                         }
                     }
                 }
+                
+                if ( options && options.length > 0 ) {
+                	options.push( { name: noneVal, code: '' } );
+                }
 
                 success( $.map( options, function ( item ) {
                     return {