details: https://code.openbravo.com/erp/devel/pi/rev/f7b0ccdf01d3
changeset: 14895:f7b0ccdf01d3
user: David Baz Fayos <david.baz <at> openbravo.com>
date: Mon Dec 19 13:56:18 2011 +0100
summary: Related to issue 19327: code improvement
diffstat:
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
| 49 ++++++++-
1 files changed, 41 insertions(+), 8 deletions(-)
diffs (74 lines):
diff -r 26982b3129be -r f7b0ccdf01d3
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
Mon Dec 19 11:33:20 2011 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
Mon Dec 19 13:56:18 2011 +0100
@@ -231,29 +231,62 @@
ATTACHMENTS_BUTTON_PROPERTIES: {
action: function(){
var selectedRows = this.view.viewGrid.getSelectedRecords(),
- attachmentExists = this.view.attachmentExists, i;
+ attachmentExists = this.view.attachmentExists,
+ attachmentSection = this.view.viewForm.getItem('_attachments_'),
+ me = this, i;
if(this.view.isShowingForm){
- if (!this.view.viewForm.getItem('_attachments_').isExpanded()) {
- this.view.viewForm.getItem('_attachments_').expandSection();
+ if (!attachmentSection.isExpanded()) {
+ attachmentSection.expandSection();
}
- this.view.viewForm.getItem('_attachments_').focusInItem();
+ attachmentSection.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);
+ this.view.viewForm.parentElement.delayCall('scrollTo', [null,
attachmentSection.getTop()], 100);
}
if(!attachmentExists){
-
this.view.viewForm.getItem('_attachments_').attachmentCanvasItem.canvas.getMember(0).getMember(0).click();
+
attachmentSection.attachmentCanvasItem.canvas.getMember(0).getMember(0).click();
}
return;
}
if(selectedRows.size() === 1){
-
this.view.viewForm.setFocusItem(this.view.viewForm.getItem('_attachments_'));
+ this.view.viewForm.setFocusItem(attachmentSection);
this.view.viewForm.forceFocusedField = '_attachments_';
this.view.viewForm.expandAttachments = true;
this.view.editRecord(selectedRows[0]);
+
+ // Move from grid view to form view could take a while.
+ // Section needs to be expanded before the viewport adjustment.
+ var expandedCount = 0, expandedInterval;
+ expandedInterval = setInterval(function() {
+ expandedCount += 1;
+ if(attachmentSection.isExpanded()){
+ me.view.viewForm.parentElement.scrollTo(null,
attachmentSection.getTop());
+ clearInterval(expandedInterval);
+ }
+ if (expandedCount === 50) {
+ clearInterval(expandedInterval);
+ }
+ }, 100);
+
if(!attachmentExists){
-
this.view.viewForm.getItem('_attachments_').attachmentCanvasItem.canvas.getMember(0).getMember(0).click();
+ if (attachmentSection.attachmentCanvasItem.canvas.getMember(0)) {
+
attachmentSection.attachmentCanvasItem.canvas.getMember(0).getMember(0).click();
+ } else {
+ // The first time the form view is loaded, the section is not
already built and it could take a while to be.
+ // Section needs to be built before the click event.
+ var clickCount = 0, clickInterval;
+ clickInterval = setInterval(function() {
+ clickCount += 1;
+ if(attachmentSection.attachmentCanvasItem.canvas.getMember(0)){
+
attachmentSection.attachmentCanvasItem.canvas.getMember(0).getMember(0).click();
+ clearInterval(clickInterval);
+ }
+ if (clickCount === 50) {
+ clearInterval(clickInterval);
+ }
+ }, 100);
+ }
}
} else {
var recordIds = "";
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits