This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Module } from '@nestjs/common'; | |
import { UsersController } from './users.controller.ts'; | |
import { UsersService } from './users.service.ts'; | |
@Module({ | |
controllers: [UsersController], | |
providers: [UsersService] | |
}) | |
export class UsersModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@nestjs/common'; | |
import { User } from './interfaces/user.interface'; | |
@Injectable() | |
export class UsersService { | |
private readonly users: User[] = []; | |
create(user: User) { | |
this.users.push(user); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Controller, Get } from '@nestjs/common'; | |
@Controller('users') | |
export class UsersController { | |
@Get() | |
findAll() { | |
return 'This will return all the users'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[...] | |
changeOrder(data) { | |
let toTask = data.to | |
let fromTask = data.from | |
let task_id = data.item.id | |
let category_id = fromTask.id == toTask.id ? null : toTask.id | |
let order = data.newIndex == data.oldIndex ? false : data.newIndex | |
if (order !== false) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[...] | |
endEditing(task) { | |
this.editingTask = null | |
axios.patch(`api/task/${task.id}`, {name: task.name}).then(response => { | |
// You can do anything you wan't here. | |
}) | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[...] | |
addNew(id) { | |
let user_id = 1 | |
let name = "New task" | |
let category_id = this.categories[id].id | |
let order = this.categories[id].tasks.length | |
axios.post('api/task', {user_id, name, order, category_id}).then(response => { | |
this.categories[id].tasks.push(response.data.data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[...] | |
loadTasks() { | |
this.categories.map(category => { | |
axios.get(`api/category/${category.id}/tasks`).then(response => { | |
category.tasks = response.data | |
}) | |
}) | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mounted() { | |
let token = localStorage.getItem('jwt') | |
axios.defaults.headers.common['Content-Type'] = 'application/json' | |
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token | |
axios.get('api/category').then(response => { | |
response.data.forEach((data) => { | |
this.categories.push({ | |
id : data.id, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import draggable from 'vuedraggable' | |
export default { | |
components: { | |
draggable | |
}, | |
data(){ | |
return { | |
categories : [], | |
editingTask : null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style scoped> | |
.card { | |
border:0; | |
border-radius: 0.5rem; | |
} | |
.transit-1 { | |
transition: all 1s; | |
} | |
.small-card { | |
padding: 1rem; |