bton/prohibit_sending_empty_emails #100
3 changed files with 14 additions and 10 deletions
|
@ -203,4 +203,4 @@ a {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<button @click.stop="handleClick" :disabled="disabled">
|
<button @click.stop="handleClick" :disabled="disabled || inProgress">
|
||||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"
|
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"
|
||||||
:class="{'d-none': !disabled}"></span>
|
:class="{'d-none': !inProgress}"></span>
|
||||||
<span class="ml-2" :class="{'d-none': !disabled}">In Progress...</span>
|
<span class="ml-2" :class="{'d-none': !inProgress}">In Progress...</span>
|
||||||
<span :class="{'d-none': disabled}"><slot></slot></span>
|
<span :class="{'d-none': inProgress}"><slot></slot></span>
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ export default {
|
||||||
name: 'AsyncButton',
|
name: 'AsyncButton',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
disabled: false,
|
inProgress: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
@ -21,17 +21,21 @@ export default {
|
||||||
type: Function,
|
type: Function,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
disabled: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async handleClick() {
|
async handleClick() {
|
||||||
if (this.task && typeof this.task === 'function') {
|
if (this.task && typeof this.task === 'function') {
|
||||||
this.disabled = true;
|
this.inProgress = true;
|
||||||
try {
|
try {
|
||||||
await this.task();
|
await this.task();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
} finally {
|
} finally {
|
||||||
this.disabled = false;
|
this.inProgress = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -43,4 +47,4 @@ export default {
|
||||||
.spinner-border {
|
.spinner-border {
|
||||||
vertical-align: -0.125em;
|
vertical-align: -0.125em;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<textarea placeholder="add comment..." v-model="newComment"
|
<textarea placeholder="add comment..." v-model="newComment"
|
||||||
class="form-control">
|
class="form-control">
|
||||||
</textarea>
|
</textarea>
|
||||||
<AsyncButton class="btn btn-primary float-right" :task="addCommentAndClear">
|
<AsyncButton class="btn btn-primary float-right" :task="addCommentAndClear" :disabled="!newComment">
|
||||||
<font-awesome-icon icon="comment"/>
|
<font-awesome-icon icon="comment"/>
|
||||||
Save Comment
|
Save Comment
|
||||||
</AsyncButton>
|
</AsyncButton>
|
||||||
|
|
Loading…
Add table
Reference in a new issue