add nova
This commit is contained in:
41
nova/resources/js/mixins/PreventsModalAbandonment.js
Normal file
41
nova/resources/js/mixins/PreventsModalAbandonment.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import { mapGetters, mapMutations } from 'vuex'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
show: { type: Boolean, default: false },
|
||||
},
|
||||
|
||||
methods: {
|
||||
...mapMutations(['allowLeavingModal', 'preventLeavingModal']),
|
||||
|
||||
/**
|
||||
* Prevent accidental abandonment only if form was changed.
|
||||
*/
|
||||
updateModalStatus() {
|
||||
this.preventLeavingModal()
|
||||
},
|
||||
|
||||
handlePreventModalAbandonment(proceed, revert) {
|
||||
if (this.canLeaveModal) {
|
||||
proceed()
|
||||
return
|
||||
}
|
||||
|
||||
if (
|
||||
window.confirm(
|
||||
this.__('Do you really want to leave? You have unsaved changes.')
|
||||
)
|
||||
) {
|
||||
this.allowLeavingModal()
|
||||
proceed()
|
||||
return
|
||||
}
|
||||
|
||||
revert()
|
||||
},
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters(['canLeaveModal']),
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user