details: /erp/devel/pi/rev/50c4ac0a866f
changeset: 12032:50c4ac0a866f
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Fri May 06 14:01:43 2011 +0200
summary: fixed issue 17044: Add to child tabs buttons defined within its
parent
diffstat:
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-action-button.js
| 20 +-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
| 38 +++-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
| 100 ++++++---
3 files changed, 112 insertions(+), 46 deletions(-)
diffs (266 lines):
diff -r bfff723f0372 -r 50c4ac0a866f
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-action-button.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-action-button.js
Fri May 06 13:57:54 2011 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-action-button.js
Fri May 06 14:01:43 2011 +0200
@@ -25,6 +25,7 @@
isc.OBToolbarActionButton.addProperties( {
visible: false,
modal: true,
+ contextView: null,
action : function() {
this.runProcess();
@@ -42,7 +43,7 @@
},
doAction: function(){
- var theView = this.view;
+ var theView = this.contextView;
var allProperties = theView.getContextInfo(false, true, false, true);
var sessionProperties = theView.getContextInfo(true, true, false, true);
@@ -89,10 +90,13 @@
closeProcessPopup: function(newWindow) {
//Keep current view for the callback function. Refresh and look for tab
message.
- var theView = this.view;
- this.view.refresh(function(){
- theView.getTabMessage();
- theView.toolBar.refreshCustomButtons();
+ var contextView = OB.ActionButton.executingProcess.contextView,
+ currentView = this.view;
+
+ currentView.refresh(function(){
+ // Refresh current view, taking the message set in the process'
context view
+ currentView.getTabMessage(contextView.tabId);
+ currentView.toolBar.refreshCustomButtons();
});
OB.ActionButton.executingProcess = null;
@@ -110,7 +114,7 @@
newWindow = '/'+newWindow;
}
- if (newWindow.startsWith(theView.mapping250)) {
+ if (newWindow.startsWith(contextView.mapping250)) {
// Refreshing current tab, do not open it again.
return;
}
@@ -129,7 +133,7 @@
return;
}
- this.visible = !this.displayIf || this.displayIf(null, null,
this.view.viewForm, record);
+ this.visible = !this.displayIf || this.displayIf(null, null,
this.contextView.viewForm, record);
// Even visible is correctly set, it is necessary to execute show() or
hide()
if (this.visible){
@@ -138,7 +142,7 @@
this.hide();
}
- var readonly = this.readOnlyIf && this.readOnlyIf(null, null,
this.view.viewForm, record);
+ var readonly = this.readOnlyIf && this.readOnlyIf(null, null,
this.contextView.viewForm, record);
if (readonly) {
this.disable();
} else {
diff -r bfff723f0372 -r 50c4ac0a866f
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
Fri May 06 13:57:54 2011 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
Fri May 06 14:01:43 2011 +0200
@@ -184,11 +184,13 @@
var rightMemberButtons = [];
var leftMemberButtons = [];
- var i;
+ var i, actionButton;
if (this.actionToolbarButtons) {
for (i = 0; i < this.actionToolbarButtons.length; i++) {
-
rightMemberButtons.push(isc.OBToolbarActionButton.create(this.actionToolbarButtons[i]));
+ actionButton =
isc.OBToolbarActionButton.create(this.actionToolbarButtons[i]);
+ actionButton.contextView = this;
+ rightMemberButtons.push(actionButton);
}
}
@@ -518,6 +520,33 @@
this.standardWindow.addView(childView);
+ // Add buttons in parent to child. Note that currently it is only added
one level.
+ var i;
+ if (this.actionToolbarButtons && this.actionToolbarButtons.length>0){
+ for (i = 0; i < this.actionToolbarButtons.length; i++) {
+ actionButton =
isc.OBToolbarActionButton.create(this.actionToolbarButtons[i]);
+ actionButton.contextView = this; // Context is still parent view
+ actionButton.toolBar = childView.toolBar;
+ actionButton.view = childView;
+
+ childView.toolBar.rightMembers.push(actionButton);
+
+ childView.toolBar.addMems([[actionButton]]);
+ childView.toolBar.addMems([[isc.HLayout.create({
+ width: (this.toolBar && this.toolBar.rightMembersMargin) || 12,
+ height: 1
+ })]]);
+ }
+
+ if (this.actionToolbarButtons.length > 0) {
+ // Add margin in the right
+ childView.toolBar.addMems([[isc.HLayout.create({
+ width: (this.toolBar && this.toolBar.rightMargin) || 4,
+ height: 1
+ })]]);
+ }
+ }
+
childView.parentView = this;
childView.parentTabSet = this.childTabSet;
@@ -1683,7 +1712,8 @@
}, callbackFunction);
},
- getTabMessage: function(){
+ getTabMessage: function(forcedTabId){
+ var tabId = forcedTabId || this.tabId;
var callback = function(resp, data, req){
if (req.clientContext && data.type && (data.text || data.title)) {
req.clientContext.messageBar.setMessage(OBMessageBar[data.type],
data.title, data.text);
@@ -1691,7 +1721,7 @@
};
OB.RemoteCallManager.call('org.openbravo.client.application.window.GetTabMessageActionHandler',
{
- tabId: this.tabId
+ tabId: tabId
}, null, callback, this);
}
});
diff -r bfff723f0372 -r 50c4ac0a866f
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
Fri May 06 13:57:54 2011 +0200
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
Fri May 06 14:01:43 2011 +0200
@@ -505,6 +505,11 @@
this.Super('addMembers', [newMembers]);
},
+
+
+ addMems: function(m) {
+ this.Super('addMembers', m );
+ },
// ** {{{ updateButtonState }}} **
//
@@ -968,52 +973,79 @@
}
}
- var buttons = this.getRightMembers(), numOfSelRecords = 0, isNew =
this.view.viewForm.isNew, hideAllButtons = typeof(isNew) !== 'undefined' &&
!isNew &&
- (!this.view.isShowingForm &&
(this.view.viewGrid.getSelectedRecords().size()===0)), currentValues =
this.view.getCurrentValues();
- var noneOrMultipleRecordsSelected =
this.view.viewGrid.getSelectedRecords().length !== 1;
- if (this.view.viewGrid.getSelectedRecords()) {
- numOfSelRecords = this.view.viewGrid.getSelectedRecords().length;
- }
+ var buttons = this.getRightMembers(), buttonContexts = [], currentContext,
buttonsByContext = [];
+ for (var i = 0; i < buttons.length; i++) {
+ if (!currentContext || currentContext !== buttons[i].contextView) {
+ // Adding new context
+ currentContext = buttons[i].contextView;
+ buttonContexts.push(currentContext);
+ buttonsByContext[currentContext] = [];
+ }
+ buttonsByContext[currentContext].push(buttons[i]);
+ }
- if (currentValues && !noSetSession && !this.view.isShowingForm && !isNew
&& !hideAllButtons) {
- var formView = this.view.viewForm, me = this;
- // Call FIC to obtain possible session attributes and set them in form
- requestParams = {
- MODE: 'SETSESSION',
- PARENT_ID: this.view.getParentId(),
- TAB_ID: this.view.tabId,
- ROW_ID: currentValues.id
- };
- var multipleSelectedRowIds = [];
- var selectedRecords = this.view.viewGrid.getSelectedRecords();
- if(selectedRecords.size() > 1){
- for (i = 0; i < selectedRecords.size(); i++) {
- multipleSelectedRowIds[i] = selectedRecords[i].id;
- }
- requestParams.MULTIPLE_ROW_IDS = multipleSelectedRowIds;
- }
- var allProperties = this.view.getContextInfo(false, true, false, true);
-
OB.RemoteCallManager.call('org.openbravo.client.application.window.FormInitializationComponent',
allProperties, requestParams, function(response, data, request){
+ var iButtonContext;
+
+ // This is needed to prevent JSLint complaining about "Don't make
functions within a loop.
+ var callbackHandler = function (currentContext, me) {
+ return function(response, data, request) {
var sessionAttributes = data.sessionAttributes, auxInputs =
data.auxiliaryInputValues, attachmentExists = data.attachmentExists;
if (sessionAttributes) {
- formView.sessionAttributes = sessionAttributes;
+ currentContext.viewForm.sessionAttributes = sessionAttributes;
}
if (auxInputs) {
this.auxInputs = {};
for (var prop in auxInputs) {
if (auxInputs.hasOwnProperty(prop)) {
- formView.setValue(prop, auxInputs[prop].value);
- formView.auxInputs[prop] = auxInputs[prop].value;
+ currentContext.viewForm.setValue(prop, auxInputs[prop].value);
+ currentContext.viewForm.auxInputs[prop] = auxInputs[prop].value;
}
}
}
- formView.view.attachmentExists = attachmentExists;
- doRefresh(buttons, currentValues || {}, noneOrMultipleRecordsSelected,
me);
- });
- } else {
- doRefresh(buttons, currentValues || {}, hideAllButtons ||
noneOrMultipleRecordsSelected, this);
- }
+ currentContext.viewForm.view.attachmentExists = attachmentExists;
+ doRefresh(buttonsByContext[currentContext], currentValues || {},
noneOrMultipleRecordsSelected, me);
+ };
+ };
+
+
+ for (iButtonContext = 0; iButtonContext < buttonContexts.length;
iButtonContext++) {
+ currentContext = buttonContexts[iButtonContext];
+ var numOfSelRecords = 0,
+ isNew = currentContext.viewForm.isNew,
+ hideAllButtons = typeof(isNew) !== 'undefined' && !isNew &&
(!currentContext.isShowingForm &&
(currentContext.viewGrid.getSelectedRecords().size()===0)), currentValues =
currentContext.getCurrentValues();
+
+ var noneOrMultipleRecordsSelected =
currentContext.viewGrid.getSelectedRecords().length !== 1;
+ if (currentContext.viewGrid.getSelectedRecords()) {
+ numOfSelRecords = currentContext.viewGrid.getSelectedRecords().length;
+ }
+
+ if (currentValues && !noSetSession && !currentContext.isShowingForm &&
!isNew && !hideAllButtons) {
+ var me = this;
+ // Call FIC to obtain possible session attributes and set them in form
+ requestParams = {
+ MODE: 'SETSESSION',
+ PARENT_ID: currentContext.getParentId(),
+ TAB_ID: currentContext.tabId,
+ ROW_ID: currentValues.id
+ };
+ var multipleSelectedRowIds = [];
+ var selectedRecords = currentContext.viewGrid.getSelectedRecords();
+ if(selectedRecords.size() > 1){
+ for (i = 0; i < selectedRecords.size(); i++) {
+ multipleSelectedRowIds[i] = selectedRecords[i].id;
+ }
+ requestParams.MULTIPLE_ROW_IDS = multipleSelectedRowIds;
+ }
+ var allProperties = currentContext.getContextInfo(false, true, false,
true);
+
OB.RemoteCallManager.call('org.openbravo.client.application.window.FormInitializationComponent',
allProperties, requestParams, callbackHandler(currentContext, me));
+ } else {
+ doRefresh(buttonsByContext[currentContext], currentValues || {},
hideAllButtons || noneOrMultipleRecordsSelected, this);
+ }
+ }
+
+
+
},
visibilityChanged: function(state){
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits