You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2013/06/11 22:12:37 UTC

svn commit: r1491936 - in /ofbiz/trunk/framework: images/webapp/images/fieldlookup.js widget/dtd/widget-form.xsd widget/src/org/ofbiz/widget/form/MacroFormRenderer.java widget/src/org/ofbiz/widget/form/ModelFormField.java

Author: jleroux
Date: Tue Jun 11 20:12:37 2013
New Revision: 1491936

URL: http://svn.apache.org/r1491936
Log:
A slightly modified patch from Leon for <<Make "showDescription" of <lookup> filed configurable individually>> https://issues.apache.org/jira/browse/OFBIZ-5211

For now, It's configured globally through "widget.lookup.showDescription" in widget.properties. 
In some case, we want to disable this feature for particular <lookup> filed. So we try to make it enabled.

1. update the widget-form.xsd to add new attribute "show-description" to <lookup> filed
  * if set this attribute explicitly to true or false, then showDescription feature is enabled or disabled respectively
  * if this attribute is not set (default), then showDescription or not depends on the "widget.lookup.showDescription" setting
2. modify ModelFormField and MacroFormRenderer to make it works
3. Since we introduce individual "showDescription" configuration, the global "SHOW_DESCRIPTION" was unable to work properly. It has been replaced by dynamic values
4. Show description function depends on ajax-autocompleter, but not vice versa. That's why the condition [options.showDescription != ""] was removed from _createAjaxAutoComplete function.

jleroux: I formatted the XSD documentation and used 

showDescription = "Y".equals(UtilProperties.getPropertyValue("widget", "widget.lookup.showDescription", "Y"));
instead of
showDescription = "Y".equals(UtilProperties.getPropertyValue("widget", "widget.lookup.showDescription", "N"));

Because, in widget.properties, widget.lookup.showDescription is Y by default (and I know that well, since I made this description working correctly in all cases)

Modified:
    ofbiz/trunk/framework/images/webapp/images/fieldlookup.js
    ofbiz/trunk/framework/widget/dtd/widget-form.xsd
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java

Modified: ofbiz/trunk/framework/images/webapp/images/fieldlookup.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/images/webapp/images/fieldlookup.js?rev=1491936&r1=1491935&r2=1491936&view=diff
==============================================================================
--- ofbiz/trunk/framework/images/webapp/images/fieldlookup.js (original)
+++ ofbiz/trunk/framework/images/webapp/images/fieldlookup.js Tue Jun 11 20:12:37 2013
@@ -20,7 +20,6 @@ var mx, my;
 var ACTIVATED_LOOKUP = null;
 var LOOKUP_DIV = null;
 var INITIALLY_COLLAPSED = null;
-var SHOW_DESCRIPTION = false;
 var COLLAPSE_SEQUENCE_NUMBER = 1999;
 
 var target = null;
@@ -212,6 +211,7 @@ var Lookup = function(options) {
 		this.formName = options.formName;
 		this.target = null;
 		this.presentation = options.presentation;
+		this.showDescription = (options.showDescription == "true") ? true : false;
 		if (options.dialogOptionalTarget != null) {
 			this.target2 = null;
 		}
@@ -245,11 +245,10 @@ var Lookup = function(options) {
 	}
 
 	function _createAjaxAutoComplete() {
-		if (options.ajaxUrl != "" && options.showDescription != "") {
-			SHOW_DESCRIPTION = options.showDescription;
+		if (options.ajaxUrl != "") {
 			// write the new input box id in the ajaxUrl Array
 			options.ajaxUrl = options.ajaxUrl.replace(options.ajaxUrl.substring(0, options.ajaxUrl.indexOf(",")), _newInputBoxId);
-			new ajaxAutoCompleter(options.ajaxUrl, options.showDescription, options.defaultMinLength, options.defaultDelay,
+			new ajaxAutoCompleter(options.ajaxUrl, (options.showDescription == "true") ? true : false, options.defaultMinLength, options.defaultDelay,
 					options.formName);
 		}
 	}
@@ -769,8 +768,9 @@ function set_values(value, value2) {
 	var target2 = obj_caller.target2;
 	write_value(value, target);
 	write_value(value2, target2)
-	if (SHOW_DESCRIPTION) {
-		setLookDescription(target.attr("id"), value + " " + value2, "", "", SHOW_DESCRIPTION);
+	var showDescription = GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP) ? GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).showDescription : false;
+	if (showDescription) {
+		setLookDescription(target.attr("id"), value + " " + value2, "", "", showDescription);
 	}
 
 	closeLookup();

Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=1491936&r1=1491935&r2=1491936&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original)
+++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Tue Jun 11 20:12:37 2013
@@ -1161,6 +1161,14 @@ under the License.
                     </xs:restriction>
                 </xs:simpleType>
             </xs:attribute>
+            <xs:attribute name="show-description" type="xs:boolean">
+                <xs:annotation>
+                    <xs:documentation>If true, a special span with css class "tooltip" will be created at right of the lookup button 
+                                      and a description will fill in. 
+                                      If not set then it depends on the "widget.lookup.showDescription" setting.
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:attribute>
         </xs:complexType>
     </xs:element>
     <xs:element name="password" substitutionGroup="AllFields">

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=1491936&r1=1491935&r2=1491936&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Tue Jun 11 20:12:37 2013
@@ -2067,7 +2067,10 @@ public class MacroFormRenderer implement
         } else {
             Debug.logWarning("Could not find uiLabelMap in context", module);
         }
-        boolean showDescription = "Y".equals(UtilProperties.getPropertyValue("widget", "widget.lookup.showDescription", "N"));
+        Boolean showDescription = lookupField.getShowDescription();
+        if (showDescription == null) {
+            showDescription = "Y".equals(UtilProperties.getPropertyValue("widget", "widget.lookup.showDescription", "Y"));
+        }
         // lastViewName, used by lookup to remember the real last view name
         String lastViewName = request.getParameter("_LAST_VIEW_NAME_"); // Try to get it from parameters firstly
         if (UtilValidate.isEmpty(lastViewName)) { // get from session

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=1491936&r1=1491935&r2=1491936&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Tue Jun 11 20:12:37 2013
@@ -3524,6 +3524,7 @@ public class ModelFormField {
         protected String lookupPosition;
         protected String fadeBackground;
         protected String initiallyCollapsed;
+        protected String showDescription;
 
         public LookupField(Element element, ModelFormField modelFormField) {
             super(element, modelFormField);
@@ -3536,6 +3537,7 @@ public class ModelFormField {
             this.lookupPosition = element.getAttribute("position");
             this.fadeBackground = element.getAttribute("fade-background");            
             this.initiallyCollapsed = element.getAttribute("initially-collapsed");
+            this.showDescription = element.getAttribute("show-description");
 
             Element subHyperlinkElement = UtilXml.firstChildElement(element, "sub-hyperlink");
             if (subHyperlinkElement != null) {
@@ -3623,6 +3625,15 @@ public class ModelFormField {
         public void setFadeBackground(String str) {
             this.fadeBackground = str;
         }
+
+        public Boolean getShowDescription() {
+            return UtilValidate.isEmpty(this.showDescription) ? null : "true".equals(this.showDescription);
+        }
+
+        public void setShowDescription(String str) {
+            this.showDescription = str;
+        }
+
         //initially-collapsed status
         public boolean getInitiallyCollapsed() {
             return "true".equals(this.initiallyCollapsed);