send to button control

This commit is contained in:
Burak Civan 2022-07-25 11:34:47 +03:00
parent f3c5f3332b
commit 9b8e9d6816
2 changed files with 19 additions and 9 deletions

View File

@ -76,6 +76,7 @@ const app = new Vue({
',,'
],
email_template: false,
minor_form_loading: false
}
},
@ -654,20 +655,19 @@ const app = new Vue({
if (response.data.success) {
if (response.data.redirect) {
this.form.loading = true;
window.location.href = response.data.redirect;
}
}
if (response.data.error) {
this.form.loading = false;
this.form.response = response.data;
}
})
.catch(error => {
this.form.loading = false;
this.form.onFail(error);
this.method_show_html = error.message;
@ -772,7 +772,6 @@ const app = new Vue({
if (response.data.success) {
if (response.data.redirect) {
this.form.loading = true;
window.location.href = response.data.redirect;
}
}
@ -946,7 +945,7 @@ const app = new Vue({
let form_html = document.querySelector('form');
if (form_html && form_html.getAttribute('id') == 'document') {
form_html.querySelectorAll('input, textarea, select, ul, li, a, [type="button"]').forEach((element) => {
form_html.querySelectorAll('input, textarea, select, ul, li, a').forEach((element) => {
element.addEventListener('click', () => {
this.onBeforeUnload();
});
@ -970,7 +969,18 @@ const app = new Vue({
onSubmitViaSendEmail() {
this.form['senddocument'] = true;
this.minor_form_loading = true;
this.onSubmit();
this.form.loading = false;
setTimeout(() => {
if (Object.keys(this.form.errors.errors.length > 0)) {
this.minor_form_loading = false;
return;
}
}, 200);
},
},
@ -1110,6 +1120,6 @@ const app = new Vue({
}
this.form.discount = this.form.discount.replace(',', '.');
},
}
},
});

View File

@ -8,11 +8,11 @@
id="invoice-send-to"
class="relative flex items-center justify-center bg-green hover:bg-green-700 text-white px-6 py-1.5 ltr:ml-2 rtl:mr-2 text-base rounded-lg disabled:bg-green-100"
override="class"
::disabled="form.loading"
::disabled="minor_form_loading"
@click="onSubmitViaSendEmail"
>
<i v-if="form.loading" class="animate-submit delay-[0.28s] absolute w-2 h-2 rounded-full left-0 right-0 -top-3.5 m-auto before:absolute before:w-2 before:h-2 before:-left-3.5 before:rounded-full before:animate-submit before:delay-[0.14s] after:absolute after:w-2 after:h-2 after:-right-3.5 after:rounded-full after:animate-submit after:delay-[0.42s]"></i>
<span :class="[{'opacity-0': form.loading}]">
<i v-if="minor_form_loading" class="animate-submit delay-[0.28s] absolute w-2 h-2 rounded-full left-0 right-0 -top-3.5 m-auto before:absolute before:w-2 before:h-2 before:-left-3.5 before:rounded-full before:animate-submit before:delay-[0.14s] after:absolute after:w-2 after:h-2 after:-right-3.5 after:rounded-full after:animate-submit after:delay-[0.42s]"></i>
<span :class="[{'opacity-0': minor_form_loading}]">
{{ trans('general.send_to') }}
</span>
</x-button>