details: https://code.openbravo.com/erp/devel/pi/rev/54b73b9d08f3
changeset: 15094:54b73b9d08f3
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Tue Jan 10 15:16:05 2012 +0100
summary: fixed bug 19382: implemented 'triggers autosave' in buttons
diffstat:
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
| 5 +-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
| 11 +-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js
| 56 ++++++---
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
| 21 ++-
4 files changed, 65 insertions(+), 28 deletions(-)
diffs (222 lines):
diff -r ea78618e25e9 -r 54b73b9d08f3
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
Tue Jan 10 15:14:15 2012 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
Tue Jan 10 15:16:05 2012 +0100
@@ -11,7 +11,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2012 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -1705,7 +1705,8 @@
},
createNewRecordForEditing: function(rowNum){
- // note: the id is dummy, will be replaced when the save succeeds
+ // note: the id is dummy, will be replaced when the save succeeds,
+ // it MUST start with _ to identify it is a temporary id
var record = {
_new: true,
id: '_' + new Date().getTime()
diff -r ea78618e25e9 -r 54b73b9d08f3
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
Tue Jan 10 15:14:15 2012 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
Tue Jan 10 15:16:05 2012 +0100
@@ -11,7 +11,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2012 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -1705,7 +1705,14 @@
// if in edit mode then the grid always has the current record selected
record[OB.Constants.ID] =
this.viewGrid.getSelectedRecord()[OB.Constants.ID];
}
-
+
+ // New records in grid have a dummy id (see
OBViewGrid.createNewRecordForEditing)
+ // whereas new form records don't have it. This temporary id starts with
_. Removing this
+ // id so it behaves in the same way in form and grid
+ if (record[OB.Constants.ID] && record[OB.Constants.ID].startsWith('_')) {
+ record[OB.Constants.ID] = undefined;
+ }
+
length = properties.length;
for (i = 0; i < length; i++) {
propertyObj = properties[i];
diff -r ea78618e25e9 -r 54b73b9d08f3
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js
Tue Jan 10 15:14:15 2012 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-action-button.js
Tue Jan 10 15:16:05 2012 +0100
@@ -11,7 +11,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011 Openbravo SLU
+ * All portions are Copyright (C) 2011-2012 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -48,13 +48,18 @@
parameters: [rowNum]
};
- theView.standardWindow.doActionAfterAutoSave(actionObject);
+ if (this.autosave) {
+ theView.standardWindow.doActionAfterAutoSave(actionObject);
+ } else {
+ OB.Utilities.callAction(actionObject);
+ }
},
doAction: function (rowNum) {
var theView = this.contextView,
me = this,
standardWindow = this.view.standardWindow,
+ autosaveButton = this.autosave,
param, allProperties, sessionProperties, callbackFunction, popupParams;
if (rowNum && !theView.viewGrid.getSelectedRecord()) {
@@ -99,7 +104,10 @@
allProperties.Command = this.command;
callbackFunction = function(){
var popup = OB.Layout.ClassicOBCompatibility.Popup.open('process',
900, 600, OB.Utilities.applicationUrl(me.obManualURL), '', null, false, false,
true, allProperties);
- popup.activeViewWhenClosed = theView;
+ if (autosaveButton) {
+ // Back to header if autosave button
+ popup.activeViewWhenClosed = theView;
+ }
};
} else {
popupParams = {
@@ -142,18 +150,29 @@
currentView.refresh(null, false, true);
};
- if (currentView.parentView) {
- currentView.parentView.setChildsToRefresh();
+ if (this.autosave) {
+ if (currentView.parentView) {
+ currentView.parentView.setChildsToRefresh();
+ } else {
+ currentView.setChildsToRefresh();
+ }
+
+ if (currentView.viewGrid.getSelectedRecord()) {
+ // There is a record selected, refresh it and its parent
+ currentView.refreshCurrentRecord(afterRefresh);
+ } else {
+ // No record selected, refresh parent
+ currentView.refreshParentRecord(afterRefresh);
+ }
} else {
- currentView.setChildsToRefresh();
- }
-
- if (currentView.viewGrid.getSelectedRecord()) {
- // There is a record selected, refresh it and its parent
- currentView.refreshCurrentRecord(afterRefresh);
- } else {
- // No record selected, refresh parent
- currentView.refreshParentRecord(afterRefresh);
+ // If the button is not autosave, do not refresh but get message.
+ contextView.getTabMessage();
+ currentView.toolBar.refreshCustomButtons();
+ if (contextView !== currentView && currentView.state ===
isc.OBStandardView.STATE_TOP_MAX) {
+ // Executing an action defined in parent tab, current tab is maximized,
+ // let's set half for each in order to see the message
+ contextView.setHalfSplit();
+ }
}
OB.ActionButton.executingProcess = null;
@@ -180,9 +199,12 @@
}
},
- updateState: function(record, hide, context) {
- var currentValues = record || this.contextView.getCurrentValues() || {};
- if (hide || !record) {
+ updateState: function(record, hide, context, keepNonAutosave) {
+ var currentValues = record || this.contextView.getCurrentValues() || {},
+ // do not hide non autosave buttons when hidding the rest if
keepNonAutosave === true
+ hideButton = hide && (!keepNonAutosave || this.autosave);
+
+ if (hideButton || !record) {
this.hide();
return;
}
diff -r ea78618e25e9 -r 54b73b9d08f3
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
Tue Jan 10 15:14:15 2012 +0100
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
Tue Jan 10 15:16:05 2012 +0100
@@ -11,7 +11,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2010-2011 Openbravo SLU
+ * All portions are Copyright (C) 2010-2012 Openbravo SLU
* All Rights Reserved.
* Contributor(s): Sreedhar Sirigiri (TDS), Mallikarjun M (TDS)
************************************************************************
@@ -1067,7 +1067,7 @@
//
refreshCustomButtons: function(noSetSession){
var selectedRecords, multipleSelectedRowIds, allProperties, i;
- function doRefresh(buttons, currentValues, hideAllButtons, me) {
+ function doRefresh(buttons, currentValues, hideAllButtons,
noneOrMultipleRecordsSelected, me) {
var i, length = me.rightMembers.length;
for (i = 0; i < length; i++) { // To disable any button previous defined
keyboard shortcut
me.rightMembers[i].disableShortcut();
@@ -1075,7 +1075,7 @@
length = buttons.length;
for (i = 0; i < length; i++) {
if (buttons[i].updateState) {
- buttons[i].updateState(currentValues, hideAllButtons);
+ buttons[i].updateState(currentValues, hideAllButtons, null,
!noneOrMultipleRecordsSelected);
}
}
length = me.leftMembers.length;
@@ -1134,7 +1134,7 @@
}
}
currentContext.viewForm.view.attachmentExists = attachmentExists;
- doRefresh(buttonsByContext[currentContext],
currentContext.getCurrentValues() || {}, noneOrMultipleRecordsSelected, me);
+ doRefresh(buttonsByContext[currentContext],
currentContext.getCurrentValues() || {}, noneOrMultipleRecordsSelected,
noneOrMultipleRecordsSelected, me);
};
};
@@ -1184,7 +1184,7 @@
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);
+ doRefresh(buttonsByContext[currentContext], currentValues || {},
hideAllButtons, noneOrMultipleRecordsSelected, this);
}
}
@@ -1221,13 +1221,20 @@
},
hideShowRightMembers: function(show) {
- var i;
+ var i, button, context;
// if showing make sure that they are not always shown
if (show) {
this.refreshCustomButtons(false);
} else {
for (i = 0; i < this.rightMembers.length; i++) {
- this.rightMembers[i].hide();
+ button = this.rightMembers[i];
+ if (button.autosave) {
+ button.hide();
+ } else{
+ // do not hide non autosave buttons, keep them in case display logic
allows it
+ context = button.contextView;
+ button.updateState(context.getCurrentValues(), false,
context.getContextInfo(false, true, true));
+ }
}
}
},
------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits