details:   /erp/devel/pi/rev/ceff6c1f72dd
changeset: 10505:ceff6c1f72dd
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Feb 10 05:55:58 2011 +0100
summary:   Several improvements to inline editing

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
 |  20 +++++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
                  |   4 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
                |   2 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
                      |   5 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
                      |  34 ++++++++-
 5 files changed, 55 insertions(+), 10 deletions(-)

diffs (164 lines):

diff -r c1ca508f8ed3 -r ceff6c1f72dd 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Thu Feb 10 04:51:17 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Thu Feb 10 05:55:58 2011 +0100
@@ -66,6 +66,7 @@
 import org.openbravo.model.ad.ui.Field;
 import org.openbravo.model.ad.ui.Tab;
 import org.openbravo.service.db.DalConnectionProvider;
+import org.openbravo.service.json.JsonConstants;
 import org.openbravo.service.json.JsonToDataConverter;
 import org.openbravo.service.json.JsonUtils;
 
@@ -144,7 +145,23 @@
       if (row == null) {
         final JsonToDataConverter fromJsonConverter = 
OBProvider.getInstance().get(
             JsonToDataConverter.class);
-        row = fromJsonConverter.toBaseOBObject(jsContent);
+
+        // create a new json object using property names:
+        final JSONObject convertedJson = new JSONObject();
+        final Entity entity = ModelProvider.getInstance().getEntityByTableName(
+            tab.getTable().getDBTableName());
+        for (Property property : entity.getProperties()) {
+          if (property.getColumnName() != null) {
+            final String inpName = "inp" + 
Sqlc.TransformaNombreColumna(property.getColumnName());
+            if (jsContent.has(inpName)) {
+              convertedJson.put(property.getName(), jsContent.get(inpName));
+            }
+          }
+        }
+        // remove the id as it must be a new record
+        convertedJson.remove("id");
+        convertedJson.put(JsonConstants.ENTITYNAME, entity.getName());
+        row = fromJsonConverter.toBaseOBObject(convertedJson);
         row.setNewOBObject(true);
       }
 
@@ -193,6 +210,7 @@
           + (t8 - t7) + ")");
       return finalObject;
     } catch (Throwable t) {
+      t.printStackTrace(System.err);
       final String jsonString = JsonUtils.convertExceptionToJson(t);
       try {
         return new JSONObject(jsonString);
diff -r c1ca508f8ed3 -r ceff6c1f72dd 
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 Feb 10 04:51:17 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Thu Feb 10 05:55:58 2011 +0100
@@ -552,6 +552,10 @@
       this.activeBar.setActive(true);
       this.setViewFocus();
     } else {
+      
+      // close any editors we may have
+      this.viewGrid.closeAnyOpenEditor();
+      
       this.toolBar.hide();
       this.activeBar.setActive(false);
       // note we can not check on viewForm visibility as 
diff -r c1ca508f8ed3 -r ceff6c1f72dd 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
    Thu Feb 10 04:51:17 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-window.js
    Thu Feb 10 05:55:58 2011 +0100
@@ -153,7 +153,7 @@
   doActionAfterAutoSave: function(action, forceDialogOnFailure) {
     // if not dirty or we know that the object has errors
     if (!this.isDirty() || (this.getDirtyEditForm() && 
this.getDirtyEditForm().hasErrors())) {
-
+      
       // clean up before calling the action, as the action
       // can set dirty form again
       this.cleanUpAutoSaveProperties();
diff -r c1ca508f8ed3 -r ceff6c1f72dd 
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 Feb 10 04:51:17 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Thu Feb 10 05:55:58 2011 +0100
@@ -109,9 +109,8 @@
     // focus is done automatically, prevent the focus event if needed
     // the focus event will set the active view
     this.ignoreFirstFocusEvent = preventFocus;
-    if (isNew) {
-      this.clearErrors();
-    } else {
+    this.clearErrors();
+    if (!isNew) {
       this.validateAfterFicReturn = true;
     }
     
diff -r c1ca508f8ed3 -r ceff6c1f72dd 
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 Feb 10 04:51:17 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Thu Feb 10 05:55:58 2011 +0100
@@ -817,6 +817,10 @@
   // one has as disadvantage that it is called multiple times
   // for one select/deselect action
   selectionUpdated: function(record, recordList){
+      
+    // close any editors we may have
+    this.closeAnyOpenEditor();
+
     this.stopHover();
     this.updateSelectedCountDisplay();
     this.view.recordSelected();
@@ -1080,8 +1084,6 @@
       record.editColumnLayout.showEditOpen();
     }
     
-    this.doSelectSingleRecord(record);
-    
     this.view.toolBar.updateButtonState();
     
     // remove the error style/message
@@ -1183,6 +1185,12 @@
   // is called when clicking a header
   hideInlineEditor: function(){
     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 (record && record.editColumnLayout) {
       record.editColumnLayout.showEditOpen();
     } else if (this.getEditForm().getValues().editColumnLayout) {
@@ -1198,7 +1206,16 @@
     return this.Super('getEditDisplayValue', arguments);
   },
   
-  rowEditorEnter: function(record, editValues, rowNum){
+  showInlineEditor : function (rowNum, colNum, newCell, newRow, suppressFocus) 
{
+    if (this.getEditForm()) {
+      this.getEditForm().clearErrors();
+    }
+    var ret = this.Super('showInlineEditor', arguments);
+    if (!newRow) {
+      return ret;
+    }
+    var record = this.getRecord(rowNum);
+     
     this.view.isEditingGrid = true;
     
     record[this.recordBaseStyleProperty] = this.baseStyleEdit;
@@ -1225,8 +1242,8 @@
     }
     
     this.view.toolBar.updateButtonState();
-    
-    return true;
+
+    return ret;
   },
   
   rowEditorExit: function(editCompletionEvent, record, newValues, rowNum){
@@ -1247,6 +1264,13 @@
     this.refreshRow(rowNum);
   },
   
+  closeAnyOpenEditor: function() {
+    // close any editors we may have
+    if (this.getEditRow() || this.getEditRow() === 0) {
+      this.endEditing();
+    }
+  },
+  
   validateField: function(field, validators, value, record, options){
     // Smartclient passes in the grid field, use the editform field
     // as it contains the latest valuemap

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to