Refactor success and error messages

This commit is contained in:
kolaente 2021-06-22 22:07:57 +02:00
parent ab4edc17de
commit cdc805c8da
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
55 changed files with 219 additions and 256 deletions

View file

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

View file

@ -161,7 +161,7 @@ export default {
return return
} }
this.$store.dispatch('lists/toggleListFavorite', list) this.$store.dispatch('lists/toggleListFavorite', list)
.catch(e => this.error(e, this)) .catch(e => this.error(e))
}, },
resize() { resize() {
// Hide the menu by default on mobile // Hide the menu by default on mobile

View file

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

View file

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

View file

@ -96,10 +96,10 @@ export default {
this.subscriptionService.create(subscription) this.subscriptionService.create(subscription)
.then(() => { .then(() => {
this.$emit('change', subscription) this.$emit('change', subscription)
this.success({message: `You are now subscribed to this ${this.entity}`}, this) this.success({message: `You are now subscribed to this ${this.entity}`})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
unsubscribe() { unsubscribe() {
@ -110,10 +110,10 @@ export default {
this.subscriptionService.delete(subscription) this.subscriptionService.delete(subscription)
.then(() => { .then(() => {
this.$emit('change', null) this.$emit('change', null)
this.success({message: `You are now unsubscribed to this ${this.entity}`}, this) this.success({message: `You are now unsubscribed to this ${this.entity}`})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
} }
}, },

View file

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

View file

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

View file

@ -361,12 +361,12 @@ export default {
}) })
this.taskService.create(newTask) this.taskService.create(newTask)
.then(r => { .then(r => {
this.success({message: 'The task was successfully created.'}, this) this.success({message: 'The task was successfully created.'})
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) this.error(e)
}) })
}, },
newList() { newList() {
@ -380,12 +380,12 @@ export default {
}) })
this.listService.create(newList) this.listService.create(newList)
.then(r => { .then(r => {
this.success({message: 'The list was successfully created.'}, this) this.success({message: 'The list was successfully created.'})
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) this.error(e)
}) })
}, },
newNamespace() { newNamespace() {
@ -393,11 +393,11 @@ export default {
this.namespaceService.create(newNamespace) this.namespaceService.create(newNamespace)
.then(r => { .then(r => {
this.$store.commit('namespaces/addNamespace', r) this.$store.commit('namespaces/addNamespace', r)
this.success({message: 'The namespace was successfully created.'}, this) this.success({message: 'The namespace was successfully created.'})
this.closeQuickActions() this.closeQuickActions()
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
newTeam() { newTeam() {
@ -408,11 +408,11 @@ export default {
name: 'teams.edit', name: 'teams.edit',
params: {id: r.id}, params: {id: r.id},
}) })
this.success({message: 'The team was successfully created.'}, this) this.success({message: 'The team was successfully created.'})
this.closeQuickActions() this.closeQuickActions()
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
select(parentIndex, index) { select(parentIndex, index) {

View file

@ -231,7 +231,7 @@ export default {
this.linkShares = r this.linkShares = r
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
add() { add() {
@ -248,14 +248,11 @@ export default {
this.name = '' this.name = ''
this.password = '' this.password = ''
this.showNewForm = false this.showNewForm = false
this.success( this.success({message: 'The link share was successfully created'})
{message: 'The link share was successfully created'},
this
)
this.load() this.load()
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
remove() { remove() {
@ -266,14 +263,11 @@ export default {
this.linkShareService this.linkShareService
.delete(linkshare) .delete(linkshare)
.then(() => { .then(() => {
this.success( this.success({message: 'The link share was successfully deleted'})
{message: 'The link share was successfully deleted'},
this
)
this.load() this.load()
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
.finally(() => { .finally(() => {
this.showDeleteModal = false this.showDeleteModal = false

View file

@ -249,7 +249,7 @@ export default {
) )
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
deleteSharable() { deleteSharable() {
@ -271,10 +271,10 @@ export default {
this.sharables.splice(i, 1) this.sharables.splice(i, 1)
} }
} }
this.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}.`})
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
add(admin) { add(admin) {
@ -295,19 +295,16 @@ export default {
this.stuffService this.stuffService
.create(this.stuffModel) .create(this.stuffModel)
.then(() => { .then(() => {
this.success( this.success({
{ message:
message: 'The ' +
'The ' + this.shareType +
this.shareType + ' was successfully added.',
' was successfully added.', })
},
this
)
this.load() this.load()
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
toggleType(sharable) { toggleType(sharable) {
@ -340,18 +337,15 @@ export default {
this.$set(this.sharables[i], 'right', r.right) this.$set(this.sharables[i], 'right', r.right)
} }
} }
this.success( this.success({
{ message:
message: 'The ' +
'The ' + this.shareType +
this.shareType + ' right was successfully updated.',
' right was successfully updated.', })
},
this
)
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
find(query) { find(query) {
@ -366,7 +360,7 @@ export default {
this.$set(this, 'found', response) this.$set(this, 'found', response)
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
clearAll() { clearAll() {

View file

@ -150,10 +150,10 @@ export default {
.then((r) => { .then((r) => {
this.$set(this, 'taskEditTask', r) this.$set(this, 'taskEditTask', r)
this.initTaskFields() this.initTaskFields()
this.success({message: 'The task has been saved successfully.'}, this) this.success({message: 'The task has been saved successfully.'})
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
}, },

View file

@ -362,7 +362,7 @@ export default {
}) })
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
addGantAttributes(t) { addGantAttributes(t) {
@ -447,7 +447,7 @@ export default {
} }
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
editTask(task) { editTask(task) {
@ -484,7 +484,7 @@ export default {
this.hideCrateNewTask() this.hideCrateNewTask()
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
}, },

View file

@ -31,7 +31,7 @@ export default {
} }
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
}, },

View file

@ -115,7 +115,7 @@ export default {
this.loadedList = cloneDeep(currentList) this.loadedList = cloneDeep(currentList)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
loadTasksForPage(e) { loadTasksForPage(e) {

View file

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

View file

@ -236,7 +236,7 @@ export default {
this.makeActions() this.makeActions()
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
addComment() { addComment() {
@ -258,13 +258,10 @@ export default {
.then((r) => { .then((r) => {
this.comments.push(r) this.comments.push(r)
this.newComment.comment = '' this.newComment.comment = ''
this.success( this.success({message: 'The comment was added successfully.'})
{message: 'The comment was added successfully.'},
this
)
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
.finally(() => { .finally(() => {
this.creating = false this.creating = false
@ -300,7 +297,7 @@ export default {
}, 2000) }, 2000)
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
.finally(() => { .finally(() => {
this.isCommentEdit = false this.isCommentEdit = false
@ -318,7 +315,7 @@ export default {
} }
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
.finally(() => { .finally(() => {
this.showDeleteModal = false this.showDeleteModal = false

View file

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

View file

@ -86,7 +86,7 @@ export default {
}, 2000) }, 2000)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.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: 'The user has been assigned successfully.'}, this) this.success({message: 'The user has been assigned successfully.'})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.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: 'The user has been unassinged successfully.'}, this) this.success({message: 'The user has been unassinged successfully.'})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
findUser(query) { findUser(query) {
@ -119,7 +119,7 @@ export default {
})) }))
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
clearAllFoundUsers() { clearAllFoundUsers() {

View file

@ -104,11 +104,11 @@ export default {
.then(() => { .then(() => {
this.$emit('input', this.labels) this.$emit('input', this.labels)
if (showNotification) { if (showNotification) {
this.success({message: 'The label has been added successfully.'}, this) this.success({message: 'The label has been added successfully.'})
} }
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
removeLabel(label) { removeLabel(label) {
@ -121,10 +121,10 @@ export default {
} }
} }
this.$emit('input', this.labels) this.$emit('input', this.labels)
this.success({message: 'The label has been removed successfully.'}, this) this.success({message: 'The label has been removed successfully.'})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
createAndAddLabel(title) { createAndAddLabel(title) {
@ -133,10 +133,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: 'The label has been created successfully.'}, this) this.success({message: 'The label has been created successfully.'})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },

View file

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

View file

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

View file

@ -192,7 +192,7 @@ export default {
this.$set(this, 'foundTasks', response) this.$set(this, 'foundTasks', response)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
addTaskRelation() { addTaskRelation() {
@ -215,7 +215,7 @@ export default {
}, 2000) }, 2000)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
removeTaskRelation() { removeTaskRelation() {
@ -239,7 +239,7 @@ export default {
}, 2000) }, 2000)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
.finally(() => { .finally(() => {
this.showDeleteModal = false this.showDeleteModal = false
@ -253,7 +253,7 @@ export default {
this.addTaskRelation() this.addTaskRelation()
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
relationKindTitle(kind, length) { relationKindTitle(kind, length) {

View file

@ -175,20 +175,16 @@ export default {
} }
this.task = t this.task = t
this.$emit('task-updated', t) this.$emit('task-updated', t)
this.success( this.success({message: 'The task was successfully ' + (this.task.done ? '' : 'un-') + 'marked as done.'}, [{
{message: 'The task was successfully ' + (this.task.done ? '' : 'un-') + 'marked as done.'}, title: 'Undo',
this, callback: () => {
[{ this.task.done = !this.task.done
title: 'Undo', this.markAsDone(!checked)
callback: () => { }
this.task.done = !this.task.done }])
this.markAsDone(!checked)
}
}],
)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
} }
@ -207,7 +203,7 @@ export default {
this.$store.dispatch('namespaces/loadNamespacesIfFavoritesDontExist') this.$store.dispatch('namespaces/loadNamespacesIfFavoritesDontExist')
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.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, this)) .catch(e => this.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: 'Avatar status was updated successfully!'}, this) this.success({message: 'Avatar status was updated successfully!'})
this.$store.commit('auth/reloadAvatar') this.$store.commit('auth/reloadAvatar')
}) })
.catch(e => this.error(e, this)) .catch(e => this.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: 'The avatar has been set successfully!'}, this) this.success({message: 'The avatar has been set successfully!'})
this.$store.commit('auth/reloadAvatar') this.$store.commit('auth/reloadAvatar')
}) })
.catch(e => this.error(e, this)) .catch(e => this.error(e))
.finally(() => { .finally(() => {
this.loading = false this.loading = false
this.isCropAvatar = false this.isCropAvatar = false

View file

@ -215,8 +215,12 @@ Vue.mixin({
}, },
formatDate: date => formatDate(date, 'PPPPpppp'), formatDate: date => formatDate(date, 'PPPPpppp'),
formatDateShort: date => formatDate(date, 'PPpp'), formatDateShort: date => formatDate(date, 'PPpp'),
error: (e, context, actions = []) => message.error(e, context, actions), error(e, actions = []) {
success: (s, context, actions = []) => message.success(s, context, actions), return message.error(e, this, actions)
},
success(s, actions = []) {
return message.success(s, this, actions)
},
colorIsDark: colorIsDark, colorIsDark: colorIsDark,
setTitle: setTitle, setTitle: setTitle,
}, },

View file

@ -1,13 +1,4 @@
export default { export default {
setLoading(context) {
const timeout = setTimeout(function () {
context.loading = true
}, 100)
return () => {
clearTimeout(timeout)
context.loading = false
}
},
error(e, context, actions = []) { error(e, context, actions = []) {
// Build the notification text from error response // Build the notification text from error response
let err = e.message let err = e.message

View file

@ -110,7 +110,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, this)) .catch(e => this.error(e))
}, },
}, },
} }

View file

@ -34,10 +34,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: 'The filter was deleted successfully.'}, this) this.success({message: 'The filter was deleted successfully.'})
this.$router.push({name: 'namespaces.index'}) this.$router.push({name: 'namespaces.index'})
}) })
.catch(e => this.error(e, this)) .catch(e => this.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, this)) .catch(e => this.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: 'The filter was saved successfully.'}, this) this.success({message: 'The filter was saved successfully.'})
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, this)) .catch(e => this.error(e))
}, },
}, },
} }

View file

@ -141,25 +141,25 @@ export default {
loadLabels() { loadLabels() {
this.$store.dispatch('labels/loadAllLabels') this.$store.dispatch('labels/loadAllLabels')
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
deleteLabel(label) { deleteLabel(label) {
this.$store.dispatch('labels/deleteLabel', label) this.$store.dispatch('labels/deleteLabel', label)
.then(() => { .then(() => {
this.success({message: 'The label was successfully deleted.'}, this) this.success({message: 'The label was successfully deleted.'})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
editLabelSubmit() { editLabelSubmit() {
this.$store.dispatch('labels/updateLabel', this.labelEditLabel) this.$store.dispatch('labels/updateLabel', this.labelEditLabel)
.then(() => { .then(() => {
this.success({message: 'The label was successfully updated.'}, this) this.success({message: 'The label was successfully updated.'})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.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: 'The label was successfully created.'}, this) this.success({message: 'The label was successfully created.'})
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
}, },

View file

@ -69,17 +69,14 @@ export default {
this.$store this.$store
.dispatch('lists/createList', this.list) .dispatch('lists/createList', this.list)
.then((r) => { .then((r) => {
this.success( this.success({message: 'The list was successfully created.'})
{ message: 'The list was successfully created.' },
this
)
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) this.error(e)
}) })
}, },
}, },

View file

@ -142,7 +142,7 @@ export default {
this.$store.commit(CURRENT_LIST, r) this.$store.commit(CURRENT_LIST, r)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
.finally(() => { .finally(() => {
this.listLoaded = this.$route.params.listId this.listLoaded = this.$route.params.listId

View file

@ -38,10 +38,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: 'The list was successfully archived.'}, this) this.success({message: 'The list was successfully archived.'})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
.finally(() => { .finally(() => {
this.$router.back() this.$router.back()

View file

@ -130,7 +130,7 @@ export default {
}) })
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, 300) }, 300)
}, },
@ -144,10 +144,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: 'The background has been set successfully!'}, this) this.success({message: 'The background has been set successfully!'})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
uploadBackground() { uploadBackground() {
@ -159,10 +159,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: 'The background has been set successfully!'}, this) this.success({message: 'The background has been set successfully!'})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
removeBackground() { removeBackground() {
@ -170,11 +170,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: 'The background has been removed successfully!'}, this) this.success({message: 'The background has been removed successfully!'})
this.$router.back() this.$router.back()
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
}, },

View file

@ -31,11 +31,11 @@ export default {
this.listService.delete(list) this.listService.delete(list)
.then(() => { .then(() => {
this.$store.commit('namespaces/removeListFromNamespaceById', list) this.$store.commit('namespaces/removeListFromNamespaceById', list)
this.success({message: 'The list was successfully deleted.'}, this) this.success({message: 'The list was successfully deleted.'})
this.$router.push({name: 'home'}) this.$router.push({name: 'home'})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
}, },

View file

@ -46,11 +46,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: 'The list was successfully duplicated.'}, this) this.success({message: 'The list was successfully duplicated.'})
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) this.error(e)
}) })
}, },
}, },

View file

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

View file

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

View file

@ -387,14 +387,14 @@ export default {
bucketId: b.id, bucketId: b.id,
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
} }
}) })
}) })
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
onDrop(bucketId, dropResult) { onDrop(bucketId, dropResult) {
@ -449,7 +449,7 @@ export default {
this.$store.dispatch('tasks/update', task) this.$store.dispatch('tasks/update', task)
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
.finally(() => { .finally(() => {
this.$set(this.taskUpdating, task.id, false) this.$set(this.taskUpdating, task.id, false)
@ -468,7 +468,7 @@ export default {
} }
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
.finally(() => { .finally(() => {
this.$set(this.taskUpdating, task.id, false) this.$set(this.taskUpdating, task.id, false)
@ -516,7 +516,7 @@ export default {
this.$store.commit('kanban/addTaskToBucket', r) this.$store.commit('kanban/addTaskToBucket', r)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
.finally(() => { .finally(() => {
if (!this.$refs[`tasks-container${task.bucketId}`][0]) { if (!this.$refs[`tasks-container${task.bucketId}`][0]) {
@ -541,7 +541,7 @@ export default {
this.showNewBucketInput = false this.showNewBucketInput = false
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
deleteBucketModal(bucketId) { deleteBucketModal(bucketId) {
@ -560,10 +560,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: 'The bucket has been deleted successfully.'}, this) this.success({message: 'The bucket has been deleted successfully.'})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
.finally(() => { .finally(() => {
this.showBucketDeleteModal = false this.showBucketDeleteModal = false
@ -590,20 +590,20 @@ export default {
.then(r => { .then(r => {
realBucket.title = r.title realBucket.title = r.title
bucketTitleElement.blur() bucketTitleElement.blur()
this.success({message: 'The bucket title has been saved successfully.'}, this) this.success({message: 'The bucket title has been saved successfully.'})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.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: 'The bucket limit been saved successfully.'}, this) this.success({message: 'The bucket limit been saved successfully.'})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
setBucketLimit(bucket) { setBucketLimit(bucket) {
@ -622,10 +622,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: 'The done bucket has been saved successfully.'}, this) this.success({message: 'The done bucket has been saved successfully.'})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
bucket.isDoneBucket = !bucket.isDoneBucket bucket.isDoneBucket = !bucket.isDoneBucket
}) })
}, },

View file

@ -323,7 +323,7 @@ export default {
labelAddings[index - 1].resolve(result) labelAddings[index - 1].resolve(result)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
} else { } else {
// label not found, create it // label not found, create it
@ -345,11 +345,11 @@ export default {
labelAddings[index - 1].resolve(result) labelAddings[index - 1].resolve(result)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
} }
}) })
@ -365,13 +365,13 @@ export default {
this.$store.commit(HAS_TASKS, true) this.$store.commit(HAS_TASKS, true)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}) })
} }
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
editTask(id) { editTask(id) {

View file

@ -131,7 +131,7 @@ export default {
this.$set(this.backgrounds, l.id, b) this.$set(this.backgrounds, l.id, b)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
} }
}) })
@ -144,7 +144,7 @@ export default {
return return
} }
this.$store.dispatch('lists/toggleListFavorite', list) this.$store.dispatch('lists/toggleListFavorite', list)
.catch(e => this.error(e, this)) .catch(e => this.error(e))
}, },
saveShowArchivedState() { saveShowArchivedState() {
localStorage.setItem('showArchived', JSON.stringify(this.showArchived)) localStorage.setItem('showArchived', JSON.stringify(this.showArchived))

View file

@ -80,14 +80,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( this.success({message: 'The namespace was successfully created.'})
{ message: 'The namespace was successfully created.' },
this
)
this.$router.back() this.$router.back()
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
}, },

View file

@ -38,10 +38,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: 'The namespace was successfully archived.'}, this) this.success({message: 'The namespace was successfully archived.'})
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
.finally(() => { .finally(() => {
this.$router.back() this.$router.back()

View file

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

View file

@ -118,7 +118,7 @@ export default {
this.setTitle(`Edit "${r.title}"`) this.setTitle(`Edit "${r.title}"`)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
save() { save() {
@ -126,11 +126,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: 'The namespace was successfully updated.'}, this) this.success({message: 'The namespace was successfully updated.'})
this.$router.back() this.$router.back()
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
}, },

View file

@ -69,7 +69,7 @@ export default {
this.setTitle(`Share "${this.namespace.title}"`) this.setTitle(`Share "${this.namespace.title}"`)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
}, },

View file

@ -203,7 +203,7 @@ export default {
this.$store.commit(HAS_TASKS, r.length > 0) this.$store.commit(HAS_TASKS, r.length > 0)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}, },
updateTasks(updatedTask) { updateTasks(updatedTask) {

View file

@ -559,7 +559,7 @@ export default {
this.setTitle(this.task.title) this.setTitle(this.task.title)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
.finally(() => { .finally(() => {
this.$nextTick(() => this.visible = true) this.$nextTick(() => this.visible = true)
@ -620,10 +620,10 @@ export default {
callback: undoCallback, callback: undoCallback,
}] }]
} }
this.success({message: 'The task was saved successfully.'}, this, actions) this.success({message: 'The task was saved successfully.'}, actions)
}) })
.catch(e => { .catch(e => {
this.error(e, this) this.error(e)
}) })
}) })
}, },
@ -648,11 +648,11 @@ export default {
deleteTask() { deleteTask() {
this.$store.dispatch('tasks/delete', this.task) this.$store.dispatch('tasks/delete', this.task)
.then(() => { .then(() => {
this.success({message: 'The task has been deleted successfully.'}, this) this.success({message: 'The task has been deleted successfully.'})
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) this.error(e)
}) })
}, },
toggleTaskDone() { toggleTaskDone() {

View file

@ -249,7 +249,7 @@ export default {
this.setTitle(`Edit Team ${this.team.name}`) this.setTitle(`Edit Team ${this.team.name}`)
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
save() { save() {
@ -263,44 +263,35 @@ export default {
.update(this.team) .update(this.team)
.then((response) => { .then((response) => {
this.team = response this.team = response
this.success( this.success({message: 'The team was successfully updated.'})
{message: 'The team was successfully updated.'},
this
)
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
deleteTeam() { deleteTeam() {
this.teamService this.teamService
.delete(this.team) .delete(this.team)
.then(() => { .then(() => {
this.success( this.success({message: 'The team was successfully deleted.'})
{message: 'The team was successfully deleted.'},
this
)
router.push({name: 'teams.index'}) router.push({name: 'teams.index'})
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
deleteUser() { deleteUser() {
this.teamMemberService this.teamMemberService
.delete(this.member) .delete(this.member)
.then(() => { .then(() => {
this.success( this.success({
{ message:
message: 'The user was successfully deleted from the team.',
'The user was successfully deleted from the team.', })
},
this
)
this.loadTeam() this.loadTeam()
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
.finally(() => { .finally(() => {
this.showUserDeleteModal = false this.showUserDeleteModal = false
@ -315,13 +306,10 @@ export default {
.create(newMember) .create(newMember)
.then(() => { .then(() => {
this.loadTeam() this.loadTeam()
this.success( this.success({message: 'The team member was successfully added.'})
{message: 'The team member was successfully added.'},
this
)
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
toggleUserType(member) { toggleUserType(member) {
@ -336,18 +324,15 @@ export default {
break break
} }
} }
this.success( this.success({
{ message:
message: 'The team member was successfully made ' +
'The team member was successfully made ' + (member.admin ? 'admin' : 'member') +
(member.admin ? 'admin' : 'member') + '.',
'.', })
},
this
)
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
findUser(query) { findUser(query) {
@ -362,7 +347,7 @@ export default {
this.$set(this, 'foundUsers', response) this.$set(this, 'foundUsers', response)
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.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) this.error(e)
}) })
}, },
}, },

View file

@ -67,13 +67,10 @@ export default {
name: 'teams.edit', name: 'teams.edit',
params: { id: response.id }, params: { id: response.id },
}) })
this.success( this.success({message: 'The team was successfully created.'})
{ message: 'The team was successfully created.' },
this
)
}) })
.catch((e) => { .catch((e) => {
this.error(e, this) this.error(e)
}) })
}, },
}, },

View file

@ -82,7 +82,9 @@
</div> </div>
</form> </form>
<div v-if="hasApiUrl && openidConnect.enabled && openidConnect.providers && openidConnect.providers.length > 0" class="mt-4"> <div
v-if="hasApiUrl && openidConnect.enabled && openidConnect.providers && openidConnect.providers.length > 0"
class="mt-4">
<x-button <x-button
@click="redirectToProvider(p)" @click="redirectToProvider(p)"
v-for="(p, k) in openidConnect.providers" v-for="(p, k) in openidConnect.providers"
@ -104,7 +106,6 @@ import {mapState} from 'vuex'
import router from '../../router' import router from '../../router'
import {HTTPFactory} from '@/http-common' import {HTTPFactory} from '@/http-common'
import message from '../../message'
import {ERROR_MESSAGE, LOADING} from '@/store/mutation-types' import {ERROR_MESSAGE, LOADING} from '@/store/mutation-types'
import legal from '../../components/misc/legal' import legal from '../../components/misc/legal'
import ApiConfig from '@/components/misc/api-config' import ApiConfig from '@/components/misc/api-config'
@ -126,7 +127,7 @@ export default {
// FIXME: Why is this here? Can we find a better place for this? // FIXME: Why is this here? Can we find a better place for this?
let emailVerifyToken = localStorage.getItem('emailConfirmToken') let emailVerifyToken = localStorage.getItem('emailConfirmToken')
if (emailVerifyToken) { if (emailVerifyToken) {
const cancel = message.setLoading(this) const cancel = this.setLoading()
HTTP.post(`user/confirm`, {token: emailVerifyToken}) HTTP.post(`user/confirm`, {token: emailVerifyToken})
.then(() => { .then(() => {
localStorage.removeItem('emailConfirmToken') localStorage.removeItem('emailConfirmToken')
@ -158,6 +159,15 @@ export default {
openidConnect: state => state.config.auth.openidConnect, openidConnect: state => state.config.auth.openidConnect,
}), }),
methods: { methods: {
setLoading() {
const timeout = setTimeout(() => {
this.loading = true
}, 100)
return () => {
clearTimeout(timeout)
this.loading = false
}
},
submit() { submit() {
this.$store.commit(ERROR_MESSAGE, '') this.$store.commit(ERROR_MESSAGE, '')
// Some browsers prevent Vue bindings from working with autofilled values. // Some browsers prevent Vue bindings from working with autofilled values.
@ -173,7 +183,8 @@ export default {
} }
this.$store.dispatch('auth/login', credentials) this.$store.dispatch('auth/login', credentials)
.catch(() => {}) .catch(() => {
})
}, },
redirectToProvider(provider) { redirectToProvider(provider) {
const state = Math.random().toString(36).substring(2, 24) const state = Math.random().toString(36).substring(2, 24)

View file

@ -338,22 +338,22 @@ export default {
methods: { methods: {
updatePassword() { updatePassword() {
if (this.passwordConfirm !== this.passwordUpdate.newPassword) { if (this.passwordConfirm !== this.passwordUpdate.newPassword) {
this.error({message: 'The new password and its confirmation don\'t match.'}, this) this.error({message: 'The new password and its confirmation don\'t match.'})
return return
} }
this.passwordUpdateService.update(this.passwordUpdate) this.passwordUpdateService.update(this.passwordUpdate)
.then(() => { .then(() => {
this.success({message: 'The password was successfully updated.'}, this) this.success({message: 'The password was successfully updated.'})
}) })
.catch(e => this.error(e, this)) .catch(e => this.error(e))
}, },
updateEmail() { updateEmail() {
this.emailUpdateService.update(this.emailUpdate) this.emailUpdateService.update(this.emailUpdate)
.then(() => { .then(() => {
this.success({message: 'Your email address was successfully updated. We\'ve sent you a link to confirm it.'}, this) this.success({message: 'Your email address was successfully updated. We\'ve sent you a link to confirm it.'})
}) })
.catch(e => this.error(e, this)) .catch(e => this.error(e))
}, },
totpStatus() { totpStatus() {
if (!this.totpEnabled) { if (!this.totpEnabled) {
@ -371,7 +371,7 @@ export default {
return return
} }
this.error(e, this) this.error(e)
}) })
}, },
totpSetQrCode() { totpSetQrCode() {
@ -388,24 +388,24 @@ export default {
this.$set(this, 'totp', r) this.$set(this, 'totp', r)
this.totpSetQrCode() this.totpSetQrCode()
}) })
.catch(e => this.error(e, this)) .catch(e => this.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: 'You\'ve successfully confirmed your totp setup and can use it from now on!'}, this) this.success({message: 'You\'ve successfully confirmed your totp setup and can use it from now on!'})
}) })
.catch(e => this.error(e, this)) .catch(e => this.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: 'Two factor authentication was sucessfully disabled.'}, this) this.success({message: 'Two factor authentication was sucessfully disabled.'})
}) })
.catch(e => this.error(e, this)) .catch(e => this.error(e))
}, },
updateSettings() { updateSettings() {
localStorage.setItem(playSoundWhenDoneKey, this.playSoundWhenDone) localStorage.setItem(playSoundWhenDoneKey, this.playSoundWhenDone)
@ -413,9 +413,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: 'The name was successfully changed.'}, this) this.success({message: 'The name was successfully changed.'})
}) })
.catch(e => this.error(e, this)) .catch(e => this.error(e))
}, },
copy(text) { copy(text) {
copy(text) copy(text)