File tree Expand file tree Collapse file tree 3 files changed +28
-7
lines changed Expand file tree Collapse file tree 3 files changed +28
-7
lines changed Original file line number Diff line number Diff line change 11<template >
22 <form @submit.prevent =" addTodo" >
3+ <!-- all fields are required-->
34 Name:<br />
45 <input
56 class =" todo-input"
910 v-model =" task"
1011 required
1112 /><br />
12- Due date:<br />
13+ Due date:<br /><!-- task due date must be on or after today date -->
1314 <input
1415 class =" todo-input"
1516 id =" dueDate"
@@ -71,6 +72,7 @@ export interface todoTask {
7172 repeatFrequency: number ;
7273 newId: number ;
7374 completed: boolean ;
75+ timesCompleted: number ;
7476}
7577const currentUtcDate: Date = new Date ();
7678const currentLocalDate: Date = new Date (
@@ -89,7 +91,8 @@ export default defineComponent({
8991 repeatOften: 1 ,
9092 repeatFrequency: repeatFrequency .Once , // set default task repetition to one-time
9193 newId: 0 , // initial id is 0
92- completed: false ,
94+ completed: false , // task not completed if task is created
95+ timesCompleted: 0 ,
9396 };
9497 },
9598 mounted() {
@@ -107,6 +110,7 @@ export default defineComponent({
107110 this .repeatOften = 1 ;
108111 this .repeatFrequency = repeatFrequency .Once ;
109112 this .completed = false ;
113+ this .timesCompleted = 0 ;
110114 },
111115 },
112116});
Original file line number Diff line number Diff line change 55 <br />
66 <p >XP: {{ xps }}</p >
77 <br />
8- <ve-progress :progress =" progresses" >Level {{ levels }}</ve-progress >
8+ <!-- show circular progress bar filled with level progress--> <ve-progress
9+ :progress =" progresses"
10+ >Level {{ levels }}</ve-progress
11+ >
912 <ul class =" todos" >
13+ <!-- repeat for each tasks-->
1014 <li v-for =" todo in todos" :key =" todo.newId" class =" todo" >
1115 <span
1216 v-bind:class =" {
1317 overdue: new Date(todo.dueDate + ' 23:59:59.999') < new Date(),
1418 }"
15- >{{ todo.task }}: Due {{ todo.dueDate }} Priority:
16- {{ todo.priority }} Difficulty: {{ todo.difficulty }} Repeat:
19+ >{{ todo.task }}: Due {{ todo.dueDate }} Priority:{{
20+ todo.priority
21+ }}
22+ Difficulty: {{ todo.difficulty }} Repeat:
1723 <span v-if =" todo.repeatFrequency != 5" >{{ todo.repeatOften }}</span
1824 >  ; <span v-if =" todo.repeatFrequency == 1" >Day</span
1925 ><span v-if =" todo.repeatFrequency == 2" >Week</span
2430 >s</span
2531 ></span
2632 >
27- <button @click =" completeTodo(todo.newId)" >Complete</button >
33+ <!-- don't show if one-time task is completed--> <button
34+ v-if =" !todo.completed"
35+ @click =" completeTodo(todo.newId)"
36+ >
37+ Complete
38+ </button >
2839 <button @click =" deleteTodo(todo.newId)" >Delete</button ><br />
2940 </li >
3041 </ul >
@@ -66,6 +77,7 @@ export default defineComponent({
6677 level: Number ,
6778 xp: Number ,
6879 completed: Boolean ,
80+ timesCompleted: Number ,
6981 },
7082 computed: {
7183 todos() {
Original file line number Diff line number Diff line change @@ -91,14 +91,19 @@ export default createStore({
9191 completed : payload . completed as boolean ,
9292 repeatOften : payload . repeatOften as number ,
9393 repeatFrequency : payload . repeatFrequency as number ,
94+ timesCompleted : payload . timesCompleted as number ,
9495 } ;
9596 state . todos . unshift ( createTask ) ;
9697 } ,
9798 complete_Todo : ( state , payload ) => {
9899 const item = state . todos . find (
99100 ( todo : { newId : number } ) => todo . newId === payload
100101 ) ;
101- item . completed = ! item . completed ; //complete task item
102+ if ( item . repeatFrequency == 5 ) {
103+ item . completed = ! item . completed ; //complete task item
104+ } else {
105+ item . timesCompleted ++ ; //increment number of times task has been completed by 1
106+ }
102107 } ,
103108 delete_Todo : ( state , payload ) => {
104109 const index = state . todos . findIndex (
You can’t perform that action at this time.
0 commit comments