details:   /erp/devel/pi/rev/b7ef9f694006
changeset: 11794:b7ef9f694006
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Apr 28 16:46:16 2011 +0200
summary:   Fixes issue 16908: The grid is not working properly. Business 
partner field always keeps the focus

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
             |   9 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
                 |   3 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
                 |  70 +++++----
 
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
 |  38 +++++-
 4 files changed, 83 insertions(+), 37 deletions(-)

diffs (213 lines):

diff -r 98952a2026a5 -r b7ef9f694006 
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
      Thu Apr 28 15:47:06 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Thu Apr 28 16:46:16 2011 +0200
@@ -1575,10 +1575,11 @@
       classicMode = true;
     }
     var value, field, record, form, component, propertyObj, type;
-    // different modes:
-    // 1) showing grid with one record selected
-    // 2) showing form with aux inputs
-    if (this.isEditingGrid) {
+
+    // a special case, the editform has been build but it is not present yet 
in the
+    // form, so isEditingGrid is true but the edit form is not there yet, in 
that 
+    // case use the viewGrid as component and the selected record
+    if (this.isEditingGrid && this.viewGrid.getEditForm()) {
       rowNum = this.viewGrid.getEditRow();
       if (rowNum || rowNum === 0) {
         record = isc.addProperties({}, this.viewGrid.getRecord(rowNum), 
this.viewGrid.getEditValues(rowNum));
diff -r 98952a2026a5 -r b7ef9f694006 
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
  Thu Apr 28 15:47:06 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Thu Apr 28 16:46:16 2011 +0200
@@ -611,6 +611,9 @@
             this.getFocusItem().focusInItem();
           }
         }
+      } else {
+        this.redraw();
+        this.view.viewGrid.refreshEditRow();
       }
     }
   },
diff -r 98952a2026a5 -r b7ef9f694006 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Thu Apr 28 15:47:06 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Thu Apr 28 16:46:16 2011 +0200
@@ -1051,8 +1051,13 @@
   // for one select/deselect action
   selectionUpdated: function(record, recordList){
   
-    // close any editors we may have
-    this.closeAnyOpenEditor();
+    // close any editors, but only if it is different from the one we are 
editing
+    if (this.isEditingGrid) {
+      var editRecord = this.getRecord(this.getEditRow());
+      if (editRecord !== record) {
+        this.closeAnyOpenEditor();
+      }
+    }
     this.stopHover();
     this.updateSelectedCountDisplay();
     this.view.recordSelected();
@@ -1315,7 +1320,9 @@
     this.scrollToRow(rowNum);
     this.updateRowCountDisplay();
     this.view.toolBar.updateButtonState(true);
-    this.redraw();
+    
+    // do it with a delay to give the system time to set the record information
+    this.markForRedraw();
   },
   
   editFailed: function(rowNum, colNum, newValues, oldValues, 
editCompletionEvent, dsResponse, dsRequest){
@@ -1347,6 +1354,7 @@
   },
   
   editComplete: function(rowNum, colNum, newValues, oldValues, 
editCompletionEvent, dsResponse){
+
     var record = this.getRecord(rowNum), editRow, editSession, autoSaveAction;
     
     // a new id has been computed use that now    
@@ -1620,21 +1628,31 @@
     this.endEditing();
   },
   
-  // is called when clicking a header
   hideInlineEditor: function(focusInBody, suppressCMHide) {
+
     var rowNum = this.getEditRow(), record = this.getRecord(rowNum);
-    
-    // clear the errors so that they don't show up at the next row
-    if (this.getEditForm()) {
-      this.getEditForm().clearErrors();
+    if (rowNum === 0 || rowNum) {
+      if (!this.rowHasErrors(rowNum)) {
+        record[this.recordBaseStyleProperty] = null;
+      }
+      
+      // clear the errors so that they don't show up at the next row
+      if (this.getEditForm()) {
+        this.getEditForm().clearErrors();
+      }
+  
+      if (record && record.editColumnLayout) {
+        isc.Log.logDebug('hideInlineEditor has record and editColumnLayout', 
'OB');
+        record.editColumnLayout.showEditOpen();
+      } else if (this.currentEditColumnLayout) {
+        this.currentEditColumnLayout.showEditOpen();
+      } else {
+        isc.Log.logDebug('hideInlineEditor has NO record and 
editColumnLayout', 'OB');
+      }
+      this.view.isEditingGrid = false;
+      this.refreshRow(rowNum);
     }
     
-    this.view.messageBar.hide();
-    if (record && record.editColumnLayout) {
-      record.editColumnLayout.showEditOpen();
-    } else if (this.getEditForm().getValues().editColumnLayout) {
-      this.getEditForm().getValues().editColumnLayout.showEditOpen();
-    }
     // always hide the clickmask, as it needs to be re-applied
     return this.Super('hideInlineEditor', [focusInBody, false]);
   },
@@ -1699,24 +1717,6 @@
     return ret;
   },
   
-  rowEditorExit: function(editCompletionEvent, record, newValues, rowNum){
-    isc.Log.logDebug('rowEditorExit ' + this.getEditRow(), 'OB');
-    if (!this.rowHasErrors(rowNum)) {
-      record[this.recordBaseStyleProperty] = null;
-    }
-    
-    if (record && record.editColumnLayout) {
-      isc.Log.logDebug('hideInlineEditor has record and editColumnLayout', 
'OB');
-      record.editColumnLayout.showEditOpen();
-    } else if (this.currentEditColumnLayout) {
-      this.currentEditColumnLayout.showEditOpen();
-    } else {
-      isc.Log.logDebug('hideInlineEditor has NO record and editColumnLayout', 
'OB');
-    }
-    this.view.isEditingGrid = false;
-    this.refreshRow(rowNum);
-  },
-  
   closeAnyOpenEditor: function(){
     delete this.wasEditing;
     // close any editors we may have
@@ -2164,6 +2164,9 @@
   },
   
   hideMember: function(memberNo) {
+    if (!this.members[memberNo]) {
+      return;
+    }
     // already hidden
     if (this.members[memberNo] && this.members[memberNo].visibility === 
isc.Canvas.HIDDEN) {
       return;
@@ -2172,6 +2175,9 @@
   },
 
   showMember: function(memberNo) {
+    if (!this.members[memberNo]) {
+      return;
+    }
     // already visible
     if (this.members[memberNo] && this.members[memberNo].visibility === 
isc.Canvas.INHERIT || this.members[memberNo].visibility === isc.Canvas.VISIBLE) 
{
       return;
diff -r 98952a2026a5 -r b7ef9f694006 
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
--- 
a/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
  Thu Apr 28 15:47:06 2011 +0200
+++ 
b/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
  Thu Apr 28 16:46:16 2011 +0200
@@ -56,6 +56,18 @@
   // disable tab to icons
   canTabToIcons: false,
   
+  // when a value is set the selectValue is called with a delay, during that 
delay
+  // the focus may have moved to another field, the selectValue will however 
again 
+  // put the focus in this field this results in infinite looping of calls
+  // https://issues.openbravo.com/view.php?id=16908
+  _selectValue : isc.FormItem.getPrototype().selectValue,
+  selectValue: function() {
+    if (!this.hasFocus) {
+      return;
+    }
+    return this._selectValue();
+  },
+  
   _original_init: isc.FormItem.getPrototype().init,
   init: function() {
     OB.Utilities.addRequiredSuffixToBaseStyle(this);
@@ -163,7 +175,31 @@
 isc.PickList.getPrototype().cachePickListResults = false;
 
 // allow max 10000 days/years/quarters in the past/future
-isc.RelativeDateItem.changeDefaults('quantityFieldDefaults', {max: 1000});
+isc.RelativeDateItem.changeDefaults('quantityFieldDefaults', {max: 1000, 
alwaysTakeSpace: false});
+
+//isc.RelativeDateItem.changeDefaults('valueFieldDefaults', 
+//    {validateOnExit: true,
+//    icons : [{
+//    src: 
'[SKIN]/../../org.openbravo.client.application/images/form/date_control.png',
+//    canFocus: false,
+//    showOver: false,
+//    showFocused: false,
+//    showFocusedWithItem: false,
+//    width: 21,
+//    height: 21,
+//    hspace: 0,
+//    keyPress: function(keyName, character, form, item, icon){
+//      if (keyName === 'Enter' && isc.EventHandler.ctrlKeyDown()) {
+//        item.showPicker();
+//        return false;
+//      }
+//      return true;
+//    },
+//    click: function(form, item, icon){
+//      item.showPicker();
+//    }
+//  }]  
+//});
 
 isc.RelativeDateItem.addProperties({
   // overridden as the displayDateFormat does not seem to work fine

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to