-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
76 lines (73 loc) · 1.56 KB
/
Copy pathscript.js
File metadata and controls
76 lines (73 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Vue.component('task-list', {
template: '#task-list',
props: {
tasks: {default: []}
},
data() {
return {
newTask: ''
};
},
computed: {
incomplete() {
return this.tasks.filter(this.inProgress).length;
}
},
methods: {
addTask() {
if (this.newTask) {
this.tasks.push({
title: this.newTask,
completed: false
});
this.newTask = '';
}
},
completeTask(task) {
task.completed = ! task.completed;
},
removeTask(index) {
this.tasks.splice(index, 1);
},
clearCompleted() {
this.tasks = this.tasks.filter(this.inProgress);
},
clearAll() {
this.tasks = [];
},
inProgress(task) {
return ! this.isCompleted(task);
},
isCompleted(task) {
return task.completed;
}
}
});
Vue.component('task-item', {
template: '#task-item',
props: ['task'],
computed: {
className() {
let classes = ['tasks__item__toggle'];
if (this.task.completed) {
classes.push('tasks__item__toggle--completed');
}
return classes.join(' ');
}
}
});
new Vue({
el: '#app',
data: {
tasks: [
{
title: 'Write a Program in C',
completed: true
},
{
title: 'Do meditaion for 10 mins',
completed: false
}
]
}
});