[FIX] portal: add loading on sign button
Show a loading spinner and disable sign button on orders to indicate that the request is processing avoiding users clicking multiple times and getting an error, that the order does not require signing opw-3709064 closes odoo/odoo#157836 Signed-off-by: Valentin Chevalier <vcr@odoo.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { Component, onMounted, useRef, useState } from "@odoo/owl";
|
||||
import dom from "@web/legacy/js/core/dom";
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { redirect } from "@web/core/utils/urls";
|
||||
@@ -62,10 +63,16 @@ class SignatureForm extends Component {
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async onClickSubmit() {
|
||||
const button = document.querySelector('.o_portal_sign_submit')
|
||||
const icon = button.removeChild(button.firstChild)
|
||||
const restoreBtnLoading = dom.addButtonLoadingEffect(button);
|
||||
|
||||
const name = this.signature.name;
|
||||
const signature = this.signature.getSignatureImage()[1];
|
||||
const data = await this.rpc(this.props.callUrl, { name, signature });
|
||||
if (data.force_refresh) {
|
||||
restoreBtnLoading();
|
||||
button.prepend(icon)
|
||||
if (data.redirect_url) {
|
||||
redirect(data.redirect_url);
|
||||
} else {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
</div>
|
||||
<div class="text-end my-3">
|
||||
<button type="submit" class="o_portal_sign_submit btn btn-primary" t-on-click.prevent="onClickSubmit" t-att-disabled="signature.isSignatureEmpty ? 'disabled' : ''">
|
||||
<i class="fa fa-check"/>
|
||||
<i class="fa fa-check me-1"/>
|
||||
<t t-esc="sendLabel"/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user