diff --git a/src/App.vue b/src/App.vue index a02b72695..5da2d0e88 100644 --- a/src/App.vue +++ b/src/App.vue @@ -105,10 +105,10 @@ export default { const accountDeletionService = new AccountDeleteService() accountDeletionService.confirm(this.$route.query.accountDeletionConfirm) .then(() => { - this.success({message: this.$t('user.deletion.confirmSuccess')}) + this.$message.success({message: this.$t('user.deletion.confirmSuccess')}) this.$store.dispatch('auth/refreshUserInfo') }) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) } }, }, diff --git a/src/components/home/contentAuth.vue b/src/components/home/contentAuth.vue index f0a78c408..b2a72b1a9 100644 --- a/src/components/home/contentAuth.vue +++ b/src/components/home/contentAuth.vue @@ -124,7 +124,7 @@ export default { loadLabels() { this.$store.dispatch('labels/loadAllLabels') .catch(e => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/components/home/navigation.vue b/src/components/home/navigation.vue index f1c2c8b4f..9e77a247f 100644 --- a/src/components/home/navigation.vue +++ b/src/components/home/navigation.vue @@ -206,7 +206,7 @@ export default { return } this.$store.dispatch('lists/toggleListFavorite', list) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) }, resize() { // Hide the menu by default on mobile @@ -252,7 +252,7 @@ export default { position, }) .catch(e => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.$set(this.listUpdating, list.id, false) diff --git a/src/components/list/partials/filters.vue b/src/components/list/partials/filters.vue index b203d8fe1..e07a2b90c 100644 --- a/src/components/list/partials/filters.vue +++ b/src/components/list/partials/filters.vue @@ -488,7 +488,7 @@ export default { .then(r => { this.$set(this, kind, r) }) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) } }, setDoneFilter() { @@ -543,7 +543,7 @@ export default { })) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, add(kind, filterName) { diff --git a/src/components/list/partials/list-card.vue b/src/components/list/partials/list-card.vue index 8cf8d2d39..90241f75e 100644 --- a/src/components/list/partials/list-card.vue +++ b/src/components/list/partials/list-card.vue @@ -71,7 +71,7 @@ export default { this.$set(this, 'background', b) }) .catch(e => { - this.error(e) + this.$message.error(e) }) .finally(() => this.backgroundLoading = false) }, @@ -82,7 +82,7 @@ export default { return } this.$store.dispatch('lists/toggleListFavorite', list) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) }, }, } diff --git a/src/components/migrator/migration.vue b/src/components/migrator/migration.vue index fcce0cc88..4182c9b75 100644 --- a/src/components/migrator/migration.vue +++ b/src/components/migrator/migration.vue @@ -130,7 +130,7 @@ export default { this.migrate() }) .catch(e => { - this.error(e) + this.$message.error(e) }) } }, @@ -141,7 +141,7 @@ export default { this.authUrl = r.url }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, migrate() { @@ -159,7 +159,7 @@ export default { this.$store.dispatch('namespaces/loadNamespaces') }) .catch(e => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.isMigrating = false @@ -176,7 +176,7 @@ export default { this.$store.dispatch('namespaces/loadNamespaces') }) .catch(e => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.isMigrating = false diff --git a/src/components/misc/subscription.vue b/src/components/misc/subscription.vue index a6d92e566..a9514a87d 100644 --- a/src/components/misc/subscription.vue +++ b/src/components/misc/subscription.vue @@ -99,10 +99,10 @@ export default { this.subscriptionService.create(subscription) .then(() => { 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 => { - this.error(e) + this.$message.error(e) }) }, unsubscribe() { @@ -113,10 +113,10 @@ export default { this.subscriptionService.delete(subscription) .then(() => { 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 => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/components/notifications/notifications.vue b/src/components/notifications/notifications.vue index a185a89c7..a04226b2c 100644 --- a/src/components/notifications/notifications.vue +++ b/src/components/notifications/notifications.vue @@ -102,7 +102,7 @@ export default { this.$set(this, 'allNotifications', r) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, to(n, index) { @@ -140,7 +140,7 @@ export default { .then(r => { this.$set(this.allNotifications, index, r) }) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) } }, }, diff --git a/src/components/quick-actions/quick-actions.vue b/src/components/quick-actions/quick-actions.vue index 5510004b7..0181793ae 100644 --- a/src/components/quick-actions/quick-actions.vue +++ b/src/components/quick-actions/quick-actions.vue @@ -388,12 +388,12 @@ export default { this.createNewTask(this.query, 0, this.currentList.id) .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.closeQuickActions() }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, newList() { @@ -407,12 +407,12 @@ export default { }) this.$store.dispatch('lists/createList', newList) .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.closeQuickActions() }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, newNamespace() { @@ -420,11 +420,11 @@ export default { this.$store.dispatch('namespaces/createNamespace', newNamespace) .then(() => { - this.success({message: this.$t('namespace.create.success')}) + this.$message.success({message: this.$t('namespace.create.success')}) this.closeQuickActions() }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, newTeam() { @@ -435,11 +435,11 @@ export default { name: 'teams.edit', params: {id: r.id}, }) - this.success({message: this.$t('team.create.success')}) + this.$message.success({message: this.$t('team.create.success')}) this.closeQuickActions() }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, select(parentIndex, index) { diff --git a/src/components/sharing/linkSharing.vue b/src/components/sharing/linkSharing.vue index 1c04186a5..34fa44ee0 100644 --- a/src/components/sharing/linkSharing.vue +++ b/src/components/sharing/linkSharing.vue @@ -234,7 +234,7 @@ export default { this.linkShares = r }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, add() { @@ -251,11 +251,11 @@ export default { this.name = '' this.password = '' this.showNewForm = false - this.success({message: this.$t('list.share.links.createSuccess')}) + this.$message.success({message: this.$t('list.share.links.createSuccess')}) this.load() }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, remove() { @@ -266,11 +266,11 @@ export default { this.linkShareService .delete(linkshare) .then(() => { - this.success({message: this.$t('list.share.links.deleteSuccess')}) + this.$message.success({message: this.$t('list.share.links.deleteSuccess')}) this.load() }) .catch((e) => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.showDeleteModal = false diff --git a/src/components/sharing/userTeam.vue b/src/components/sharing/userTeam.vue index fab1a59d1..d429032dc 100644 --- a/src/components/sharing/userTeam.vue +++ b/src/components/sharing/userTeam.vue @@ -282,7 +282,7 @@ export default { ) }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, deleteSharable() { @@ -304,10 +304,10 @@ export default { 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) => { - this.error(e) + this.$message.error(e) }) }, add(admin) { @@ -328,11 +328,11 @@ export default { this.stuffService .create(this.stuffModel) .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() }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, toggleType(sharable) { @@ -365,10 +365,10 @@ export default { 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) => { - this.error(e) + this.$message.error(e) }) }, find(query) { @@ -383,7 +383,7 @@ export default { this.$set(this, 'found', response) }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, clearAll() { diff --git a/src/components/tasks/add-task.vue b/src/components/tasks/add-task.vue index 0bd5e4d81..231b56415 100644 --- a/src/components/tasks/add-task.vue +++ b/src/components/tasks/add-task.vue @@ -86,7 +86,7 @@ export default { this.errorMessage = this.$t('list.create.addListRequired') return } - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/components/tasks/edit-task.vue b/src/components/tasks/edit-task.vue index da1af0115..7e03f07d9 100644 --- a/src/components/tasks/edit-task.vue +++ b/src/components/tasks/edit-task.vue @@ -149,10 +149,10 @@ export default { .then((r) => { this.$set(this, 'taskEditTask', r) this.initTaskFields() - this.success({message: this.$t('task.detail.updateSuccess')}) + this.$message.success({message: this.$t('task.detail.updateSuccess')}) }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/components/tasks/gantt-component.vue b/src/components/tasks/gantt-component.vue index 19e064b21..bf1804fff 100644 --- a/src/components/tasks/gantt-component.vue +++ b/src/components/tasks/gantt-component.vue @@ -354,7 +354,7 @@ export default { }) }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, addGantAttributes(t) { @@ -439,7 +439,7 @@ export default { } }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, editTask(task) { @@ -476,7 +476,7 @@ export default { this.hideCrateNewTask() }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, formatYear(date) { diff --git a/src/components/tasks/mixins/taskList.js b/src/components/tasks/mixins/taskList.js index 92e5de1f7..4c490d2ee 100644 --- a/src/components/tasks/mixins/taskList.js +++ b/src/components/tasks/mixins/taskList.js @@ -88,7 +88,7 @@ export default { this.loadedList = cloneDeep(currentList) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, @@ -161,7 +161,7 @@ export default { this.$set(this.tasks, e.newIndex, r) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/components/tasks/partials/attachments.vue b/src/components/tasks/partials/attachments.vue index 4f70d74b8..3637b7330 100644 --- a/src/components/tasks/partials/attachments.vue +++ b/src/components/tasks/partials/attachments.vue @@ -229,10 +229,10 @@ export default { 'attachments/removeById', this.attachmentToDelete.id, ) - this.success(r) + this.$message.success(r) }) .catch((e) => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.showDeleteModal = false diff --git a/src/components/tasks/partials/comments.vue b/src/components/tasks/partials/comments.vue index 296eb5c78..8bfb861d8 100644 --- a/src/components/tasks/partials/comments.vue +++ b/src/components/tasks/partials/comments.vue @@ -234,7 +234,7 @@ export default { this.makeActions() }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, addComment() { @@ -256,11 +256,11 @@ export default { .then((r) => { this.comments.push(r) this.newComment.comment = '' - this.success({message: this.$t('task.comment.addedSuccess')}) + this.$message.success({message: this.$t('task.comment.addedSuccess')}) this.makeActions() }) .catch((e) => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.creating = false @@ -296,7 +296,7 @@ export default { }, 2000) }) .catch((e) => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.isCommentEdit = false @@ -314,7 +314,7 @@ export default { } }) .catch((e) => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.showDeleteModal = false diff --git a/src/components/tasks/partials/defer-task.vue b/src/components/tasks/partials/defer-task.vue index f45ff8649..5c3209d3f 100644 --- a/src/components/tasks/partials/defer-task.vue +++ b/src/components/tasks/partials/defer-task.vue @@ -132,7 +132,7 @@ export default { this.$emit('input', r) }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/components/tasks/partials/description.vue b/src/components/tasks/partials/description.vue index 194390ec2..2e401974d 100644 --- a/src/components/tasks/partials/description.vue +++ b/src/components/tasks/partials/description.vue @@ -89,7 +89,7 @@ export default { }, 2000) }) .catch(e => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.saving = false diff --git a/src/components/tasks/partials/editAssignees.vue b/src/components/tasks/partials/editAssignees.vue index 271e66815..fe32f7a47 100644 --- a/src/components/tasks/partials/editAssignees.vue +++ b/src/components/tasks/partials/editAssignees.vue @@ -84,10 +84,10 @@ export default { this.$store.dispatch('tasks/addAssignee', {user: user, taskId: this.taskId}) .then(() => { this.$emit('input', this.assignees) - this.success({message: this.$t('task.assignee.assignSuccess')}) + this.$message.success({message: this.$t('task.assignee.assignSuccess')}) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, removeAssignee(user) { @@ -99,10 +99,10 @@ export default { this.assignees.splice(a, 1) } } - this.success({message: this.$t('task.assignee.assignSuccess')}) + this.$message.success({message: this.$t('task.assignee.assignSuccess')}) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, findUser(query) { @@ -119,7 +119,7 @@ export default { })) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, clearAllFoundUsers() { diff --git a/src/components/tasks/partials/editLabels.vue b/src/components/tasks/partials/editLabels.vue index 5f69fef24..e4711e5b2 100644 --- a/src/components/tasks/partials/editLabels.vue +++ b/src/components/tasks/partials/editLabels.vue @@ -115,11 +115,11 @@ export default { .then(() => { bubble() if (showNotification) { - this.success({message: this.$t('task.label.addSuccess')}) + this.$message.success({message: this.$t('task.label.addSuccess')}) } }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, removeLabel(label) { @@ -141,10 +141,10 @@ export default { this.$store.dispatch('tasks/removeLabel', {label: label, taskId: this.taskId}) .then(() => { removeFromState() - this.success({message: this.$t('task.label.removeSuccess')}) + this.$message.success({message: this.$t('task.label.removeSuccess')}) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, createAndAddLabel(title) { @@ -157,10 +157,10 @@ export default { .then(r => { this.addLabel(r, false) this.labels.push(r) - this.success({message: this.$t('task.label.removeSuccess')}) + this.$message.success({message: this.$t('task.label.removeSuccess')}) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, diff --git a/src/components/tasks/partials/heading.vue b/src/components/tasks/partials/heading.vue index 681371a5b..4dae84209 100644 --- a/src/components/tasks/partials/heading.vue +++ b/src/components/tasks/partials/heading.vue @@ -81,7 +81,7 @@ export default { }, 2000) }) .catch(e => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.saving = false diff --git a/src/components/tasks/partials/kanban-card.vue b/src/components/tasks/partials/kanban-card.vue index dfc89c3df..72d360e44 100644 --- a/src/components/tasks/partials/kanban-card.vue +++ b/src/components/tasks/partials/kanban-card.vue @@ -102,7 +102,7 @@ export default { } }) .catch(e => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.loadingInternal = false diff --git a/src/components/tasks/partials/listSearch.vue b/src/components/tasks/partials/listSearch.vue index a2eb5b96c..7c648c168 100644 --- a/src/components/tasks/partials/listSearch.vue +++ b/src/components/tasks/partials/listSearch.vue @@ -63,7 +63,7 @@ export default { this.$set(this, 'foundLists', response) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, clearAll() { diff --git a/src/components/tasks/partials/relatedTasks.vue b/src/components/tasks/partials/relatedTasks.vue index 04d0a748e..2cb7a3810 100644 --- a/src/components/tasks/partials/relatedTasks.vue +++ b/src/components/tasks/partials/relatedTasks.vue @@ -196,7 +196,7 @@ export default { this.$set(this, 'foundTasks', response) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, addTaskRelation() { @@ -219,7 +219,7 @@ export default { }, 2000) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, removeTaskRelation() { @@ -243,7 +243,7 @@ export default { }, 2000) }) .catch(e => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.showDeleteModal = false @@ -257,7 +257,7 @@ export default { this.addTaskRelation() }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, relationKindTitle(kind, length) { diff --git a/src/components/tasks/partials/singleTaskInList.vue b/src/components/tasks/partials/singleTaskInList.vue index 145ac00bd..51a048019 100644 --- a/src/components/tasks/partials/singleTaskInList.vue +++ b/src/components/tasks/partials/singleTaskInList.vue @@ -175,7 +175,7 @@ export default { } this.task = t this.$emit('task-updated', t) - this.success({ + this.$message.success({ message: this.task.done ? this.$t('task.doneSuccess') : this.$t('task.undoneSuccess'), @@ -188,7 +188,7 @@ export default { }]) }) .catch(e => { - this.error(e) + this.$message.error(e) }) } @@ -207,7 +207,7 @@ export default { this.$store.dispatch('namespaces/loadNamespacesIfFavoritesDontExist') }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, hideDeferDueDatePopup(e) { diff --git a/src/components/user/avatar-settings.vue b/src/components/user/avatar-settings.vue index 02260ef15..f84858160 100644 --- a/src/components/user/avatar-settings.vue +++ b/src/components/user/avatar-settings.vue @@ -93,16 +93,16 @@ export default { .then(r => { this.avatarProvider = r.avatarProvider }) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) }, updateAvatarStatus() { const avatarStatus = new AvatarModel({avatarProvider: this.avatarProvider}) this.avatarService.update(avatarStatus) .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') }) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) }, uploadAvatar() { this.loading = true @@ -112,10 +112,10 @@ export default { canvas.toBlob(blob => { this.avatarService.create(blob) .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') }) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) .finally(() => { this.loading = false this.isCropAvatar = false diff --git a/src/components/user/settings/data-export.vue b/src/components/user/settings/data-export.vue index ca3b5fb1e..3060d0389 100644 --- a/src/components/user/settings/data-export.vue +++ b/src/components/user/settings/data-export.vue @@ -61,10 +61,10 @@ export default { this.dataExportService.request(this.password) .then(() => { - this.success({message: this.$t('user.export.success')}) + this.$message.success({message: this.$t('user.export.success')}) this.password = '' }) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) }, }, } diff --git a/src/components/user/settings/deletion.vue b/src/components/user/settings/deletion.vue index 602d1be70..878a23e59 100644 --- a/src/components/user/settings/deletion.vue +++ b/src/components/user/settings/deletion.vue @@ -113,10 +113,10 @@ export default { this.accountDeleteService.request(this.password) .then(() => { - this.success({message: this.$t('user.deletion.requestSuccess')}) + this.$message.success({message: this.$t('user.deletion.requestSuccess')}) this.password = '' }) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) }, cancelDeletion() { if (this.password === '') { @@ -127,11 +127,11 @@ export default { this.accountDeleteService.cancel(this.password) .then(() => { - this.success({message: this.$t('user.deletion.scheduledCancelSuccess')}) + this.$message.success({message: this.$t('user.deletion.scheduledCancelSuccess')}) this.$store.dispatch('auth/refreshUserInfo') this.password = '' }) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) }, }, } diff --git a/src/main.ts b/src/main.ts index 2fc17bc43..a145476cf 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,6 +2,8 @@ import Vue from 'vue' import App from './App.vue' import router from './router' +import {error, success} from './message' + declare global { interface Window { API_URL: string; @@ -26,7 +28,6 @@ import './registerServiceWorker' // @ts-ignore - no types available import vueShortkey from 'vue-shortkey' // Mixins -import message from './message' import {colorIsDark} from './helpers/color/colorIsDark' import {setTitle} from './helpers/setTitle' import {getNamespaceTitle} from './helpers/getNamespaceTitle' @@ -61,6 +62,29 @@ Vue.component('icon', FontAwesomeIcon) 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' Vue.directive('focus', focus) @@ -94,12 +118,6 @@ Vue.mixin({ getListTitle(l) { 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, setTitle: setTitle, }, diff --git a/src/message/index.js b/src/message/index.js index cafd1f1d8..e425caf7a 100644 --- a/src/message/index.js +++ b/src/message/index.js @@ -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.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 (path !== message) { @@ -25,23 +27,23 @@ export const getErrorText = (r, $t) => { return [r.message] } -export default { - error(e, context, $t, actions = []) { - context.$notify({ - type: 'error', - title: $t('error.error'), - text: getErrorText(e, $t), +export function error(e, context, actions = []) { + context.$notify({ + type: 'error', + title: i18n.t('error.error'), + text: getErrorText(e), + actions: actions, + }) + console.error(e, actions) +} + +export function success(e, context, actions = []) { + context.$notify({ + type: 'success', + title: i18n.t('error.success'), + text: getErrorText(e), + data: { actions: actions, - }) - }, - success(e, context, $t, actions = []) { - context.$notify({ - type: 'success', - title: $t('error.success'), - text: getErrorText(e, $t), - data: { - actions: actions, - }, - }) - }, + }, + }) } \ No newline at end of file diff --git a/src/views/filters/CreateSavedFilter.vue b/src/views/filters/CreateSavedFilter.vue index a9cd21023..889c35d4d 100644 --- a/src/views/filters/CreateSavedFilter.vue +++ b/src/views/filters/CreateSavedFilter.vue @@ -108,7 +108,7 @@ export default { this.$store.dispatch('namespaces/loadNamespaces') this.$router.push({name: 'list.index', params: {listId: r.getListId()}}) }) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) }, }, } diff --git a/src/views/filters/settings/delete.vue b/src/views/filters/settings/delete.vue index bc139a607..489d5c6db 100644 --- a/src/views/filters/settings/delete.vue +++ b/src/views/filters/settings/delete.vue @@ -35,10 +35,10 @@ export default { this.filterService.delete(filter) .then(() => { 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'}) }) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) }, }, } diff --git a/src/views/filters/settings/edit.vue b/src/views/filters/settings/edit.vue index c1d873ae2..5af865a48 100644 --- a/src/views/filters/settings/edit.vue +++ b/src/views/filters/settings/edit.vue @@ -110,19 +110,19 @@ export default { this.filter = r this.filters = objectToSnakeCase(this.filter.filters) }) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) }, save() { this.filter.filters = this.filters this.filterService.update(this.filter) .then(r => { 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.filters = objectToSnakeCase(this.filter.filters) this.$router.back() }) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) }, }, } diff --git a/src/views/labels/ListLabels.vue b/src/views/labels/ListLabels.vue index 88a947d73..1f5adcc49 100644 --- a/src/views/labels/ListLabels.vue +++ b/src/views/labels/ListLabels.vue @@ -140,25 +140,25 @@ export default { loadLabels() { this.$store.dispatch('labels/loadAllLabels') .catch(e => { - this.error(e) + this.$message.error(e) }) }, deleteLabel(label) { this.$store.dispatch('labels/deleteLabel', label) .then(() => { - this.success({message: this.$t('label.deleteSuccess')}) + this.$message.success({message: this.$t('label.deleteSuccess')}) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, editLabelSubmit() { this.$store.dispatch('labels/updateLabel', this.labelEditLabel) .then(() => { - this.success({message: this.$t('label.edit.success')}) + this.$message.success({message: this.$t('label.edit.success')}) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, editLabel(label) { diff --git a/src/views/labels/NewLabel.vue b/src/views/labels/NewLabel.vue index 6fd10d557..35ba726d5 100644 --- a/src/views/labels/NewLabel.vue +++ b/src/views/labels/NewLabel.vue @@ -77,10 +77,10 @@ export default { name: 'labels.index', params: {id: r.id}, }) - this.success({message: this.$t('label.create.success')}) + this.$message.success({message: this.$t('label.create.success')}) }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/views/list/NewList.vue b/src/views/list/NewList.vue index 83dc5e069..1f252d707 100644 --- a/src/views/list/NewList.vue +++ b/src/views/list/NewList.vue @@ -69,14 +69,14 @@ export default { this.$store .dispatch('lists/createList', this.list) .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 }, }) }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/views/list/ShowList.vue b/src/views/list/ShowList.vue index 98c5113cf..1ac6ee963 100644 --- a/src/views/list/ShowList.vue +++ b/src/views/list/ShowList.vue @@ -148,7 +148,7 @@ export default { this.setTitle(this.getListTitle(r)) }) .catch(e => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.listLoaded = this.$route.params.listId diff --git a/src/views/list/settings/archive.vue b/src/views/list/settings/archive.vue index 5ee21b50c..e1d5b23c5 100644 --- a/src/views/list/settings/archive.vue +++ b/src/views/list/settings/archive.vue @@ -36,10 +36,10 @@ export default { .then(r => { this.$store.commit('currentList', 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 => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.$router.back() diff --git a/src/views/list/settings/background.vue b/src/views/list/settings/background.vue index 060322c0e..117c10e1c 100644 --- a/src/views/list/settings/background.vue +++ b/src/views/list/settings/background.vue @@ -132,7 +132,7 @@ export default { }) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, 300) }, @@ -146,10 +146,10 @@ export default { .then(l => { this.$store.commit(CURRENT_LIST, 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 => { - this.error(e) + this.$message.error(e) }) }, uploadBackground() { @@ -161,10 +161,10 @@ export default { .then(l => { this.$store.commit(CURRENT_LIST, 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 => { - this.error(e) + this.$message.error(e) }) }, removeBackground() { @@ -172,11 +172,11 @@ export default { .then(l => { this.$store.commit(CURRENT_LIST, 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() }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/views/list/settings/delete.vue b/src/views/list/settings/delete.vue index ab09d4241..6f889505e 100644 --- a/src/views/list/settings/delete.vue +++ b/src/views/list/settings/delete.vue @@ -25,11 +25,11 @@ export default { this.$store.dispatch('lists/deleteList', list) .then(() => { - this.success({message: this.$t('list.delete.success')}) + this.$message.success({message: this.$t('list.delete.success')}) this.$router.push({name: 'home'}) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/views/list/settings/duplicate.vue b/src/views/list/settings/duplicate.vue index 3cf14bd3a..5cceb11ac 100644 --- a/src/views/list/settings/duplicate.vue +++ b/src/views/list/settings/duplicate.vue @@ -48,11 +48,11 @@ export default { .then(r => { this.$store.commit('namespaces/addListToNamespace', 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}}) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/views/list/settings/edit.vue b/src/views/list/settings/edit.vue index e02dcd84d..2fb83d758 100644 --- a/src/views/list/settings/edit.vue +++ b/src/views/list/settings/edit.vue @@ -109,17 +109,17 @@ export default { this.setTitle(this.$t('list.edit.title', {list: this.list.title})) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, save() { this.$store.dispatch('lists/updateList', this.list) .then(() => { - this.success({message: this.$t('list.edit.success')}) + this.$message.success({message: this.$t('list.edit.success')}) this.$router.back() }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/views/list/settings/share.vue b/src/views/list/settings/share.vue index 94926adc6..7a760a1e3 100644 --- a/src/views/list/settings/share.vue +++ b/src/views/list/settings/share.vue @@ -70,7 +70,7 @@ export default { this.setTitle(this.$t('list.share.title', {list: this.list.title})) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/views/list/views/Kanban.vue b/src/views/list/views/Kanban.vue index 549f30f3c..29961f351 100644 --- a/src/views/list/views/Kanban.vue +++ b/src/views/list/views/Kanban.vue @@ -367,14 +367,14 @@ export default { bucketId: b.id, }) .catch(e => { - this.error(e) + this.$message.error(e) }) } }) }) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, updateTaskPosition(e) { @@ -395,7 +395,7 @@ export default { this.$store.dispatch('tasks/update', task) .catch(e => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.$set(this.taskUpdating, task.id, false) @@ -419,7 +419,7 @@ export default { this.$store.commit('kanban/addTaskToBucket', r) }) .catch(e => { - this.error(e) + this.$message.error(e) }) .finally(() => { if (!this.$refs[`tasks-container${bucketId}`][0]) { @@ -444,7 +444,7 @@ export default { this.showNewBucketInput = false }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, deleteBucketModal(bucketId) { @@ -463,10 +463,10 @@ export default { this.$store.dispatch('kanban/deleteBucket', {bucket: bucket, params: this.params}) .then(() => { - this.success({message: this.$t('list.kanban.deleteBucketSuccess')}) + this.$message.success({message: this.$t('list.kanban.deleteBucketSuccess')}) }) .catch(e => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.showBucketDeleteModal = false @@ -499,20 +499,20 @@ export default { .then(r => { realBucket.title = r.title bucketTitleElement.blur() - this.success({message: this.$t('list.kanban.bucketTitleSavedSuccess')}) + this.$message.success({message: this.$t('list.kanban.bucketTitleSavedSuccess')}) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, updateBucket(bucket) { bucket.limit = parseInt(bucket.limit) this.$store.dispatch('kanban/updateBucket', bucket) .then(() => { - this.success({message: this.$t('list.kanban.bucketLimitSavedSuccess')}) + this.$message.success({message: this.$t('list.kanban.bucketLimitSavedSuccess')}) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, updateBucketPosition(e) { @@ -526,7 +526,7 @@ export default { this.$store.dispatch('kanban/updateBucket', bucket) .catch(e => { - this.error(e) + this.$message.error(e) }) }, setBucketLimit(bucket) { @@ -549,10 +549,10 @@ export default { bucket.isDoneBucket = !bucket.isDoneBucket this.$store.dispatch('kanban/updateBucket', bucket) .then(() => { - this.success({message: this.$t('list.kanban.doneBucketSavedSuccess')}) + this.$message.success({message: this.$t('list.kanban.doneBucketSavedSuccess')}) }) .catch(e => { - this.error(e) + this.$message.error(e) bucket.isDoneBucket = !bucket.isDoneBucket }) }, diff --git a/src/views/namespaces/NewNamespace.vue b/src/views/namespaces/NewNamespace.vue index 0804954a5..52996a63d 100644 --- a/src/views/namespaces/NewNamespace.vue +++ b/src/views/namespaces/NewNamespace.vue @@ -78,11 +78,11 @@ export default { .create(this.namespace) .then((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() }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/views/namespaces/settings/archive.vue b/src/views/namespaces/settings/archive.vue index 4e7559285..aef98415b 100644 --- a/src/views/namespaces/settings/archive.vue +++ b/src/views/namespaces/settings/archive.vue @@ -39,10 +39,10 @@ export default { this.namespaceService.update(this.namespace) .then(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 => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.$router.back() diff --git a/src/views/namespaces/settings/delete.vue b/src/views/namespaces/settings/delete.vue index 1a867f5e0..143f65024 100644 --- a/src/views/namespaces/settings/delete.vue +++ b/src/views/namespaces/settings/delete.vue @@ -36,11 +36,11 @@ export default { this.$store.dispatch('namespaces/deleteNamespace', namespace) .then(() => { - this.success({message: this.$t('namespace.delete.success')}) + this.$message.success({message: this.$t('namespace.delete.success')}) this.$router.push({name: 'home'}) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/views/namespaces/settings/edit.vue b/src/views/namespaces/settings/edit.vue index 316c0a970..f2f8bead6 100644 --- a/src/views/namespaces/settings/edit.vue +++ b/src/views/namespaces/settings/edit.vue @@ -119,7 +119,7 @@ export default { this.setTitle(this.title) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, save() { @@ -127,11 +127,11 @@ export default { .then(r => { // Update the namespace in the parent 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() }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/views/namespaces/settings/share.vue b/src/views/namespaces/settings/share.vue index e1b210522..1fb61b981 100644 --- a/src/views/namespaces/settings/share.vue +++ b/src/views/namespaces/settings/share.vue @@ -70,7 +70,7 @@ export default { this.setTitle(this.title) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/views/tasks/ShowTasks.vue b/src/views/tasks/ShowTasks.vue index 1321c1ee7..08eb51bd4 100644 --- a/src/views/tasks/ShowTasks.vue +++ b/src/views/tasks/ShowTasks.vue @@ -206,7 +206,7 @@ export default { this.$set(this, 'tasks', tasks) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, updateTasks(updatedTask) { diff --git a/src/views/tasks/TaskDetailView.vue b/src/views/tasks/TaskDetailView.vue index 2f866bc2b..e45541d79 100644 --- a/src/views/tasks/TaskDetailView.vue +++ b/src/views/tasks/TaskDetailView.vue @@ -567,7 +567,7 @@ export default { this.setTitle(this.task.title) }) .catch(e => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.$nextTick(() => this.visible = true) @@ -628,10 +628,10 @@ export default { callback: undoCallback, }] } - this.success({message: this.$t('task.detail.updateSuccess')}, actions) + this.$message.success({message: this.$t('task.detail.updateSuccess')}, actions) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }) }, @@ -656,11 +656,11 @@ export default { deleteTask() { this.$store.dispatch('tasks/delete', this.task) .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}}) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, toggleTaskDone() { @@ -701,7 +701,7 @@ export default { this.$store.dispatch('namespaces/loadNamespacesIfFavoritesDontExist') }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/views/teams/EditTeam.vue b/src/views/teams/EditTeam.vue index 266003de9..7d4f4f210 100644 --- a/src/views/teams/EditTeam.vue +++ b/src/views/teams/EditTeam.vue @@ -239,7 +239,7 @@ export default { this.setTitle(this.title) }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, save() { @@ -253,32 +253,32 @@ export default { .update(this.team) .then((response) => { this.team = response - this.success({message: this.$t('team.edit.success')}) + this.$message.success({message: this.$t('team.edit.success')}) }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, deleteTeam() { this.teamService .delete(this.team) .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'}) }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, deleteUser() { this.teamMemberService .delete(this.member) .then(() => { - this.success({message: this.$t('team.edit.deleteUser.success')}) + this.$message.success({message: this.$t('team.edit.deleteUser.success')}) this.loadTeam() }) .catch((e) => { - this.error(e) + this.$message.error(e) }) .finally(() => { this.showUserDeleteModal = false @@ -293,10 +293,10 @@ export default { .create(newMember) .then(() => { this.loadTeam() - this.success({message: this.$t('team.edit.userAddedSuccess')}) + this.$message.success({message: this.$t('team.edit.userAddedSuccess')}) }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, toggleUserType(member) { @@ -311,14 +311,14 @@ export default { break } } - this.success({ + this.$message.success({ message: member.admin ? this.$t('team.edit.madeAdmin') : this.$t('team.edit.madeMember'), }) }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, findUser(query) { @@ -333,7 +333,7 @@ export default { this.$set(this, 'foundUsers', response) }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, clearAll() { diff --git a/src/views/teams/ListTeams.vue b/src/views/teams/ListTeams.vue index 2e166593c..0d3c78ce5 100644 --- a/src/views/teams/ListTeams.vue +++ b/src/views/teams/ListTeams.vue @@ -50,7 +50,7 @@ export default { this.$set(this, 'teams', response) }) .catch(e => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/views/teams/NewTeam.vue b/src/views/teams/NewTeam.vue index 63c4bfc39..277051494 100644 --- a/src/views/teams/NewTeam.vue +++ b/src/views/teams/NewTeam.vue @@ -67,10 +67,10 @@ export default { name: 'teams.edit', params: { id: response.id }, }) - this.success({message: this.$t('team.create.success') }) + this.$message.success({message: this.$t('team.create.success') }) }) .catch((e) => { - this.error(e) + this.$message.error(e) }) }, }, diff --git a/src/views/user/DataExportDownload.vue b/src/views/user/DataExportDownload.vue index f22dd9262..71507c528 100644 --- a/src/views/user/DataExportDownload.vue +++ b/src/views/user/DataExportDownload.vue @@ -57,7 +57,7 @@ export default { } this.dataExportService.download(this.password) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) }, }, } diff --git a/src/views/user/Settings.vue b/src/views/user/Settings.vue index 08fd04743..98adfede4 100644 --- a/src/views/user/Settings.vue +++ b/src/views/user/Settings.vue @@ -383,22 +383,22 @@ export default { updatePassword() { if (this.passwordConfirm !== this.passwordUpdate.newPassword) { - this.error({message: this.$t('user.settings.passwordsDontMatch')}) + this.$message.error({message: this.$t('user.settings.passwordsDontMatch')}) return } this.passwordUpdateService.update(this.passwordUpdate) .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() { this.emailUpdateService.update(this.emailUpdate) .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() { if (!this.totpEnabled) { @@ -416,7 +416,7 @@ export default { return } - this.error(e) + this.$message.error(e) }) }, totpSetQrCode() { @@ -433,24 +433,24 @@ export default { this.$set(this, 'totp', r) this.totpSetQrCode() }) - .catch(e => this.error(e)) + .catch(e => this.$message.error(e)) }, totpConfirm() { this.totpService.enable({passcode: this.totpConfirmPasscode}) .then(() => { 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() { this.totpService.disable({password: this.totpDisablePassword}) .then(() => { this.totpEnrolled = false 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() { localStorage.setItem(playSoundWhenDoneKey, this.playSoundWhenDone) @@ -460,9 +460,9 @@ export default { this.userSettingsService.update(this.settings) .then(() => { 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() { if (window.location.hash === this.$route.hash) {