Fixed issue 19327: 'attachment' viewport now is placed ok when toolbar icon is pressed
authorDavid Baz Fayos <david.baz@openbravo.com>
Sun, 18 Dec 2011 20:58:28 +0100
changeset 15071 e3c9c9b1424f
parent 15070 9e5b0a0ffea5
child 15072 dc800102fd82
Fixed issue 19327: 'attachment' viewport now is placed ok when toolbar icon is pressed
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	Wed Dec 28 13:40:21 2011 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js	Sun Dec 18 20:58:28 2011 +0100
@@ -233,10 +233,17 @@
       var selectedRows = this.view.viewGrid.getSelectedRecords(),
           attachmentExists = this.view.attachmentExists, i;
       if(this.view.isShowingForm){
-        this.view.viewForm.getItem('_attachments_').expandSection();
-        this.view.viewForm.scrollToBottom();
+        if (!this.view.viewForm.getItem('_attachments_').isExpanded()) {
+          this.view.viewForm.getItem('_attachments_').expandSection();
+        }
+        this.view.viewForm.getItem('_attachments_').focusInItem();
+        if (this.view.viewForm.parentElement) {
+          // scroll after things have been expanded
+          this.view.viewForm.parentElement.delayCall('scrollTo', [null, this.view.viewForm.getItem('_attachments_').getTop()], 100);
+        }
+
         if(!attachmentExists){
-          this.view.viewForm.getItem('_attachments_').canvasItem.canvas.getMember(0).getMember(0).click();
+          this.view.viewForm.getItem('_attachments_').attachmentCanvasItem.canvas.getMember(0).getMember(0).click();
         }
         return;
       }
@@ -246,7 +253,7 @@
         this.view.viewForm.expandAttachments = true;
         this.view.editRecord(selectedRows[0]);
         if(!attachmentExists){
-          this.view.viewForm.getItem('_attachments_').canvasItem.canvas.getMember(0).getMember(0).click();
+          this.view.viewForm.getItem('_attachments_').attachmentCanvasItem.canvas.getMember(0).getMember(0).click();
         }
       } else {
         var recordIds = "";