diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-05-13 15:26:12 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-05-13 15:26:12 +0200 |
| commit | 8dd5a85267b522ba569ab9ed44901f95fffbeb4f (patch) | |
| tree | ddb62d1e83e1b810b96c05f6819ca66f8d6b4955 /addons/payment/static | |
| parent | 15716642e1975b4f2f29916011a4be29804cda88 (diff) | |
| parent | 60e71302a38b36214efec1213882f573e3ea453c (diff) | |
[MERGE] forward port branch saas-12.3 up to 60e71302a38
Diffstat (limited to 'addons/payment/static')
| -rw-r--r-- | addons/payment/static/src/js/payment_form.js | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/addons/payment/static/src/js/payment_form.js b/addons/payment/static/src/js/payment_form.js index 6c795facd3b..fdab7ed573f 100644 --- a/addons/payment/static/src/js/payment_form.js +++ b/addons/payment/static/src/js/payment_form.js @@ -122,6 +122,18 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({ } }, + disableButton: function (button) { + $(button).attr('disabled', true); + $(button).children('.fa-lock').removeClass('fa-lock'); + $(button).prepend('<span class="o_loader"><i class="fa fa-refresh fa-spin"></i> </span>'); + }, + + enableButton: function (button) { + $(button).attr('disabled', false); + $(button).children('.fa').addClass('fa-lock'); + $(button).find('span.o_loader').remove(); + }, + //-------------------------------------------------------------------------- // Handlers //-------------------------------------------------------------------------- @@ -184,10 +196,7 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({ return; } - $(button).attr('disabled', true); - $(button).children('.fa-plus-circle').removeClass('fa-plus-circle'); - $(button).prepend('<span class="o_loader"><i class="fa fa-refresh fa-spin"></i> </span>'); - + this.disableButton(button); // do the call to the route stored in the 'data_set' input of the acquirer form, the data must be called 'create-route' return this._rpc({ route: ds.dataset.createRoute, @@ -219,14 +228,10 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({ } } // here we remove the 'processing' icon from the 'add a new payment' button - $(button).attr('disabled', false); - $(button).children('.fa').addClass('fa-plus-circle'); - $(button).find('span.o_loader').remove(); + self.enableButton(button); }).guardedCatch(function (error) { // if the rpc fails, pretty obvious - $(button).attr('disabled', false); - $(button).children('.fa').addClass('fa-plus-circle'); - $(button).find('span.o_loader').remove(); + self.enableButton(button); self.displayError( _t('Server Error'), @@ -294,6 +299,7 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({ } } else { // if the user is using an old payment then we just submit the form + this.disableButton(button); form.submit(); return new Promise(function () {}); } |
