Added dangerous-button component, smarter modal
This commit is contained in:
parent
16f631af1a
commit
32dc18ed6e
|
@ -0,0 +1,44 @@
|
||||||
|
<template>
|
||||||
|
<div @click="showModal = true" class="ui red button">
|
||||||
|
<slot></slot>
|
||||||
|
|
||||||
|
<modal class="small" :show.sync="showModal">
|
||||||
|
<div class="header">
|
||||||
|
<slot name="modal-header">Do you want to confirm this action?</slot>
|
||||||
|
</div>
|
||||||
|
<div class="scrolling content">
|
||||||
|
<div class="description">
|
||||||
|
<slot name="modal-content"></slot>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="actions">
|
||||||
|
<div class="ui cancel button">Cancel</div>
|
||||||
|
<div class="ui confirm red button" @click="confirm">
|
||||||
|
<slot name="modal-confirm">Confirm</slot>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</modal>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import Modal from '@/components/semantic/Modal'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: ['action'],
|
||||||
|
components: {
|
||||||
|
Modal
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
showModal: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
confirm () {
|
||||||
|
this.showModal = false
|
||||||
|
this.action()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -8,4 +8,8 @@ import Username from '@/components/common/Username'
|
||||||
|
|
||||||
Vue.component('username', Username)
|
Vue.component('username', Username)
|
||||||
|
|
||||||
|
import DangerousButton from '@/components/common/DangerousButton'
|
||||||
|
|
||||||
|
Vue.component('dangerous-button', DangerousButton)
|
||||||
|
|
||||||
export default {}
|
export default {}
|
||||||
|
|
|
@ -19,8 +19,15 @@ export default {
|
||||||
control: null
|
control: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
beforeDestroy () {
|
||||||
|
if (this.control) {
|
||||||
|
this.control.remove()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initModal () {
|
||||||
this.control = $(this.$el).modal({
|
this.control = $(this.$el).modal({
|
||||||
|
duration: 100,
|
||||||
onApprove: function () {
|
onApprove: function () {
|
||||||
this.$emit('approved')
|
this.$emit('approved')
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
|
@ -31,14 +38,19 @@ export default {
|
||||||
this.$emit('update:show', false)
|
this.$emit('update:show', false)
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
show: {
|
show: {
|
||||||
handler (newValue) {
|
handler (newValue) {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
|
this.initModal()
|
||||||
this.control.modal('show')
|
this.control.modal('show')
|
||||||
} else {
|
} else {
|
||||||
|
if (this.control) {
|
||||||
this.control.modal('hide')
|
this.control.modal('hide')
|
||||||
|
this.control.remove()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue