1
0

Make all api fields snake_case (#105)

Change all snake/camelCase mix and match to camelCase everywhere

Fix conversion to not interfer with service interceptors

Add dynamic conversion between camelCase and snake_case to services

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/105
This commit is contained in:
konrad
2020-04-12 21:54:46 +00:00
parent de36296bac
commit 4a413e7f3c
60 changed files with 296 additions and 189 deletions

View File

@ -32,7 +32,7 @@
</button>
</div>
<div class="field task-add" v-if="!list.is_archived">
<div class="field task-add" v-if="!list.isArchived">
<div class="field is-grouped">
<p class="control has-icons-left is-expanded" :class="{ 'is-loading': taskService.loading}">
<input v-focus class="input" :class="{ 'disabled': taskService.loading}" v-model="newTaskText" type="text" placeholder="Add a new task..." @keyup.enter="addTask()"/>
@ -59,7 +59,7 @@
<div class="tasks" v-if="tasks && tasks.length > 0" :class="{'short': isTaskEdit}">
<div class="task" v-for="t in tasks" :key="t.id">
<single-task-in-list :the-task="t" @taskUpdated="updateTasks"/>
<div @click="editTask(t.id)" class="icon settings" v-if="!list.is_archived">
<div @click="editTask(t.id)" class="icon settings" v-if="!list.isArchived">
<icon icon="pencil-alt"/>
</div>
</div>
@ -159,7 +159,7 @@
}
this.showError = false
let task = new TaskModel({text: this.newTaskText, listID: this.$route.params.id})
let task = new TaskModel({text: this.newTaskText, listId: this.$route.params.id})
this.taskService.create(task)
.then(r => {
this.tasks.push(r)

View File

@ -46,7 +46,7 @@
},
methods: {
loadPendingTasks() {
let params = {sort_by: ['due_date_unix', 'id'], order_by: ['desc', 'desc']}
let params = {sort_by: ['dueDate_unix', 'id'], order_by: ['desc', 'desc']}
if (!this.showAll) {
params.startdate = Math.round(+ this.startDate / 1000)
params.enddate = Math.round(+ this.endDate / 1000)

View File

@ -55,15 +55,15 @@
</th>
<th v-if="activeColumns.dueDate">
Due&nbsp;Date
<sort :order="sortBy.due_date_unix" @click="sort('due_date_unix')"/>
<sort :order="sortBy.dueDate_unix" @click="sort('dueDate_unix')"/>
</th>
<th v-if="activeColumns.startDate">
Start&nbsp;Date
<sort :order="sortBy.start_date_unix" @click="sort('start_date_unix')"/>
<sort :order="sortBy.startDate_unix" @click="sort('startDate_unix')"/>
</th>
<th v-if="activeColumns.endDate">
End&nbsp;Date
<sort :order="sortBy.end_date_unix" @click="sort('end_date_unix')"/>
<sort :order="sortBy.endDate_unix" @click="sort('endDate_unix')"/>
</th>
<th v-if="activeColumns.percentDone">
%&nbsp;Done

View File

@ -28,7 +28,7 @@
</div>
<edit-assignees
:task-i-d="task.id"
:list-i-d="task.listID"
:list-i-d="task.listId"
:initial-assignees="task.assignees"
ref="assignees"
/>
@ -193,8 +193,8 @@
</h3>
<related-tasks
:task-i-d="taskID"
:list-id="task.listID"
:initial-related-tasks="task.related_tasks"
:list-id="task.listId"
:initial-related-tasks="task.relatedTasks"
:show-no-relations-notice="true"
ref="relatedTasks"
/>
@ -397,7 +397,7 @@
this.activeFields.repeatAfter = this.task.repeatAfter.amount > 0
this.activeFields.labels = this.task.labels.length > 0
this.activeFields.attachments = this.task.attachments.length > 0
this.activeFields.relatedTasks = Object.keys(this.task.related_tasks).length > 0
this.activeFields.relatedTasks = Object.keys(this.task.relatedTasks).length > 0
},
saveTaskOnChange() {
this.$refs.taskTitle.spellcheck = false
@ -444,7 +444,7 @@
// FIXME: Throw this away once we have vuex
this.$parent.namespaces.forEach(n => {
n.lists.forEach(l => {
if (l.id === this.task.listID) {
if (l.id === this.task.listId) {
this.list = l
this.namespace = n
return

View File

@ -114,7 +114,7 @@
<div class="field has-addons">
<div class="control is-expanded">
<edit-assignees :task-i-d="taskEditTask.id" :list-i-d="taskEditTask.listID" :initial-assignees="taskEditTask.assignees"/>
<edit-assignees :task-i-d="taskEditTask.id" :list-i-d="taskEditTask.listId" :initial-assignees="taskEditTask.assignees"/>
</div>
</div>
@ -128,8 +128,8 @@
<related-tasks
class="is-narrow"
:task-i-d="task.id"
:list-id="task.listID"
:initial-related-tasks="task.related_tasks"
:list-id="task.listId"
:initial-related-tasks="task.relatedTasks"
/>
<button type="submit" class="button is-success is-fullwidth" :class="{ 'is-loading': taskService.loading}">

View File

@ -235,7 +235,7 @@
prepareTasks() {
const getAllTasks = (page = 1) => {
return this.taskCollectionService.getAll({listID: this.$route.params.id}, {}, page)
return this.taskCollectionService.getAll({listId: this.$route.params.id}, {}, page)
.then(tasks => {
if(page < this.taskCollectionService.totalPages) {
return getAllTasks(page + 1)
@ -367,7 +367,7 @@
if (!this.newTaskFieldActive) {
return
}
let task = new TaskModel({text: this.newTaskTitle, listID: this.list.id})
let task = new TaskModel({text: this.newTaskTitle, listId: this.list.id})
this.taskService.create(task)
.then(r => {
this.tasksWithoutDates.push(this.addGantAttributes(r))

View File

@ -27,7 +27,7 @@ export default {
if (search !== '') {
params.s = search
}
this.taskCollectionService.getAll({listID: this.$route.params.id}, params, page)
this.taskCollectionService.getAll({listId: this.$route.params.id}, params, page)
.then(r => {
this.$set(this, 'tasks', r)
this.$set(this, 'pages', [])

View File

@ -33,7 +33,7 @@
<td>{{ a.file.getHumanSize() }}</td>
<td>{{ a.file.mime }}</td>
<td v-tooltip="formatDate(a.created)">{{ formatDateSince(a.created) }}</td>
<td><user :user="a.created_by" :avatar-size="30"/></td>
<td><user :user="a.createdBy" :avatar-size="30"/></td>
<td>
<div class="buttons has-addons">
<a class="button is-primary noshadow" @click="downloadAttachment(a)" v-tooltip="'Download this attachment'">
@ -153,7 +153,7 @@
this.uploadFiles(this.$refs.files.files)
},
uploadFiles(files) {
const attachmentModel = new AttachmentModel({task_id: this.taskID})
const attachmentModel = new AttachmentModel({taskId: this.taskID})
this.attachmentService.create(attachmentModel, files)
.then(r => {
if(r.success !== null) {

View File

@ -94,9 +94,9 @@
},
created() {
this.taskCommentService = new TaskCommentService()
this.newComment = new TaskCommentModel({task_id: this.taskID})
this.commentEdit = new TaskCommentModel({task_id: this.taskID})
this.commentToDelete = new TaskCommentModel({task_id: this.taskID})
this.newComment = new TaskCommentModel({taskId: this.taskID})
this.commentEdit = new TaskCommentModel({taskId: this.taskID})
this.commentToDelete = new TaskCommentModel({taskId: this.taskID})
this.comments = []
},
mounted() {
@ -109,7 +109,7 @@
},
methods: {
loadComments() {
this.taskCommentService.getAll({task_id: this.taskID})
this.taskCommentService.getAll({taskId: this.taskID})
.then(r => {
this.$set(this, 'comments', r)
})
@ -143,7 +143,7 @@
if (this.commentEdit.comment === '') {
return
}
this.commentEdit.task_id = this.taskID
this.commentEdit.taskId = this.taskID
this.taskCommentService.update(this.commentEdit)
.then(r => {
for (const c in this.comments) {

View File

@ -84,7 +84,7 @@
},
methods: {
addAssignee(user) {
const taskAssignee = new TaskAssigneeModel({user_id: user.id, task_id: this.taskID})
const taskAssignee = new TaskAssigneeModel({userId: user.id, taskId: this.taskID})
this.taskAssigneeService.create(taskAssignee)
.then(() => {
this.success({message: 'The user was successfully assigned.'}, this)
@ -94,7 +94,7 @@
})
},
removeAssignee(user) {
const taskAssignee = new TaskAssigneeModel({user_id: user.id, task_id: this.taskID})
const taskAssignee = new TaskAssigneeModel({userId: user.id, taskId: this.taskID})
this.taskAssigneeService.delete(taskAssignee)
.then(() => {
// Remove the assignee from the list
@ -115,7 +115,7 @@
return
}
this.listUserService.getAll({listID: this.listID}, {s: query})
this.listUserService.getAll({listId: this.listID}, {s: query})
.then(response => {
// Filter the results to not include users who are already assigned
this.$set(this, 'foundUsers', differenceWith(response, this.assignees, (first, second) => {

View File

@ -22,7 +22,7 @@
>
<template slot="tag" slot-scope="{ option }">
<span class="tag"
:style="{'background': option.hex_color, 'color': option.textColor}">
:style="{'background': option.hexColor, 'color': option.textColor}">
<span>{{ option.title }}</span>
<a class="delete is-small" @click="removeLabel(option)"></a>
</span>
@ -108,7 +108,7 @@
this.$set(this, 'foundLabels', [])
},
addLabel(label) {
let labelTask = new LabelTaskModel({taskID: this.taskID, label_id: label.id})
let labelTask = new LabelTaskModel({taskID: this.taskID, labelId: label.id})
this.labelTaskService.create(labelTask)
.then(() => {
this.success({message: 'The label was successfully added.'}, this)
@ -119,7 +119,7 @@
})
},
removeLabel(label) {
let labelTask = new LabelTaskModel({taskID: this.taskID, label_id: label.id})
let labelTask = new LabelTaskModel({taskID: this.taskID, labelId: label.id})
this.labelTaskService.delete(labelTask)
.then(() => {
// Remove the label from the list

View File

@ -1,6 +1,6 @@
<template>
<div class="label-wrapper">
<span class="tag" v-for="label in labels" :style="{'background': label.hex_color, 'color': label.textColor}" :key="label.id">
<span class="tag" v-for="label in labels" :style="{'background': label.hexColor, 'color': label.textColor}" :key="label.id">
<span>{{ label.title }}</span>
</span>
</div>

View File

@ -54,7 +54,7 @@
{{t.text}}
</span>
</router-link>
<a class="remove" @click="() => {showDeleteModal = true; relationToDelete = {relation_kind: kind, other_task_id: t.id}}">
<a class="remove" @click="() => {showDeleteModal = true; relationToDelete = {relationKind: kind, otherTaskId: t.id}}">
<icon icon="trash-alt"/>
</a>
</div>
@ -156,9 +156,9 @@
},
addTaskRelation() {
let rel = new TaskRelationModel({
task_id: this.taskID,
other_task_id: this.newTaskRelationTask.id,
relation_kind: this.newTaskRelationKind,
taskId: this.taskID,
otherTaskId: this.newTaskRelationTask.id,
relationKind: this.newTaskRelationKind,
})
this.taskRelationService.create(rel)
.then(() => {
@ -176,15 +176,15 @@
},
removeTaskRelation() {
let rel = new TaskRelationModel({
relation_kind: this.relationToDelete.relation_kind,
task_id: this.taskID,
other_task_id: this.relationToDelete.other_task_id,
relationKind: this.relationToDelete.relationKind,
taskId: this.taskID,
otherTaskId: this.relationToDelete.otherTaskId,
})
this.taskRelationService.delete(rel)
.then(r => {
Object.keys(this.relatedTasks).forEach(relationKind => {
for (const t in this.relatedTasks[relationKind]) {
if (this.relatedTasks[relationKind][t].id === this.relationToDelete.other_task_id && relationKind === this.relationToDelete.relation_kind) {
if (this.relatedTasks[relationKind][t].id === this.relationToDelete.otherTaskId && relationKind === this.relationToDelete.relationKind) {
this.relatedTasks[relationKind].splice(t, 1)
}
}
@ -199,7 +199,7 @@
})
},
createAndRelateTask(text) {
const newTask = new TaskModel({text: text, listID: this.listId})
const newTask = new TaskModel({text: text, listId: this.listId})
this.taskService.create(newTask)
.then(r => {
this.newTaskRelationTask = r

View File

@ -3,9 +3,9 @@
<fancycheckbox v-model="task.done" @change="markAsDone" :disabled="isArchived"/>
<router-link :to="{ name: 'taskDetailView', params: { id: task.id } }" class="tasktext" :class="{ 'done': task.done}">
<!-- Show any parent tasks to make it clear this task is a sub task of something -->
<span class="parent-tasks" v-if="typeof task.related_tasks.parenttask !== 'undefined'">
<template v-for="(pt, i) in task.related_tasks.parenttask">
{{ pt.text }}<template v-if="(i + 1) < task.related_tasks.parenttask.length">,&nbsp;</template>
<span class="parent-tasks" v-if="typeof task.relatedTasks.parenttask !== 'undefined'">
<template v-for="(pt, i) in task.relatedTasks.parenttask">
{{ pt.text }}<template v-if="(i + 1) < task.relatedTasks.parenttask.length">,&nbsp;</template>
</template>
>
</span>