11<template >
2- <form @submit.prevent =" addTodo" >
3- <!-- all fields are required in order to add a task-->
4- Name:<br /><!-- task name can be up to 255 characters in length-->
5- <input
6- class =" todo-input"
7- id =" name"
8- type =" text"
9- placeholder =" Enter task name"
10- maxlength =" 255"
11- v-model =" task"
12- required
13- /><br />
14- Due date:<br /><!-- task due date must be on or after today date-->
15- <input
16- class =" todo-input"
17- id =" due-date"
18- type =" date"
19- placeholder =" Enter due date"
20- v-model =" originalDueDate"
21- required
22- /><br />
23- Priority:<br />
2+ <form @submit.prevent =" addTodo" ><!-- all fields are required in order to add a task-->
3+ Name:<br ><!-- task name can be up to 255 characters in length-->
4+ <input class =" todo-input" id =" name" type =" text" placeholder =" Enter task name" maxlength =" 255" v-model =" task" required /><br >
5+ Due date:<br ><!-- task due date must be on or after today date-->
6+ <input class =" todo-input" id =" due-date" type =" date" placeholder =" Enter due date" v-model =" originalDueDate" required /><br >
7+ Priority:<br >
248 <select class =" todo-input" id =" priority" v-model =" priority" required >
259 <option value =" 1" >Low</option >
2610 <option value =" 2" >Medium</option >
27- <option value =" 3" >High</option ></select
28- ><br />
29- Difficulty:<br />
11+ <option value =" 3" >High</option ></select ><br >
12+ Difficulty:<br >
3013 <select class =" todo-input" id =" difficulty" v-model =" difficulty" required >
3114 <option value =" 1" >Easy</option >
3215 <option value =" 2" >Medium</option >
33- <option value =" 3" >Hard</option ></select
34- ><br />
35- Repeat every:<br />
36- <input
37- class =" todo-input"
38- id =" repeat-every"
39- type =" number"
40- placeholder =" Enter number of days/weeks/months/years to repeat"
41- v-model =" repeatEvery"
42- required
43- min =" 1"
44- step =" 1"
45- /><br />
46- Repeat interval:<br />
47- <select
48- class =" todo-input"
49- id =" repeat-interval"
50- v-model =" repeatInterval"
51- required
52- >
16+ <option value =" 3" >Hard</option ></select ><br >
17+ Repeat every:<br >
18+ <input class =" todo-input" id =" repeat-every" type =" number" placeholder =" Enter number of days/weeks/months/years to repeat" v-model =" repeatEvery" required min =" 1" step =" 1" /><br >
19+ Repeat interval:<br >
20+ <select class =" todo-input" id =" repeat-interval" v-model =" repeatInterval" required >
5321 <option value =" 1" >Daily</option >
5422 <option value =" 2" >Weekly</option >
5523 <option value =" 3" >Monthly</option >
5624 <option value =" 4" >Yearly</option >
57- <option value =" 5" >Once</option ></select
58- ><br />
25+ <option value =" 5" >Once</option ></select ><br >
5926 <button type =" submit" >Add Task</button >
6027 </form >
6128</template >
@@ -65,29 +32,23 @@ import store from "@/store";
6532import { Difficulty , Priority , RepeatInterval } from " ./TodoList.vue" ;
6633import { defineComponent } from " vue" ;
6734
68- export interface TodoTask {
69- // todo task interface
70- task: string ; // task name
71- dueDate: Date ; // task due date
72- priority: number ; // task priority
73- difficulty: number ; // task difficulty
74- repeatEvery: number ; // task repetition number of days/weeks/months/years
75- repeatInterval: number ; // task repetition interval
76- newId: number ; // task id
77- isCompleted: boolean ; // task completed or not
78- timesCompleted: number ; // number of times tasks has been completed
79- streak: number ; // task completion streak
80- originalDueDate: Date ; // task original due date in YYYY-MM-DD string
35+ export interface TodoTask {// todo task interface
36+ task: string ;// task name
37+ dueDate: Date ;// task due date
38+ priority: number ;// task priority
39+ difficulty: number ;// task difficulty
40+ repeatEvery: number ;// task repetition number of days/weeks/months/years
41+ repeatInterval: number ;// task repetition interval
42+ newId: number ;// task id
43+ isCompleted: boolean ;// task completed or not
44+ timesCompleted: number ;// number of times tasks has been completed
45+ streak: number ;// task completion streak
46+ originalDueDate: Date ;// task original due date in YYYY-MM-DD string
8147}
82- const currentUtcDate: Date = new Date (); // current UTC date
83- const currentLocalDate: Date = new Date (
84- currentUtcDate .setMinutes (
85- currentUtcDate .getMinutes () - currentUtcDate .getTimezoneOffset (),
86- ),
87- ); // currect date in local time zone
48+ const currentUtcDate: Date = new Date ();// current UTC date
49+ const currentLocalDate: Date = new Date (currentUtcDate .setMinutes (currentUtcDate .getMinutes () - currentUtcDate .getTimezoneOffset ()));// currect date in local time zone
8850
89- export default defineComponent ({
90- // define component to default values when task is created
51+ export default defineComponent ({// define component to default values when task is created
9152 data() {
9253 return {
9354 task: " " ,
@@ -98,18 +59,16 @@ export default defineComponent({
9859 repeatInterval: RepeatInterval ?.Once , // set default task repetition interval to one-time
9960 newId: 0 , // initial task id is 0
10061 isCompleted: false , // task not completed if a task is created
101- timesCompleted: 0 , // set default task times completed to 0
102- streak: 0 , // set default task streak to 0
103- rank: 1 , // set default task rank to 1
104- rankXp: 0 , // set default task rank XP to 0
105- rankProgress: 0 , // set default rank progress to 0
106- originalDueDate: currentLocalDate .toISOString ().split (" T" )[0 ], // set a default original task due date to today
62+ timesCompleted: 0 ,// set default task times completed to 0
63+ streak: 0 ,// set default task streak to 0
64+ rank: 1 ,// set default task rank to 1
65+ rankXp: 0 ,// set default task rank XP to 0
66+ rankProgress: 0 ,// set default rank progress to 0
67+ originalDueDate: currentLocalDate .toISOString ().split (" T" )[0 ] // set a default original task due date to today
10768 };
10869 },
10970 mounted() {
110- const dueDateInput = document .getElementById (
111- " due-date" ,
112- ) as HTMLInputElement ; // get due date value as input element
71+ const dueDateInput = document .getElementById (" due-date" ) as HTMLInputElement ;// get due date value as input element
11372 dueDateInput .min = currentLocalDate .toISOString ().split (" T" )[0 ]; // task minimum due date must be today
11473 },
11574 methods: {
0 commit comments