Skip to content

Commit 39d6669

Browse files
author
Phil Wing
committed
Added calendar date adjuster.
1 parent 3b2691e commit 39d6669

File tree

5 files changed

+50
-17
lines changed

5 files changed

+50
-17
lines changed

src/components/ListItems/BooleanSlider.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ export default {
3737
},
3838
methods: {
3939
emitSliderChange() {
40-
this.$emit('update:modelValue', this.isChecked); // Emit for v-model binding
41-
console.log("toggling");
40+
this.$emit('update:modelValue', this.isChecked); // Emit for v-model bindingS
4241
},
4342
toggleSlider() {
4443
this.isChecked = !this.isChecked;

src/components/ListItems/ListElement.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import TimeInput from './TimeInput.vue';
6767
import MinuteInput from './MinuteInput.vue';
6868
import { createList } from '../../api.js';
6969
import './ListElement.css';
70+
import { getTodayDate } from '../../date.js';
7071
7172
export default {
7273
name: 'ListElement',
@@ -83,6 +84,10 @@ export default {
8384
multiplayer: {
8485
type: Boolean,
8586
required: false
87+
},
88+
initialDate: {
89+
type: String,
90+
required: false,
8691
}
8792
},
8893
data() {
@@ -125,6 +130,11 @@ export default {
125130
immediate: true,
126131
deep: true, // Watch deeply for changes in array content
127132
},*/
133+
initialDate(){
134+
if(this.listName!='Backburner'){
135+
136+
}
137+
}
128138
},
129139
created() {
130140
this.loadInitialData();
@@ -251,7 +261,7 @@ export default {
251261
return {
252262
textString: text || '',
253263
scheduledCheckbox: false,
254-
scheduledDate: null,
264+
scheduledDate: this.initialDate,
255265
scheduledTime: null,
256266
taskTimeEstimate: 0,
257267
recurringTask: false,
@@ -266,7 +276,7 @@ export default {
266276
//Will be replaced eventually
267277
textString: text,
268278
scheduledCheckbox: this.scheduledCheckbox,
269-
scheduledDate: this.scheduledDate,
279+
scheduledDate: this.initialDate,
270280
scheduledTime: this.scheduledTime,
271281
taskTimeEstimate: this.taskTimeEstimate,
272282
recurringTask: false,

src/date.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,31 @@ export function getTodayDate() {
88
return `${year}-${month}-${day}`; // Format: YYYY-MM-DD
99
}
1010

11-
11+
export function incrementDate(dateString) {
12+
let date;
13+
14+
// Check if dateString is null or undefined, use current date if so
15+
if (!dateString) {
16+
date = new Date(this.getCurrentDate()); // Convert the current date string to a Date object
17+
} else {
18+
date = new Date(dateString); // Convert the provided dateString to a Date object
19+
}
20+
21+
date.setDate(date.getDate() + 1); // Increment the date by 1
22+
return date.toISOString().split('T')[0]; // Return the incremented date as a string in YYYY-MM-DD format
23+
}
24+
25+
export function decrementDate(dateString) {
26+
let date;
27+
28+
// Check if dateString is null or undefined, use current date if so
29+
if (!dateString) {
30+
date = new Date(this.getCurrentDate()); // Convert the current date string to a Date object
31+
} else {
32+
date = new Date(dateString); // Convert the provided dateString to a Date object
33+
}
34+
35+
date.setDate(date.getDate() - 1); // Increment the date by 1
36+
return date.toISOString().split('T')[0]; // Return the incremented date as a string in YYYY-MM-DD format
37+
}
1238

src/router/generalRoutes.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
// src/router/routes/generalRoutes.js
2-
import AboutMe from '@/views/AboutMe.vue';
32
import Learn from '@/views/Learn.vue';
43
import Type from '@/views/Type.vue';
54
import Lists from '@/views/Lists.vue';
65
import Settings from '@/views/Settings.vue';
76

87
export default [
9-
{
10-
path: '/about-me',
11-
name: 'AboutMe',
12-
component: AboutMe
13-
},
148
{
159
path: '/learn',
1610
name: 'Learn',

src/views/Dashboard.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
<!--Need to put these in a v-if is bound to the emits of multiplayer toggle-->
88
<div class="bigButton" id="previousDay" @click="decrementDay"
99
:style="{ 'background-color': colors.background }">&lt;&lt;</div>
10-
<DateInput :style="{margin:'0px' }" @date-selected="handleDueDateChange" :initialDate="currentDate"/>
11-
<div class="bigButton" id="nextDay" :style="{ 'background-color': colors.background }">>></div>
10+
<DateInput :style="{margin:'0px',color:'white' }" @date-selected="handleDateChange" v-model="currentDate"/>
11+
<div class="bigButton" id="nextDay" @click="incrementDay"
12+
:style="{ 'background-color': colors.background }">>></div>
1213
</div>
1314
</div>
1415

1516
<div class="page-container" :style="{ 'background-color': colors.background }">
1617
<div class="lists-container">
1718
<ListElement listName="Backburner" v-model="backburner" />
18-
<ListElement listName="Daily List" v-model="dailyList" :multiplayer="isChecked"/>
19+
<ListElement listName="Daily List" v-model="dailyList" :initialDate="currentDate"/>
1920
<DailyCalendar v-model:list1="backburner" v-model:list2="dailyList" />
2021
</div>
2122
</div>
@@ -31,6 +32,7 @@ import DailyCalendar from '@/components/CalendarComponents/DailyCalendar.vue';
3132
import DateInput from '@/components/ListItems/DateInput.vue';
3233
import './cssViews/Dashboard.css';
3334
import MultiplayerToggle from '@/components/DashboardComponents/MultiplayerToggle.vue';
35+
import { getTodayDate, incrementDate, decrementDate } from '../date.js'
3436
3537
export default {
3638
name: 'DashboardWorld',
@@ -45,7 +47,7 @@ export default {
4547
colors: colors,
4648
dailyList: [],
4749
backburner: [],
48-
currentDate: 0,
50+
currentDate: getTodayDate(),
4951
isChecked: false,
5052
};
5153
},
@@ -63,10 +65,12 @@ export default {
6365
this.itemsArray[this.selectedItemIndex].scheduledDate = date;
6466
},
6567
decrementDay() {
66-
console.log("0");
68+
this.currentDate = decrementDate(this.currentDate);
69+
console.log(this.currentDate);
6770
},
6871
incrementDay() {
69-
72+
this.currentDate = incrementDate(this.currentDate);
73+
console.log(this.currentDate);
7074
},
7175
onEventClicked({ event, listType, index }) {
7276
console.log(`Event clicked:`, event);

0 commit comments

Comments
 (0)