Fixes issue 16139 Selecting new record in grid from context menu in white space click should add new record at the end of the list
authorMartin Taal <martin.taal@openbravo.com>
Sat, 05 Mar 2011 15:49:33 +0100
changeset 11032 c242649f3689
parent 11031 98b3b41b82c0
child 11033 94907954324a
Fixes issue 16139 Selecting new record in grid from context menu in white space click should add new record at the end of the list
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	Sat Mar 05 14:44:53 2011 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js	Sat Mar 05 15:49:33 2011 +0100
@@ -849,6 +849,24 @@
     var singleSelected = this.getSelectedRecords().length === 1;
     var field = this.getField(colNum);
     var grid = this;
+    if (recordsSelected) {
+      var allSelectedHaveErrors = true;
+      for (var i = 0; i < this.getSelectedRecords().length; i++) {
+        var localRowNum = this.getRecordIndex(this.getSelectedRecords()[i]);
+        if (!this.rowHasErrors(localRowNum)) {
+          allSelectedHaveErrors = false;
+          break;
+        }
+      }
+      if (allSelectedHaveErrors) {
+        menuItems.add({
+          title: OB.I18N.getLabel('OBUIAPP_UndoChanges'),
+          click: function(){
+            grid.view.undo();
+          }
+        });
+      }
+    }
     menuItems.add({
       title: OB.I18N.getLabel('OBUIAPP_CreateRecordInGrid'),
       click: function(){
@@ -1153,6 +1171,8 @@
     var insertRow = this.getDrawArea()[0];
     if (rowNum || rowNum === 0) {
       insertRow = rowNum + 1;
+    } else {
+      insertRow = this.getTotalRows();
     }
     this.createNewRecordForEditing(insertRow);
     this.startEditing(insertRow);