details:   /erp/devel/pi/rev/2de941ea3367
changeset: 12643:2de941ea3367
user:      Iván Perdomo <ivan.perdomo <at> openbravo.com>
date:      Wed Jun 01 16:18:33 2011 +0200
summary:   Issue 17042: Reset width property when field is not displayed

details:   /erp/devel/pi/rev/2fe831f49373
changeset: 12644:2fe831f49373
user:      Iván Perdomo <ivan.perdomo <at> openbravo.com>
date:      Wed Jun 01 16:20:40 2011 +0200
summary:   Fixes issue 17042: Move status bar fields at the end of the form
- Ensure that they don't take space using, alwaysTakeSpace: false
- They are not part of any field group

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
  |   1 +
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
 |  43 ++++++---
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/NumberUIDefinition.java
         |  18 +++-
 3 files changed, 45 insertions(+), 17 deletions(-)

diffs (140 lines):

diff -r 947e071da9a7 -r 2fe831f49373 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
      Wed Jun 01 13:10:51 2011 +0200
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
      Wed Jun 01 16:20:40 2011 +0200
@@ -36,6 +36,7 @@
         targetEntity: '${fieldDefinition.targetEntity?string}',
         <#if !fieldDefinition.displayed>
         editorType: 'HiddenItem',
+        alwaysTakeSpace: false,
         </#if>
         required: ${fieldDefinition.required?string},
           <#if fieldDefinition.redrawOnChange?string = "true" && 
fieldDefinition.displayed>
diff -r 947e071da9a7 -r 2fe831f49373 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
     Wed Jun 01 13:10:51 2011 +0200
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
     Wed Jun 01 16:20:40 2011 +0200
@@ -63,7 +63,7 @@
   private static final String MORE_INFO_GROUP_ID = 
"402880E72F1C15A5012F1C7AA98B00E8";
 
   private Tab tab;
-  private List<String> statusBarFields = null;
+  private List<String> statusBarFields = new ArrayList<String>();
 
   protected Template getComponentTemplate() {
     return OBDal.getInstance().get(Template.class, TEMPLATE_ID);
@@ -87,8 +87,6 @@
     final Map<Field, String> displayLogicMap = new HashMap<Field, String>();
     final Map<Field, String> readOnlyLogicMap = new HashMap<Field, String>();
 
-    statusBarFields = new ArrayList<String>();
-
     // Processing dynamic expressions (display logic)
     for (Field f : adFields) {
       if (f.getDisplayLogic() == null || f.getDisplayLogic().equals("") || 
!f.isActive()
@@ -171,23 +169,14 @@
     int colNum = 1;
     for (Field field : adFields) {
 
-      if (field.getColumn() == null || !field.isActive()
-          || (!field.isDisplayed() && !field.isShownInStatusBar())) {
+      if (field.getColumn() == null || !field.isActive() || 
!field.isDisplayed()
+          || ApplicationUtils.isUIButton(field)) {
         continue;
       }
 
       final Property property = 
KernelUtils.getInstance().getPropertyFromColumn(field.getColumn(),
           false);
 
-      // a button domain type, continue for now
-      if (ApplicationUtils.isUIButton(field)) {
-        continue;
-      }
-
-      if (field.isShownInStatusBar() != null && field.isShownInStatusBar()) {
-        statusBarFields.add(property.getName());
-      }
-
       final OBViewField viewField = new OBViewField();
       viewField.setField(field);
       viewField.setProperty(property);
@@ -260,6 +249,9 @@
     fields.add(attachmentDefinition);
     fields.add(attachmentsCanvas);
 
+    // add status bar fields
+    processStatusBarFields(fields, adFields);
+
     return fields;
   }
 
@@ -271,6 +263,29 @@
     return statusBarFields;
   }
 
+  private void processStatusBarFields(List<OBViewFieldDefinition> fields, 
List<Field> adFields) {
+    for (Field field : adFields) {
+
+      if (field.isShownInStatusBar() == null || !field.isShownInStatusBar()) {
+        continue;
+      }
+
+      final Property property = 
KernelUtils.getInstance().getPropertyFromColumn(field.getColumn(),
+          false);
+
+      statusBarFields.add(property.getName());
+
+      final OBViewField viewField = new OBViewField();
+      viewField.setField(field);
+      viewField.setProperty(property);
+      viewField.setRedrawOnChange(false);
+      viewField.setShowIf("");
+      viewField.setReadOnlyIf("");
+
+      fields.add(viewField);
+    }
+  }
+
   private interface OBViewFieldDefinition {
     public String getLabel();
 
diff -r 947e071da9a7 -r 2fe831f49373 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/NumberUIDefinition.java
--- 
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/NumberUIDefinition.java
     Wed Jun 01 13:10:51 2011 +0200
+++ 
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/NumberUIDefinition.java
     Wed Jun 01 16:20:40 2011 +0200
@@ -103,7 +103,11 @@
     String fieldProperties = super.getFieldProperties(field);
     try {
       JSONObject o = new JSONObject(fieldProperties);
-      o.put("width", "50%");
+      if (field.isDisplayed() != null && field.isDisplayed()) {
+        o.put("width", "50%");
+      } else {
+        o.put("width", "");
+      }
       return o.toString();
     } catch (Exception e) { // ignore
       return fieldProperties;
@@ -114,7 +118,11 @@
   public String getFieldProperties(Field field, boolean getValueFromSession) {
     try {
       JSONObject o = new JSONObject(super.getFieldProperties(field, 
getValueFromSession));
-      o.put("width", "50%");
+      if (field.isDisplayed() != null && field.isDisplayed()) {
+        o.put("width", "50%");
+      } else {
+        o.put("width", "");
+      }
       // If a column has a numeric reference, and is required, and doesn't 
have a default, then
       // the default '0' is set
       if (!getValueFromSession && field.getColumn().isMandatory()
@@ -123,7 +131,11 @@
         final JSONObject jsonObject = new JSONObject();
         jsonObject.put("value", 0);
         jsonObject.put("classicValue", 0);
-        jsonObject.put("width", "50%");
+        if (field.isDisplayed() != null && field.isDisplayed()) {
+          o.put("width", "50%");
+        } else {
+          o.put("width", "");
+        }
         return jsonObject.toString();
       }
       return o.toString();

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to