details:   /erp/devel/pi/rev/65517f6caa64
changeset: 10699:65517f6caa64
user:      Iván Perdomo <ivan.perdomo <at> openbravo.com>
date:      Wed Feb 16 12:05:21 2011 +0100
summary:   Implements First Focused Field
- Fixes some field focus issues
- Relate to https://www.pivotaltracker.com/story/show/9513213

details:   /erp/devel/pi/rev/b98b3801efa7
changeset: 10700:b98b3801efa7
user:      Iván Perdomo <ivan.perdomo <at> openbravo.com>
date:      Wed Feb 16 12:05:50 2011 +0100
summary:   Changed hardcoded URL in Getting Started view

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
  |   5 +-
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-form.js.ftl
   |   1 -
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
 |   4 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
          |   6 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
              |  76 +++++++--
 
modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-getting-started-view.js
                 |   9 +-
 6 files changed, 76 insertions(+), 25 deletions(-)

diffs (228 lines):

diff -r fd76e44b053b -r b98b3801efa7 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
      Wed Feb 16 10:17:28 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
      Wed Feb 16 12:05:50 2011 +0100
@@ -57,13 +57,16 @@
             }
 
             return context && (${fieldDefinition.showIf});
-          },
+          },          
           </#if>
           <#if fieldDefinition.searchField>
           displayField: '${fieldDefinition.name?js_string}._identifier',
           valueField: '${fieldDefinition.name?js_string}',
           showPickerIcon: ${(!fieldDefinition.parentProperty)?string},
           </#if>
+          <#if fieldDefinition.firstFocusedField>
+          firstFocusedField: true,
+          </#if>
         </#if>
         <#if fieldDefinition.type = "OBSectionItem" || fieldDefinition.type = 
"OBLinkedItemSectionItem" >
         sectionExpanded: true,
diff -r fd76e44b053b -r b98b3801efa7 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-form.js.ftl
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-form.js.ftl
       Wed Feb 16 10:17:28 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-form.js.ftl
       Wed Feb 16 12:05:50 2011 +0100
@@ -45,7 +45,6 @@
           }
         </#if>
         </#list>
-        f.setFindNewFocusItem();
       }
     }
 })
diff -r fd76e44b053b -r b98b3801efa7 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
     Wed Feb 16 10:17:28 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
     Wed Feb 16 12:05:50 2011 +0100
@@ -265,6 +265,10 @@
       return uiDefinition instanceof FKSearchUIDefinition;
     }
 
+    public boolean isFirstFocusedField() {
+      return field.isFirstFocusedField() && field.isDisplayed();
+    }
+
     public String getType() {
       return getUIDefinition().getName();
     }
diff -r fd76e44b053b -r b98b3801efa7 
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
      Wed Feb 16 10:17:28 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
      Wed Feb 16 12:05:50 2011 +0100
@@ -496,7 +496,7 @@
   },
   
   setViewFocus: function(){
-    
+
     var object, functionName;
     
     // clear for a non-focusable item
@@ -773,10 +773,6 @@
       var rowNum = this.viewGrid.getRecordIndex(record);
       this.viewForm.editRecord(this.viewGrid.getEditedRecord(rowNum), 
preventFocus);
     }
-    
-    if (!preventFocus) {
-      isc.Page.setEvent(isc.EH.IDLE, this.viewForm, isc.Page.FIRE_ONCE, 
'focus');
-    }
   },
   
   setMaximizeRestoreButtonState: function(){
diff -r fd76e44b053b -r b98b3801efa7 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Wed Feb 16 10:17:28 2011 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
  Wed Feb 16 12:05:50 2011 +0100
@@ -65,15 +65,30 @@
   // is false for forms used in grid editing
   // true for the main form
   isViewForm: false,
-  
+
+  // Name to the first focused field defined in AD
+  firstFocusedField: null,
+
   // is set in the OBLinkedItemSectionItem.initWidget
   linkedItemSection: null,
 
   initWidget: function() {
+    var length, i, item;
     // add the obFormProperties to ourselves, the obFormProperties
     // are re-used for inline grid editing
     isc.addProperties(this, this.obFormProperties);
+
     this.Super('initWidget', arguments);
+
+    length = this.getItems().length;
+
+    for(i = 0; i < length; i++) {
+      item = this.getItem(i);
+      if(item && item.firstFocusedField) {
+        this.firstFocusedField = item.name;
+        break;
+      }
+    }
   },
   
   setHasChanged: function(value) {
@@ -127,11 +142,7 @@
     } else {
       this.view.statusBar.setStateLabel();
     }
-
-    this.resetFocusItem();
-    if (!preventFocus) {
-      this.focus();
-    }
+    
   },
   
   editNewRecord: function(preventFocus){
@@ -177,13 +188,28 @@
   },
   
   // reset the focus item to the first item which can get focus
-  resetFocusItem: function(){
-    var items = this.getItems();
+  resetFocusItem: function() {
+    var items = this.getItems(), length = items.length, item;
+
+    if(!this.isDrawn()) {
+      isc.Page.setEvent(isc.EH.IDLE, this, isc.Page.FIRE_ONCE, 
'resetFocusItem');
+      return;
+    }
+
+    if(this.firstFocusedField) {
+      item = this.getItem(this.firstFocusedField);
+      if(item && item.getCanFocus()) {
+        item.focusInItem();
+        this.view.lastFocusedField = item;
+        return;
+      }
+    }
+
     if (items) {
-      for (var i = 0; i < items.length; i++) {
-        var item = items[i];
+      for (var i = 0; i < length; i++) {
+        item = items[i];
         if (item.getCanFocus() && !item.isDisabled()) {
-          this.setFocusItem(item);
+          this.focusInItem(item);
           this.view.lastFocusedItem = item;
           return;
         }
@@ -192,15 +218,31 @@
   },
   
   setFindNewFocusItem: function() {
-    var focusItem = this.getFocusItem();
+    var focusItem = this.getFocusItem(), item, items = this.getItems(),
+        length = items.length;
+
+    if(!this.isDrawn()) {
+      isc.Page.setEvent(isc.EH.IDLE, this, isc.Page.FIRE_ONCE, 
'resetFocusItem');
+      return;
+    }
+
+    if(this.firstFocusedField) {
+      item = this.getItem(this.firstFocusedField);
+      if(item && item.getCanFocus()) {
+        item.focusInItem();
+        this.view.lastFocusedField = item;
+        return;
+      }
+    }
+
     // no need to find a new item
     if (focusItem && !focusItem.isDisabled() && focusItem.getCanFocus()) {
       return;
     }
-    var items = this.getItems();
+
     if (items) {
-      for (var i = 0; i < items.length; i++) {
-        var item = items[i];
+      for (var i = 0; i < length; i++) {
+        item = items[i];
         if (item.getCanFocus() && !item.isDisabled()) {
           item.focusInItem();
           return;
@@ -378,7 +420,7 @@
     this.view.toolBar.updateButtonState();
     // note onFieldChanged uses the form.readOnly set above
     this.onFieldChanged(this);
-    this.focus();
+
     delete this.inFicCall;
     if (this.callSaveAfterFICReturn) {
       delete this.callSaveAfterFICReturn;
@@ -388,6 +430,8 @@
       OB.Utilities.callAction(editValues.actionAfterFicReturn);
       delete editValues.actionAfterFicReturn;
     }
+
+    this.resetFocusItem();
   },
   
   setDisabled: function(state) {
diff -r fd76e44b053b -r b98b3801efa7 
modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-getting-started-view.js
--- 
a/modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-getting-started-view.js
     Wed Feb 16 10:17:28 2011 +0100
+++ 
b/modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-getting-started-view.js
     Wed Feb 16 12:05:50 2011 +0100
@@ -26,12 +26,17 @@
   width: '100%',
   height: '100%',
   iframe: null,
-  initWidget: function() {
+  initWidget: function(args) {
+
+    if(!args.contentsURL) {
+      isc.Log.logError('contentsURL parameter is required');
+    }
+
     this.iframe = isc.HTMLFlow.create({
       width: '100%',
       height: '100%',
       contentsType: 'page',
-      contentsURL: document.location.protocol + 
'//butler.openbravo.com/web/static-content/en_US/gettingstarted/tab_navigate.html?nocache='
 + Math.random()
+      contentsURL: (args.contentsURL ? args.contentsURL : 'about:blank')
     });
     this.addMember(this.iframe);
     this.Super('initWidget', arguments);

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to