Add <once-button> component for Buefy templates

i.e. just a button, which allows only one click and then auto-disables
This commit is contained in:
Lance Edgar 2019-05-21 20:11:57 -05:00
parent b16a81cf6e
commit f4f435c682
3 changed files with 108 additions and 25 deletions

View file

@ -0,0 +1,45 @@
const OnceButton = {
template: [
'<b-button',
':type="type"',
':native-type="nativeType"',
':disabled="disabled"',
'@click="clicked"',
'>',
'{{ text }}',
'</b-button>'
].join(' '),
props: {
type: String,
nativeType: String,
text: String,
working: String,
workingText: String
},
data() {
return {
disabled: false
}
},
methods: {
clicked(event) {
this.disabled = true
if (this.workingText) {
this.text = this.workingText
} else if (this.working) {
this.text = this.working + ", please wait..."
} else {
this.text = "Working, please wait..."
}
}
}
}
Vue.component('once-button', OnceButton)