svn commit: r1438501 - /ofbiz/trunk/framework/images/webapp/images/miscAjaxFunctions.js

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1438501 - /ofbiz/trunk/framework/images/webapp/images/miscAjaxFunctions.js

jleroux@apache.org
Author: jleroux
Date: Fri Jan 25 13:27:54 2013
New Revision: 1438501

URL: http://svn.apache.org/viewvc?rev=1438501&view=rev
Log:
A patch from Taher Alkhateeb for "Corrections and improvements to dependent drop-downs" https://issues.apache.org/jira/browse/OFBIZ-5126

* The getDependentDropdownValues function in miscAjaxFunctions.js is modified with a new argument to allow for empty selections. Therefore, copying the behavior of form widget drop-down's "allow-empty"
* There is only one file affected by item number 2 above, therefore, I fixed it to include the argument in getDependentDropdownValues

Modified:
    ofbiz/trunk/framework/images/webapp/images/miscAjaxFunctions.js

Modified: ofbiz/trunk/framework/images/webapp/images/miscAjaxFunctions.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/miscAjaxFunctions.js?rev=1438501&r1=1438500&r2=1438501&view=diff
==============================================================================
--- ofbiz/trunk/framework/images/webapp/images/miscAjaxFunctions.js (original)
+++ ofbiz/trunk/framework/images/webapp/images/miscAjaxFunctions.js Fri Jan 25 13:27:54 2013
@@ -26,13 +26,14 @@
 // descName     = name of the dependent drop-down description
 // selected     = optional name of a selected option
 // callback     = optional javascript function called at end
+// allowEmpty   = optional boolean argument, allow selection of an empty value for the dependentId
 // hide         = optional boolean argument, if true the dependent drop-down field (targetField) will be hidden when no options are available else only disabled. False by default.
 // hideTitle    = optional boolean argument (hide must be set to true), if true the title of the dependent drop-down field (targetField) will be hidden when no options are available else only disabled. False by default.
 // inputField   = optional name of an input field    
 //  this is to handle a specific case where an input field is needed instead of a drop-down when no values are returned by the request
 //  this will be maybe extended later to use an auto-completed drop-down or a lookup, instead of straight drop-down currently, when there are too much values to populate
 //  this is e.g. currently used in the Product Price Rules screen
-function getDependentDropdownValues(request, paramKey, paramField, targetField, responseName, keyName, descName, selected, callback, hide, hideTitle, inputField){
+function getDependentDropdownValues(request, paramKey, paramField, targetField, responseName, keyName, descName, selected, callback, allowEmpty, hide, hideTitle, inputField){
     target = '#' + targetField;
     input = '#' + inputField;
     targetTitle = target + '_title'
@@ -49,6 +50,14 @@ function getDependentDropdownValues(requ
             list = result[responseName];
             // Create and show dependent select options            
             if (list) {
+                if(allowEmpty) {
+                    // Allow null selection in dependent and set it as default if no selection exists.
+                    if (selected == undefined || selected == "_none_") {
+                      optionList += "<option selected='selected' value=''></option>";
+                    } else {
+                      optionList += "<option value=''></option>";
+                    }
+                }
                 jQuery.each(list, function(key, value){
                     if (typeof value == 'string') {
                         values = value.split(': ');