|
1 | 1 | <template>
|
2 |
| - <form @submit.prevent="addTodo"> |
3 |
| - Name:<br/> |
4 |
| - <input class="todo-input" id="name" type="text" placeholder="Enter task name" v-model="task" required/><br/> |
5 |
| - Due date:<br/> |
6 |
| - <input class="todo-input" id="dueDate" type="date" placeholder="Enter due date" v-model="dueDate" required/><br/> |
7 |
| - Priority:<br/> |
8 |
| - <select class="todo-input" id="priority" v-model="priority" required> |
9 |
| - <option value="1">Low</option><option value="2">Medium</option><option value="3">High</option></select><br/> |
10 |
| - Difficulty:<br/> |
11 |
| - <select class="todo-input" id="difficulty" v-model="difficulty" required> |
12 |
| - <option value="1">Easy</option><option value="2">Medium</option><option value="3">Hard</option></select><br/> |
13 |
| - Repeat often:<br/> |
14 |
| - <input class="todo-input" id="repeat-often" type="number" placeholder="Enter number of days/weeks/months/years to repeat" v-model="repeatOften" required min="1"/><br/> |
15 |
| - Repeat frequency:<br/> |
16 |
| - <select class="todo-input" id="repeat-frequency" v-model="repeatFrequency" required> |
17 |
| - <option value="1">Daily</option><option value="2">Weekly</option><option value="3">Monthly</option><option value="4">Yearly</option><option value="5">Once</option></select><br/> |
18 |
| - <button type="submit">Add Todo</button> |
19 |
| - </form> |
| 2 | + <form @submit.prevent="addTodo"> |
| 3 | + Name:<br /> |
| 4 | + <input |
| 5 | + class="todo-input" |
| 6 | + id="name" |
| 7 | + type="text" |
| 8 | + placeholder="Enter task name" |
| 9 | + v-model="task" |
| 10 | + required |
| 11 | + /><br /> |
| 12 | + Due date:<br /> |
| 13 | + <input |
| 14 | + class="todo-input" |
| 15 | + id="dueDate" |
| 16 | + type="date" |
| 17 | + placeholder="Enter due date" |
| 18 | + v-model="dueDate" |
| 19 | + required |
| 20 | + /><br /> |
| 21 | + Priority:<br /> |
| 22 | + <select class="todo-input" id="priority" v-model="priority" required> |
| 23 | + <option value="1">Low</option> |
| 24 | + <option value="2">Medium</option> |
| 25 | + <option value="3">High</option></select |
| 26 | + ><br /> |
| 27 | + Difficulty:<br /> |
| 28 | + <select class="todo-input" id="difficulty" v-model="difficulty" required> |
| 29 | + <option value="1">Easy</option> |
| 30 | + <option value="2">Medium</option> |
| 31 | + <option value="3">Hard</option></select |
| 32 | + ><br /> |
| 33 | + Repeat often:<br /> |
| 34 | + <input |
| 35 | + class="todo-input" |
| 36 | + id="repeat-often" |
| 37 | + type="number" |
| 38 | + placeholder="Enter number of days/weeks/months/years to repeat" |
| 39 | + v-model="repeatOften" |
| 40 | + required |
| 41 | + min="1" |
| 42 | + /><br /> |
| 43 | + Repeat frequency:<br /> |
| 44 | + <select |
| 45 | + class="todo-input" |
| 46 | + id="repeat-frequency" |
| 47 | + v-model="repeatFrequency" |
| 48 | + required |
| 49 | + > |
| 50 | + <option value="1">Daily</option> |
| 51 | + <option value="2">Weekly</option> |
| 52 | + <option value="3">Monthly</option> |
| 53 | + <option value="4">Yearly</option> |
| 54 | + <option value="5">Once</option></select |
| 55 | + ><br /> |
| 56 | + <button type="submit">Add Todo</button> |
| 57 | + </form> |
20 | 58 | </template>
|
21 | 59 |
|
22 | 60 | <script lang="ts">
|
23 |
| -import store from '@/store'; |
24 |
| -import { difficulty, priority, repeatFrequency } from './TodoList.vue'; |
25 |
| -import { defineComponent } from 'vue'; |
| 61 | +import store from "@/store"; |
| 62 | +import { difficulty, priority, repeatFrequency } from "./TodoList.vue"; |
| 63 | +import { defineComponent } from "vue"; |
26 | 64 |
|
27 | 65 | export interface todoTask {
|
28 |
| - task: string; |
29 |
| - dueDate: Date; |
30 |
| - priority: number; |
31 |
| - difficulty: number; |
32 |
| - repeatOften: number; |
33 |
| - repeatFrequency: number; |
34 |
| - newId: number; |
35 |
| - completed: boolean; |
| 66 | + task: string; |
| 67 | + dueDate: Date; |
| 68 | + priority: number; |
| 69 | + difficulty: number; |
| 70 | + repeatOften: number; |
| 71 | + repeatFrequency: number; |
| 72 | + newId: number; |
| 73 | + completed: boolean; |
36 | 74 | }
|
37 | 75 | const currentUtcDate: Date = new Date();
|
38 |
| -const currentLocalDate: Date = new Date(currentUtcDate.setMinutes(currentUtcDate.getMinutes() - currentUtcDate.getTimezoneOffset())); |
| 76 | +const currentLocalDate: Date = new Date( |
| 77 | + currentUtcDate.setMinutes( |
| 78 | + currentUtcDate.getMinutes() - currentUtcDate.getTimezoneOffset() |
| 79 | + ) |
| 80 | +); |
39 | 81 |
|
40 |
| -export default defineComponent ({ |
41 |
| - data() { |
42 |
| - return { |
43 |
| - task: "", |
44 |
| - dueDate: currentLocalDate.toISOString().split('T')[0],//set default due date to today |
45 |
| - priority: priority.Low,//set default priority is low |
46 |
| - difficulty: difficulty.Easy,//set default difficulty is easy |
47 |
| - repeatOften: 1, |
48 |
| - repeatFrequency: repeatFrequency.Once,//set default task repetition to one-time |
49 |
| - newId: 0,//initial id is 0 |
50 |
| - completed: false |
51 |
| - }; |
| 82 | +export default defineComponent({ |
| 83 | + data() { |
| 84 | + return { |
| 85 | + task: "", |
| 86 | + dueDate: currentLocalDate.toISOString().split("T")[0], //set default due date to today |
| 87 | + priority: priority.Low, //set default priority is low |
| 88 | + difficulty: difficulty.Easy, //set default difficulty is easy |
| 89 | + repeatOften: 1, |
| 90 | + repeatFrequency: repeatFrequency.Once, //set default task repetition to one-time |
| 91 | + newId: 0, //initial id is 0 |
| 92 | + completed: false, |
| 93 | + }; |
| 94 | + }, |
| 95 | + mounted() { |
| 96 | + const dueDateInput = document.getElementById("dueDate") as HTMLInputElement; |
| 97 | + dueDateInput.min = currentLocalDate.toISOString().split("T")[0]; //minimum due date must be today |
| 98 | + }, |
| 99 | + methods: { |
| 100 | + addTodo: function (): void | todoTask[] { |
| 101 | + store.dispatch("createTask", this); |
| 102 | + this.newId++; |
| 103 | + this.task = ""; |
| 104 | + this.dueDate = currentLocalDate.toISOString().split("T")[0]; |
| 105 | + this.priority = priority.Low; |
| 106 | + this.difficulty = difficulty.Easy; |
| 107 | + this.repeatOften = 1; |
| 108 | + this.repeatFrequency = repeatFrequency.Once; |
| 109 | + this.completed = false; |
52 | 110 | },
|
53 |
| - mounted() { |
54 |
| - const dueDateInput = document.getElementById('dueDate') as HTMLInputElement; |
55 |
| - dueDateInput.min = currentLocalDate.toISOString().split('T')[0];//minimum due date must be today |
56 |
| - }, |
57 |
| - methods: { |
58 |
| - addTodo: function(): void | todoTask[] { |
59 |
| - store.dispatch("createTask", this); |
60 |
| - this.newId++; |
61 |
| - this.task = ""; |
62 |
| - this.dueDate = currentLocalDate.toISOString().split('T')[0]; |
63 |
| - this.priority = priority.Low; |
64 |
| - this.difficulty = difficulty.Easy; |
65 |
| - this.repeatOften = 1; |
66 |
| - this.repeatFrequency = repeatFrequency.Once; |
67 |
| - this.completed = false; |
68 |
| - } |
69 |
| - } |
| 111 | + }, |
70 | 112 | });
|
71 | 113 | </script>
|
72 | 114 |
|
73 |
| -<style lang="scss"> |
74 |
| -
|
75 |
| -</style> |
| 115 | +<style lang="scss"></style> |
0 commit comments