details:   /erp/devel/pi/rev/0185bdc06cfb
changeset: 10050:0185bdc06cfb
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Sat Jan 22 12:08:56 2011 +0100
summary:   Solve label next to checkbox in grid mode

details:   /erp/devel/pi/rev/d39f167881ed
changeset: 10051:d39f167881ed
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Sat Jan 22 12:10:32 2011 +0100
summary:   Prevent onchange event when blurring date, showpicker when clicking 
search item

details:   /erp/devel/pi/rev/325f2d74350c
changeset: 10052:325f2d74350c
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Sat Jan 22 12:11:35 2011 +0100
summary:   Solve focus handling for readonlylogic, when clicking in other view

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-form.js.ftl
      |   1 +
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
      |   2 +-
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
    |   4 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
          |  46 +++++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
             |  16 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
                 |   6 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form-linked-items.js
    |   1 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
                 |  22 ++-
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
                  |   2 +-
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/YesNoUIDefinition.java
             |  19 ++
 
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
     |   3 +
 
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
 |  78 +++++++--
 12 files changed, 165 insertions(+), 35 deletions(-)

diffs (truncated from 449 to 300 lines):

diff -r 7fc43d2aeed8 -r 325f2d74350c 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-form.js.ftl
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-form.js.ftl
       Fri Jan 21 20:18:17 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-form.js.ftl
       Sat Jan 22 12:11:35 2011 +0100
@@ -37,5 +37,6 @@
         }
       </#if>
       </#list>
+      form.setFindNewFocusItem();
     }
 })
diff -r 7fc43d2aeed8 -r 325f2d74350c 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
       Fri Jan 21 20:18:17 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-grid.js.ftl
       Sat Jan 22 12:11:35 2011 +0100
@@ -23,7 +23,7 @@
         { 
         autoExpand: ${field.autoExpand}, type: '${field.type}',
         editorProperties: {
-          ${field.fieldProperties}
+          ${field.gridEditorFieldProperties}
         }
         ${field.gridFieldProperties}
         ${field.filterEditorProperties}
diff -r 7fc43d2aeed8 -r 325f2d74350c 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
     Fri Jan 21 20:18:17 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
     Sat Jan 22 12:11:35 2011 +0100
@@ -193,8 +193,8 @@
       return property.getTargetEntity().getName();
     }
 
-    public String getFieldProperties() {
-      String props = uiDefinition.getFieldProperties(field).trim();
+    public String getGridEditorFieldProperties() {
+      String props = uiDefinition.getGridEditorFieldProperties(field).trim();
       if (props.startsWith("{")) {
         props = props.substring(1, props.length() - 1);
       }
diff -r 7fc43d2aeed8 -r 325f2d74350c 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
   Fri Jan 21 20:18:17 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
   Sat Jan 22 12:11:35 2011 +0100
@@ -67,8 +67,9 @@
 
 // a global function as it is called from classic windows
 function closeSearch(action, value, display, parameters, wait){
-  var length, i, hiddenInputName, targetFld = isc.OBSearchItem.openSearchItem;
-  if (action === 'SAVE') {
+  var length, i, hiddenInputName, targetFld = isc.OBSearchItem.openSearchItem,
+    currentValue = targetFld.getValue();
+  if (action === 'SAVE' && currentValue !== value) {    
     if (!targetFld.valueMap) {
       targetFld.valueMap = {};
     }
@@ -164,6 +165,9 @@
   }, 
 
   showPicker: function(){
+    if (this.isFocusable()) {
+      this.focusInItem(); 
+    }
     var parameters = [], index = 0, i = 0, length, fld, inpName;
     parameters[index++] = 'inpIDValue';
     if (this.getValue()) {
@@ -326,6 +330,9 @@
     // when collapsing set the focus to the header
     this.form.setFocusItem(this);
     var ret = this.Super('collapseSection', arguments);
+    if (this.form.view) {
+      this.form.view.setAsActiveView();
+    }
     return ret;
   },
   
@@ -344,6 +351,10 @@
       this.form.parentElement.delayCall('scrollTo', [null, this.getTop()], 
100);    
     }
 
+    if (this.form.view) {
+      this.form.view.setAsActiveView();
+    }
+
     return ret;
   },
     
@@ -729,20 +740,45 @@
   // Called when changing a value.
   change: function(form, item, value, oldValue){ /* transformInput */
     var isADate = value !== null &&
-    Object.prototype.toString.call(value) === '[object Date]';
+              Object.prototype.toString.call(value) === '[object Date]';
     if (isADate) {
       return;
     }
-    item.setValue(OBDateItem.autoCompleteDate(item.dateFormat, value, this));
+    // prevent change events from happening
+    var completedDate = OBDateItem.autoCompleteDate(item.dateFormat, value, 
this);
+    if (completedDate !== oldValue) {
+      item.setValue(completedDate);
+    }
   },
   
   // to prevent infinite looping as setFormErrors will also blur
   inBlur: false,
+
+  // compare while ignoring milli difference
+  compareValues : function (value1, value2) {
+    // not a date let the super class do it
+    if (!isc.isA.Date(value1) || !isc.isA.Date(value2)) {
+      return this.Super('compareValues', arguments);
+    }
+    var difference = value1.getTime() - value2.getTime();
+    if (difference < -1000) {
+      return 1;
+    } else if (difference > 1000) {
+      return -1;
+    } else {
+      return 0;
+    }
+  },
   
   // ** {{{ blur }}} **
   // Called when the focus leaves the field (sets value and validates)
   blur: function(){
-    this.setValue(OBDateItem.expandDateYear(this.dateFormat, this.getValue()));
+    var newValue = OBDateItem.expandDateYear(this.dateFormat, this.getValue()),
+    oldValue = this.getValue();
+    
+    if (oldValue !== newValue) {      
+      this.setValue(newValue);
+    }
     if (!this.inBlur) {
       this.inBlur = true;
       this.checkOBDateItemValue();
diff -r 7fc43d2aeed8 -r 325f2d74350c 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Fri Jan 21 20:18:17 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Sat Jan 22 12:11:35 2011 +0100
@@ -586,6 +586,12 @@
   },
   
   setViewFocus: function(){
+    
+    if (this._inFocusInItem) {
+      this._inFocusInItem = null;
+      return;
+    }
+    
     var object, functionName;
     
     // clear for a non-focusable item
@@ -593,15 +599,15 @@
       this.lastFocusedItem = null;
     }
     
-    if (this.lastFocusedItem) {
+    if (this.viewForm && this.viewForm.getFocusItem()) {
+      object = this.viewForm;
+      functionName = 'focus';
+    } else if (this.lastFocusedItem) {
       object = this.lastFocusedItem;
       functionName = 'focusInItem';
     } else if (this.viewGrid && !this.isShowingForm) {
       object = this.viewGrid;
       functionName = 'focusInFilterEditor';
-    } else if (this.viewForm && this.viewForm.getFocusItem()) {
-      object = this.viewForm;
-      functionName = 'focus';
     }
     
     isc.Page.setEvent(isc.EH.IDLE, object, isc.Page.FIRE_ONCE, functionName);
@@ -637,6 +643,8 @@
       this.activeBar.setActive(true);
       this.setViewFocus();
     } else {
+      this.lastFocusedItem = this.viewForm.getFocusItem();
+      this.viewForm.setFocusItem(null);
       this.activeBar.setActive(false);
       this.toolBar.hide();
       // note we can not check on viewForm visibility as 
diff -r 7fc43d2aeed8 -r 325f2d74350c 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
  Fri Jan 21 20:18:17 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
  Sat Jan 22 12:11:35 2011 +0100
@@ -387,8 +387,7 @@
   var fullYear = dateFormat.indexOf('%Y') !== -1 ? 
OBDate.substring(dateFormat.indexOf('%Y'), dateFormat.indexOf('%Y') + 4) : 0;
   var month = dateFormat.indexOf('%m') !== -1 ? 
OBDate.substring(dateFormat.indexOf('%m'), dateFormat.indexOf('%m') + 2) : 0;
   var day = dateFormat.indexOf('%d') !== -1 ? 
OBDate.substring(dateFormat.indexOf('%d'), dateFormat.indexOf('%d') + 2) : 0;
-  // note if there is no hour in the dateformat then use the value 12 to 
prevent winter/summertime issues 
-  var hours = dateFormat.indexOf('%H') !== -1 ? 
OBDate.substring(dateFormat.indexOf('%H'), dateFormat.indexOf('%H') + 2) : 12;
+  var hours = dateFormat.indexOf('%H') !== -1 ? 
OBDate.substring(dateFormat.indexOf('%H'), dateFormat.indexOf('%H') + 2) : 0;
   var minutes = dateFormat.indexOf('%M') !== -1 ? 
OBDate.substring(dateFormat.indexOf('%M'), dateFormat.indexOf('%M') + 2) : 0;
   var seconds = dateFormat.indexOf('%S') !== -1 ? 
OBDate.substring(dateFormat.indexOf('%S'), dateFormat.indexOf('%S') + 2) : 0;
   
@@ -423,7 +422,8 @@
   JSDate.setHours(hours);
   JSDate.setMinutes(minutes);
   JSDate.setSeconds(seconds);
-  
+  JSDate.setMilliseconds(0);
+
   if (JSDate.toString() === 'Invalid Date' || JSDate.toString() === 'NaN') {
     return null;
   } else {
diff -r 7fc43d2aeed8 -r 325f2d74350c 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form-linked-items.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form-linked-items.js
     Fri Jan 21 20:18:17 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form-linked-items.js
     Sat Jan 22 12:11:35 2011 +0100
@@ -107,6 +107,7 @@
     // items should be created, note that the linked items should not 
     // be read until the expand actually takes place (see below)
     this.label = isc.Label.create({
+      canFocus: true,
       width: '100%',
       height: '100%',
       contents: 'Implement me'
diff -r 7fc43d2aeed8 -r 325f2d74350c 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Fri Jan 21 20:18:17 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Sat Jan 22 12:11:35 2011 +0100
@@ -66,6 +66,7 @@
   },
   
   editRecord: function(record, preventFocus){
+    this.setFocusItem(null);
     this.setHasChanged(false);
 
     this.setNewState(false);
@@ -91,6 +92,7 @@
   },
   
   editNewRecord: function(preventFocus){
+    this.setFocusItem(null);
     // focus is done automatically, prevent the focus event if needed
     // the focus event will set the active view
     this.ignoreFirstFocusEvent = preventFocus;
@@ -136,7 +138,7 @@
     if (items) {
       for (var i = 0; i < items.length; i++) {
         var item = items[i];
-        if (!item.isDisabled() && (item.getCanFocus() || item.canFocus)) {
+        if (item.getCanFocus() && !item.isDisabled()) {
           this.setFocusItem(item);
           return;
         }
@@ -144,6 +146,24 @@
     }
   },
   
+  setFindNewFocusItem: function() {
+    var focusItem = this.getFocusItem();
+    // no need to find a new item
+    if (focusItem && !focusItem.isDisabled() && focusItem.getCanFocus()) {
+      return;
+    }
+    var items = this.getItems();
+    if (items) {
+      for (var i = 0; i < items.length; i++) {
+        var item = items[i];
+        if (item.getCanFocus() && !item.isDisabled()) {
+          item.focusInItem();
+          return;
+        }
+      }
+    }    
+  },
+  
   getFieldFromInpColumnName: function(inpColumnName){
     if (!this.fieldsByInpColumnName) {
       var localResult = [], fields = this.getFields();
diff -r 7fc43d2aeed8 -r 325f2d74350c 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
--- 
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
   Fri Jan 21 20:18:17 2011 +0100
+++ 
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
   Sat Jan 22 12:11:35 2011 +0100
@@ -273,7 +273,7 @@
    * @return a JSONObject string which is used to initialize the formitem.
    */
   public String getGridEditorFieldProperties(Field field) {
-    return "";
+    return getFieldProperties(field);
   }
 
   public Reference getReference() {
diff -r 7fc43d2aeed8 -r 325f2d74350c 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/YesNoUIDefinition.java
--- 
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/YesNoUIDefinition.java
      Fri Jan 21 20:18:17 2011 +0100
+++ 
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/YesNoUIDefinition.java
      Sat Jan 22 12:11:35 2011 +0100
@@ -18,6 +18,8 @@
  */
 package org.openbravo.client.kernel.reference;
 
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.base.exception.OBException;
 import org.openbravo.model.ad.ui.Field;
 
 /**
@@ -52,6 +54,23 @@
   }
 
   @Override
+  public String getGridEditorFieldProperties(Field field) {
+    final String superGridEditorProps = 
super.getGridEditorFieldProperties(field);
+    if (superGridEditorProps.length() > 0) {
+      try {
+        final JSONObject json = new JSONObject(superGridEditorProps);
+        json.put("showTitle", false);
+        json.put("showLabel", false);
+        return json.toString();
+      } catch (Exception e) {

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to