Skip to content

Commit

Permalink
Change of appearance when clicking on the done button, and small chan…
Browse files Browse the repository at this point in the history
…ges when updating a ToDO
  • Loading branch information
darioxlz committed Dec 19, 2018
1 parent d7bbf2d commit 638b58d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 4 additions & 0 deletions frontend/components/todo-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,18 @@ const TodoList = {

this.currentTodo = item;
this.showEditor = true;
this.newName = this.currentTodo.name;
},

updateTodo () {
console.info("Update", this.currentTodo, this.newName);
this.currentTodo.name = this.newName;
this.display[this.editIndex] = this.currentTodo;

localStorage.setItem("todos", JSON.stringify(this.display));
this.newName = "";

this.showEditor = false;
},

refreshList () {
Expand Down
8 changes: 3 additions & 5 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ <h1>Add a Todo</h1>
<h1>Your To-Do's</h1>
</div>



<div class="col">
<div class="row" v-if="showEditor">
<div class="col-6">
<input v-model="newName" class="form-control form-control-lg" type="text" placeholder="Enter new todo name">
<input v-model="newName" @keyup.enter='updateTodo()' class="form-control form-control-lg" type="text" placeholder="Enter new todo name">
</div>

<div class="col-6">
Expand All @@ -67,8 +65,8 @@ <h1>Your To-Do's</h1>
</select>

<div class="d-none d-md-block">
<button class="btn btn-success mr-2 rounded" @click="changeState(index)">Done</button>

<button v-if="todo.state == 'pending'" class="btn btn-success mr-2 rounded" @click="changeState(index)">Done</button>
<button v-if="todo.state == 'finished'" class="btn btn-danger mr-2 rounded" @click="changeState(index)">Undone</button>
<button type="button" @click="showTodoEditor(todo, index)" class="btn btn-primary mr-2 rounded">Edit</button>
<button type="button" @click="deleteTodo(index, todo)" class="btn btn-danger rounded">Delete</button>
</div>
Expand Down

0 comments on commit 638b58d

Please sign in to comment.