Skip to content

Commit 2b9e663

Browse files
committed
added activate todolist
1 parent d50949b commit 2b9e663

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

index.html

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
<body>
1515
<div id="app">
1616
<div class="app-content">
17-
<div class="todobox">
17+
<div class="todobox" >
1818
<ul> <!-- list of todos -->
19-
<div v-for="todolist in todos">
20-
<todolist v-bind:todolist="todolist"></todolist>
19+
<div v-for="todolist in todos" v-bind:class="{active: todolist.isActive}">
20+
<todolist v-bind:todolist="todolist" ></todolist>
2121
</div>
2222
</ul>
2323
<form v-on:submit.prevent="addItem(todoListId = 1)" >\
@@ -44,9 +44,19 @@
4444
props: ['todolist'],
4545
template:'\
4646
<li>\
47-
<h2>{{todolist.title}} </h2>\
47+
<h2 v-on:click="activateTodolist">{{todolist.title}} </h2>\
4848
<todo-items v-bind:todolist="todolist"></todo-items>\
49-
</li>'
49+
</li>',
50+
methods: {
51+
activateTodolist: function() {
52+
var todolist = this.todolist;
53+
todolist.isActive = !todolist.isActive;
54+
var index = vm.todos.indexOf(todolist);
55+
vm.todos.splice(index, 1);
56+
vm.todos.map(function(todolist){todolist.isActive = false});
57+
vm.todos.splice(index, 0, todolist);
58+
}
59+
}
5060
});
5161
Vue.component('todo-items', {
5262
props: ['todolist'],
@@ -115,9 +125,6 @@ <h3>\
115125
methods: {
116126
activateTodoItem: function() {
117127
this.$emit('activateItem');
118-
},
119-
activateTodo: function(todoItem) {
120-
121128
},
122129
deleteItem: function() {
123130
this.$emit('deleteItem');
@@ -175,6 +182,7 @@ <h3>\
175182
_this.todos = [data];
176183
}
177184
_this.todos.map(function(todolist) {
185+
todolist.isActive = false;
178186
todolist.all_items.map(function(item) {
179187
item.isActive = false
180188
});

0 commit comments

Comments
 (0)