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

@ -10,11 +10,11 @@
<span
v-for="l in labels" :key="l.id"
class="tag"
:class="{'disabled': user.infos.id !== l.created_by.id}"
:style="{'background': l.hex_color, 'color': l.textColor}"
:class="{'disabled': user.infos.id !== l.createdBy.id}"
:style="{'background': l.hexColor, 'color': l.textColor}"
>
<span
v-if="user.infos.id !== l.created_by.id"
v-if="user.infos.id !== l.createdBy.id"
v-tooltip.bottom="'You are not allowed to edit this label because you dont own it.'">
{{ l.title }}
</span>
@ -24,7 +24,7 @@
v-else>
{{ l.title }}
</a>
<a class="delete is-small" @click="deleteLabel(l)" v-if="user.infos.id === l.created_by.id"></a>
<a class="delete is-small" @click="deleteLabel(l)" v-if="user.infos.id === l.createdBy.id"></a>
</span>
</div>
<div class="column is-4" v-if="isLabelEdit">
@ -57,7 +57,7 @@
<label class="label">Color</label>
<div class="control">
<verte
v-model="labelEditLabel.hex_color"
v-model="labelEditLabel.hexColor"
menuPosition="top"
picker="square"
model="hex"
@ -155,7 +155,7 @@
})
},
editLabel(label) {
if(label.created_by.id !== this.user.infos.id) {
if(label.createdBy.id !== this.user.infos.id) {
return
}
this.labelEditLabel = label

View File

@ -1,6 +1,6 @@
<template>
<div class="loader-container" :class="{ 'is-loading': listService.loading}">
<div class="notification is-warning" v-if="list.is_archived">
<div class="notification is-warning" v-if="list.isArchived">
This list is archived.
It is not possible to create new or edit tasks or it.
</div>
@ -28,7 +28,7 @@
<div class="field">
<label class="label" for="isArchivedCheck">Is Archived</label>
<div class="control">
<fancycheckbox v-model="list.is_archived" v-tooltip="'If a list is archived, you cannot create new tasks or edit the list or existing tasks.'">
<fancycheckbox v-model="list.isArchived" v-tooltip="'If a list is archived, you cannot create new tasks or edit the list or existing tasks.'">
This list is archived
</fancycheckbox>
</div>
@ -37,7 +37,7 @@
<label class="label">Color</label>
<div class="control">
<verte
v-model="list.hex_color"
v-model="list.hexColor"
menuPosition="top"
picker="square"
model="hex"

View File

@ -5,7 +5,7 @@
<icon icon="cog" size="2x"/>
</router-link>
<h1 :style="{ 'opacity': list.title === '' ? '0': '1' }">{{ list.title === '' ? 'Loading...': list.title}}</h1>
<div class="notification is-warning" v-if="list.is_archived">
<div class="notification is-warning" v-if="list.isArchived">
This list is archived.
It is not possible to create new or edit tasks or it.
</div>

View File

@ -1,6 +1,6 @@
<template>
<div class="loader-container" v-bind:class="{ 'is-loading': namespaceService.loading}">
<div class="notification is-warning" v-if="namespace.is_archived">
<div class="notification is-warning" v-if="namespace.isArchived">
This namespace is archived.
It is not possible to create new lists or edit it.
</div>
@ -28,7 +28,7 @@
<div class="field">
<label class="label" for="isArchivedCheck">Is Archived</label>
<div class="control">
<fancycheckbox v-model="namespace.is_archived" v-tooltip="'If a namespace is archived, you cannot create new lists or edit it.'">
<fancycheckbox v-model="namespace.isArchived" v-tooltip="'If a namespace is archived, you cannot create new lists or edit it.'">
This namespace is archived
</fancycheckbox>
</div>
@ -37,7 +37,7 @@
<label class="label">Color</label>
<div class="control">
<verte
v-model="namespace.hex_color"
v-model="namespace.hexColor"
menuPosition="top"
picker="square"
model="hex"

View File

@ -52,7 +52,7 @@
</div>
</td>
<td>
{{ s.shared_by.username }}
{{ s.sharedBy.username }}
</td>
<td class="type">
<template v-if="s.right === rights.ADMIN">
@ -145,7 +145,7 @@
return
}
this.linkShareService.getAll({listID: this.listID})
this.linkShareService.getAll({listId: this.listID})
.then(r => {
this.linkShares = r
})
@ -154,7 +154,7 @@
})
},
add() {
let newLinkShare = new LinkShareModel({right: this.selectedRight, listID: this.listID})
let newLinkShare = new LinkShareModel({right: this.selectedRight, listId: this.listID})
this.linkShareService.create(newLinkShare)
.then(() => {
this.selectedRight = rights.READ
@ -166,7 +166,7 @@
})
},
remove() {
let linkshare = new LinkShareModel({id: this.linkIDToDelete, listID: this.listID})
let linkshare = new LinkShareModel({id: this.linkIDToDelete, listId: this.listID})
this.linkShareService.delete(linkshare)
.then(() => {
this.success({message: 'The link share was successfully deleted'}, this)

View File

@ -28,7 +28,7 @@
auth.linkShareAuth(this.$route.params.share)
.then((r) => {
this.loading = false
router.push({name: 'showList', params: {id: r.list_id}})
router.push({name: 'showList', params: {id: r.listId}})
})
.catch(e => {
this.error(e, this)

View File

@ -175,7 +175,7 @@
if (this.type === 'list') {
this.typeString = `list`
this.stuffService = new UserListService()
this.stuffModel = new UserListModel({listID: this.id})
this.stuffModel = new UserListModel({listId: this.id})
} else if (this.type === 'namespace') {
this.typeString = `namespace`
this.stuffService = new UserNamespaceService()
@ -192,7 +192,7 @@
if (this.type === 'list') {
this.typeString = `list`
this.stuffService = new TeamListService()
this.stuffModel = new TeamListModel({listID: this.id})
this.stuffModel = new TeamListModel({listId: this.id})
} else if (this.type === 'namespace') {
this.typeString = `namespace`
this.stuffService = new TeamNamespaceService()
@ -219,17 +219,17 @@
deleteSharable() {
if (this.shareType === 'user') {
this.stuffModel.userID = this.sharable.username
this.stuffModel.userId = this.sharable.username
} else if (this.shareType === 'team') {
this.stuffModel.teamID = this.sharable.id
this.stuffModel.teamId = this.sharable.id
}
this.stuffService.delete(this.stuffModel)
.then(() => {
this.showDeleteModal = false
for (const i in this.sharables) {
if (
(this.sharables[i].id === this.stuffModel.userID && this.shareType === 'user') ||
(this.sharables[i].id === this.stuffModel.teamID && this.shareType === 'team')
(this.sharables[i].id === this.stuffModel.userId && this.shareType === 'user') ||
(this.sharables[i].id === this.stuffModel.teamId && this.shareType === 'team')
) {
this.sharables.splice(i, 1)
}
@ -250,9 +250,9 @@
}
if (this.shareType === 'user') {
this.stuffModel.userID = this.sharable.username
this.stuffModel.userId = this.sharable.username
} else if (this.shareType === 'team') {
this.stuffModel.teamID = this.sharable.id
this.stuffModel.teamId = this.sharable.id
}
this.stuffService.create(this.stuffModel)
@ -275,17 +275,17 @@
if (this.shareType === 'user') {
this.stuffModel.userID = sharable.username
this.stuffModel.userId = sharable.username
} else if (this.shareType === 'team') {
this.stuffModel.teamID = sharable.id
this.stuffModel.teamId = sharable.id
}
this.stuffService.update(this.stuffModel)
.then(r => {
for (const i in this.sharables) {
if (
(this.sharables[i].id === this.stuffModel.userID && this.shareType === 'user') ||
(this.sharables[i].id === this.stuffModel.teamID && this.shareType === 'team')
(this.sharables[i].id === this.stuffModel.userId && this.shareType === 'user') ||
(this.sharables[i].id === this.stuffModel.teamId && this.shareType === 'team')
) {
this.$set(this.sharables[i], 'right', r.right)
}

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>

View File

@ -175,14 +175,14 @@
},
methods: {
loadTeam() {
this.member = new TeamMemberModel({teamID: this.$route.params.id})
this.member = new TeamMemberModel({teamId: this.$route.params.id})
this.team = new TeamModel({id: this.$route.params.id})
this.teamService.get(this.team)
.then(response => {
this.$set(this, 'team', response)
let members = response.members
for (const m in members) {
members[m].teamID = this.$route.params.id
members[m].teamId = this.$route.params.id
if (members[m].id === this.user.infos.id && members[m].admin) {
this.userIsAdmin = true
}

View File

@ -66,7 +66,7 @@
return
}
let passwordReset = new PasswordResetModel({new_password: this.credentials.password})
let passwordReset = new PasswordResetModel({newPassword: this.credentials.password})
this.passwordResetService.resetPassword(passwordReset)
.then(response => {
this.successMessage = response.data.message