fix: namespace collision of global error method with draggable error method

This commit is contained in:
Dominik Pschenitschni 2021-08-25 12:28:29 +02:00 committed by kolaente
parent 0da7a46612
commit ebeca48be4
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
57 changed files with 229 additions and 209 deletions

View file

@ -105,10 +105,10 @@ export default {
const accountDeletionService = new AccountDeleteService() const accountDeletionService = new AccountDeleteService()
accountDeletionService.confirm(this.$route.query.accountDeletionConfirm) accountDeletionService.confirm(this.$route.query.accountDeletionConfirm)
.then(() => { .then(() => {
this.success({message: this.$t('user.deletion.confirmSuccess')}) this.$message.success({message: this.$t('user.deletion.confirmSuccess')})
this.$store.dispatch('auth/refreshUserInfo') this.$store.dispatch('auth/refreshUserInfo')
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
} }
}, },
}, },

View file

@ -124,7 +124,7 @@ export default {
loadLabels() { loadLabels() {
this.$store.dispatch('labels/loadAllLabels') this.$store.dispatch('labels/loadAllLabels')
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -206,7 +206,7 @@ export default {
return return
} }
this.$store.dispatch('lists/toggleListFavorite', list) this.$store.dispatch('lists/toggleListFavorite', list)
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
resize() { resize() {
// Hide the menu by default on mobile // Hide the menu by default on mobile
@ -252,7 +252,7 @@ export default {
position, position,
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.$set(this.listUpdating, list.id, false) this.$set(this.listUpdating, list.id, false)

View file

@ -488,7 +488,7 @@ export default {
.then(r => { .then(r => {
this.$set(this, kind, r) this.$set(this, kind, r)
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
} }
}, },
setDoneFilter() { setDoneFilter() {
@ -543,7 +543,7 @@ export default {
})) }))
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
add(kind, filterName) { add(kind, filterName) {

View file

@ -71,7 +71,7 @@ export default {
this.$set(this, 'background', b) this.$set(this, 'background', b)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
.finally(() => this.backgroundLoading = false) .finally(() => this.backgroundLoading = false)
}, },
@ -82,7 +82,7 @@ export default {
return return
} }
this.$store.dispatch('lists/toggleListFavorite', list) this.$store.dispatch('lists/toggleListFavorite', list)
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
}, },
} }

View file

@ -130,7 +130,7 @@ export default {
this.migrate() this.migrate()
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
} }
}, },
@ -141,7 +141,7 @@ export default {
this.authUrl = r.url this.authUrl = r.url
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
migrate() { migrate() {
@ -159,7 +159,7 @@ export default {
this.$store.dispatch('namespaces/loadNamespaces') this.$store.dispatch('namespaces/loadNamespaces')
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.isMigrating = false this.isMigrating = false
@ -176,7 +176,7 @@ export default {
this.$store.dispatch('namespaces/loadNamespaces') this.$store.dispatch('namespaces/loadNamespaces')
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.isMigrating = false this.isMigrating = false

View file

@ -99,10 +99,10 @@ export default {
this.subscriptionService.create(subscription) this.subscriptionService.create(subscription)
.then(() => { .then(() => {
this.$emit('change', subscription) this.$emit('change', subscription)
this.success({message: this.$t('task.subscription.subscribeSuccess', {entity: this.entity})}) this.$message.success({message: this.$t('task.subscription.subscribeSuccess', {entity: this.entity})})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
unsubscribe() { unsubscribe() {
@ -113,10 +113,10 @@ export default {
this.subscriptionService.delete(subscription) this.subscriptionService.delete(subscription)
.then(() => { .then(() => {
this.$emit('change', null) this.$emit('change', null)
this.success({message: this.$t('task.subscription.unsubscribeSuccess', {entity: this.entity})}) this.$message.success({message: this.$t('task.subscription.unsubscribeSuccess', {entity: this.entity})})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -102,7 +102,7 @@ export default {
this.$set(this, 'allNotifications', r) this.$set(this, 'allNotifications', r)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
to(n, index) { to(n, index) {
@ -140,7 +140,7 @@ export default {
.then(r => { .then(r => {
this.$set(this.allNotifications, index, r) this.$set(this.allNotifications, index, r)
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
} }
}, },
}, },

View file

@ -388,12 +388,12 @@ export default {
this.createNewTask(this.query, 0, this.currentList.id) this.createNewTask(this.query, 0, this.currentList.id)
.then(r => { .then(r => {
this.success({message: this.$t('task.createSuccess')}) this.$message.success({message: this.$t('task.createSuccess')})
this.$router.push({name: 'task.detail', params: {id: r.id}}) this.$router.push({name: 'task.detail', params: {id: r.id}})
this.closeQuickActions() this.closeQuickActions()
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
newList() { newList() {
@ -407,12 +407,12 @@ export default {
}) })
this.$store.dispatch('lists/createList', newList) this.$store.dispatch('lists/createList', newList)
.then(r => { .then(r => {
this.success({message: this.$t('list.create.createdSuccess')}) this.$message.success({message: this.$t('list.create.createdSuccess')})
this.$router.push({name: 'list.index', params: {listId: r.id}}) this.$router.push({name: 'list.index', params: {listId: r.id}})
this.closeQuickActions() this.closeQuickActions()
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
newNamespace() { newNamespace() {
@ -420,11 +420,11 @@ export default {
this.$store.dispatch('namespaces/createNamespace', newNamespace) this.$store.dispatch('namespaces/createNamespace', newNamespace)
.then(() => { .then(() => {
this.success({message: this.$t('namespace.create.success')}) this.$message.success({message: this.$t('namespace.create.success')})
this.closeQuickActions() this.closeQuickActions()
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
newTeam() { newTeam() {
@ -435,11 +435,11 @@ export default {
name: 'teams.edit', name: 'teams.edit',
params: {id: r.id}, params: {id: r.id},
}) })
this.success({message: this.$t('team.create.success')}) this.$message.success({message: this.$t('team.create.success')})
this.closeQuickActions() this.closeQuickActions()
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
select(parentIndex, index) { select(parentIndex, index) {

View file

@ -234,7 +234,7 @@ export default {
this.linkShares = r this.linkShares = r
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
add() { add() {
@ -251,11 +251,11 @@ export default {
this.name = '' this.name = ''
this.password = '' this.password = ''
this.showNewForm = false this.showNewForm = false
this.success({message: this.$t('list.share.links.createSuccess')}) this.$message.success({message: this.$t('list.share.links.createSuccess')})
this.load() this.load()
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
remove() { remove() {
@ -266,11 +266,11 @@ export default {
this.linkShareService this.linkShareService
.delete(linkshare) .delete(linkshare)
.then(() => { .then(() => {
this.success({message: this.$t('list.share.links.deleteSuccess')}) this.$message.success({message: this.$t('list.share.links.deleteSuccess')})
this.load() this.load()
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.showDeleteModal = false this.showDeleteModal = false

View file

@ -282,7 +282,7 @@ export default {
) )
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
deleteSharable() { deleteSharable() {
@ -304,10 +304,10 @@ export default {
this.sharables.splice(i, 1) this.sharables.splice(i, 1)
} }
} }
this.success({message: this.$t('list.share.userTeam.removeSuccess', {type: this.shareTypeName, sharable: this.sharableName})}) this.$message.success({message: this.$t('list.share.userTeam.removeSuccess', {type: this.shareTypeName, sharable: this.sharableName})})
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
add(admin) { add(admin) {
@ -328,11 +328,11 @@ export default {
this.stuffService this.stuffService
.create(this.stuffModel) .create(this.stuffModel)
.then(() => { .then(() => {
this.success({message: this.$t('list.share.userTeam.addedSuccess', {type: this.shareTypeName})}) this.$message.success({message: this.$t('list.share.userTeam.addedSuccess', {type: this.shareTypeName})})
this.load() this.load()
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
toggleType(sharable) { toggleType(sharable) {
@ -365,10 +365,10 @@ export default {
this.$set(this.sharables[i], 'right', r.right) this.$set(this.sharables[i], 'right', r.right)
} }
} }
this.success({message: this.$t('list.share.userTeam.updatedSuccess', {type: this.shareTypeName})}) this.$message.success({message: this.$t('list.share.userTeam.updatedSuccess', {type: this.shareTypeName})})
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
find(query) { find(query) {
@ -383,7 +383,7 @@ export default {
this.$set(this, 'found', response) this.$set(this, 'found', response)
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
clearAll() { clearAll() {

View file

@ -86,7 +86,7 @@ export default {
this.errorMessage = this.$t('list.create.addListRequired') this.errorMessage = this.$t('list.create.addListRequired')
return return
} }
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -149,10 +149,10 @@ export default {
.then((r) => { .then((r) => {
this.$set(this, 'taskEditTask', r) this.$set(this, 'taskEditTask', r)
this.initTaskFields() this.initTaskFields()
this.success({message: this.$t('task.detail.updateSuccess')}) this.$message.success({message: this.$t('task.detail.updateSuccess')})
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -354,7 +354,7 @@ export default {
}) })
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
addGantAttributes(t) { addGantAttributes(t) {
@ -439,7 +439,7 @@ export default {
} }
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
editTask(task) { editTask(task) {
@ -476,7 +476,7 @@ export default {
this.hideCrateNewTask() this.hideCrateNewTask()
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
formatYear(date) { formatYear(date) {

View file

@ -88,7 +88,7 @@ export default {
this.loadedList = cloneDeep(currentList) this.loadedList = cloneDeep(currentList)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
@ -161,7 +161,7 @@ export default {
this.$set(this.tasks, e.newIndex, r) this.$set(this.tasks, e.newIndex, r)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -229,10 +229,10 @@ export default {
'attachments/removeById', 'attachments/removeById',
this.attachmentToDelete.id, this.attachmentToDelete.id,
) )
this.success(r) this.$message.success(r)
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.showDeleteModal = false this.showDeleteModal = false

View file

@ -234,7 +234,7 @@ export default {
this.makeActions() this.makeActions()
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
addComment() { addComment() {
@ -256,11 +256,11 @@ export default {
.then((r) => { .then((r) => {
this.comments.push(r) this.comments.push(r)
this.newComment.comment = '' this.newComment.comment = ''
this.success({message: this.$t('task.comment.addedSuccess')}) this.$message.success({message: this.$t('task.comment.addedSuccess')})
this.makeActions() this.makeActions()
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.creating = false this.creating = false
@ -296,7 +296,7 @@ export default {
}, 2000) }, 2000)
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.isCommentEdit = false this.isCommentEdit = false
@ -314,7 +314,7 @@ export default {
} }
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.showDeleteModal = false this.showDeleteModal = false

View file

@ -132,7 +132,7 @@ export default {
this.$emit('input', r) this.$emit('input', r)
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -89,7 +89,7 @@ export default {
}, 2000) }, 2000)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.saving = false this.saving = false

View file

@ -84,10 +84,10 @@ export default {
this.$store.dispatch('tasks/addAssignee', {user: user, taskId: this.taskId}) this.$store.dispatch('tasks/addAssignee', {user: user, taskId: this.taskId})
.then(() => { .then(() => {
this.$emit('input', this.assignees) this.$emit('input', this.assignees)
this.success({message: this.$t('task.assignee.assignSuccess')}) this.$message.success({message: this.$t('task.assignee.assignSuccess')})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
removeAssignee(user) { removeAssignee(user) {
@ -99,10 +99,10 @@ export default {
this.assignees.splice(a, 1) this.assignees.splice(a, 1)
} }
} }
this.success({message: this.$t('task.assignee.assignSuccess')}) this.$message.success({message: this.$t('task.assignee.assignSuccess')})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
findUser(query) { findUser(query) {
@ -119,7 +119,7 @@ export default {
})) }))
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
clearAllFoundUsers() { clearAllFoundUsers() {

View file

@ -115,11 +115,11 @@ export default {
.then(() => { .then(() => {
bubble() bubble()
if (showNotification) { if (showNotification) {
this.success({message: this.$t('task.label.addSuccess')}) this.$message.success({message: this.$t('task.label.addSuccess')})
} }
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
removeLabel(label) { removeLabel(label) {
@ -141,10 +141,10 @@ export default {
this.$store.dispatch('tasks/removeLabel', {label: label, taskId: this.taskId}) this.$store.dispatch('tasks/removeLabel', {label: label, taskId: this.taskId})
.then(() => { .then(() => {
removeFromState() removeFromState()
this.success({message: this.$t('task.label.removeSuccess')}) this.$message.success({message: this.$t('task.label.removeSuccess')})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
createAndAddLabel(title) { createAndAddLabel(title) {
@ -157,10 +157,10 @@ export default {
.then(r => { .then(r => {
this.addLabel(r, false) this.addLabel(r, false)
this.labels.push(r) this.labels.push(r)
this.success({message: this.$t('task.label.removeSuccess')}) this.$message.success({message: this.$t('task.label.removeSuccess')})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },

View file

@ -81,7 +81,7 @@ export default {
}, 2000) }, 2000)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.saving = false this.saving = false

View file

@ -102,7 +102,7 @@ export default {
} }
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.loadingInternal = false this.loadingInternal = false

View file

@ -63,7 +63,7 @@ export default {
this.$set(this, 'foundLists', response) this.$set(this, 'foundLists', response)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
clearAll() { clearAll() {

View file

@ -196,7 +196,7 @@ export default {
this.$set(this, 'foundTasks', response) this.$set(this, 'foundTasks', response)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
addTaskRelation() { addTaskRelation() {
@ -219,7 +219,7 @@ export default {
}, 2000) }, 2000)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
removeTaskRelation() { removeTaskRelation() {
@ -243,7 +243,7 @@ export default {
}, 2000) }, 2000)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.showDeleteModal = false this.showDeleteModal = false
@ -257,7 +257,7 @@ export default {
this.addTaskRelation() this.addTaskRelation()
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
relationKindTitle(kind, length) { relationKindTitle(kind, length) {

View file

@ -175,7 +175,7 @@ export default {
} }
this.task = t this.task = t
this.$emit('task-updated', t) this.$emit('task-updated', t)
this.success({ this.$message.success({
message: this.task.done ? message: this.task.done ?
this.$t('task.doneSuccess') : this.$t('task.doneSuccess') :
this.$t('task.undoneSuccess'), this.$t('task.undoneSuccess'),
@ -188,7 +188,7 @@ export default {
}]) }])
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
} }
@ -207,7 +207,7 @@ export default {
this.$store.dispatch('namespaces/loadNamespacesIfFavoritesDontExist') this.$store.dispatch('namespaces/loadNamespacesIfFavoritesDontExist')
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
hideDeferDueDatePopup(e) { hideDeferDueDatePopup(e) {

View file

@ -93,16 +93,16 @@ export default {
.then(r => { .then(r => {
this.avatarProvider = r.avatarProvider this.avatarProvider = r.avatarProvider
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
updateAvatarStatus() { updateAvatarStatus() {
const avatarStatus = new AvatarModel({avatarProvider: this.avatarProvider}) const avatarStatus = new AvatarModel({avatarProvider: this.avatarProvider})
this.avatarService.update(avatarStatus) this.avatarService.update(avatarStatus)
.then(() => { .then(() => {
this.success({message: this.$t('user.settings.avatar.statusUpdateSuccess')}) this.$message.success({message: this.$t('user.settings.avatar.statusUpdateSuccess')})
this.$store.commit('auth/reloadAvatar') this.$store.commit('auth/reloadAvatar')
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
uploadAvatar() { uploadAvatar() {
this.loading = true this.loading = true
@ -112,10 +112,10 @@ export default {
canvas.toBlob(blob => { canvas.toBlob(blob => {
this.avatarService.create(blob) this.avatarService.create(blob)
.then(() => { .then(() => {
this.success({message: this.$t('user.settings.avatar.setSuccess')}) this.$message.success({message: this.$t('user.settings.avatar.setSuccess')})
this.$store.commit('auth/reloadAvatar') this.$store.commit('auth/reloadAvatar')
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
.finally(() => { .finally(() => {
this.loading = false this.loading = false
this.isCropAvatar = false this.isCropAvatar = false

View file

@ -61,10 +61,10 @@ export default {
this.dataExportService.request(this.password) this.dataExportService.request(this.password)
.then(() => { .then(() => {
this.success({message: this.$t('user.export.success')}) this.$message.success({message: this.$t('user.export.success')})
this.password = '' this.password = ''
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
}, },
} }

View file

@ -113,10 +113,10 @@ export default {
this.accountDeleteService.request(this.password) this.accountDeleteService.request(this.password)
.then(() => { .then(() => {
this.success({message: this.$t('user.deletion.requestSuccess')}) this.$message.success({message: this.$t('user.deletion.requestSuccess')})
this.password = '' this.password = ''
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
cancelDeletion() { cancelDeletion() {
if (this.password === '') { if (this.password === '') {
@ -127,11 +127,11 @@ export default {
this.accountDeleteService.cancel(this.password) this.accountDeleteService.cancel(this.password)
.then(() => { .then(() => {
this.success({message: this.$t('user.deletion.scheduledCancelSuccess')}) this.$message.success({message: this.$t('user.deletion.scheduledCancelSuccess')})
this.$store.dispatch('auth/refreshUserInfo') this.$store.dispatch('auth/refreshUserInfo')
this.password = '' this.password = ''
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
}, },
} }

View file

@ -2,6 +2,8 @@ import Vue from 'vue'
import App from './App.vue' import App from './App.vue'
import router from './router' import router from './router'
import {error, success} from './message'
declare global { declare global {
interface Window { interface Window {
API_URL: string; API_URL: string;
@ -26,7 +28,6 @@ import './registerServiceWorker'
// @ts-ignore - no types available // @ts-ignore - no types available
import vueShortkey from 'vue-shortkey' import vueShortkey from 'vue-shortkey'
// Mixins // Mixins
import message from './message'
import {colorIsDark} from './helpers/color/colorIsDark' import {colorIsDark} from './helpers/color/colorIsDark'
import {setTitle} from './helpers/setTitle' import {setTitle} from './helpers/setTitle'
import {getNamespaceTitle} from './helpers/getNamespaceTitle' import {getNamespaceTitle} from './helpers/getNamespaceTitle'
@ -61,6 +62,29 @@ Vue.component('icon', FontAwesomeIcon)
Vue.use(vueShortkey, {prevent: ['input', 'textarea', '.input', '[contenteditable]']}) Vue.use(vueShortkey, {prevent: ['input', 'textarea', '.input', '[contenteditable]']})
// define as global property
const Message = {
install(Vue) {
if (this.installed) {
return
}
this.installed = true
const message = {
error(e, actions = []) {
return error(e, Vue.prototype, actions)
},
success(s, actions = []) {
return success(s, Vue.prototype, actions)
},
}
Vue.prototype['$message'] = message
},
}
Vue.use(Message)
import focus from './directives/focus' import focus from './directives/focus'
Vue.directive('focus', focus) Vue.directive('focus', focus)
@ -94,12 +118,6 @@ Vue.mixin({
getListTitle(l) { getListTitle(l) {
return getListTitle(l, (p: VueI18n.Path) => this.$t(p)) return getListTitle(l, (p: VueI18n.Path) => this.$t(p))
}, },
error(e, actions = []) {
return message.error(e, this, (p: VueI18n.Path) => this.$t(p), actions)
},
success(s, actions = []) {
return message.success(s, this, (p: VueI18n.Path) => this.$t(p), actions)
},
colorIsDark: colorIsDark, colorIsDark: colorIsDark,
setTitle: setTitle, setTitle: setTitle,
}, },

View file

@ -1,9 +1,11 @@
export const getErrorText = (r, $t) => { import {i18n} from '@/i18n/setup'
export const getErrorText = (r) => {
if (r.response && r.response.data) { if (r.response && r.response.data) {
if(r.response.data.code) { if(r.response.data.code) {
const path = `error.${r.response.data.code}` const path = `error.${r.response.data.code}`
const message = $t(path) const message = i18n.t(path)
// If message and path are equal no translation exists for that error code // If message and path are equal no translation exists for that error code
if (path !== message) { if (path !== message) {
@ -25,23 +27,23 @@ export const getErrorText = (r, $t) => {
return [r.message] return [r.message]
} }
export default { export function error(e, context, actions = []) {
error(e, context, $t, actions = []) {
context.$notify({ context.$notify({
type: 'error', type: 'error',
title: $t('error.error'), title: i18n.t('error.error'),
text: getErrorText(e, $t), text: getErrorText(e),
actions: actions, actions: actions,
}) })
}, console.error(e, actions)
success(e, context, $t, actions = []) { }
export function success(e, context, actions = []) {
context.$notify({ context.$notify({
type: 'success', type: 'success',
title: $t('error.success'), title: i18n.t('error.success'),
text: getErrorText(e, $t), text: getErrorText(e),
data: { data: {
actions: actions, actions: actions,
}, },
}) })
},
} }

View file

@ -108,7 +108,7 @@ export default {
this.$store.dispatch('namespaces/loadNamespaces') this.$store.dispatch('namespaces/loadNamespaces')
this.$router.push({name: 'list.index', params: {listId: r.getListId()}}) this.$router.push({name: 'list.index', params: {listId: r.getListId()}})
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
}, },
} }

View file

@ -35,10 +35,10 @@ export default {
this.filterService.delete(filter) this.filterService.delete(filter)
.then(() => { .then(() => {
this.$store.dispatch('namespaces/loadNamespaces') this.$store.dispatch('namespaces/loadNamespaces')
this.success({message: this.$t('filters.delete.success')}) this.$message.success({message: this.$t('filters.delete.success')})
this.$router.push({name: 'namespaces.index'}) this.$router.push({name: 'namespaces.index'})
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
}, },
} }

View file

@ -110,19 +110,19 @@ export default {
this.filter = r this.filter = r
this.filters = objectToSnakeCase(this.filter.filters) this.filters = objectToSnakeCase(this.filter.filters)
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
save() { save() {
this.filter.filters = this.filters this.filter.filters = this.filters
this.filterService.update(this.filter) this.filterService.update(this.filter)
.then(r => { .then(r => {
this.$store.dispatch('namespaces/loadNamespaces') this.$store.dispatch('namespaces/loadNamespaces')
this.success({message: this.$t('filters.attributes.edit.success')}) this.$message.success({message: this.$t('filters.attributes.edit.success')})
this.filter = r this.filter = r
this.filters = objectToSnakeCase(this.filter.filters) this.filters = objectToSnakeCase(this.filter.filters)
this.$router.back() this.$router.back()
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
}, },
} }

View file

@ -140,25 +140,25 @@ export default {
loadLabels() { loadLabels() {
this.$store.dispatch('labels/loadAllLabels') this.$store.dispatch('labels/loadAllLabels')
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
deleteLabel(label) { deleteLabel(label) {
this.$store.dispatch('labels/deleteLabel', label) this.$store.dispatch('labels/deleteLabel', label)
.then(() => { .then(() => {
this.success({message: this.$t('label.deleteSuccess')}) this.$message.success({message: this.$t('label.deleteSuccess')})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
editLabelSubmit() { editLabelSubmit() {
this.$store.dispatch('labels/updateLabel', this.labelEditLabel) this.$store.dispatch('labels/updateLabel', this.labelEditLabel)
.then(() => { .then(() => {
this.success({message: this.$t('label.edit.success')}) this.$message.success({message: this.$t('label.edit.success')})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
editLabel(label) { editLabel(label) {

View file

@ -77,10 +77,10 @@ export default {
name: 'labels.index', name: 'labels.index',
params: {id: r.id}, params: {id: r.id},
}) })
this.success({message: this.$t('label.create.success')}) this.$message.success({message: this.$t('label.create.success')})
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -69,14 +69,14 @@ export default {
this.$store this.$store
.dispatch('lists/createList', this.list) .dispatch('lists/createList', this.list)
.then((r) => { .then((r) => {
this.success({message: this.$t('list.create.createdSuccess') }) this.$message.success({message: this.$t('list.create.createdSuccess') })
this.$router.push({ this.$router.push({
name: 'list.index', name: 'list.index',
params: { listId: r.id }, params: { listId: r.id },
}) })
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -148,7 +148,7 @@ export default {
this.setTitle(this.getListTitle(r)) this.setTitle(this.getListTitle(r))
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.listLoaded = this.$route.params.listId this.listLoaded = this.$route.params.listId

View file

@ -36,10 +36,10 @@ export default {
.then(r => { .then(r => {
this.$store.commit('currentList', r) this.$store.commit('currentList', r)
this.$store.commit('namespaces/setListInNamespaceById', r) this.$store.commit('namespaces/setListInNamespaceById', r)
this.success({message: this.$t('list.archive.success')}) this.$message.success({message: this.$t('list.archive.success')})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.$router.back() this.$router.back()

View file

@ -132,7 +132,7 @@ export default {
}) })
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, 300) }, 300)
}, },
@ -146,10 +146,10 @@ export default {
.then(l => { .then(l => {
this.$store.commit(CURRENT_LIST, l) this.$store.commit(CURRENT_LIST, l)
this.$store.commit('namespaces/setListInNamespaceById', l) this.$store.commit('namespaces/setListInNamespaceById', l)
this.success({message: this.$t('list.background.success')}) this.$message.success({message: this.$t('list.background.success')})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
uploadBackground() { uploadBackground() {
@ -161,10 +161,10 @@ export default {
.then(l => { .then(l => {
this.$store.commit(CURRENT_LIST, l) this.$store.commit(CURRENT_LIST, l)
this.$store.commit('namespaces/setListInNamespaceById', l) this.$store.commit('namespaces/setListInNamespaceById', l)
this.success({message: this.$t('list.background.success')}) this.$message.success({message: this.$t('list.background.success')})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
removeBackground() { removeBackground() {
@ -172,11 +172,11 @@ export default {
.then(l => { .then(l => {
this.$store.commit(CURRENT_LIST, l) this.$store.commit(CURRENT_LIST, l)
this.$store.commit('namespaces/setListInNamespaceById', l) this.$store.commit('namespaces/setListInNamespaceById', l)
this.success({message: this.$t('list.background.removeSuccess')}) this.$message.success({message: this.$t('list.background.removeSuccess')})
this.$router.back() this.$router.back()
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -25,11 +25,11 @@ export default {
this.$store.dispatch('lists/deleteList', list) this.$store.dispatch('lists/deleteList', list)
.then(() => { .then(() => {
this.success({message: this.$t('list.delete.success')}) this.$message.success({message: this.$t('list.delete.success')})
this.$router.push({name: 'home'}) this.$router.push({name: 'home'})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -48,11 +48,11 @@ export default {
.then(r => { .then(r => {
this.$store.commit('namespaces/addListToNamespace', r.list) this.$store.commit('namespaces/addListToNamespace', r.list)
this.$store.commit('lists/setList', r.list) this.$store.commit('lists/setList', r.list)
this.success({message: this.$t('list.duplicate.success')}) this.$message.success({message: this.$t('list.duplicate.success')})
this.$router.push({name: 'list.index', params: {listId: r.list.id}}) this.$router.push({name: 'list.index', params: {listId: r.list.id}})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -109,17 +109,17 @@ export default {
this.setTitle(this.$t('list.edit.title', {list: this.list.title})) this.setTitle(this.$t('list.edit.title', {list: this.list.title}))
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
save() { save() {
this.$store.dispatch('lists/updateList', this.list) this.$store.dispatch('lists/updateList', this.list)
.then(() => { .then(() => {
this.success({message: this.$t('list.edit.success')}) this.$message.success({message: this.$t('list.edit.success')})
this.$router.back() this.$router.back()
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -70,7 +70,7 @@ export default {
this.setTitle(this.$t('list.share.title', {list: this.list.title})) this.setTitle(this.$t('list.share.title', {list: this.list.title}))
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -367,14 +367,14 @@ export default {
bucketId: b.id, bucketId: b.id,
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
} }
}) })
}) })
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
updateTaskPosition(e) { updateTaskPosition(e) {
@ -395,7 +395,7 @@ export default {
this.$store.dispatch('tasks/update', task) this.$store.dispatch('tasks/update', task)
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.$set(this.taskUpdating, task.id, false) this.$set(this.taskUpdating, task.id, false)
@ -419,7 +419,7 @@ export default {
this.$store.commit('kanban/addTaskToBucket', r) this.$store.commit('kanban/addTaskToBucket', r)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
if (!this.$refs[`tasks-container${bucketId}`][0]) { if (!this.$refs[`tasks-container${bucketId}`][0]) {
@ -444,7 +444,7 @@ export default {
this.showNewBucketInput = false this.showNewBucketInput = false
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
deleteBucketModal(bucketId) { deleteBucketModal(bucketId) {
@ -463,10 +463,10 @@ export default {
this.$store.dispatch('kanban/deleteBucket', {bucket: bucket, params: this.params}) this.$store.dispatch('kanban/deleteBucket', {bucket: bucket, params: this.params})
.then(() => { .then(() => {
this.success({message: this.$t('list.kanban.deleteBucketSuccess')}) this.$message.success({message: this.$t('list.kanban.deleteBucketSuccess')})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.showBucketDeleteModal = false this.showBucketDeleteModal = false
@ -499,20 +499,20 @@ export default {
.then(r => { .then(r => {
realBucket.title = r.title realBucket.title = r.title
bucketTitleElement.blur() bucketTitleElement.blur()
this.success({message: this.$t('list.kanban.bucketTitleSavedSuccess')}) this.$message.success({message: this.$t('list.kanban.bucketTitleSavedSuccess')})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
updateBucket(bucket) { updateBucket(bucket) {
bucket.limit = parseInt(bucket.limit) bucket.limit = parseInt(bucket.limit)
this.$store.dispatch('kanban/updateBucket', bucket) this.$store.dispatch('kanban/updateBucket', bucket)
.then(() => { .then(() => {
this.success({message: this.$t('list.kanban.bucketLimitSavedSuccess')}) this.$message.success({message: this.$t('list.kanban.bucketLimitSavedSuccess')})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
updateBucketPosition(e) { updateBucketPosition(e) {
@ -526,7 +526,7 @@ export default {
this.$store.dispatch('kanban/updateBucket', bucket) this.$store.dispatch('kanban/updateBucket', bucket)
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
setBucketLimit(bucket) { setBucketLimit(bucket) {
@ -549,10 +549,10 @@ export default {
bucket.isDoneBucket = !bucket.isDoneBucket bucket.isDoneBucket = !bucket.isDoneBucket
this.$store.dispatch('kanban/updateBucket', bucket) this.$store.dispatch('kanban/updateBucket', bucket)
.then(() => { .then(() => {
this.success({message: this.$t('list.kanban.doneBucketSavedSuccess')}) this.$message.success({message: this.$t('list.kanban.doneBucketSavedSuccess')})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
bucket.isDoneBucket = !bucket.isDoneBucket bucket.isDoneBucket = !bucket.isDoneBucket
}) })
}, },

View file

@ -78,11 +78,11 @@ export default {
.create(this.namespace) .create(this.namespace)
.then((r) => { .then((r) => {
this.$store.commit('namespaces/addNamespace', r) this.$store.commit('namespaces/addNamespace', r)
this.success({message: this.$t('namespace.create.success') }) this.$message.success({message: this.$t('namespace.create.success') })
this.$router.back() this.$router.back()
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -39,10 +39,10 @@ export default {
this.namespaceService.update(this.namespace) this.namespaceService.update(this.namespace)
.then(r => { .then(r => {
this.$store.commit('namespaces/setNamespaceById', r) this.$store.commit('namespaces/setNamespaceById', r)
this.success({message: this.$t('namespace.archive.success')}) this.$message.success({message: this.$t('namespace.archive.success')})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.$router.back() this.$router.back()

View file

@ -36,11 +36,11 @@ export default {
this.$store.dispatch('namespaces/deleteNamespace', namespace) this.$store.dispatch('namespaces/deleteNamespace', namespace)
.then(() => { .then(() => {
this.success({message: this.$t('namespace.delete.success')}) this.$message.success({message: this.$t('namespace.delete.success')})
this.$router.push({name: 'home'}) this.$router.push({name: 'home'})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -119,7 +119,7 @@ export default {
this.setTitle(this.title) this.setTitle(this.title)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
save() { save() {
@ -127,11 +127,11 @@ export default {
.then(r => { .then(r => {
// Update the namespace in the parent // Update the namespace in the parent
this.$store.commit('namespaces/setNamespaceById', r) this.$store.commit('namespaces/setNamespaceById', r)
this.success({message: this.$t('namespace.edit.success')}) this.$message.success({message: this.$t('namespace.edit.success')})
this.$router.back() this.$router.back()
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -70,7 +70,7 @@ export default {
this.setTitle(this.title) this.setTitle(this.title)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -206,7 +206,7 @@ export default {
this.$set(this, 'tasks', tasks) this.$set(this, 'tasks', tasks)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
updateTasks(updatedTask) { updateTasks(updatedTask) {

View file

@ -567,7 +567,7 @@ export default {
this.setTitle(this.task.title) this.setTitle(this.task.title)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.$nextTick(() => this.visible = true) this.$nextTick(() => this.visible = true)
@ -628,10 +628,10 @@ export default {
callback: undoCallback, callback: undoCallback,
}] }]
} }
this.success({message: this.$t('task.detail.updateSuccess')}, actions) this.$message.success({message: this.$t('task.detail.updateSuccess')}, actions)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}) })
}, },
@ -656,11 +656,11 @@ export default {
deleteTask() { deleteTask() {
this.$store.dispatch('tasks/delete', this.task) this.$store.dispatch('tasks/delete', this.task)
.then(() => { .then(() => {
this.success({message: this.$t('task.detail.deleteSuccess')}) this.$message.success({message: this.$t('task.detail.deleteSuccess')})
this.$router.push({name: 'list.index', params: {listId: this.task.listId}}) this.$router.push({name: 'list.index', params: {listId: this.task.listId}})
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
toggleTaskDone() { toggleTaskDone() {
@ -701,7 +701,7 @@ export default {
this.$store.dispatch('namespaces/loadNamespacesIfFavoritesDontExist') this.$store.dispatch('namespaces/loadNamespacesIfFavoritesDontExist')
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -239,7 +239,7 @@ export default {
this.setTitle(this.title) this.setTitle(this.title)
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
save() { save() {
@ -253,32 +253,32 @@ export default {
.update(this.team) .update(this.team)
.then((response) => { .then((response) => {
this.team = response this.team = response
this.success({message: this.$t('team.edit.success')}) this.$message.success({message: this.$t('team.edit.success')})
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
deleteTeam() { deleteTeam() {
this.teamService this.teamService
.delete(this.team) .delete(this.team)
.then(() => { .then(() => {
this.success({message: this.$t('team.edit.delete.success')}) this.$message.success({message: this.$t('team.edit.delete.success')})
this.$router.push({name: 'teams.index'}) this.$router.push({name: 'teams.index'})
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
deleteUser() { deleteUser() {
this.teamMemberService this.teamMemberService
.delete(this.member) .delete(this.member)
.then(() => { .then(() => {
this.success({message: this.$t('team.edit.deleteUser.success')}) this.$message.success({message: this.$t('team.edit.deleteUser.success')})
this.loadTeam() this.loadTeam()
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
.finally(() => { .finally(() => {
this.showUserDeleteModal = false this.showUserDeleteModal = false
@ -293,10 +293,10 @@ export default {
.create(newMember) .create(newMember)
.then(() => { .then(() => {
this.loadTeam() this.loadTeam()
this.success({message: this.$t('team.edit.userAddedSuccess')}) this.$message.success({message: this.$t('team.edit.userAddedSuccess')})
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
toggleUserType(member) { toggleUserType(member) {
@ -311,14 +311,14 @@ export default {
break break
} }
} }
this.success({ this.$message.success({
message: member.admin ? message: member.admin ?
this.$t('team.edit.madeAdmin') : this.$t('team.edit.madeAdmin') :
this.$t('team.edit.madeMember'), this.$t('team.edit.madeMember'),
}) })
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
findUser(query) { findUser(query) {
@ -333,7 +333,7 @@ export default {
this.$set(this, 'foundUsers', response) this.$set(this, 'foundUsers', response)
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
clearAll() { clearAll() {

View file

@ -50,7 +50,7 @@ export default {
this.$set(this, 'teams', response) this.$set(this, 'teams', response)
}) })
.catch(e => { .catch(e => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -67,10 +67,10 @@ export default {
name: 'teams.edit', name: 'teams.edit',
params: { id: response.id }, params: { id: response.id },
}) })
this.success({message: this.$t('team.create.success') }) this.$message.success({message: this.$t('team.create.success') })
}) })
.catch((e) => { .catch((e) => {
this.error(e) this.$message.error(e)
}) })
}, },
}, },

View file

@ -57,7 +57,7 @@ export default {
} }
this.dataExportService.download(this.password) this.dataExportService.download(this.password)
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
}, },
} }

View file

@ -383,22 +383,22 @@ export default {
updatePassword() { updatePassword() {
if (this.passwordConfirm !== this.passwordUpdate.newPassword) { if (this.passwordConfirm !== this.passwordUpdate.newPassword) {
this.error({message: this.$t('user.settings.passwordsDontMatch')}) this.$message.error({message: this.$t('user.settings.passwordsDontMatch')})
return return
} }
this.passwordUpdateService.update(this.passwordUpdate) this.passwordUpdateService.update(this.passwordUpdate)
.then(() => { .then(() => {
this.success({message: this.$t('user.settings.passwordUpdateSuccess')}) this.$message.success({message: this.$t('user.settings.passwordUpdateSuccess')})
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
updateEmail() { updateEmail() {
this.emailUpdateService.update(this.emailUpdate) this.emailUpdateService.update(this.emailUpdate)
.then(() => { .then(() => {
this.success({message: this.$t('user.settings.updateEmailSuccess')}) this.$message.success({message: this.$t('user.settings.updateEmailSuccess')})
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
totpStatus() { totpStatus() {
if (!this.totpEnabled) { if (!this.totpEnabled) {
@ -416,7 +416,7 @@ export default {
return return
} }
this.error(e) this.$message.error(e)
}) })
}, },
totpSetQrCode() { totpSetQrCode() {
@ -433,24 +433,24 @@ export default {
this.$set(this, 'totp', r) this.$set(this, 'totp', r)
this.totpSetQrCode() this.totpSetQrCode()
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
totpConfirm() { totpConfirm() {
this.totpService.enable({passcode: this.totpConfirmPasscode}) this.totpService.enable({passcode: this.totpConfirmPasscode})
.then(() => { .then(() => {
this.$set(this.totp, 'enabled', true) this.$set(this.totp, 'enabled', true)
this.success({message: this.$t('user.settings.totp.confirmSuccess')}) this.$message.success({message: this.$t('user.settings.totp.confirmSuccess')})
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
totpDisable() { totpDisable() {
this.totpService.disable({password: this.totpDisablePassword}) this.totpService.disable({password: this.totpDisablePassword})
.then(() => { .then(() => {
this.totpEnrolled = false this.totpEnrolled = false
this.$set(this, 'totp', new TotpModel()) this.$set(this, 'totp', new TotpModel())
this.success({message: this.$t('user.settings.totp.disableSuccess')}) this.$message.success({message: this.$t('user.settings.totp.disableSuccess')})
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
updateSettings() { updateSettings() {
localStorage.setItem(playSoundWhenDoneKey, this.playSoundWhenDone) localStorage.setItem(playSoundWhenDoneKey, this.playSoundWhenDone)
@ -460,9 +460,9 @@ export default {
this.userSettingsService.update(this.settings) this.userSettingsService.update(this.settings)
.then(() => { .then(() => {
this.$store.commit('auth/setUserSettings', this.settings) this.$store.commit('auth/setUserSettings', this.settings)
this.success({message: this.$t('user.settings.general.savedSuccess')}) this.$message.success({message: this.$t('user.settings.general.savedSuccess')})
}) })
.catch(e => this.error(e)) .catch(e => this.$message.error(e))
}, },
anchorHashCheck() { anchorHashCheck() {
if (window.location.hash === this.$route.hash) { if (window.location.hash === this.$route.hash) {