File tree Expand file tree Collapse file tree 1 file changed +50
-5
lines changed Expand file tree Collapse file tree 1 file changed +50
-5
lines changed Original file line number Diff line number Diff line change 4
4
Loading..
5
5
</div >
6
6
<form v-else >
7
- <div class =" form-group" >
8
- <label >Todo Subject</label >
9
- <input v-model =" todo.subject" type =" text" class =" form-control" >
7
+ <div class =" row" >
8
+ <div class =" col-6" >
9
+ <div class =" form-group" >
10
+ <label >Subject</label >
11
+ <input
12
+ v-model =" todo.subject"
13
+ type =" text"
14
+ class =" form-control"
15
+ >
16
+ </div >
17
+ </div >
18
+ <div class =" col-6" >
19
+ <div class =" form-group" >
20
+ <label >Status</label >
21
+ <div >
22
+ <button
23
+ class =" btn"
24
+ type =" button"
25
+ :class =" todo.completed ? 'btn-success' : 'btn-danger'"
26
+ @click =" toggleTodoStatus"
27
+ >
28
+ {{ todo.completed ? 'Completed' : 'Incomplete' }}
29
+ </button >
30
+ </div >
31
+ </div >
32
+ </div >
10
33
</div >
11
- <button class =" btn btn-primary" >Save</button >
34
+
35
+ <button type =" submit" class =" btn btn-primary" >
36
+ Save
37
+ </button >
38
+ <button
39
+ class =" btn btn-outline-dark ml-2"
40
+ @click =" moveToTodoListPage"
41
+ >
42
+ Cancel
43
+ </button >
12
44
</form >
13
45
</template >
14
46
15
47
<script >
16
- import { useRoute } from ' vue-router' ;
48
+ import { useRoute , useRouter } from ' vue-router' ;
17
49
import axios from ' axios' ;
18
50
import { ref } from ' @vue/reactivity' ;
19
51
20
52
export default {
21
53
setup () {
22
54
const route = useRoute ();
55
+ const router = useRouter ();
23
56
const todo = ref (null );
24
57
const loading = ref (true );
25
58
@@ -30,11 +63,23 @@ export default {
30
63
loading .value = false ;
31
64
};
32
65
66
+ const toggleTodoStatus = () => {
67
+ todo .value .completed = ! todo .value .completed ;
68
+ };
69
+
70
+ const moveToTodoListPage = () => {
71
+ router .push ({
72
+ name: ' Todos'
73
+ })
74
+ };
75
+
33
76
getTodo ();
34
77
35
78
return {
36
79
todo,
37
80
loading,
81
+ toggleTodoStatus,
82
+ moveToTodoListPage,
38
83
};
39
84
}
40
85
}
You can’t perform that action at this time.
0 commit comments