Skip to content

Commit

Permalink
Catch all swal dismissals
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermendes committed Apr 9, 2018
1 parent f65662b commit 30d5f7c
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 19 deletions.
4 changes: 4 additions & 0 deletions components/forms/PybossaForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ export default {
preConfirm: () => {
return this.process()
}
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
},
Expand Down
4 changes: 4 additions & 0 deletions components/presenters/IIIFAnnotation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ export default {
}
resolve()
})
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
}
Expand Down
4 changes: 4 additions & 0 deletions components/presenters/Z3950.vue
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,10 @@ export default {
comments: this.$refs.comments.value
})
}
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
},
Expand Down
4 changes: 4 additions & 0 deletions mixins/deleteDomainObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export const deleteDomainObject = {
})
callback()
}
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
}
}
Expand Down
4 changes: 4 additions & 0 deletions pages/account/_name/templates/_id/delete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ export default {
name: this.currentUser.name
}
})
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
}
}
Expand Down
16 changes: 10 additions & 6 deletions pages/account/register/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,16 @@ export default {
*/
onSuccess (data) {
if (data.status === 'sent') {
this.$swal(
'Confirm your email',
'To complete your registration please click the confirmation ' +
'link in the email that we just sent you',
'success'
)
this.$swal({
title: 'Confirm your email',
text: 'To complete your registration please click the ' +
'confirmation link in the email that we just sent you',
type: 'success'
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions pages/account/reset-password.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ export default {
has expired.</p><p>Please try submitting the password reset form
again.</p>`,
type: 'warning'
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
}
}
Expand Down
4 changes: 3 additions & 1 deletion pages/admin/collection/_short_name/celebrations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ export default {
}).then(() => {
this.$confetti.stop()
}).catch(err => {
console.debug(err)
this.$confetti.stop()
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
}
}
Expand Down
4 changes: 4 additions & 0 deletions pages/admin/collection/_short_name/exports/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ export default {
})
this.$store.dispatch('UPDATE_CURRENT_COLLECTION', data)
}
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
}
}
Expand Down
4 changes: 4 additions & 0 deletions pages/admin/collection/_short_name/tags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ export default {
this.$notifications.success({ message: `Tag deleted` })
this.refresh()
}
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
},
Expand Down
12 changes: 2 additions & 10 deletions pages/admin/collection/_short_name/volumes/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ export default {
'cannot be deleted.',
type: 'warning'
}).catch(err => {
// Refactor if vue-sweetalert gets updated to swal v.7
if (
!(typeof err === 'string' ||
(typeof err === 'object' && err.hasOwnProperty('dismiss')))
) {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
Expand Down Expand Up @@ -148,11 +144,7 @@ export default {
this.volumes = this.volumes.filter(vol => (vol.id !== id))
}
}).catch(err => {
// Refactor if vue-sweetalert gets updated to swal v.7
if (
!(typeof err === 'string' ||
(typeof err === 'object' && err.hasOwnProperty('dismiss')))
) {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
}).then(() => {
Expand Down
4 changes: 4 additions & 0 deletions pages/admin/project/_short_name/publish.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ export default {
}
})
}
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
}
}
Expand Down
4 changes: 4 additions & 0 deletions pages/admin/project/_short_name/results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export default {
if (result) {
this.$notifications.success({ message: result.message })
}
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
},
Expand Down
8 changes: 7 additions & 1 deletion pages/admin/project/_short_name/template.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ export default {
this.analyseAllResults()
}
}).catch(err => {
this.$nuxt.error(err)
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
},
Expand Down Expand Up @@ -148,6 +150,10 @@ export default {
if (result) {
this.$notifications.success({ message: result.message })
}
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
}
}
Expand Down
8 changes: 8 additions & 0 deletions pages/admin/site/results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ export default {
}
}).then(data => {
this.$notifications.flash(data)
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
},
Expand All @@ -130,6 +134,10 @@ export default {
}
}).then(data => {
this.$notifications.flash(data)
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
}
}
Expand Down
8 changes: 8 additions & 0 deletions pages/admin/site/templates.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ export default {
this.removeTemplateFromTable(template)
this.$notifications.flash(data)
this.$store.dispatch('UPDATE_N_PENDING_TEMPLATES', this.$axios)
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
},
Expand Down Expand Up @@ -143,6 +147,10 @@ export default {
this.removeTemplateFromTable(template)
this.$notifications.flash(data)
this.$store.dispatch('UPDATE_N_PENDING_TEMPLATES', this.$axios)
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,18 @@ export default {
this.$confetti.start({
shape: this.currentCollection.info.celebrations.confetti
})
this.$swal({
html: marked(msg)
}).then(() => {
this.$confetti.stop()
}).catch(err => {
console.debug(err)
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
this.$confetti.stop()
})
this.$router.push({
name: 'collection-short_name-projects',
params: {
Expand Down Expand Up @@ -319,6 +323,10 @@ export default {
title: 'Thank you!',
html: 'Your contribution has been saved successfully and will ' +
'directly help enable future research.'
}).catch(err => {
if (typeof err === 'object' && err.hasOwnProperty('dismiss')) {
this.$nuxt.error(err)
}
})
} else {
this.$notifications.answerSaved()
Expand Down

0 comments on commit 30d5f7c

Please sign in to comment.