2019-04-05 04:26:08 +11:00
|
|
|
<template>
|
2019-07-05 17:17:44 +10:00
|
|
|
<button
|
|
|
|
:disabled="progress || disabled"
|
|
|
|
@click="onClick"
|
|
|
|
>
|
2019-04-05 04:26:08 +11:00
|
|
|
<template v-if="progress">
|
|
|
|
<slot name="progress" />
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<slot />
|
|
|
|
</template>
|
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
disabled: {
|
|
|
|
type: Boolean
|
|
|
|
},
|
2019-04-05 04:45:46 +11:00
|
|
|
click: { // click event handler. Must return a promise
|
2019-04-05 04:26:08 +11:00
|
|
|
type: Function,
|
|
|
|
default: () => Promise.resolve()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
progress: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onClick () {
|
|
|
|
this.progress = true
|
|
|
|
this.click().then(() => { this.progress = false })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|