Author: jleroux
Date: Thu Oct 7 10:16:46 2010
New Revision: 1005395
URL: http://svn.apache.org/viewvc?rev=1005395&view=rev
Log:
Clarifies, improves and generalize getDependentDropdownValues.js.
* Now it's possible to also hide the drop-down field title
* Clarify the inputField usage (now a boolean)
* Allows to use allow-empty="true" on main field (of course dependent field as
well if needed). For that onComplete is used and generalizes
* longer Fade duration (from 1.5 to 2.5) to let enough time to read...
An example of hide+hideField use with setCountryStatesEventJs.ftl.
I should "soon" commit the new Price Rules screen which uses the inputField
parameter for the Quantity condition
Any functional changes as setCountryStatesEventJs.ftl and the
getDependentDropdownValues optional parameters are not used OOTB
Modified:
ofbiz/trunk/framework/common/webcommon/includes/setCountryStatesEventJs.ftl
ofbiz/trunk/framework/images/webapp/images/getDependentDropdownValues.js
Modified:
ofbiz/trunk/framework/common/webcommon/includes/setCountryStatesEventJs.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/includes/setCountryStatesEventJs.ftl?rev=1005395&r1=1005394&r2=1005395&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/webcommon/includes/setCountryStatesEventJs.ftl
(original)
+++ ofbiz/trunk/framework/common/webcommon/includes/setCountryStatesEventJs.ftl
Thu Oct 7 10:16:46 2010
@@ -20,9 +20,9 @@ under the License.
document.observe('dom:loaded', function() {
if ($('${dependentForm}')) {
Event.observe($('${dependentForm}_countryGeoId'), 'change', function()
{
- getDependentDropdownValues('getAssociatedStateList',
'countryGeoId', '${dependentForm}_countryGeoId',
'${dependentForm}_stateProvinceGeoId', 'stateList', 'geoId', 'geoName', '', '');
+ getDependentDropdownValues('getAssociatedStateList',
'countryGeoId', '${dependentForm}_countryGeoId',
'${dependentForm}_stateProvinceGeoId', 'stateList', 'geoId', 'geoName', '', '',
'true', 'true');
});
- getDependentDropdownValues('getAssociatedStateList', 'countryGeoId',
'${dependentForm}_countryGeoId', '${dependentForm}_stateProvinceGeoId',
'stateList', 'geoId', 'geoName', '${selectedStateProvinceGeoId}', '');
+ getDependentDropdownValues('getAssociatedStateList', 'countryGeoId',
'${dependentForm}_countryGeoId', '${dependentForm}_stateProvinceGeoId',
'stateList', 'geoId', 'geoName', '${selectedStateProvinceGeoId}', '', 'true',
'true');
}
})
</script>
Modified:
ofbiz/trunk/framework/images/webapp/images/getDependentDropdownValues.js
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/getDependentDropdownValues.js?rev=1005395&r1=1005394&r2=1005395&view=diff
==============================================================================
--- ofbiz/trunk/framework/images/webapp/images/getDependentDropdownValues.js
(original)
+++ ofbiz/trunk/framework/images/webapp/images/getDependentDropdownValues.js
Thu Oct 7 10:16:46 2010
@@ -17,20 +17,25 @@
* under the License.
*/
-// *** getDependentDropdownValues allows to dynamically populate a dependent
dropdown on change on its parent dropdown, doesn't require any fixed naming
convention
+// *** getDependentDropdownValues allows to dynamically populate a dependent
drop-down on change on its parent drop-down, doesn't require any fixed naming
convention
// request = request calling the service which retrieve the info from the
DB, ex: getAssociatedStateList
// paramKey = parameter value used in the called service
-// paramField = parent dropdown field Id (mainId)
-// targetField = dependend dropdown field Id (dependentId)
+// paramField = parent drop-down field Id (mainId)
+// targetField = dependent drop-down field Id (dependentId)
// responseName = result returned by the service (using a standard json
response, ie chaining json request)
-// keyName = keyName of the dependent dropdown
-// descName = name of the dependent dropdown description
+// keyName = keyName of the dependent drop-down
+// descName = name of the dependent drop-down description
// selected = optional name of a selected option
// callback = optional javascript function called at end
-// inputField = optional name of an input field to use instead of a dropdown
(this will be extended later to use an of autocompleted dropdown, instead of
dropdown or a lookup, when there are too much values to populate)
-// hide = optional argument, if true the dependend dropdown field
(targetField) will be hidden when no options are available else only disabled.
False by default.
-function getDependentDropdownValues(request, paramKey, paramField,
targetField, responseName, keyName, descName, selected, callback, hide) {
- // parameters
+// 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 boolean argument
+// 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) {
var params = new Array();
params[paramKey] = $F(paramField);
@@ -41,12 +46,13 @@ function getDependentDropdownValues(requ
onSuccess: function(transport) {
var data = transport.responseText.evalJSON(true);
list = data[responseName];
- // this is to handle a specific case where an input field is
needed, uses inputField for the field name
- if (!list) {
+ // 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 (else
if allow-empty="true" is used autoComplete handle the case)
+ // this will be maybe extended later to use an autocompleted
drop-down or a lookup, instead of drop-down currently, when there are too much
values to populate
+ if (!list && inputField) {
$(targetField).hide();
$(targetField).insert({after: new
Element('input', {name : arguments[9], id : targetField + '_input', size :
3})});
return;
- } else {
+ } else if (inputField) {
if ($(targetField + '_input')) {
$(targetField + '_input').remove();
$(targetField).show();
@@ -68,25 +74,34 @@ function getDependentDropdownValues(requ
}
}
});
- $(targetField).update(optionList);
if ((list.size() < 1) || ((list.size() == 1) &&
list[0].indexOf("_NA_") >=0)) {
Form.Element.disable(targetField);
if (hide) {
if ($(targetField).visible()) {
- Effect.Fade(targetField,
{duration: 1.5});
- }
+ Effect.Fade(targetField,
{duration: 2.5});
+ if (hideTitle)
Effect.Fade(targetField + '_title', {duration: 2.5});
+ } else {
+ Effect.Appear(targetField, {duration: 0.0});
+ if (hideTitle) Effect.Appear(targetField +
'_title', {duration: 0.0});
+ Effect.Fade(targetField,
{duration: 2.5});
+ if (hideTitle)
Effect.Fade(targetField + '_title', {duration: 2.5});
+ }
}
} else {
Form.Element.enable(targetField);
if (hide) {
if (!$(targetField).visible()) {
Effect.Appear(targetField, {duration: 0.0});
+ if (hideTitle) Effect.Appear(targetField +
'_title', {duration: 0.0});
}
}
}
if (callback != null)
eval(callback);
- }
+ },
+ onComplete: function() {
+ $(targetField).update(optionList);
+ }
});
}