details:   /erp/devel/pi/rev/797f15a7db7e
changeset: 10369:797f15a7db7e
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Fri Feb 04 06:03:50 2011 +0100
summary:   Changed cursor on menu to pointer

details:   /erp/devel/pi/rev/2616535378cf
changeset: 10370:2616535378cf
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Fri Feb 04 06:08:00 2011 +0100
summary:   Added error display/message in grid editing

details:   /erp/devel/pi/rev/b00f7e6cd5e2
changeset: 10371:b00f7e6cd5e2
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Fri Feb 04 06:08:11 2011 +0100
summary:   Prevent caching of picklists

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view-datasource.js
                                                                       |    8 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
                                                                                
  |   55 ++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
                                                                                
        |   12 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
                                                                                
      |  187 ++++++++-
 
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/images/grid/gridButton-edit-error.png
      |    0 
 
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/images/grid/gridButton-edit-error_Down.png
 |    0 
 
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/images/grid/gridButton-edit-error_Over.png
 |    0 
 
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/ob-grid-styles.css
                         |   56 ++-
 
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/ob-grid-styles.js
                          |   10 +-
 
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/ob-navigation-bar-styles.css
               |    1 +
 
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
                                                                      |    3 +
 11 files changed, 282 insertions(+), 50 deletions(-)

diffs (truncated from 636 to 300 lines):

diff -r 92cc443d6765 -r b00f7e6cd5e2 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view-datasource.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view-datasource.js
   Thu Feb 03 19:57:34 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view-datasource.js
   Fri Feb 04 06:08:11 2011 +0100
@@ -78,6 +78,14 @@
               [ 
requestProperties.clientContext.progressIndicatorSelectedRecord ],
               200);
     }
+    
+    // doing row editing
+    if (this.view.viewGrid.getEditRow()) {
+      if (!requestProperties.clientContext) {
+        requestProperties.clientContext = {};
+      }
+      requestProperties.clientContext.editRow = 
this.view.viewGrid.getEditRow(); 
+    }
 
     var newRequestProperties = this.getTabInfoRequestProperties(this.view,
         requestProperties);
diff -r 92cc443d6765 -r b00f7e6cd5e2 
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 03 19:57:34 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Fri Feb 04 06:08:11 2011 +0100
@@ -261,12 +261,17 @@
       return true;
     }
     var msg = '', title = null, type = isc.OBMessageBar.TYPE_ERROR, isLabel = 
false, params = null;
+    var gridEditing = req.clientContext.editRow || req.clientContext.editRow 
=== 0;  
     if (isc.isA.String(data)) {
       msg = data;
     } else if (data && data.response) {
       if (data.response.errors) {
         // give it to the form
-        this.viewForm.handleFieldErrors(data.response.errors);
+        if (this.isShowingForm) {
+          this.viewForm.handleFieldErrors(data.response.errors);
+        } else {
+          this.viewGrid.setRecordFieldErrorMessages(req.clientContext.editRow, 
data.response.errors);
+        }
         return true;
       } else if (data.response.error) {
         var error = data.response.error;
@@ -304,16 +309,35 @@
       index2 = msg.indexOf('@', index1 + 1);
       if (index2 !== -1) {
         errorCode = msg.substring(index1 + 1, index2);
-        this.messageBar.setLabel(type, title, errorCode, params);
+        if (gridEditing) {
+          this.setLabelInRow(req.clientContext.editRow, errorCode, params);
+        } else {
+          this.messageBar.setLabel(type, title, errorCode, params);
+        }
       }
     } else if (isLabel) {
-      this.messageBar.setLabel(type, title, msg, params);
+      if (gridEditing) {
+        this.setLabelInRow(req.clientContext.editRow, errorCode, params);
+      } else {
+        this.messageBar.setLabel(type, title, msg, params);
+      }
+    } else if (gridEditing) {
+      this.viewGrid.setRecordErrorMessage(req.clientContext.editRow, msg);
     } else {
       this.messageBar.setMessage(type, title, msg);
     }
     return true;
   },
   
+  setLabelInRow: function(rowNum, label, params) {
+    var me = this;
+    OB.I18N.getLabel(label, params, {
+      setLabel: function(text){
+        me.viewGrid.setRecordErrorMessage(rowNum, text);
+      }
+    }, 'setLabel');
+  },
+  
   // ** {{{ createViewStructure }}} **
   // Is to be overridden, is called in initWidget.
   createViewStructure: function(){
@@ -1184,22 +1208,17 @@
   undo: function(){
     var view = this, callback, form;
     if (this.isEditingGrid) {
-      form = this.viewGrid.getEditForm();
+      view.viewGrid.cancelEditing();
+      return;
     } else {
       form = this.viewForm;
     }
-    if (form.hasChanged) {
-      callback = function(ok){
-        if (ok) {
-          form.undo();
-        }
-      };
-      isc.ask(OB.I18N.getLabel('OBUIAPP_ConfirmUndo', callback), callback);
-      return;
-    }
-    throw {
-      message: 'Undo should only be enabled if the form has changed.'
+    callback = function(ok){
+      if (ok) {
+        form.undo();
+      }
     };
+    isc.ask(OB.I18N.getLabel('OBUIAPP_ConfirmUndo', callback), callback);
   },
   
   // ++++++++++++++++++++ Parent-Child Tab Handling ++++++++++++++++++++++++++
@@ -1307,7 +1326,7 @@
   //++++++++++++++++++ Reading context ++++++++++++++++++++++++++++++
   
   getContextInfo: function(onlySessionProperties, classicMode, 
forceSettingContextVars, convertToClassicFormat){
-    var contextInfo = {}, addProperty;
+    var contextInfo = {}, addProperty, rowNum;
     // if classicmode is undefined then both classic and new props are used
     var classicModeUndefined = (typeof classicMode === 'undefined');
     if (classicModeUndefined) {
@@ -1318,7 +1337,7 @@
     // 1) showing grid with one record selected
     // 2) showing form with aux inputs
     if (this.isEditingGrid) {
-      record = isc.addProperties({}, this.viewGrid.getSelectedRecord(), 
this.viewGrid.getEditForm().getValues());
+      record = isc.addProperties({}, this.viewGrid.getSelectedRecord(), 
this.viewGrid.getEditValues(this.viewGrid.getEditRow()));
       component = this.viewGrid.getEditForm();
       form = component;
     } else if (this.isShowingForm) {
@@ -1327,6 +1346,8 @@
       form = component;
     } else {
       record = this.viewGrid.getSelectedRecord();
+      rowNum = this.viewGrid.getRecordIndex(record);
+      record = isc.addProperties({}, record, 
this.viewGrid.getEditValues(rowNum));    
       component = this.viewGrid;
     }
     
diff -r 92cc443d6765 -r b00f7e6cd5e2 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
    Thu Feb 03 19:57:34 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
    Fri Feb 04 06:08:11 2011 +0100
@@ -34,13 +34,15 @@
     buttonType: 'save',
     prompt: OB.I18N.getLabel('OBUIAPP_SaveRow'),
     updateState: function() {
-      var view = this.view, form = view.viewForm;      
+      var view = this.view, form = view.viewForm, hasErrors = false, editRow;  
    
       if (view.isShowingForm) {
         this.setDisabled(!form.isNew && (form.isSaving || form.readOnly || 
               !view.hasValidState() || !form.hasChanged));
       } else if (view.isEditingGrid) {
           form = view.viewGrid.getEditForm();
-          this.setDisabled(!form.isNew && (form.isSaving || form.readOnly || 
+          editRow = view.viewGrid.getEditRow();
+          hasErrors = view.viewGrid.rowHasErrors(editRow);
+          this.setDisabled(!form.isNew && !hasErrors && (form.isSaving || 
form.readOnly || 
                 !view.hasValidState() || !form.hasChanged));
       } else {
         // enable when supporting grid editing
@@ -121,13 +123,15 @@
     buttonType: 'undo',
     prompt: OB.I18N.getLabel('OBUIAPP_Undo'),
     updateState: function() {
-      var view = this.view, form = view.viewForm, grid = view.viewGrid;
+      var view = this.view, form = view.viewForm, grid = view.viewGrid, 
hasErrors = false, editRow;
       if (view.isShowingForm) {
         this.setDisabled(form.isSaving || form.readOnly || 
!view.hasValidState() || 
             !form.hasChanged);
       } else if (view.isEditingGrid) {
+        editRow = view.viewGrid.getEditRow();
+        hasErrors = view.viewGrid.rowHasErrors(editRow);
         form = grid.getEditForm();
-        this.setDisabled(!form.isNew && (form.isSaving || form.readOnly || 
+        this.setDisabled(!form.isNew && !hasErrors && (form.isSaving || 
form.readOnly || 
               !view.hasValidState() || !form.hasChanged));
       } else {
         // support for editable grid
diff -r 92cc443d6765 -r b00f7e6cd5e2 
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 03 19:57:34 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
  Fri Feb 04 06:08:11 2011 +0100
@@ -24,7 +24,8 @@
   // note following 2 values should be the same
   // ListGrid._$ArrowUp and ListGrid._$ArrowDown
   ARROW_UP_KEY_NAME: 'Arrow_Up',
-  ARROW_DOWN_KEY_NAME: 'Arrow_Down'
+  ARROW_DOWN_KEY_NAME: 'Arrow_Down',
+  ERROR_MESSAGE_PROP : isc.OBViewGrid.ERROR_MESSAGE_PROP
 });
 
 // = OBViewGrid =
@@ -131,6 +132,8 @@
   
   currentEditColumnLayout: null,
   
+  recordBaseStyleProperty: '_recordStyle',
+  
   dataProperties: {
     useClientFiltering: false,
     useClientSorting: false,
@@ -229,6 +232,10 @@
         return OB.Utilities.getPromptString(cellErrors);
       }
     }
+    if (record[isc.OBViewGrid.ERROR_MESSAGE_PROP]) {
+      return record[isc.OBViewGrid.ERROR_MESSAGE_PROP];
+    }
+
     return this.Super('cellHoverHTML', arguments);
   },
   
@@ -896,19 +903,20 @@
   
   // +++++++++++++++++ functions for the editing +++++++++++++++++
   
-  saveEditedValues: function(rowNum, colNum, newValues, oldValues, 
editValuesID, editCompletionEvent, saveCallback){
-    this.setEditValues(this.getEditRow(), this.getEditForm().getValues(), 
true);
-    return this.Super('saveEditedValues', arguments);
-  },
-  
   editFailed: function(rowNum, colNum, newValues, oldValues, 
editCompletionEvent, dsResponse, dsRequest){
+    var record = this.getRecord(rowNum);
     var view = this.view;
-    if (dsResponse) {
-      view.setErrorMessageFromResponse(dsResponse, dsResponse.data, dsRequest);
+    
+    // set the default error message, 
+    // is possibly overridden in the next call
+    if (!record[isc.OBViewGrid.ERROR_MESSAGE_PROP]) {
+      this.setRecordErrorMessage(rowNum, 
OB.I18N.getLabel('OBUIAPP_ErrorInFields'));
     }
+    
     if (!view.isVisible()) {
       isc.warn(OB.I18N.getLabel('OBUIAPP_AutoSaveError', [view.tabTitle]));
     }
+
     this.view.updateTabTitle();
     this.view.toolBar.updateButtonState();
   },
@@ -926,31 +934,54 @@
       record.editColumnLayout = oldValues.editColumnLayout;
     }
     if (record.editColumnLayout) {
+      record.editColumnLayout.editButton.setErrorState(false);
       record.editColumnLayout.showEditOpen();
     }
+    this.view.toolBar.updateButtonState();
+
+    // remove the error style/message
+    this.setRecordErrorMessage(rowNum, null);
+
+    // update after the error message has been removed
     this.view.updateTabTitle();
-    this.view.toolBar.updateButtonState();
-    
+
     return this.Super('editComplete', arguments);
   },
   
   discardEdits: function(rowNum, colNum, dontHideEditor, editCompletionEvent){
     var localArguments = arguments;
     var me = this;
-    if (this.getEditForm().valuesHaveChanged()) {
+    if (this.getEditForm().valuesHaveChanged() || this.rowHasErrors(rowNum)) {
       isc.ask(OB.I18N.getLabel('OBUIAPP_ConfirmCancelEdit'), function(value){
         if (value) {
+          // remove the error style/msg    
+          me.setRecordErrorMessage(rowNum, null);
+    
+          // update after removing the error msg
           me.view.updateTabTitle();
           me.view.toolBar.updateButtonState();
+          
           me.Super('discardEdits', localArguments);
         }
       });
     } else {
+      // remove the error style/msg    
+      this.setRecordErrorMessage(rowNum, null);
+      
+      // update after removing the error msg
       this.view.updateTabTitle();
       this.view.toolBar.updateButtonState();
+
       me.Super('discardEdits', localArguments);
     }
   },
+    
+  getEditDisplayValue : function (rowNum, colNum, record) {
+    // somehow this extra call is needed to not restore
+    // the old value when the new value is null
+    this.storeUpdatedEditorValue();
+    return this.Super('getEditDisplayValue', arguments);
+  },
   
   rowEditorEnter: function(record, editValues, rowNum){
     this.view.isEditingGrid = true;
@@ -966,13 +997,18 @@
     if (record && record.editColumnLayout) {
       record.editColumnLayout.showSaveCancel();
     }
+    
+    this.view.toolBar.updateButtonState();
+    

------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to