details:   https://code.openbravo.com/erp/devel/pi/rev/67bed13f91ca
changeset: 35885:67bed13f91ca
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Wed May 22 19:21:34 2019 +0200
summary:   Fixes issue 39865: Do not create line if mandatory fields of current 
are empty

In the view grid, if in a new line there are mandatory fields not filled in, it 
should not be
possible to create a new line.

To prevent that, the updateState function of the new line toolbar button has 
been updated, and
the doCellEditEnd function of ob-view-grid also takes it into account.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
  |  6 +++++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
 |  7 +++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r a1ba443733e7 -r 67bed13f91ca 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Tue May 21 23:28:26 2019 +0530
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Wed May 22 19:21:34 2019 +0200
@@ -3495,7 +3495,11 @@
     }
 
     // If leaving the row...
-    if (editCompletionEvent === 'enter' || editCompletionEvent === 'arrow_up' 
|| editCompletionEvent === 'arrow_down') {
+    if (newRow) {
+      // do not leave the row if the row is new and not all mandatory fields 
have been set
+      if (editForm && editForm.isNew && !editForm.allRequiredFieldsSet()) {
+        return;
+      }
       // See issue https://issues.openbravo.com/view.php?id=19830
       if (this.view.standardWindow.getDirtyEditForm()) {
         this.view.standardWindow.getDirtyEditForm().validateForm();
diff -r a1ba443733e7 -r 67bed13f91ca 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
    Tue May 21 23:28:26 2019 +0530
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
    Wed May 22 19:21:34 2019 +0200
@@ -122,8 +122,11 @@
     prompt: OB.I18N.getLabel('OBUIAPP_NewRow'),
     updateState: function () {
       var view = this.view,
-          selectedRecords = view.viewGrid.getSelectedRecords();
-      this.setDisabled(view.viewGrid.isGrouped || view.isShowingForm || 
view.readOnly || view.editOrDeleteOnly || view.singleRecord || 
!view.hasValidState() || (selectedRecords && selectedRecords.length > 1) || 
view.isShowingTree || !view.roleCanCreateRecords());
+          selectedRecords = view.viewGrid.getSelectedRecords(),
+          form = view.viewGrid.getEditForm(),
+          allFieldsSet = form && form.allRequiredFieldsSet(),
+          isNew = form && form.isNew;
+      this.setDisabled(view.viewGrid.isGrouped || view.isShowingForm || 
view.readOnly || view.editOrDeleteOnly || view.singleRecord || 
!view.hasValidState() || (selectedRecords && selectedRecords.length > 1) || 
view.isShowingTree || !view.roleCanCreateRecords() || (isNew && !allFieldsSet));
     },
     keyboardShortcutId: 'ToolBar_NewRow'
   },


_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to