details:   /erp/devel/pi/rev/fafef5ff2676
changeset: 9646:fafef5ff2676
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Sat Jan 08 20:55:46 2011 +0100
summary:   Add prevent active filtering parameter

details:   /erp/devel/pi/rev/a3317b12e513
changeset: 9647:a3317b12e513
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Sat Jan 08 20:56:09 2011 +0100
summary:   Add prevent active filtering parameter

details:   /erp/devel/pi/rev/8e5e2ccd56ac
changeset: 9648:8e5e2ccd56ac
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Sat Jan 08 20:57:18 2011 +0100
summary:   Improved error handling on delete, added noactive parameter, remove 
messagebar on edit record

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/ChildTabRecordCounterActionHandler.java
 |   1 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
                  |  96 +++++++--
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
                      |  28 +-
 
modules/org.openbravo.service.json/src/org/openbravo/service/json/DataEntityQueryService.java
                         |  13 +
 
modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java
                         |   4 +
 
modules/org.openbravo.service.json/src/org/openbravo/service/json/JsonConstants.java
                                  |   1 +
 6 files changed, 106 insertions(+), 37 deletions(-)

diffs (truncated from 343 to 300 lines):

diff -r 03efb297a0fb -r 8e5e2ccd56ac 
modules/org.openbravo.client.application/src/org/openbravo/client/application/ChildTabRecordCounterActionHandler.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ChildTabRecordCounterActionHandler.java
     Sat Jan 08 20:31:12 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ChildTabRecordCounterActionHandler.java
     Sat Jan 08 20:57:18 2011 +0100
@@ -61,6 +61,7 @@
       qryParameters.put(JsonConstants.NOCOUNT_PARAMETER, "false");
       qryParameters.put(JsonConstants.STARTROW_PARAMETER, "0");
       qryParameters.put(JsonConstants.ENDROW_PARAMETER, "" + 
Integer.MAX_VALUE);
+      qryParameters.put(JsonConstants.NO_ACTIVE_FILTER, "true");
 
       final JSONArray childTabList = dataObject.getJSONArray("tabs");
       final List<JSONObject> result = new ArrayList<JSONObject>();
diff -r 03efb297a0fb -r 8e5e2ccd56ac 
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
      Sat Jan 08 20:31:12 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Sat Jan 08 20:57:18 2011 +0100
@@ -311,13 +311,24 @@
     isc.defineClass(obDsClassname, ds.getClass());
     
     var modifiedDs = isc.addProperties({}, ds, {
+      fetchData: function(criteria, callback, requestProperties){
+        var newRequestProperties = 
OB.Utilities._getTabInfoRequestProperties(this.view, requestProperties);
+        var additionalPara = {
+          _operationType: 'fetch',
+          _noActiveFilter: true
+        };
+        isc.addProperties(newRequestProperties.params, additionalPara);
+        return this.Super('fetchData', [criteria, callback, 
newRequestProperties]);
+      },
+      
       updateData: function(updatedRecord, callback, requestProperties){
         var newRequestProperties = 
OB.Utilities._getTabInfoRequestProperties(this.view, requestProperties);
         //standard update is not sent with operationType
         var additionalPara = {
-          _operationType: 'update'
+          _operationType: 'update',
+          _noActiveFilter: true
         };
-        isc.addProperties(requestProperties.params, additionalPara);
+        isc.addProperties(newRequestProperties.params, additionalPara);
         this.Super('updateData', [updatedRecord, callback, 
newRequestProperties]);
       },
       
@@ -325,9 +336,10 @@
         var newRequestProperties = 
OB.Utilities._getTabInfoRequestProperties(this.view, requestProperties);
         //standard update is not sent with operationType
         var additionalPara = {
-          _operationType: 'add'
+          _operationType: 'add',
+          _noActiveFilter: true
         };
-        isc.addProperties(requestProperties.params, additionalPara);
+        isc.addProperties(newRequestProperties.params, additionalPara);
         this.Super('addData', [updatedRecord, callback, newRequestProperties]);
       },
       
@@ -335,28 +347,35 @@
         var newRequestProperties = 
OB.Utilities._getTabInfoRequestProperties(this.view, requestProperties);
         //standard update is not sent with operationType
         var additionalPara = {
-          _operationType: 'remove'
+          _operationType: 'remove',
+          _noActiveFilter: true
         };
-        isc.addProperties(requestProperties.params, additionalPara);
+        isc.addProperties(newRequestProperties.params, additionalPara);
         this.Super('removeData', [updatedRecord, callback, 
newRequestProperties]);
       },
       
       transformResponse: function(dsResponse, dsRequest, jsonData){
-        if (!jsonData.response || jsonData.response.status === 'undefined' || 
jsonData.response.status !== 0) { //0 is success
-          if (jsonData.response && jsonData.response.error) {
-            var error = jsonData.response.error;
-            if (error.type && error.type === 'user') {
-              OB.KernelUtilities.handleUserException(error.message, 
error.params);
+        if (!dsRequest.willHandleError) {
+          if (!jsonData.response || jsonData.response.status === 'undefined' 
|| jsonData.response.status !== 0) { //0 is success
+            if (jsonData.response && jsonData.response.error) {
+              var error = jsonData.response.error;
+              if (error.type && error.type === 'user') {
+                OB.KernelUtilities.handleUserException(error.message, 
error.params);
+              } else {
+                OB.KernelUtilities.handleSystemException(error.message);
+              }
+            } else if (!dsRequest.willHandleError) {
+              OB.KernelUtilities.handleSystemException('Error occured');
+            } else if (dsResponse.status && dsResponse.status === 
isc.RPCResponse.STATUS_FAILURE) {
+              this.view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, 
null, jsonData.data);
             } else {
-              OB.KernelUtilities.handleSystemException(error.message);
+              this.view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, 
null, OB.I18N.getLabel('OBUIAPP_ErrorInFields'));
             }
-          } else if (!dsRequest.willHandleError) {
-            OB.KernelUtilities.handleSystemException('Error occured');
-          } else if (dsResponse.status && dsResponse.status === 
isc.RPCResponse.STATUS_FAILURE) {
-            this.view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, 
jsonData.data);
-          } else {
-            this.view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, 
OB.I18N.getLabel('OBUIAPP_ErrorInFields'));
           }
+        } else {
+          // there are some cases where the jsonData is not passed, in case of 
errors
+          // make it available through the response object
+          dsResponse.dataObject = jsonData;
         }
         return this.Super('transformResponse', arguments);
       },
@@ -692,6 +711,8 @@
   // child views also
   editRecord: function(record, preventFocus){
   
+    this.messageBar.hide();
+    
     if (!record) { //  new case
       this.viewGrid.deselectAllRecords();
       this.viewForm.editNewRecord(preventFocus);
@@ -890,7 +911,7 @@
     };
     
     var props = {};
-    this.getContextInfo({}, props);
+    this.getContextInfo({}, props, false);
     
     
OB.RemoteCallManager.call('org.openbravo.client.application.ChildTabRecordCounterActionHandler',
 data, props, callback, null);
   },
@@ -949,12 +970,24 @@
     }
     
     var callback = function(ok){
-      var removeCallBack = function(resp, data, req){
-//        console.log(req);
-//        console.log(data);
-//        console.log(resp);
+      var error, removeCallBack = function(resp, data, req){
+        //        console.log(req);
+        //        console.log(data);
+        //        console.log(resp);
         if (resp.status === isc.RPCResponse.STATUS_SUCCESS) {
           view.messageBar.setMessage(isc.OBMessageBar.TYPE_SUCCESS, null, 
OB.I18N.getLabel('OBUIAPP_DeleteResult', [deleteCount]));
+          view.viewGrid.filterData(view.viewGrid.getCriteria());
+          view.viewGrid.updateRowCountDisplay();
+        } else {
+          // get the error message from the dataObject 
+          if (resp.dataObject && resp.dataObject.response && 
resp.dataObject.response.error && resp.dataObject.response.error.message) {
+            error = resp.dataObject.response.error;
+            if (error.type && error.type === 'user') {
+              view.messageBar.setLabel(isc.OBMessageBar.TYPE_ERROR, null, 
error.message, error.params);
+            } else {
+              view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, 
OB.I18N.getLabel('OBUIAPP_DeleteResult', [0]));
+            }
+          }
         }
       };
       
@@ -962,7 +995,7 @@
         var selection = view.viewGrid.getSelection().duplicate();
         // deselect the current records
         view.viewGrid.deselectAllRecords();
-
+        
         view.viewGrid.removeData(selection[0], removeCallBack, {
           willHandleError: true
         });
@@ -1051,6 +1084,11 @@
   //++++++++++++++++++ Reading context ++++++++++++++++++++++++++++++
   
   getContextInfo: function(allProperties, sessionProperties, classicMode){
+    // if classicmode is undefined then both classic and new props are used
+    var classicModeUndefined = (typeof classicMode === 'undefined');
+    if (classicModeUndefined) {
+      classicMode = true;
+    }
     var value, field, record, component;
     // different modes:
     // 1) showing grid with one record selected
@@ -1077,17 +1115,19 @@
         value = record[properties[i].property];
         field = component.getField(properties[i].property);
         if (typeof value !== 'undefined') {
-          if (classicMode) {
+          if (classicMode || classicModeUndefined) {
             allProperties[properties[i].column] = value;
-          } else {
+          }
+          if (!classicMode || classicModeUndefined) {
             // surround the property name with @ symbols to make them different
             // from filter criteria and such          
             allProperties['@' + this.entity + '.' + properties[i].property + 
'@'] = value;
           }
           if (properties[i].sessionProperty) {
-            if (classicMode) {
+            if (classicMode || classicModeUndefined) {
               sessionProperties[properties[i].dbColumn] = value;
-            } else {
+            }
+            if (!classicMode || classicModeUndefined) {
               sessionProperties['@' + this.entity + '.' + 
properties[i].property + '@'] = value;
             }
           }
diff -r 03efb297a0fb -r 8e5e2ccd56ac 
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
  Sat Jan 08 20:31:12 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Sat Jan 08 20:57:18 2011 +0100
@@ -52,6 +52,8 @@
   fieldsByInpColumnName: null,
   fieldsByColumnName: null,
   
+  isNew: false,
+  
   initWidget: function(){
     // iterate over the fields and set the datasource
     //    var field, i, fieldsNum = this.fields.length;
@@ -66,6 +68,7 @@
   },
   
   editRecord: function(record, preventFocus){
+    this.isNew = false;
     // focus is done automatically, prevent the focus event if needed
     // the focus event will set the active view
     this.ignoreFirstFocusEvent = preventFocus;
@@ -81,6 +84,7 @@
   },
   
   editNewRecord: function(preventFocus){
+    this.isNew = true;
     // focus is done automatically, prevent the focus event if needed
     // the focus event will set the active view
     this.ignoreFirstFocusEvent = preventFocus;
@@ -320,7 +324,7 @@
   },
   
   saveRow: function(){
-    var i, length, flds;
+    var i, length, flds, form = this;
     
     // disable the save
     this.view.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_SAVE, true);
@@ -329,28 +333,34 @@
       //      console.log(data);
       //      console.log(resp.status);
       //      console.log(resp.errors);
-      var index1, index2, errorCode;
+      var index1, index2, errorCode, view = form.view;
       var status = resp.status;
       if (status === isc.RPCResponse.STATUS_SUCCESS) {
-        this.view.messageBar.setMessage(isc.OBMessageBar.TYPE_SUCCESS, null, 
OB.I18N.getLabel('OBUIAPP_SaveSuccess'));
+        view.messageBar.setMessage(isc.OBMessageBar.TYPE_SUCCESS, null, 
OB.I18N.getLabel('OBUIAPP_SaveSuccess'));
         // disable undo, enable delete
-        this.view.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_UNDO, true);
-        this.view.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_DELETE, 
false);
+        view.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_UNDO, true);
+        view.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_DELETE, false);
+        if (form.isNew) {
+          view.viewGrid.updateRowCountDisplay();
+        }
+        form.isNew = false;
       } else if (status === isc.RPCResponse.STATUS_VALIDATION_ERROR && 
resp.errors) {
-        this.handleFieldErrors(resp.errors);
+        view.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_SAVE, false);
+        form.handleFieldErrors(resp.errors);
       } else {
         if (isc.isA.String(data) && data.indexOf('@') !== -1) {
           index1 = data.indexOf('@');
           index2 = data.indexOf('@', index1 + 1);
           if (index2 !== -1) {
             errorCode = data.substring(index1 + 1, index2);
-            this.view.messageBar.setLabel(isc.OBMessageBar.TYPE_ERROR, null, 
errorCode);
+            view.messageBar.setLabel(isc.OBMessageBar.TYPE_ERROR, null, 
errorCode);
           } else {
-            this.view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, 
data);
+            view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, 
data);
           }
         } else {
-          this.view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, 
data);
+          view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null, data);
         }
+        view.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_SAVE, false);
       }
       
       return false;
diff -r 03efb297a0fb -r 8e5e2ccd56ac 
modules/org.openbravo.service.json/src/org/openbravo/service/json/DataEntityQueryService.java
--- 
a/modules/org.openbravo.service.json/src/org/openbravo/service/json/DataEntityQueryService.java
     Sat Jan 08 20:31:12 2011 +0100
+++ 
b/modules/org.openbravo.service.json/src/org/openbravo/service/json/DataEntityQueryService.java
     Sat Jan 08 20:57:18 2011 +0100
@@ -50,6 +50,7 @@
   private Integer firstResult = null;
   private Integer maxResults = null;
 
+  private boolean filterOnActive = true;
   private QueryBuilder queryBuilder = new QueryBuilder();
 
   /**
@@ -65,6 +66,9 @@
     if (queryBuilder.hasOrganizationParameter()) {
       obq.setFilterOnReadableOrganization(false);
     }
+    if (!filterOnActive) {
+      obq.setFilterOnActive(false);
+    }
     obq.setNamedParameters(queryBuilder.getNamedParameters());
 
     return obq.count();
@@ -97,6 +101,7 @@
     if (queryBuilder.hasOrganizationParameter()) {
       obq.setFilterOnReadableOrganization(false);

------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to