svn commit: r1062709 - in /ofbiz/trunk/framework: images/webapp/images/fieldlookup.js widget/templates/htmlFormMacroLibrary.ftl

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

svn commit: r1062709 - in /ofbiz/trunk/framework: images/webapp/images/fieldlookup.js widget/templates/htmlFormMacroLibrary.ftl

jleroux@apache.org
Author: jleroux
Date: Mon Jan 24 09:55:17 2011
New Revision: 1062709

URL: http://svn.apache.org/viewvc?rev=1062709&view=rev
Log:
A patch from Leon "In layer mode, the attribute "target-parameter" of a lookup field is not used" (https://issues.apache.org/jira/browse/OFBIZ-3954) - OFBIZ-3954

As xsd describes, "target-parameter" of a lookup field can be used to transfer extra parameters to lookup something. But if we choose "layer" mode (the default mode of lookup), this attribute does nothing. It works before jQuery introduced. I guess this feature is forgot by mistake during migration.

JLR: Nice catch! Actually IIRW it's because this has been introduced in trunk after we migrated this part in the jQuery branch and it passed "hidden" when I merged the trunk in branch.

Modified:
    ofbiz/trunk/framework/images/webapp/images/fieldlookup.js
    ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl

Modified: ofbiz/trunk/framework/images/webapp/images/fieldlookup.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/fieldlookup.js?rev=1062709&r1=1062708&r2=1062709&view=diff
==============================================================================
--- ofbiz/trunk/framework/images/webapp/images/fieldlookup.js (original)
+++ ofbiz/trunk/framework/images/webapp/images/fieldlookup.js Mon Jan 24 09:55:17 2011
@@ -180,7 +180,7 @@ function initiallyCollapseDelayed() {
 /*************************************
 * Fieldlookup Class & Methods
 *************************************/
-function ConstructLookup(requestUrl, inputFieldId, dialogTarget, dialogOptionalTarget, formName, width, height, position, modal, ajaxUrl, showDescription, presentation) {
+function ConstructLookup(requestUrl, inputFieldId, dialogTarget, dialogOptionalTarget, formName, width, height, position, modal, ajaxUrl, showDescription, presentation, args) {
     
     // add the presentation attribute to the request url to let the request know which decorator should be loaded
     if(!presentation) {
@@ -244,7 +244,13 @@ function ConstructLookup(requestUrl, inp
         draggable: true,
         resizeable: true,
         open: function() {
-            jQuery("#" + lookupId).load(requestUrl, function(data){
+            var requestUrlAndArgs = requestUrl;
+            if (typeof args == "object" && jQuery.isArray(args)) {
+                for (var i = 0; i < args.length; i++) {
+                        requestUrlAndArgs += "&parm" + i + "=" + jQuery(args[i]).val();
+                }
+            }
+            jQuery("#" + lookupId).load(requestUrlAndArgs, function(data){
                 modifySubmitButton(lookupId);
                 // set up the window chaining
                 // if the ACTIVATED_LOOKUP var is set there have to be more than one lookup,

Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=1062709&r1=1062708&r2=1062709&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Mon Jan 24 09:55:17 2011
@@ -516,7 +516,21 @@ jQuery(document).ready(function(){
     </#if>
     <script type="text/javascript">
         jQuery(document).ready(function(){
-            new ConstructLookup("${fieldFormName}", "${id}", document.${formName?html}.${name?html}, <#if descriptionFieldName?has_content>document.${formName?html}.${descriptionFieldName}<#else>null</#if>, "${formName?html}", "${width}", "${height}", "${position}", "${fadeBackground}", <#if ajaxEnabled?has_content && ajaxEnabled>"${ajaxUrl}", "${showDescription}"<#else>"", ""</#if>, '${presentation!}');
+            new ConstructLookup("${fieldFormName}", "${id}", document.${formName?html}.${name?html}, <#if descriptionFieldName?has_content>document.${formName?html}.${descriptionFieldName}<#else>null</#if>, "${formName?html}", "${width}", "${height}", "${position}", "${fadeBackground}", <#if ajaxEnabled?has_content && ajaxEnabled>"${ajaxUrl}", "${showDescription}"<#else>"", ""</#if>, '${presentation!}'<#rt/>
+    <#if targetParameterIter?has_content>
+      <#assign isFirst = true>
+      <#lt/>, [<#rt/>
+      <#list targetParameterIter as item>
+        <#if isFirst>
+          <#lt/>document.${formName}.${item}<#rt/>
+        <#else>
+          <#lt/> ,document.${formName}.${item}<#rt/>
+          <#assign isFirst = false>
+        </#if>
+      </#list>
+      <#lt/>]<#rt/>
+    </#if>
+            <#lt/>);
         });
     </script>
 </#if>