svn commit: r964717 - in /ofbiz/branches/jquery/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: r964717 - in /ofbiz/branches/jquery/framework: images/webapp/images/fieldlookup.js widget/templates/htmlFormMacroLibrary.ftl

jleroux@apache.org
Author: jleroux
Date: Fri Jul 16 08:53:17 2010
New Revision: 964717

URL: http://svn.apache.org/viewvc?rev=964717&view=rev
Log:
A patch from Sascha Rodekamp "Multiple lookups target problem" (https://issues.apache.org/jira/browse/OFBIZ-3845) - OFBIZ-3845

Fix a bug reported by Shubham Dubey on the jQuery branch, steps:
(1) Go to any page having more than one lookup.
(2) Click on any lookup and find the corresponding information and click on tab to select the information.
Any lookup we select, lookup for same lookupId is created, which is for the last lookup.

JLR: I tried locally on default page (https://localhost:8443/catalog/control/login?USERNAME=admin&PASSWORD=ofbiz) and it works well as also confirmed by Shubham

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

Modified: ofbiz/branches/jquery/framework/images/webapp/images/fieldlookup.js
URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/images/webapp/images/fieldlookup.js?rev=964717&r1=964716&r2=964717&view=diff
==============================================================================
--- ofbiz/branches/jquery/framework/images/webapp/images/fieldlookup.js (original)
+++ ofbiz/branches/jquery/framework/images/webapp/images/fieldlookup.js Fri Jul 16 08:53:17 2010
@@ -178,6 +178,83 @@ function initiallyCollapseDelayed() {
 /*************************************
 * Fieldlookup Class & Methods
 *************************************/
+function ConstructLookup(requestUrl, inputFieldId, dialogTarget, dialogOptionalTarget, formName, width, height, position, modal) {
+    // create Link Element with unique Key
+    var lookupId = GLOBAL_LOOKUP_REF.createNextKey();
+
+    var inputBox = document.getElementById(inputFieldId);
+    inputBox.id = lookupId + "_" + inputFieldId;
+    var parent = inputBox.parentNode;
+
+
+    var link = document.createElement('A');
+    link.href = "javascript:void(0);";
+    link.id = lookupId + "_button";
+
+    parent.appendChild(link);
+
+    var hiddenDiv = document.createElement("DIV");
+    hiddenDiv.id = lookupId;
+    hiddenDiv.css = "{display: none;}";
+    hiddenDiv.title = "My Dialog " + lookupId + " --> Target:  " + requestUrl;
+
+    parent.appendChild(hiddenDiv);
+    
+    // Lookup Configuration
+    var dialogOpts = {
+        modal: (modal == "true") ? true : false,
+        bgiframe: true,
+        autoOpen: false,
+        height: (height != "") ? height : 500,
+        width: (width != "") ? width :620,
+        draggable: true,
+        resizeable: true,
+        open: function() {
+            jQuery("#" + lookupId).load(requestUrl);
+        },
+        close: function() {
+            //when the window is closed the prev Lookup get the focus (if exists)
+            var prevLookup = GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).prevLookup;
+            if (prevLookup != null) {
+                identifyLookup(prevLookup);
+            }
+        }
+
+    };
+    
+    // init Dialog and register
+    // create an object with all Lookup Informationes that are needed
+    var dialogRef = jQuery("#" + lookupId).dialog(dialogOpts);
+    
+    //setting up global variabels, for external access
+    this.lookupId = lookupId;
+    this.formName = formName;
+    this.target = null;
+    if (dialogOptionalTarget != null) {
+        this.target2 = null;
+    }
+    ((GLOBAL_LOOKUP_REF.countFields() - 1) >=0) ? this.prevLookup = (GLOBAL_LOOKUP_REF.countFields() - 1) + "_lookupId" : null;
+    this.dialogRef = dialogRef;
+    //write external settings in global window manager
+    GLOBAL_LOOKUP_REF.setReference(lookupId, this);
+    
+    // bind click Event to Dialog button
+    jQuery("#" + lookupId + "_button").click(
+        function (){
+            jQuery("#" + lookupId).dialog("open");
+            jQuery("#" + lookupId).dialog(dialogOpts);
+            GLOBAL_LOOKUP_REF.getReference(lookupId).target = jQuery(dialogTarget);
+            if (dialogOptionalTarget != null) {
+                //the target2 have to be set here, because the input field is not created before
+                GLOBAL_LOOKUP_REF.getReference(lookupId).target2 = jQuery(dialogOptionalTarget);
+            }
+            // thats a quite bad hack to modifay the buttons
+            identifyLookup(lookupId);
+            window.setTimeout("modifySubmitButton('" + lookupId +"')", 800);
+            return false;
+        }
+    );
+}
 
 function FieldLookupCounter() {
  this.refArr = {};

Modified: ofbiz/branches/jquery/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=964717&r1=964716&r2=964717&view=diff
==============================================================================
--- ofbiz/branches/jquery/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/branches/jquery/framework/widget/templates/htmlFormMacroLibrary.ftl Fri Jul 16 08:53:17 2010
@@ -458,108 +458,32 @@ ${item.description}</span>
 <#macro renderLookupField className alert name value size maxlength id event action disabled autocomplete descriptionFieldName formName fieldFormName targetParameterIter imgSrc ajaxUrl ajaxEnabled presentation width height position fadeBackground clearText showDescription initiallyCollapsed>
 <span class="field-lookup">
 <#if size?has_content && size=="0"><input type="hidden" <#if name?has_content> name="${name}"/></#if><#else><input type="text" <@renderClass className alert /><#if name?has_content> name="${name}"</#if><#if value?has_content> value="${value}"</#if><#if size?has_content> size="${size}"</#if><#if maxlength?has_content> maxlength="${maxlength}"</#if><#if id?has_content> id="${id}"</#if><#rt/><#if disabled?has_content && disabled> disabled="disabled"</#if><#rt/><#if event?has_content && action?has_content> ${event}="${action}"</#if><#rt/><#if autocomplete?has_content> autocomplete="off"</#if>/><#rt/></#if>
-    <script type="text/javascript">
-        // create Link Element with unique Key
-        var lookupId = GLOBAL_LOOKUP_REF.createNextKey();
-        var inputBox = document.getElementById("${id}");
-        inputBox.id = lookupId + "_${id}";
-        var parent = inputBox.parentNode;
-
-
-        var link = document.createElement('A');
-        link.href = "javascript:void(0);";
-        link.id = lookupId + "_button";
-
-        parent.appendChild(link);
-
-        var hiddenDiv = document.createElement("DIV");
-        hiddenDiv.id = lookupId;
-        hiddenDiv.css = "{display: none;}";
-        hiddenDiv.title = "My Dialog " + lookupId;
-
-        parent.appendChild(hiddenDiv);
-
-        // Lookup Configuration
-        var dialogOpts = {
-            modal: true,
-            bgiframe: true,
-            autoOpen: false,
-            height: 500,
-            width: 620,
-            draggable: true,
-            resizeable: true,
-            open: function() {
-                jQuery("#" + lookupId).load("${fieldFormName}");
-            },
-            close: function() {
-                //when the window is closed the prev Lookup get the focus (if exists)
-                var prevLookup = GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).prevLookup;
-                if (prevLookup != null) {
-                    identifyLookup(prevLookup);
-                }
-            }
-
-        };
-
-        // init Dialog and register
-        // create an object with all Lookup Informationes that are needed
-        var dialogRef = jQuery("#" + lookupId).dialog(dialogOpts);
-        var ref = function(lookupId) {
-            this.lookupId = lookupId;
-            this.formName = "${formName?html}";
-            this.target = jQuery("form[name=${formName?html}] #" + lookupId + "_${id?html}");
-            <#if descriptionFieldName?has_content>
-            this.target2 = null;
-            </#if>
-            ((GLOBAL_LOOKUP_REF.countFields() - 1) >=0) ? this.prevLookup = (GLOBAL_LOOKUP_REF.countFields() - 1) + "_lookupId" : null;
-            this.dialogRef = dialogRef;
-           };
-        GLOBAL_LOOKUP_REF.setReference(lookupId, new ref(lookupId));
-
-        // bind click Event to Dialog button
-        jQuery("#" + lookupId + "_button").click(
-            function (){
-                jQuery("#" + lookupId).dialog("open");
-                jQuery("#" + lookupId).dialog(dialogOpts);
-                <#if descriptionFieldName?has_content>
-                //the target2 have to be set here, because the input field is not created before
-                GLOBAL_LOOKUP_REF.getReference(lookupId).target2 = jQuery(document.${formName?html}.${descriptionFieldName});
-                </#if>
-                // thats a quite bad hack to modifay the buttons
-                identifyLookup(lookupId)
-                window.setTimeout("modifySubmitButton('" +lookupId +"')", 800);
-                return false;
-            }
-        );
-    </script>
 <#if presentation?has_content && descriptionFieldName?has_content && presentation == "window">
-<#--
-<a href="javascript:call_fieldlookup3(document.${formName?html}.${name?html},document.${formName?html}.${descriptionFieldName},'${fieldFormName}'<#rt/>
+     <a href="javascript:call_fieldlookup3(document.${formName?html}.${name?html},document.${formName?html}.${descriptionFieldName},'${fieldFormName}'<#rt/>
+    <#if targetParameterIter?has_content>
+     <#list targetParameterIter as item>
+    ,document.${formName}.${item}.value<#rt>
+     </#list>
+    </#if>
+    );"></a><#rt>
 <#elseif presentation?has_content && presentation == "window">
- <a href="javascript:call_fieldlookup2(document.${formName}.${name},'${fieldFormName}'<#rt/>
-<#elseif descriptionFieldName?has_content>
- <button id="open${formName?html}.${name?html}"></button>
- <script>
-     $("#open${formName?html}.${name?html}").dialog();
-
- </script>
- <a href="javascript:call_fieldlookupLayer3(document.${formName?html}.${name?html},document.${formName?html}.${descriptionFieldName},'${fieldFormName}','${width}','${height}','${position}','${fadeBackground}','${initiallyCollapsed}'<#rt/>
+     <a href="javascript:call_fieldlookup2(document.${formName}.${name},'${fieldFormName}'<#rt/>
+    <#if targetParameterIter?has_content>
+     <#list targetParameterIter as item>
+    ,document.${formName}.${item}.value<#rt>
+     </#list>
+    </#if>
+    );"></a><#rt>
 <#else>
- <a href="javascript:call_fieldlookupLayer(document.${formName?html}.${name?html},'${fieldFormName}','${width}','${height}','${position}','${fadeBackground}','${initiallyCollapsed}'<#rt/>
-</#if>
-<#if targetParameterIter?has_content>
- <#list targetParameterIter as item>
-,document.${formName}.${item}.value<#rt>
- </#list>
+    <script type="text/javascript">
+        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}");
+    </script>
 </#if>
-);"></a><#rt>
 <#if disabled?has_content && disabled><a id="${id}_clear" style="background:none;margin-left:5px;margin-right:15px;" class="clearField" href="javascript:void();" onclick="javascript:document.${formName}.${name}.value='';<#if descriptionFieldName?has_content>document.${formName}.${descriptionFieldName}.value='';</#if>">${clearText}</a></#if>
 </span>
 <#if ajaxEnabled?has_content && ajaxEnabled>
     <script language="JavaScript" type="text/javascript">ajaxAutoCompleter('${ajaxUrl}', ${showDescription});</script><#t/>
 </#if>
--->
-</#if>
 </#macro>
 
 <#macro renderNextPrev paginateStyle paginateFirstStyle viewIndex highIndex listSize viewSize ajaxEnabled javaScriptEnabled ajaxFirstUrl firstUrl paginateFirstLabel paginatePreviousStyle ajaxPreviousUrl previousUrl paginatePreviousLabel pageLabel ajaxSelectUrl selectUrl ajaxSelectSizeUrl selectSizeUrl commonDisplaying paginateNextStyle ajaxNextUrl nextUrl paginateNextLabel paginateLastStyle ajaxLastUrl lastUrl paginateLastLabel paginateViewSizeLabel>