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() {
this.$store.dispatch('labels/loadAllLabels')
.catch(e => {
this.error(e, this)
this.error(e)
})
},
},

View file

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

View file

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

View file

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

View file

@ -96,10 +96,10 @@ export default {
this.subscriptionService.create(subscription)
.then(() => {
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 => {
this.error(e, this)
this.error(e)
})
},
unsubscribe() {
@ -110,10 +110,10 @@ export default {
this.subscriptionService.delete(subscription)
.then(() => {
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 => {
this.error(e, this)
this.error(e)
})
}
},

View file

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

View file

@ -98,7 +98,7 @@ export default {
this.$set(this, 'allNotifications', r)
})
.catch(e => {
this.error(e, this)
this.error(e)
})
},
to(n, index) {
@ -136,7 +136,7 @@ export default {
.then(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)
.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.closeQuickActions()
})
.catch((e) => {
this.error(e, this)
this.error(e)
})
},
newList() {
@ -380,12 +380,12 @@ export default {
})
this.listService.create(newList)
.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.closeQuickActions()
})
.catch((e) => {
this.error(e, this)
this.error(e)
})
},
newNamespace() {
@ -393,11 +393,11 @@ export default {
this.namespaceService.create(newNamespace)
.then(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()
})
.catch((e) => {
this.error(e, this)
this.error(e)
})
},
newTeam() {
@ -408,11 +408,11 @@ export default {
name: 'teams.edit',
params: {id: r.id},
})
this.success({message: 'The team was successfully created.'}, this)
this.success({message: 'The team was successfully created.'})
this.closeQuickActions()
})
.catch((e) => {
this.error(e, this)
this.error(e)
})
},
select(parentIndex, index) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -175,20 +175,16 @@ export default {
}
this.task = t
this.$emit('task-updated', t)
this.success(
{message: 'The task was successfully ' + (this.task.done ? '' : 'un-') + 'marked as done.'},
this,
[{
this.success({message: 'The task was successfully ' + (this.task.done ? '' : 'un-') + 'marked as done.'}, [{
title: 'Undo',
callback: () => {
this.task.done = !this.task.done
this.markAsDone(!checked)
}
}],
)
}])
})
.catch(e => {
this.error(e, this)
this.error(e)
})
}
@ -207,7 +203,7 @@ export default {
this.$store.dispatch('namespaces/loadNamespacesIfFavoritesDontExist')
})
.catch(e => {
this.error(e, this)
this.error(e)
})
},
hideDeferDueDatePopup(e) {

View file

@ -93,16 +93,16 @@ export default {
.then(r => {
this.avatarProvider = r.avatarProvider
})
.catch(e => this.error(e, this))
.catch(e => this.error(e))
},
updateAvatarStatus() {
const avatarStatus = new AvatarModel({avatarProvider: this.avatarProvider})
this.avatarService.update(avatarStatus)
.then(() => {
this.success({message: 'Avatar status was updated successfully!'}, this)
this.success({message: 'Avatar status was updated successfully!'})
this.$store.commit('auth/reloadAvatar')
})
.catch(e => this.error(e, this))
.catch(e => this.error(e))
},
uploadAvatar() {
this.loading = true
@ -112,10 +112,10 @@ export default {
canvas.toBlob(blob => {
this.avatarService.create(blob)
.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')
})
.catch(e => this.error(e, this))
.catch(e => this.error(e))
.finally(() => {
this.loading = false
this.isCropAvatar = false

View file

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

View file

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

View file

@ -110,7 +110,7 @@ export default {
this.$store.dispatch('namespaces/loadNamespaces')
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)
.then(() => {
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'})
})
.catch(e => this.error(e, this))
.catch(e => this.error(e))
},
},
}

View file

@ -110,19 +110,19 @@ export default {
this.filter = r
this.filters = objectToSnakeCase(this.filter.filters)
})
.catch(e => this.error(e, this))
.catch(e => this.error(e))
},
save() {
this.filter.filters = this.filters
this.filterService.update(this.filter)
.then(r => {
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.filters = objectToSnakeCase(this.filter.filters)
this.$router.back()
})
.catch(e => this.error(e, this))
.catch(e => this.error(e))
},
},
}

View file

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

View file

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

View file

@ -69,17 +69,14 @@ export default {
this.$store
.dispatch('lists/createList', this.list)
.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 },
})
})
.catch((e) => {
this.error(e, this)
this.error(e)
})
},
},

View file

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

View file

@ -38,10 +38,10 @@ export default {
.then(r => {
this.$store.commit('currentList', 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 => {
this.error(e, this)
this.error(e)
})
.finally(() => {
this.$router.back()

View file

@ -130,7 +130,7 @@ export default {
})
})
.catch(e => {
this.error(e, this)
this.error(e)
})
}, 300)
},
@ -144,10 +144,10 @@ export default {
.then(l => {
this.$store.commit(CURRENT_LIST, 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 => {
this.error(e, this)
this.error(e)
})
},
uploadBackground() {
@ -159,10 +159,10 @@ export default {
.then(l => {
this.$store.commit(CURRENT_LIST, 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 => {
this.error(e, this)
this.error(e)
})
},
removeBackground() {
@ -170,11 +170,11 @@ export default {
.then(l => {
this.$store.commit(CURRENT_LIST, 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()
})
.catch(e => {
this.error(e, this)
this.error(e)
})
},
},

View file

@ -31,11 +31,11 @@ export default {
this.listService.delete(list)
.then(() => {
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'})
})
.catch(e => {
this.error(e, this)
this.error(e)
})
},
},

View file

@ -46,11 +46,11 @@ export default {
.then(r => {
this.$store.commit('namespaces/addListToNamespace', 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}})
})
.catch(e => {
this.error(e, this)
this.error(e)
})
},
},

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -80,14 +80,11 @@ export default {
.create(this.namespace)
.then((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.$router.back()
})
.catch((e) => {
this.error(e, this)
this.error(e)
})
},
},

View file

@ -38,10 +38,10 @@ export default {
this.namespaceService.update(this.namespace)
.then(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 => {
this.error(e, this)
this.error(e)
})
.finally(() => {
this.$router.back()

View file

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

View file

@ -118,7 +118,7 @@ export default {
this.setTitle(`Edit "${r.title}"`)
})
.catch(e => {
this.error(e, this)
this.error(e)
})
},
save() {
@ -126,11 +126,11 @@ export default {
.then(r => {
// Update the namespace in the parent
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()
})
.catch(e => {
this.error(e, this)
this.error(e)
})
},
},

View file

@ -69,7 +69,7 @@ export default {
this.setTitle(`Share "${this.namespace.title}"`)
})
.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)
})
.catch(e => {
this.error(e, this)
this.error(e)
})
},
updateTasks(updatedTask) {

View file

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

View file

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

View file

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

View file

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

View file

@ -82,7 +82,9 @@
</div>
</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
@click="redirectToProvider(p)"
v-for="(p, k) in openidConnect.providers"
@ -104,7 +106,6 @@ import {mapState} from 'vuex'
import router from '../../router'
import {HTTPFactory} from '@/http-common'
import message from '../../message'
import {ERROR_MESSAGE, LOADING} from '@/store/mutation-types'
import legal from '../../components/misc/legal'
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?
let emailVerifyToken = localStorage.getItem('emailConfirmToken')
if (emailVerifyToken) {
const cancel = message.setLoading(this)
const cancel = this.setLoading()
HTTP.post(`user/confirm`, {token: emailVerifyToken})
.then(() => {
localStorage.removeItem('emailConfirmToken')
@ -158,6 +159,15 @@ export default {
openidConnect: state => state.config.auth.openidConnect,
}),
methods: {
setLoading() {
const timeout = setTimeout(() => {
this.loading = true
}, 100)
return () => {
clearTimeout(timeout)
this.loading = false
}
},
submit() {
this.$store.commit(ERROR_MESSAGE, '')
// Some browsers prevent Vue bindings from working with autofilled values.
@ -173,7 +183,8 @@ export default {
}
this.$store.dispatch('auth/login', credentials)
.catch(() => {})
.catch(() => {
})
},
redirectToProvider(provider) {
const state = Math.random().toString(36).substring(2, 24)

View file

@ -338,22 +338,22 @@ export default {
methods: {
updatePassword() {
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
}
this.passwordUpdateService.update(this.passwordUpdate)
.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() {
this.emailUpdateService.update(this.emailUpdate)
.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() {
if (!this.totpEnabled) {
@ -371,7 +371,7 @@ export default {
return
}
this.error(e, this)
this.error(e)
})
},
totpSetQrCode() {
@ -388,24 +388,24 @@ export default {
this.$set(this, 'totp', r)
this.totpSetQrCode()
})
.catch(e => this.error(e, this))
.catch(e => this.error(e))
},
totpConfirm() {
this.totpService.enable({passcode: this.totpConfirmPasscode})
.then(() => {
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() {
this.totpService.disable({password: this.totpDisablePassword})
.then(() => {
this.totpEnrolled = false
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() {
localStorage.setItem(playSoundWhenDoneKey, this.playSoundWhenDone)
@ -413,9 +413,9 @@ export default {
this.userSettingsService.update(this.settings)
.then(() => {
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)