Use message mixin for handling success and error messages (#51)

Use message mixin everywhere

Add mixin for success and error messages

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/51
This commit is contained in:
konrad 2020-01-30 21:47:08 +00:00
parent a0c4732f81
commit 1170e030f6
25 changed files with 94 additions and 116 deletions

View file

@ -193,7 +193,6 @@
<script> <script>
import auth from './auth' import auth from './auth'
import message from './message'
import router from './router' import router from './router'
import NamespaceService from './services/namespace' import NamespaceService from './services/namespace'
@ -284,7 +283,7 @@
this.$set(this, 'namespaces', r) this.$set(this, 'namespaces', r)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
loadNamespacesIfNeeded(e) { loadNamespacesIfNeeded(e) {

View file

@ -95,7 +95,6 @@
import LabelService from '../../services/label' import LabelService from '../../services/label'
import LabelModel from '../../models/label' import LabelModel from '../../models/label'
import message from '../../message'
import auth from '../../auth' import auth from '../../auth'
export default { export default {
@ -124,7 +123,7 @@
this.$set(this, 'labels', r) this.$set(this, 'labels', r)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
deleteLabel(label) { deleteLabel(label) {
@ -136,10 +135,10 @@
this.labels.splice(l, 1) this.labels.splice(l, 1)
} }
} }
message.success({message: 'The label was successfully deleted.'}, this) this.success({message: 'The label was successfully deleted.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
editLabelSubmit() { editLabelSubmit() {
@ -150,10 +149,10 @@
this.$set(this.labels, l, r) this.$set(this.labels, l, r)
} }
} }
message.success({message: 'The label was successfully updated.'}, this) this.success({message: 'The label was successfully updated.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
editLabel(label) { editLabel(label) {

View file

@ -60,7 +60,6 @@
<script> <script>
import auth from '../../auth' import auth from '../../auth'
import router from '../../router' import router from '../../router'
import message from '../../message'
import manageSharing from '../sharing/userTeam' import manageSharing from '../sharing/userTeam'
import LinkSharing from '../sharing/linkSharing'; import LinkSharing from '../sharing/linkSharing';
@ -114,7 +113,7 @@
this.manageUsersComponent = 'manageSharing' this.manageUsersComponent = 'manageSharing'
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
submit() { submit() {
@ -129,20 +128,20 @@
} }
} }
} }
message.success({message: 'The list was successfully updated.'}, this) this.success({message: 'The list was successfully updated.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
deleteList() { deleteList() {
this.listService.delete(this.list) this.listService.delete(this.list)
.then(() => { .then(() => {
message.success({message: 'The list was successfully deleted.'}, this) this.success({message: 'The list was successfully deleted.'}, this)
router.push({name: 'home'}) router.push({name: 'home'})
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
} }

View file

@ -26,7 +26,6 @@
<script> <script>
import auth from '../../auth' import auth from '../../auth'
import router from '../../router' import router from '../../router'
import message from '../../message'
import ListService from '../../services/list' import ListService from '../../services/list'
import ListModel from '../../models/list' import ListModel from '../../models/list'
@ -55,11 +54,11 @@
this.listService.create(this.list) this.listService.create(this.list)
.then(response => { .then(response => {
this.$parent.loadNamespaces() this.$parent.loadNamespaces()
message.success({message: 'The list was successfully created.'}, this) this.success({message: 'The list was successfully created.'}, this)
router.push({name: 'showList', params: {id: response.id}}) router.push({name: 'showList', params: {id: response.id}})
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
back() { back() {

View file

@ -19,7 +19,6 @@
<script> <script>
import auth from '../../auth' import auth from '../../auth'
import router from '../../router' import router from '../../router'
import message from '../../message'
import ShowListTask from '../tasks/ShowListTasks' import ShowListTask from '../tasks/ShowListTasks'
import Gantt from '../tasks/Gantt' import Gantt from '../tasks/Gantt'
@ -69,7 +68,7 @@
this.$set(this, 'list', r) this.$set(this, 'list', r)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
} }

View file

@ -47,7 +47,6 @@
<script> <script>
import WunderlistMigrationService from '../../services/migrator/wunderlist' import WunderlistMigrationService from '../../services/migrator/wunderlist'
import message from '../../message'
export default { export default {
name: 'wunderlist', name: 'wunderlist',
@ -77,7 +76,7 @@
this.migrate() this.migrate()
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
} }
}, },
@ -88,7 +87,7 @@
this.authUrl = r.url this.authUrl = r.url
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
migrate() { migrate() {
@ -99,7 +98,7 @@
this.message = r.message this.message = r.message
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
.finally(() => { .finally(() => {
this.isMigrating = false this.isMigrating = false

View file

@ -58,7 +58,6 @@
<script> <script>
import auth from '../../auth' import auth from '../../auth'
import router from '../../router' import router from '../../router'
import message from '../../message'
import manageSharing from '../sharing/userTeam' import manageSharing from '../sharing/userTeam'
import NamespaceService from '../../services/namespace' import NamespaceService from '../../services/namespace'
@ -111,7 +110,7 @@
this.manageUsersComponent = 'manageSharing' this.manageUsersComponent = 'manageSharing'
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
submit() { submit() {
@ -124,20 +123,20 @@
this.$set(this.$parent.namespaces, n, r) this.$set(this.$parent.namespaces, n, r)
} }
} }
message.success({message: 'The namespace was successfully updated.'}, this) this.success({message: 'The namespace was successfully updated.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
deleteNamespace() { deleteNamespace() {
this.namespaceService.delete(this.namespace) this.namespaceService.delete(this.namespace)
.then(() => { .then(() => {
message.success({message: 'The namespace was successfully deleted.'}, this) this.success({message: 'The namespace was successfully deleted.'}, this)
router.push({name: 'home'}) router.push({name: 'home'})
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
} }
} }

View file

@ -27,7 +27,6 @@
<script> <script>
import auth from '../../auth' import auth from '../../auth'
import router from '../../router' import router from '../../router'
import message from '../../message'
import NamespaceModel from "../../models/namespace"; import NamespaceModel from "../../models/namespace";
import NamespaceService from "../../services/namespace"; import NamespaceService from "../../services/namespace";
@ -55,11 +54,11 @@
this.namespaceService.create(this.namespace) this.namespaceService.create(this.namespace)
.then(() => { .then(() => {
this.$parent.loadNamespaces() this.$parent.loadNamespaces()
message.success({message: 'The namespace was successfully created.'}, this) this.success({message: 'The namespace was successfully created.'}, this)
router.push({name: 'home'}) router.push({name: 'home'})
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
back() { back() {

View file

@ -104,7 +104,6 @@
</template> </template>
<script> <script>
import message from '../../message'
import rights from '../../models/rights' import rights from '../../models/rights'
import LinkShareService from '../../services/linkShare' import LinkShareService from '../../services/linkShare'
@ -155,7 +154,7 @@
this.linkShares = r this.linkShares = r
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
add() { add() {
@ -163,22 +162,22 @@
this.linkShareService.create(newLinkShare) this.linkShareService.create(newLinkShare)
.then(() => { .then(() => {
this.selectedRight = rights.READ this.selectedRight = rights.READ
message.success({message: 'The link share was successfully created'}, this) this.success({message: 'The link share was successfully created'}, this)
this.load() this.load()
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
remove() { remove() {
let linkshare = new LinkShareModel({id: this.linkIDToDelete, listID: this.listID}) let linkshare = new LinkShareModel({id: this.linkIDToDelete, listID: this.listID})
this.linkShareService.delete(linkshare) this.linkShareService.delete(linkshare)
.then(() => { .then(() => {
message.success({message: 'The link share was successfully deleted'}, this) this.success({message: 'The link share was successfully deleted'}, this)
this.load() this.load()
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
.finally(() => { .finally(() => {
this.showDeleteModal = false this.showDeleteModal = false

View file

@ -11,7 +11,6 @@
<script> <script>
import auth from '../../auth' import auth from '../../auth'
import router from '../../router' import router from '../../router'
import message from '../../message'
export default { export default {
name: 'linkSharingAuth', name: 'linkSharingAuth',
@ -32,7 +31,7 @@
router.push({name: 'showList', params: {id: r.list_id}}) router.push({name: 'showList', params: {id: r.list_id}})
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
} }
}, },

View file

@ -106,7 +106,6 @@
<script> <script>
import auth from '../../auth' import auth from '../../auth'
import message from '../../message'
import multiselect from 'vue-multiselect' import multiselect from 'vue-multiselect'
import UserNamespaceService from '../../services/userNamespace' import UserNamespaceService from '../../services/userNamespace'
@ -215,7 +214,7 @@
this.$set(this, 'sharables', r) this.$set(this, 'sharables', r)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
deleteSharable() { deleteSharable() {
@ -236,10 +235,10 @@
this.sharables.splice(i, 1) this.sharables.splice(i, 1)
} }
} }
message.success({message: 'The ' + this.shareType + ' was successfully deleted from the ' + this.typeString + '.'}, this) this.success({message: 'The ' + this.shareType + ' was successfully deleted from the ' + this.typeString + '.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
add(admin) { add(admin) {
@ -259,11 +258,11 @@
this.stuffService.create(this.stuffModel) this.stuffService.create(this.stuffModel)
.then(() => { .then(() => {
message.success({message: 'The ' + this.shareType + ' was successfully added.'}, this) this.success({message: 'The ' + this.shareType + ' was successfully added.'}, this)
this.load() this.load()
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
toggleType() { toggleType() {
@ -292,10 +291,10 @@
this.$set(this.sharables[i], 'right', r.right) this.$set(this.sharables[i], 'right', r.right)
} }
} }
message.success({message: 'The ' + this.shareType + ' right was successfully updated.'}, this) this.success({message: 'The ' + this.shareType + ' right was successfully updated.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
find(query) { find(query) {
@ -309,7 +308,7 @@
this.$set(this, 'found', response) this.$set(this, 'found', response)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
clearAll () { clearAll () {

View file

@ -93,8 +93,6 @@
</template> </template>
<script> <script>
import message from '../../message'
import ListService from '../../services/list' import ListService from '../../services/list'
import TaskService from '../../services/task' import TaskService from '../../services/task'
import ListModel from '../../models/list' import ListModel from '../../models/list'
@ -155,10 +153,10 @@
this.tasks.push(r) this.tasks.push(r)
this.sortTasks() this.sortTasks()
this.newTaskText = '' this.newTaskText = ''
message.success({message: 'The task was successfully created.'}, this) this.success({message: 'The task was successfully created.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
loadTasks(page) { loadTasks(page) {
@ -198,7 +196,7 @@
} }
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
loadTasksForPage(e) { loadTasksForPage(e) {
@ -217,10 +215,10 @@
this.taskService.update(task) this.taskService.update(task)
.then(() => { .then(() => {
this.sortTasks() this.sortTasks()
message.success({message: 'The task was successfully ' + (task.done ? '' : 'un-') + 'marked as done.'}, this) this.success({message: 'The task was successfully ' + (task.done ? '' : 'un-') + 'marked as done.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
} }

View file

@ -31,7 +31,6 @@
</template> </template>
<script> <script>
import router from '../../router' import router from '../../router'
import message from '../../message'
import TaskService from '../../services/task' import TaskService from '../../services/task'
import PriorityLabel from './reusable/priorityLabel' import PriorityLabel from './reusable/priorityLabel'
@ -81,7 +80,7 @@
this.$set(this, 'tasks', r) this.$set(this, 'tasks', r)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
gotoList(lid) { gotoList(lid) {

View file

@ -261,7 +261,6 @@
</template> </template>
<script> <script>
import message from '../../message'
import TaskService from '../../services/task' import TaskService from '../../services/task'
import TaskModel from '../../models/task' import TaskModel from '../../models/task'
import relationKinds from '../../models/relationKinds' import relationKinds from '../../models/relationKinds'
@ -361,17 +360,17 @@
this.activeFields.relatedTasks = Object.keys(this.task.related_tasks).length > 0 this.activeFields.relatedTasks = Object.keys(this.task.related_tasks).length > 0
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
saveTask() { saveTask() {
this.taskService.update(this.task) this.taskService.update(this.task)
.then(r => { .then(r => {
this.$set(this, 'task', r) this.$set(this, 'task', r)
message.success({message: 'The task was saved successfully.'}, this) this.success({message: 'The task was saved successfully.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
setListAndNamespaceTitleFromParent() { setListAndNamespaceTitleFromParent() {
@ -393,11 +392,11 @@
deleteTask() { deleteTask() {
this.taskService.delete(this.task) this.taskService.delete(this.task)
.then(() => { .then(() => {
message.success({message: 'The task been deleted successfully.'}, this) this.success({message: 'The task been deleted successfully.'}, this)
router.push({name: 'showList', params: {id: this.list.id}}) router.push({name: 'showList', params: {id: this.list.id}})
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
}, },

View file

@ -134,7 +134,6 @@
</template> </template>
<script> <script>
import message from '../../message'
import flatPickr from 'vue-flatpickr-component' import flatPickr from 'vue-flatpickr-component'
import 'flatpickr/dist/flatpickr.css' import 'flatpickr/dist/flatpickr.css'
import verte from 'verte' import verte from 'verte'
@ -208,10 +207,10 @@
this.taskService.update(this.taskEditTask) this.taskService.update(this.taskEditTask)
.then(r => { .then(r => {
this.$set(this, 'taskEditTask', r) this.$set(this, 'taskEditTask', r)
message.success({message: 'The task was successfully updated.'}, this) this.success({message: 'The task was successfully updated.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
}, },

View file

@ -126,7 +126,6 @@
<script> <script>
import VueDragResize from 'vue-drag-resize' import VueDragResize from 'vue-drag-resize'
import message from '../../message'
import EditTask from './edit-task' import EditTask from './edit-task'
import TaskService from '../../services/task' import TaskService from '../../services/task'
@ -297,10 +296,10 @@
} }
} }
message.success({message: 'The task was successfully updated.'}, this) this.success({message: 'The task was successfully updated.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, 100) }, 100)
}, },
@ -332,10 +331,10 @@
this.tasksWithoutDates.push(this.addGantAttributes(r)) this.tasksWithoutDates.push(this.addGantAttributes(r))
this.newTaskTitle = '' this.newTaskTitle = ''
this.hideCrateNewTask() this.hideCrateNewTask()
message.success({message: 'The task was successfully created.'}, this) this.success({message: 'The task was successfully created.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
}, },

View file

@ -76,7 +76,6 @@
<script> <script>
import AttachmentService from '../../../services/attachment' import AttachmentService from '../../../services/attachment'
import AttachmentModel from '../../../models/attachment' import AttachmentModel from '../../../models/attachment'
import message from '../../../message'
export default { export default {
name: 'attachments', name: 'attachments',
@ -153,18 +152,18 @@
.then(r => { .then(r => {
if(r.success !== null) { if(r.success !== null) {
r.success.forEach(a => { r.success.forEach(a => {
message.success({message: 'Successfully uploaded ' + a.file.name}, this) this.success({message: 'Successfully uploaded ' + a.file.name}, this)
this.attachments.push(a) this.attachments.push(a)
}) })
} }
if(r.errors !== null) { if(r.errors !== null) {
r.errors.forEach(m => { r.errors.forEach(m => {
message.error(m, this) this.error(m)
}) })
} }
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
@ -177,10 +176,10 @@
this.attachments.splice(a, 1) this.attachments.splice(a, 1)
} }
} }
message.success(r, this) this.success(r, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
.finally(() => { .finally(() => {
this.showDeleteModal = false this.showDeleteModal = false

View file

@ -34,7 +34,6 @@
<script> <script>
import {differenceWith} from 'lodash' import {differenceWith} from 'lodash'
import message from '../../../message'
import multiselect from 'vue-multiselect' import multiselect from 'vue-multiselect'
import UserModel from '../../../models/user' import UserModel from '../../../models/user'
@ -88,10 +87,10 @@
const taskAssignee = new TaskAssigneeModel({user_id: user.id, task_id: this.taskID}) const taskAssignee = new TaskAssigneeModel({user_id: user.id, task_id: this.taskID})
this.taskAssigneeService.create(taskAssignee) this.taskAssigneeService.create(taskAssignee)
.then(() => { .then(() => {
message.success({message: 'The user was successfully assigned.'}, this) this.success({message: 'The user was successfully assigned.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
removeAssignee(user) { removeAssignee(user) {
@ -104,10 +103,10 @@
this.assignees.splice(a, 1) this.assignees.splice(a, 1)
} }
} }
message.success({message: 'The user was successfully unassigned.'}, this) this.success({message: 'The user was successfully unassigned.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
findUser(query) { findUser(query) {
@ -124,7 +123,7 @@
})) }))
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
clearAllFoundUsers() { clearAllFoundUsers() {

View file

@ -35,7 +35,6 @@
</template> </template>
<script> <script>
import message from '../../../message'
import { differenceWith } from 'lodash' import { differenceWith } from 'lodash'
import multiselect from 'vue-multiselect' import multiselect from 'vue-multiselect'
@ -101,7 +100,7 @@
this.labelTimeout = null this.labelTimeout = null
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, 300) }, 300)
}, },
@ -112,10 +111,10 @@
let labelTask = new LabelTaskModel({taskID: this.taskID, label_id: label.id}) let labelTask = new LabelTaskModel({taskID: this.taskID, label_id: label.id})
this.labelTaskService.create(labelTask) this.labelTaskService.create(labelTask)
.then(() => { .then(() => {
message.success({message: 'The label was successfully added.'}, this) this.success({message: 'The label was successfully added.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
removeLabel(label) { removeLabel(label) {
@ -128,10 +127,10 @@
this.labels.splice(l, 1) this.labels.splice(l, 1)
} }
} }
message.success({message: 'The label was successfully removed.'}, this) this.success({message: 'The label was successfully removed.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
createAndAddLabel(title) { createAndAddLabel(title) {
@ -142,7 +141,7 @@
this.labels.push(r) this.labels.push(r)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },

View file

@ -79,7 +79,6 @@
import TaskRelationModel from '../../../models/taskRelation' import TaskRelationModel from '../../../models/taskRelation'
import multiselect from 'vue-multiselect' import multiselect from 'vue-multiselect'
import message from '../../../message'
export default { export default {
name: 'relatedTasks', name: 'relatedTasks',
@ -138,7 +137,7 @@
this.$set(this, 'foundTasks', response) this.$set(this, 'foundTasks', response)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
clearAllFoundTasks() { clearAllFoundTasks() {
@ -158,10 +157,10 @@
this.relatedTasks[this.newTaskRelationKind].push(this.newTaskRelationTask) this.relatedTasks[this.newTaskRelationKind].push(this.newTaskRelationTask)
this.newTaskRelationKind = 'unset' this.newTaskRelationKind = 'unset'
this.newTaskRelationTask = new TaskModel() this.newTaskRelationTask = new TaskModel()
message.success({message: 'The task relation was created successfully'}, this) this.success({message: 'The task relation was created successfully'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
removeTaskRelation() { removeTaskRelation() {
@ -179,10 +178,10 @@
} }
} }
}) })
message.success(r, this) this.success(r, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
.finally(() => { .finally(() => {
this.showDeleteModal = false this.showDeleteModal = false

View file

@ -137,7 +137,6 @@
<script> <script>
import auth from '../../auth' import auth from '../../auth'
import router from '../../router' import router from '../../router'
import message from '../../message'
import TeamService from '../../services/team' import TeamService from '../../services/team'
import TeamModel from '../../models/team' import TeamModel from '../../models/team'
@ -190,37 +189,37 @@
} }
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
submit() { submit() {
this.teamService.update(this.team) this.teamService.update(this.team)
.then(response => { .then(response => {
this.team = response this.team = response
message.success({message: 'The team was successfully updated.'}, this) this.success({message: 'The team was successfully updated.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
deleteTeam() { deleteTeam() {
this.teamService.delete(this.team) this.teamService.delete(this.team)
.then(() => { .then(() => {
message.success({message: 'The team was successfully deleted.'}, this) this.success({message: 'The team was successfully deleted.'}, this)
router.push({name: 'listTeams'}) router.push({name: 'listTeams'})
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
deleteUser() { deleteUser() {
this.teamMemberService.delete(this.member) this.teamMemberService.delete(this.member)
.then(() => { .then(() => {
message.success({message: 'The user was successfully deleted from the team.'}, this) this.success({message: 'The user was successfully deleted from the team.'}, this)
this.loadTeam() this.loadTeam()
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
.finally(() => { .finally(() => {
this.showUserDeleteModal = false this.showUserDeleteModal = false
@ -230,10 +229,10 @@
this.teamMemberService.create(this.member) this.teamMemberService.create(this.member)
.then(() => { .then(() => {
this.loadTeam() this.loadTeam()
message.success({message: 'The team member was successfully added.'}, this) this.success({message: 'The team member was successfully added.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
toggleUserType(member) { toggleUserType(member) {

View file

@ -20,7 +20,6 @@
<script> <script>
import auth from '../../auth' import auth from '../../auth'
import router from '../../router' import router from '../../router'
import message from '../../message'
import TeamService from '../../services/team' import TeamService from '../../services/team'
export default { export default {
@ -48,7 +47,7 @@
this.$set(this, 'teams', response) this.$set(this, 'teams', response)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
} }

View file

@ -26,7 +26,6 @@
<script> <script>
import auth from '../../auth' import auth from '../../auth'
import router from '../../router' import router from '../../router'
import message from '../../message'
import TeamModel from '../../models/team' import TeamModel from '../../models/team'
import TeamService from '../../services/team' import TeamService from '../../services/team'
@ -54,10 +53,10 @@
this.teamService.create(this.team) this.teamService.create(this.team)
.then(response => { .then(response => {
router.push({name:'editTeam', params:{id: response.id}}) router.push({name:'editTeam', params:{id: response.id}})
message.success({message: 'The team was successfully created.'}, this) this.success({message: 'The team was successfully created.'}, this)
}) })
.catch(e => { .catch(e => {
message.error(e, this) this.error(e, this)
}) })
}, },
back() { back() {

View file

@ -120,12 +120,15 @@ Vue.directive('focus', {
// Check the user's auth status when the app starts // Check the user's auth status when the app starts
auth.checkAuth() auth.checkAuth()
// Format date mixin // Mixins
import moment from 'moment' import moment from 'moment'
import message from './message'
Vue.mixin({ Vue.mixin({
methods: { methods: {
formatDateSince: date => moment(date).fromNow(), formatDateSince: date => moment(date).fromNow(),
formatDate: date => moment(date).format('LLL'), formatDate: date => moment(date).format('LLL'),
error: (e, context) => message.error(e, context),
success: (s, context) => message.success(s, context),
} }
}) })

View file

@ -40,5 +40,4 @@ export default {
context.loading = false context.loading = false
}, },
} }