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:
@ -93,8 +93,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import message from '../../message'
|
||||
|
||||
import ListService from '../../services/list'
|
||||
import TaskService from '../../services/task'
|
||||
import ListModel from '../../models/list'
|
||||
@ -155,10 +153,10 @@
|
||||
this.tasks.push(r)
|
||||
this.sortTasks()
|
||||
this.newTaskText = ''
|
||||
message.success({message: 'The task was successfully created.'}, this)
|
||||
this.success({message: 'The task was successfully created.'}, this)
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
loadTasks(page) {
|
||||
@ -198,7 +196,7 @@
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
loadTasksForPage(e) {
|
||||
@ -217,10 +215,10 @@
|
||||
this.taskService.update(task)
|
||||
.then(() => {
|
||||
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 => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@
|
||||
</template>
|
||||
<script>
|
||||
import router from '../../router'
|
||||
import message from '../../message'
|
||||
import TaskService from '../../services/task'
|
||||
import PriorityLabel from './reusable/priorityLabel'
|
||||
|
||||
@ -81,7 +80,7 @@
|
||||
this.$set(this, 'tasks', r)
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
gotoList(lid) {
|
||||
|
@ -261,7 +261,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import message from '../../message'
|
||||
import TaskService from '../../services/task'
|
||||
import TaskModel from '../../models/task'
|
||||
import relationKinds from '../../models/relationKinds'
|
||||
@ -361,17 +360,17 @@
|
||||
this.activeFields.relatedTasks = Object.keys(this.task.related_tasks).length > 0
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
saveTask() {
|
||||
this.taskService.update(this.task)
|
||||
.then(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 => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
setListAndNamespaceTitleFromParent() {
|
||||
@ -393,11 +392,11 @@
|
||||
deleteTask() {
|
||||
this.taskService.delete(this.task)
|
||||
.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}})
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
},
|
||||
|
@ -134,7 +134,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import message from '../../message'
|
||||
import flatPickr from 'vue-flatpickr-component'
|
||||
import 'flatpickr/dist/flatpickr.css'
|
||||
import verte from 'verte'
|
||||
@ -208,10 +207,10 @@
|
||||
this.taskService.update(this.taskEditTask)
|
||||
.then(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 => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
},
|
||||
|
@ -126,7 +126,6 @@
|
||||
|
||||
<script>
|
||||
import VueDragResize from 'vue-drag-resize'
|
||||
import message from '../../message'
|
||||
import EditTask from './edit-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 => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
}, 100)
|
||||
},
|
||||
@ -332,10 +331,10 @@
|
||||
this.tasksWithoutDates.push(this.addGantAttributes(r))
|
||||
this.newTaskTitle = ''
|
||||
this.hideCrateNewTask()
|
||||
message.success({message: 'The task was successfully created.'}, this)
|
||||
this.success({message: 'The task was successfully created.'}, this)
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
},
|
||||
|
@ -76,7 +76,6 @@
|
||||
<script>
|
||||
import AttachmentService from '../../../services/attachment'
|
||||
import AttachmentModel from '../../../models/attachment'
|
||||
import message from '../../../message'
|
||||
|
||||
export default {
|
||||
name: 'attachments',
|
||||
@ -153,18 +152,18 @@
|
||||
.then(r => {
|
||||
if(r.success !== null) {
|
||||
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)
|
||||
})
|
||||
}
|
||||
if(r.errors !== null) {
|
||||
r.errors.forEach(m => {
|
||||
message.error(m, this)
|
||||
this.error(m)
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
|
||||
},
|
||||
@ -177,10 +176,10 @@
|
||||
this.attachments.splice(a, 1)
|
||||
}
|
||||
}
|
||||
message.success(r, this)
|
||||
this.success(r, this)
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
.finally(() => {
|
||||
this.showDeleteModal = false
|
||||
|
@ -34,7 +34,6 @@
|
||||
|
||||
<script>
|
||||
import {differenceWith} from 'lodash'
|
||||
import message from '../../../message'
|
||||
import multiselect from 'vue-multiselect'
|
||||
|
||||
import UserModel from '../../../models/user'
|
||||
@ -88,10 +87,10 @@
|
||||
const taskAssignee = new TaskAssigneeModel({user_id: user.id, task_id: this.taskID})
|
||||
this.taskAssigneeService.create(taskAssignee)
|
||||
.then(() => {
|
||||
message.success({message: 'The user was successfully assigned.'}, this)
|
||||
this.success({message: 'The user was successfully assigned.'}, this)
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
removeAssignee(user) {
|
||||
@ -104,10 +103,10 @@
|
||||
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 => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
findUser(query) {
|
||||
@ -124,7 +123,7 @@
|
||||
}))
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
clearAllFoundUsers() {
|
||||
|
@ -35,7 +35,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import message from '../../../message'
|
||||
import { differenceWith } from 'lodash'
|
||||
import multiselect from 'vue-multiselect'
|
||||
|
||||
@ -101,7 +100,7 @@
|
||||
this.labelTimeout = null
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
}, 300)
|
||||
},
|
||||
@ -112,10 +111,10 @@
|
||||
let labelTask = new LabelTaskModel({taskID: this.taskID, label_id: label.id})
|
||||
this.labelTaskService.create(labelTask)
|
||||
.then(() => {
|
||||
message.success({message: 'The label was successfully added.'}, this)
|
||||
this.success({message: 'The label was successfully added.'}, this)
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
removeLabel(label) {
|
||||
@ -128,10 +127,10 @@
|
||||
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 => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
createAndAddLabel(title) {
|
||||
@ -142,7 +141,7 @@
|
||||
this.labels.push(r)
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
|
||||
|
@ -79,7 +79,6 @@
|
||||
import TaskRelationModel from '../../../models/taskRelation'
|
||||
|
||||
import multiselect from 'vue-multiselect'
|
||||
import message from '../../../message'
|
||||
|
||||
export default {
|
||||
name: 'relatedTasks',
|
||||
@ -138,7 +137,7 @@
|
||||
this.$set(this, 'foundTasks', response)
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
clearAllFoundTasks() {
|
||||
@ -158,10 +157,10 @@
|
||||
this.relatedTasks[this.newTaskRelationKind].push(this.newTaskRelationTask)
|
||||
this.newTaskRelationKind = 'unset'
|
||||
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 => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
},
|
||||
removeTaskRelation() {
|
||||
@ -179,10 +178,10 @@
|
||||
}
|
||||
}
|
||||
})
|
||||
message.success(r, this)
|
||||
this.success(r, this)
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(e, this)
|
||||
this.error(e, this)
|
||||
})
|
||||
.finally(() => {
|
||||
this.showDeleteModal = false
|
||||
|
Reference in New Issue
Block a user