fixed issue 28911: Possible to create new rows in edit only tabs in grid view
authorNaroa Iriarte <naroa.iriarte@openbravo.com>
Fri, 12 Jun 2015 13:22:31 +0200
changeset 26926 0df4adc6623d
parent 26925 9db429437ead
child 26927 fa5bbdf39822
child 26928 7e18f8ff4719
fixed issue 28911: Possible to create new rows in edit only tabs in grid view

The problem was that when the UI pattern of the tab was set as "edit only", it was
possible to create new records in grid view, after editing the last record in grid view
and pressing the tab key and also by pressing the down arrow key.

The problem was in the ob-standard-view.js. There were two functions, one called
"setEditOrDeleteOnly" and another one called "setSingleRecord".
The first one, was calling another function called "setListEndEditAction" that changed
the value of "listEndEditAction" from "next" to "done" and that is the correct behaviour,
because if it is next, it allows to create a new row and in these cases we don't want it.
So, in the second function, "setSingleRecord", it was necessary to call the same function
for changing value of "listEndEditAction" from "next" to "done" for avoiding the bad behavior
of being able to create new rows.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Mon Jun 15 13:40:23 2015 +0000
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Fri Jun 12 13:22:31 2015 +0200
@@ -3443,7 +3443,7 @@
     return ret;
   },
 
-  //used in Edit or Delete only UI pattern
+  //used in Edit or Delete only UI pattern and in Single Record UI pattern
   setListEndEditAction: function () {
     this.listEndEditAction = 'done';
   },
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Mon Jun 15 13:40:23 2015 +0000
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js	Fri Jun 12 13:22:31 2015 +0200
@@ -978,12 +978,19 @@
   setEditOrDeleteOnly: function (editOrDeleteOnly) {
     this.editOrDeleteOnly = editOrDeleteOnly;
     if (editOrDeleteOnly) {
-      this.viewGrid.setListEndEditAction();
+      this.dontCreateNewRowAutomatically();
     }
   },
 
   setSingleRecord: function (singleRecord) {
     this.singleRecord = singleRecord;
+    if (singleRecord) {
+      this.dontCreateNewRowAutomatically();
+    }
+  },
+
+  dontCreateNewRowAutomatically: function () {
+    this.viewGrid.setListEndEditAction();
   },
 
   allowNewRow: function () {