details:   /erp/devel/pi/rev/4ef7c6fa1824
changeset: 11179:4ef7c6fa1824
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Mar 10 14:23:52 2011 +0100
summary:   Automatically add sequencenumber/lineno as sort clause

details:   /erp/devel/pi/rev/b6cb84c2517d
changeset: 11180:b6cb84c2517d
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Mar 10 14:24:35 2011 +0100
summary:   Removed space

details:   /erp/devel/pi/rev/a8a9fe6a5d65
changeset: 11181:a8a9fe6a5d65
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Mar 10 14:26:02 2011 +0100
summary:   Double click on cell opens form with correct field focused

details:   /erp/devel/pi/rev/40df33ccddc6
changeset: 11182:40df33ccddc6
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Mar 10 19:09:23 2011 +0100
summary:   Fix issue that cancel button forced a save, Fixes issue 16215: 
Parent records are hidden when creating the line

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
 |  13 ++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
          |  24 ++++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
              |  39 ++++++++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
              |  37 ++++++---
 
modules/org.openbravo.service.datasource/web/org.openbravo.service.datasource/js/ob-datasource-utilities.js
   |  21 +++++
 src-db/database/sourcedata/AD_REF_LIST.xml                                     
                               |   2 +-
 6 files changed, 109 insertions(+), 27 deletions(-)

diffs (truncated from 343 to 300 lines):

diff -r 8c44ad13e0d6 -r 40df33ccddc6 
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
     Thu Mar 10 18:04:48 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewGridComponent.java
     Thu Mar 10 19:09:23 2011 +0100
@@ -42,6 +42,7 @@
 import org.openbravo.model.ad.ui.Field;
 import org.openbravo.model.ad.ui.Tab;
 import org.openbravo.model.common.order.Order;
+import org.openbravo.model.common.order.OrderLine;
 import org.openbravo.service.json.JsonConstants;
 
 /**
@@ -56,6 +57,7 @@
 
   private boolean applyTransactionalFilter = false;
   private Tab tab;
+  private Entity entity;
   private List<LocalField> fields = null;
 
   private final List<Field> fieldsInDynamicExpression = new ArrayList<Field>();
@@ -72,6 +74,7 @@
 
   public void setTab(Tab tab) {
     this.tab = tab;
+    entity = ModelProvider.getInstance().getEntityByTableId((String) 
DalUtil.getId(tab.getTable()));
   }
 
   public String getWhereClause() {
@@ -85,6 +88,14 @@
     if (tab.getHqlorderbyclause() != null) {
       return tab.getHqlorderbyclause();
     }
+    // use 2 examples of sequence number of line no
+    if (entity.hasProperty(Tab.PROPERTY_SEQUENCENUMBER)) {
+      return Tab.PROPERTY_SEQUENCENUMBER;
+    }
+    if (entity.hasProperty(OrderLine.PROPERTY_LINENO)) {
+      return OrderLine.PROPERTY_LINENO;
+    }
+
     return JsonConstants.IDENTIFIER;
   }
 
@@ -101,8 +112,6 @@
     }
     String transactionalFilter = " e.updated > " + 
JsonConstants.QUERY_PARAM_TRANSACTIONAL_RANGE
         + " ";
-    final Entity entity = ModelProvider.getInstance().getEntityByTableId(
-        (String) DalUtil.getId(tab.getTable()));
     if (entity.hasProperty(Order.PROPERTY_PROCESSED)) {
       transactionalFilter += " or e.processed = 'N' ";
     }
diff -r 8c44ad13e0d6 -r 40df33ccddc6 
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 Mar 10 18:04:48 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Thu Mar 10 19:09:23 2011 +0100
@@ -816,7 +816,7 @@
   // ** {{{ editRecord }}} **
   // Opens the edit form and selects the record in the grid, will refresh
   // child views also
-  editRecord: function(record, preventFocus){
+  editRecord: function(record, preventFocus, focusFieldName){
 
     this.messageBar.hide();
     
@@ -833,7 +833,7 @@
       // also handle the case that there are unsaved values in the grid
       // show them in the form
       var rowNum = this.viewGrid.getRecordIndex(record);
-      this.viewForm.editRecord(this.viewGrid.getEditedRecord(rowNum), 
preventFocus, this.viewGrid.recordHasChanges(rowNum));
+      this.viewForm.editRecord(this.viewGrid.getEditedRecord(rowNum), 
preventFocus, this.viewGrid.recordHasChanges(rowNum), focusFieldName);
     }
   },
   
@@ -1268,16 +1268,26 @@
       return;
     }
     var record = this.viewGrid.getSelectedRecord();
-    var criteria = {};
-    criteria[OB.Constants.ID] = record.id;
-    // force a fetch from the server
-    criteria._dummy = new Date().getTime();
+    criteria = {
+        operator: 'and', 
+        _constructor: "AdvancedCriteria", 
+        criteria:[]};
+        
+    // add a dummy criteria to force a fetch
+    criteria.criteria.push(isc.OBRestDataSource.getDummyCriterion());
+
+    // and add a criteria for the record itself
+    criteria.criteria.push({
+      fieldName: OB.Constants.ID,
+      operator: 'equals',
+      value: record.id
+    });
     
     var me = this;
     var callback = function(resp, data, req) {
       // this line does not work, but it should:
 //      me.getDataSource().updateCaches(resp, req);
-      // therefore doe an explicit update of the visual components
+      // therefore do an explicit update of the visual components
       if (me.isShowingForm) {
         me.viewForm.refresh();
       }
diff -r 8c44ad13e0d6 -r 40df33ccddc6 
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 Mar 10 18:04:48 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Thu Mar 10 19:09:23 2011 +0100
@@ -107,7 +107,7 @@
     }
   },
   
-  editRecord: function(record, preventFocus, hasChanges){
+  editRecord: function(record, preventFocus, hasChanges, focusFieldName){
     var ret = this.Super('editRecord', arguments);
     this.doEditRecordActions(preventFocus, false);
     if (hasChanges) {
@@ -116,6 +116,11 @@
     
     this.view.setTargetRecordInWindow(record.id);
     
+    // used when clicking on a cell in a grid
+    if (!preventFocus && focusFieldName) {
+      this.forceFocusedField = focusFieldName;
+    }
+    
     return ret;
   },
   
@@ -196,8 +201,12 @@
     unmaskedTargets.push(this.view.toolBar.getLeftMember('undo'));
     
     // the row cancel button
-    if (this.view.viewGrid.getSelectedRecord() && 
this.view.viewGrid.getSelectedRecord().editColumnLayout) {
-      
unmaskedTargets.push(this.view.viewGrid.getSelectedRecord().editColumnLayout.cancelButton);
+    var editRow = this.view.viewGrid.getEditRow();
+    if (editRow || editRow === 0) {
+      var record = this.view.viewGrid.getRecord(editRow);
+      if (record && record.editColumnLayout) {
+        unmaskedTargets.push(record.editColumnLayout.cancelButton);
+      }
     }
     this.Super('showClickMask', [clickAction, mode, unmaskedTargets]);
   },  
@@ -224,6 +233,17 @@
   resetFocusItem: function() {
     var items = this.getItems(), length = items.length, item;
     
+    // used when double clicking a specific cell in a record
+    if (this.forceFocusedField) {
+      item = this.getItem(this.forceFocusedField);
+      if(item && item.getCanFocus()) {
+        this.setFocusInItem(item, true);
+        delete this.forceFocusedField;
+        return;
+      }
+      delete this.forceFocusedField;
+    }
+
     if(this.firstFocusedField) {
       item = this.getItem(this.firstFocusedField);
       if(item && item.getCanFocus()) {
@@ -263,7 +283,18 @@
   setFindNewFocusItem: function() {
     var focusItem = this.getFocusItem(), item, items = this.getItems(),
         length = items.length;
-
+    
+    // used when double clicking a specific cell in a record
+    if (this.forceFocusedField) {
+      item = this.getItem(this.forceFocusedField);
+      if(item && item.getCanFocus()) {
+        this.setFocusInItem(item, true);
+        delete this.forceFocusedField;
+        return;
+      }
+      delete this.forceFocusedField;
+    }
+    
     if(this.firstFocusedField) {
       item = this.getItem(this.firstFocusedField);
       if(item && item.getCanFocus()) {
diff -r 8c44ad13e0d6 -r 40df33ccddc6 
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 Mar 10 18:04:48 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Thu Mar 10 19:09:23 2011 +0100
@@ -143,6 +143,12 @@
   timeFormatter: 'to24HourTime',
   
   dataProperties: {
+    // this means that after an update/add the new/updated row does not fit 
+    // in the current filter criteria then they are still shown
+    // note that if this is set to false that when using the _dummy criteria
+    // that the _dummy criteria can mean that new/updated records are not 
+    // shown in the grid
+    //neverDropUpdatedRows: true,
     useClientFiltering: false,
     useClientSorting: false,
     
@@ -291,7 +297,7 @@
         return OB.Utilities.getPromptString(cellErrors);
       }
     }
-    if (record[isc.OBViewGrid.ERROR_MESSAGE_PROP]) {
+    if (record && record[isc.OBViewGrid.ERROR_MESSAGE_PROP]) {
       return record[isc.OBViewGrid.ERROR_MESSAGE_PROP];
     }
     
@@ -343,12 +349,18 @@
     return this.Super('headerClick', arguments);
   },
 
-  // handle the del key when rows have been selected
+  // handle the del key when rows have been selected or space key
   bodyKeyPress : function (event, eventInfo) {
     if (event.keyName === 'Delete' && this.getSelectedRecords().length > 0) {
       this.view.deleteSelectedRows();
       return;      
     }
+    // don't let the default space action do something if others keys are also 
+    // pressed
+    if (event.keyName === 'Space' && 
+      (isc.EventHandler.ctrlKeyDown() || isc.EventHandler.altKeyDown() || 
isc.EventHandler.shiftKeyDown())) {
+      return true;
+    }
     return this.Super('bodyKeyPress', arguments);
   },
 
@@ -727,18 +739,14 @@
         criteria:[]};
         
       // add a dummy criteria to force a fetch
-      criteria.criteria.push({
-        fieldName: '_dummy',
-        operator: 'equals',
-        value: this.targetRecordId
-      });
+      criteria.criteria.push(isc.OBRestDataSource.getDummyCriterion());
       
       // remove the filter clause we don't want to use
       this.filterClause = null;
     } else {
       // remove the _dummy
       for (i = 0; i < criteria.criteria.length; i++) {
-        if (criteria.criteria[i].fieldName === '_dummy') {
+        if (criteria.criteria[i].fieldName === 
isc.OBRestDataSource.DUMMY_CRITERION_NAME) {
           criteria.criteria.removeAt(i);
           break;
         }
@@ -778,13 +786,15 @@
         });
       }
     }
-        // get rid of some unneeded stuff in the criteria
+    
+    // get rid of some unneeded stuff in the criteria
     if (criteria && criteria.criteria) {
       var internalCriteria = criteria.criteria;
       for (i = (internalCriteria.length - 1); i >= 0; i--) {
         var shouldRemove = false;
         criterion = internalCriteria[i];
-        if (criterion.fieldName && criterion.fieldName.startsWith('_') && 
criterion.fieldName !== '_dummy') {
+        // but do not remove dummy criterion
+        if (criterion.fieldName && criterion.fieldName.startsWith('_') && 
criterion.fieldName !== isc.OBRestDataSource.DUMMY_CRITERION_NAME) {
           shouldRemove = true;
         } else if (isc.isA.emptyString(criterion.value)) {
           shouldRemove = true;
@@ -866,7 +876,7 @@
     var actionObject = {
       target: this.view,
       method: this.view.editRecord,
-      parameters: [record]
+      parameters: [record, false, (field ? field.name : null)]
     };
     this.view.standardWindow.doActionAfterAutoSave(actionObject, true);
   },
@@ -1473,7 +1483,7 @@
   },
   
   // is called when clicking a header
-  hideInlineEditor: function(){
+  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
@@ -1487,7 +1497,8 @@
     } else if (this.getEditForm().getValues().editColumnLayout) {
       this.getEditForm().getValues().editColumnLayout.showEditOpen();
     }
-    return this.Super('hideInlineEditor', arguments);
+    // always hide the clickmask, as it needs to be re-applied
+    return this.Super('hideInlineEditor', [focusInBody, false]);
   },
   
   getEditDisplayValue: function(rowNum, colNum, record){
diff -r 8c44ad13e0d6 -r 40df33ccddc6 
modules/org.openbravo.service.datasource/web/org.openbravo.service.datasource/js/ob-datasource-utilities.js
--- 
a/modules/org.openbravo.service.datasource/web/org.openbravo.service.datasource/js/ob-datasource-utilities.js
       Thu Mar 10 18:04:48 2011 +0100
+++ 
b/modules/org.openbravo.service.datasource/web/org.openbravo.service.datasource/js/ob-datasource-utilities.js
       Thu Mar 10 19:09:23 2011 +0100
@@ -123,6 +123,19 @@
 // always use a subclass to make it easier to override some default stuff
 isc.ClassFactory.defineClass('OBRestDataSource', isc.RestDataSource);
 

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to