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:
parent
b16a81cf6e
commit
f4f435c682
3 changed files with 108 additions and 25 deletions
45
tailbone/static/js/tailbone.buefy.oncebutton.js
Normal file
45
tailbone/static/js/tailbone.buefy.oncebutton.js
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue