details: https://code.openbravo.com/erp/devel/pi/rev/9216d290b2f2
changeset: 26266:9216d290b2f2
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Thu Mar 26 10:26:30 2015 +0100
summary: fixed bug 29388, related to issue 29418: Done can be clicked more
than once
In process definition Done button was enabled and clickable while client side
validations were being evaluated. This was specially noticeable if those
validations
perform backend requests to be completed (which is the case of Add Payment).
Fixed by disabling Done button as first step before executing any validation.
diffstat:
modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js
| 20 ++++----
modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addTransaction.js
| 5 +-
modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-findTransaction.js
| 7 ++-
modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-matchStatement.js
| 2 +-
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js
| 25 +++++++--
web/js/validateCostingRuleProcess.js
| 4 +-
6 files changed, 40 insertions(+), 23 deletions(-)
diffs (253 lines):
diff -r 172462e800ba -r 9216d290b2f2
modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js
---
a/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js
Wed Mar 25 21:19:20 2015 +0000
+++
b/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js
Thu Mar 26 10:26:30 2015 +0100
@@ -1062,7 +1062,7 @@
OB.RemoteCallManager.call('org.openbravo.advpaymentmngt.actionHandler.AddPaymentReloadLabelsActionHandler',
{}, params, callbackReloadLabelsActionHandler);
};
-OB.APRM.AddPayment.onProcess = function (view, actionHandlerCall) {
+OB.APRM.AddPayment.onProcess = function (view, actionHandlerCall,
clientSideValidationFail) {
var orderInvoiceGrid = view.theForm.getItem('order_invoice').canvas.viewGrid,
receivedFrom = view.theForm.getItem('received_from').getValue(),
issotrx = view.theForm.getItem('issotrx').getValue(),
@@ -1103,31 +1103,31 @@
// If there is Overpayment check it exists a business partner
if (overpaymentAction && receivedFrom === null) {
view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null,
OB.I18N.getLabel('APRM_CreditWithoutBPartner'));
- return false;
+ return clientSideValidationFail();
}
//If Actual Payment amount is negative, it is not necessary to use credit.
if ((total.compareTo(BigDecimal.prototype.ZERO) < 0) &&
(creditTotalItem.signum() !== 0)) {
view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null,
OB.I18N.getLabel('APRM_CreditWithNegativeAmt'));
- return false;
+ return clientSideValidationFail();
}
if (actualPayment.compareTo(total.subtract(creditTotalItem)) > 0 &&
totalOustandingAmount.compareTo(amountInvOrds.add(totalWriteOffAmount)) > 0) {
// Not all the payment amount has been allocated
view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null,
OB.I18N.getLabel('APRM_JSNOTALLAMOUTALLOCATED'));
- return false;
+ return clientSideValidationFail();
} else if (total.compareTo(actualPayment.add(creditTotalItem)) > 0) {
// More than available amount has been distributed
view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null,
OB.I18N.getLabel('APRM_JSMOREAMOUTALLOCATED'));
- return false;
+ return clientSideValidationFail();
}
if ((total.compareTo(creditTotalItem) < 0) && (overpaymentField.isVisible()
&& overpaymentAction === 'CR')) {
view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null,
OB.I18N.getLabel('APRM_MORECREDITAMOUNT'));
- return false;
+ return clientSideValidationFail();
}
if (document !== null && document !== '' &&
actualPayment.compareTo(BigDecimal.prototype.ZERO) === 0 && view.parentWindow
&& view.parentWindow.windowId) {
view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null,
OB.I18N.getLabel('APRM_ZEROAMOUNTPAYMENTTRANSACTION'));
- return false;
+ return clientSideValidationFail();
}
//It is not possible to add a glitem with both amounts equal to 0
@@ -1139,7 +1139,7 @@
paidOutAmt = new BigDecimal(String(glitemGrid.getEditedCell(i,
paidOutField) || 0));
if (receivedInAmt.signum() === 0 && paidOutAmt.signum() === 0) {
view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null,
OB.I18N.getLabel('APRM_GLITEMSDIFFERENTZERO'));
- return false;
+ return clientSideValidationFail();
}
}
@@ -1147,13 +1147,13 @@
//Check if there are blocked Business Partners
if (data.message.severity === 'error') {
view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR,
data.message.title, data.message.text);
- return false;
+ return clientSideValidationFail();
}
// Check if the write off limit has been exceeded
if (writeOffLimitPreference === 'Y') {
if (totalWriteOffAmount > data.writeofflimit) {
view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null,
OB.I18N.getLabel('APRM_NotAllowWriteOff'));
- return false;
+ return clientSideValidationFail();
}
}
actionHandlerCall(view);
diff -r 172462e800ba -r 9216d290b2f2
modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addTransaction.js
---
a/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addTransaction.js
Wed Mar 25 21:19:20 2015 +0000
+++
b/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addTransaction.js
Thu Mar 26 10:26:30 2015 +0100
@@ -30,12 +30,14 @@
};
-OB.APRM.AddTransaction.onProcess = function (view, actionHandlerCall) {
+OB.APRM.AddTransaction.onProcess = function (view, actionHandlerCall,
clientSideValidationFail) {
var execute;
execute = function (ok) {
if (ok) {
actionHandlerCall(view);
+ } else {
+ clientSideValidationFail();
}
};
@@ -52,6 +54,7 @@
if (("BPD" === trxType || "BPW" === trxType) && !glitemId && !paymentId) {
view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null,
OB.I18N.getLabel('APRM_INVALID_TRANSACTION'));
+ clientSideValidationFail();
} else if (trxAmt !== blineAmt) {
// Split required
if (hideSplitConfirmation === 'Y') {
diff -r 172462e800ba -r 9216d290b2f2
modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-findTransaction.js
---
a/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-findTransaction.js
Wed Mar 25 21:19:20 2015 +0000
+++
b/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-findTransaction.js
Thu Mar 26 10:26:30 2015 +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) 2014 Openbravo SLU
+ * All portions are Copyright (C) 2014-2015 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -19,12 +19,14 @@
OB.APRM.FindTransactions = {};
-OB.APRM.FindTransactions.onProcess = function (view, actionHandlerCall) {
+OB.APRM.FindTransactions.onProcess = function (view, actionHandlerCall,
clientSideValidationFail) {
var execute;
execute = function (ok) {
if (ok) {
actionHandlerCall(view);
+ } else {
+ clientSideValidationFail();
}
};
@@ -57,6 +59,7 @@
} else {
// No Transaction selected
view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null,
OB.I18N.getLabel('APRM_SELECT_RECORD_ERROR'));
+ clientSideValidationFail();
}
}
};
\ No newline at end of file
diff -r 172462e800ba -r 9216d290b2f2
modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-matchStatement.js
---
a/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-matchStatement.js
Wed Mar 25 21:19:20 2015 +0000
+++
b/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-matchStatement.js
Thu Mar 26 10:26:30 2015 +0100
@@ -56,7 +56,7 @@
grid.fetchData(newCriteria);
};
-OB.APRM.MatchStatement.onProcess = function (view, actionHandlerCall) {
+OB.APRM.MatchStatement.onProcess = function (view, actionHandlerCall,
clientSideValidationFail ) {
var execute;
execute = function (ok) {
if (ok) {
diff -r 172462e800ba -r 9216d290b2f2
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js
---
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js
Wed Mar 25 21:19:20 2015 +0000
+++
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/process/ob-parameter-window-view.js
Thu Mar 26 10:26:30 2015 +0100
@@ -64,6 +64,7 @@
// Buttons
function actionClick() {
+ view.setAllButtonEnabled(false);
view.messageBar.hide();
if (view.theForm) {
view.theForm.errorMessage = '';
@@ -80,6 +81,7 @@
view.messageBar.setMessage(isc.OBMessageBar.TYPE_ERROR, null,
OB.I18N.getLabel('OBUIAPP_ErrorInFields'));
}
}
+ view.setAllButtonEnabled(view.allRequiredParametersSet());
}
}
@@ -402,6 +404,7 @@
}
}
+ this.setAllButtonEnabled(this.allRequiredParametersSet());
this.showProcessing(false);
if (message) {
if (this.popup) {
@@ -531,7 +534,7 @@
doProcess: function (btnValue) {
var i, tmp, view = this,
grid, allProperties = this.getUnderLyingRecordContext(false, true,
false, true),
- selection, len, allRows, params, tab, actionHandlerCall;
+ selection, len, allRows, params, tab, actionHandlerCall,
clientSideValidationFail;
// activeView = view.parentWindow && view.parentWindow.activeView, ???.
if (this.resultLayout && this.resultLayout.destroy) {
this.resultLayout.destroy();
@@ -562,7 +565,10 @@
};
if (this.clientSideValidation) {
- this.clientSideValidation(this, actionHandlerCall);
+ clientSideValidationFail = function () {
+ view.setAllButtonEnabled(view.allRequiredParametersSet());
+ };
+ this.clientSideValidation(this, actionHandlerCall,
clientSideValidationFail);
} else {
actionHandlerCall(this);
}
@@ -715,22 +721,27 @@
return (this.buttonOwnerView &&
this.buttonOwnerView.getContextInfo(onlySessionProperties, classicMode,
forceSettingContextVars, convertToClassicFormat)) || {};
},
- handleButtonsStatus: function () {
- var allRequiredSet = this.allRequiredParametersSet();
+
+ setAllButtonEnabled: function (enabled) {
if (this.isReport) {
if (this.pdfExport) {
- this.pdfButton.setEnabled(allRequiredSet);
+ this.pdfButton.setEnabled(enabled);
}
if (this.xlsExport) {
- this.xlsButton.setEnabled(allRequiredSet);
+ this.xlsButton.setEnabled(enabled);
}
} else {
if (this.okButton) {
- this.okButton.setEnabled(allRequiredSet);
+ this.okButton.setEnabled(enabled);
}
}
},
+ handleButtonsStatus: function () {
+ var allRequiredSet = this.allRequiredParametersSet();
+ this.setAllButtonEnabled(allRequiredSet);
+ },
+
// returns true if any non-grid required parameter does not have a value
allRequiredParametersSet: function () {
var i, item, length = this.theForm.getItems().length,
diff -r 172462e800ba -r 9216d290b2f2 web/js/validateCostingRuleProcess.js
--- a/web/js/validateCostingRuleProcess.js Wed Mar 25 21:19:20 2015 +0000
+++ b/web/js/validateCostingRuleProcess.js Thu Mar 26 10:26:30 2015 +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) 2014 Openbravo SLU
+ * All portions are Copyright (C) 2014-2015 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -25,7 +25,7 @@
};
-OB.ValidateCostingRule.onProcess = function (view, actionHandlerCall) {
+OB.ValidateCostingRule.onProcess = function (view, actionHandlerCall,
clientSideValidationFail) {
var callbackOnProcessActionHandler, execute;
callbackOnProcessActionHandler = function (response, data, request) {
execute = function (ok) {
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits