Refactor modals so they work when nested in other components and fix BaseForm so it doesn't repeat ModalMixin logic
This commit is contained in:
parent
5e77c4f29c
commit
85c99182f7
@ -8,6 +8,7 @@ import MultiStepModalForm from './multi_step_modal_form'
|
|||||||
import multicheckboxinput from '../multi_checkbox_input'
|
import multicheckboxinput from '../multi_checkbox_input'
|
||||||
import checkboxinput from '../checkbox_input'
|
import checkboxinput from '../checkbox_input'
|
||||||
import levelofwarrant from '../levelofwarrant'
|
import levelofwarrant from '../levelofwarrant'
|
||||||
|
import Modal from '../../mixins/modal'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'base-form',
|
name: 'base-form',
|
||||||
@ -19,36 +20,7 @@ export default {
|
|||||||
multicheckboxinput,
|
multicheckboxinput,
|
||||||
checkboxinput,
|
checkboxinput,
|
||||||
levelofwarrant,
|
levelofwarrant,
|
||||||
|
Modal,
|
||||||
},
|
},
|
||||||
mixins: [FormMixin],
|
mixins: [FormMixin, Modal],
|
||||||
methods: {
|
|
||||||
closeModal: function(name) {
|
|
||||||
this.activeModal = null
|
|
||||||
this.$root.$emit('modalOpen', false)
|
|
||||||
if (this.$root.allyHandler) this.$root.allyHandler.disengage()
|
|
||||||
},
|
|
||||||
|
|
||||||
openModal: function(name) {
|
|
||||||
this.$root.activeModal = name
|
|
||||||
this.$root.$emit('modalOpen', true)
|
|
||||||
const idSelector = `#${this.$root.modalId}`
|
|
||||||
|
|
||||||
this.$root.allyHandler = ally.maintain.disabled({
|
|
||||||
filter: idSelector,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data: function() {
|
|
||||||
return {
|
|
||||||
activeModal: null,
|
|
||||||
allyHandler: null,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
modalId: function() {
|
|
||||||
return !!this.$root.activeModal
|
|
||||||
? `modal--${this.$root.activeModal}`
|
|
||||||
: null
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
@ -73,9 +73,10 @@ const app = new Vue({
|
|||||||
},
|
},
|
||||||
|
|
||||||
mounted: function() {
|
mounted: function() {
|
||||||
this.$on('modalOpen', isOpen => {
|
this.$on('modalOpen', data => {
|
||||||
if (isOpen) {
|
if (data['isOpen']) {
|
||||||
document.body.className += ' modal-open'
|
document.body.className += ' modal-open'
|
||||||
|
this.activeModal = data['name']
|
||||||
} else {
|
} else {
|
||||||
document.body.className = document.body.className.replace(
|
document.body.className = document.body.className.replace(
|
||||||
' modal-open',
|
' modal-open',
|
||||||
|
@ -10,7 +10,7 @@ export default {
|
|||||||
|
|
||||||
openModal: function(name) {
|
openModal: function(name) {
|
||||||
this.activeModal = name
|
this.activeModal = name
|
||||||
this.$emit('modalOpen', true)
|
this.$root.$emit('modalOpen', { isOpen: true, name: name })
|
||||||
const idSelector = `#${this.modalId}`
|
const idSelector = `#${this.modalId}`
|
||||||
|
|
||||||
this.allyHandler = ally.maintain.disabled({
|
this.allyHandler = ally.maintain.disabled({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user