Disable button when loading

pull/1088/head
Cagatay Civici 2021-04-16 11:06:52 +03:00
parent f17d8ce07c
commit 3e29cec8f3
1 changed files with 6 additions and 2 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<button :class="buttonClass" type="button" v-ripple> <button :class="buttonClass" type="button" v-ripple :disabled="disabled">
<slot> <slot>
<span v-if="loading && !icon" :class="iconClass"></span> <span v-if="loading && !icon" :class="iconClass"></span>
<span v-if="icon" :class="iconClass"></span> <span v-if="icon" :class="iconClass"></span>
@ -46,7 +46,8 @@ export default {
'p-button p-component': true, 'p-button p-component': true,
'p-button-icon-only': this.icon && !this.label, 'p-button-icon-only': this.icon && !this.label,
'p-button-vertical': (this.iconPos === 'top' || this.iconPos === 'bottom') && this.label, 'p-button-vertical': (this.iconPos === 'top' || this.iconPos === 'bottom') && this.label,
'p-disabled': this.$attrs.disabled 'p-disabled': this.$attrs.disabled || this.loading,
'p-button-loading': this.loading
} }
}, },
iconClass() { iconClass() {
@ -66,6 +67,9 @@ export default {
'p-badge p-component', this.badgeClass, { 'p-badge p-component', this.badgeClass, {
'p-badge-no-gutter': this.badge && String(this.badge).length === 1 'p-badge-no-gutter': this.badge && String(this.badge).length === 1
}] }]
},
disabled() {
return this.$attrs.disabled || this.loading;
} }
}, },
directives: { directives: {