# HG changeset patch
# User Augusto Mauch <augusto.mauch@openbravo.com>
# Date 1419852178 -3600
#      Mon Dec 29 12:22:58 2014 +0100
# Node ID 23ec78f0009ba42540d190f963f0807de7386d25
# Parent  fbc674d56f047b43b679e4092bd57a0c13b81385
Fixes bug 28396:Focus not placed in field group if form has no editable fields

The issue 28396 [1] describes a problem that happens when the first focused field is a field group. This other issue [2] describes a very similar problem, the only difference beinge that instead of being reproduced in general field groups, it was reproduced for the specific audit field group. Its fixes [3], [4] only solved the problem for that particular field group.

The present changeset fixes the problem in a more general way. Instead on checking the type of the field being focused (that will change depending of whether the field group is general or specific (audit, notes, attachments, etc) it calls isc.isA.SectionItem to see whether the focused field is a field group.

[1] https://issues.openbravo.com/view.php?id=28396
[2] https://issues.openbravo.com/view.php?id=28231
[3] https://code.openbravo.com/erp/devel/pi/rev/a72704b89964c9dd369c422ccefeecca16e26551
[4] https://code.openbravo.com/erp/devel/pi/rev/c523abe0e8115d406c7e2515be7aef9d5209ce73

diff --git a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
@@ -486,8 +486,8 @@
 
     var focusItem = this.getFocusItem();
 
-    if (initializingForm && focusItem.type === 'OBAuditSectionItem') {
-      // if the does not have any editable fields, the first OBAuditSectionItem will be focused
+    if (initializingForm && isc.isA.SectionItem(focusItem)) {
+      // if the form does not have any editable fields, the first section item will be focused
       // in that case dont move the scroll to the focused item and show the first batch of fields
       this.view.formContainerLayout.scrollToTop();
       return;
