-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.html
More file actions
181 lines (156 loc) · 6.05 KB
/
Copy pathtasks.html
File metadata and controls
181 lines (156 loc) · 6.05 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<style>
</style>
</head>
<body class="bg-light">
<div class="container" id="codelab">
<div class="row justify-content-center mt-5">
<div class="col-md-5">
<div class="row justify-content-center">
<div class="col-md-3">
<img class="w-100" :src="image" alt="">
</div>
</div>
<div class="row">
<div class="col">
<a :href="link">Click me!</a>
</div>
</div>
<div class="row">
<div class="col">
<h4 :class="{'text-center':isActive}" class="" :style="{fontSize: `${fontSize}px`}">Test Text</h4>
</div>
</div>
<div class="row mt-4">
<div class="col">
<div class="input-group mb-3">
<input @keyup.enter="addTask" v-model.trim="text" type="text" class="form-control"
placeholder="Enter task...">
<div class="input-group-append">
<button @click="addTask" class="btn btn-outline-secondary" type="button">Add</button>
</div>
</div>
</div>
</div>
<div class="row" v-if="completed.length > 0">
<div class="col">
<h4>Completed:</h4>
</div>
</div>
<div class="row">
<div class="col">
<ul class="list-group">
<li v-for="(task,index) in completed" class="list-group-item ">
<div class="row justify-content-between">
<div class="col-auto">
<span>{{task.text}}</span>
</div>
<div class="col-auto">
<div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
<button @click="deleteTask(index)" type="button" class="btn btn-danger">Remove
</button>
<button @click="task.completed = !task.completed" type="button"
class="btn btn-info">Toggle
</button>
</div>
</div>
</div>
</li>
</ul>
</div>
</div>
<div class="row" v-if="uncompleted.length > 0">
<div class="col">
<h4>Uncompleted:</h4>
</div>
</div>
<div class="row">
<div class="col">
<ul class="list-group">
<li v-for="(task,index) in uncompleted" class="list-group-item ">
<div class="row justify-content-between">
<div class="col-auto">
<span>{{task.text}}</span>
</div>
<div class="col-auto">
<div class="btn-group btn-group-sm" role="group" aria-label="Basic example">
<button @click="deleteTask(task)" type="button" class="btn btn-danger">Remove
</button>
<button @click="task.completed = !task.completed" type="button"
class="btn btn-info">Toggle
</button>
</div>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
vue = new Vue({
el: "#codelab",
data: {
image: "",
link: "",
text: "",
tasks: [],
isActive: false,
fontSize: 18
},
methods: {
addTask: function () {
if (this.text === "")
return;
let newTask = {
text: this.text,
completed: false,
};
this.tasks.push(newTask);
this.text = "";
},
deleteTask: function (task) {
let sure = confirm(`Are you sure you want to delete the task ${task.text}?`);
if (sure){
let index = this.tasks.indexOf(task);
this.tasks.splice(index, 1);
}
}
},
computed: {
completed() {
// return this.tasks.filter(task => task.completed)
// same as:
return this.tasks.filter(function (task) {
return task.completed;
})
},
uncompleted() {
// return this.tasks.filter(task => !task.completed)
// same as:
return this.tasks.filter(function (task) {
return !task.completed;
})
}
},
mounted() {
console.log("Vue is mounted now!");
},
updated() {
console.log("Updated!")
},
})
</script>
</body>
</html>