General UI Improvement (again) (#255)

* Add and fix some stuff

* Add warning when leaving to `mod/create`

* Fix mods/create not working
This commit is contained in:
Johan Novak
2021-06-17 22:03:12 -07:00
committed by GitHub
parent 566833da6e
commit 5859ac7a58
9 changed files with 114 additions and 22 deletions

View File

@@ -577,6 +577,8 @@ export default {
donationLinks: [],
donationPlatforms: [],
isEditing: true,
}
},
watch: {
@@ -595,6 +597,25 @@ export default {
}
},
},
mounted() {
function preventLeave(e) {
e.preventDefault()
e.returnValue = ''
}
window.addEventListener('beforeunload', preventLeave)
this.$once('hook:beforeDestroy', () => {
window.removeEventListener('beforeunload', preventLeave)
})
},
beforeRouteLeave(to, from, next) {
if (
this.isEditing &&
!window.confirm('Are you sure that you want to leave without saving?')
) {
return
}
next()
},
methods: {
async createDraft() {
this.draft = true
@@ -672,6 +693,7 @@ export default {
},
})
this.isEditing = false
await this.$router.replace('/dashboard/projects')
} catch (err) {
let description = err.response.data.description