diff --git a/src/components/Calendar.vue b/src/components/Calendar.vue
index a948a03..24a8009 100644
--- a/src/components/Calendar.vue
+++ b/src/components/Calendar.vue
@@ -1,31 +1,47 @@
@@ -64,11 +80,16 @@
S
+
+
+ v-for ="(day) in dates"
+ :id ="day !== null ? `${day}-${monthYear}` : undefined"
+ :class ="{
+ 'item': day !== null,
+ 'item-selected' : selectedDays.has(`${day}-${monthYear}`)
+ }">
{{ day }}
diff --git a/src/helpers/ArrayHelper.ts b/src/helpers/ArrayHelper.ts
index 51a34f0..adf0390 100644
--- a/src/helpers/ArrayHelper.ts
+++ b/src/helpers/ArrayHelper.ts
@@ -7,18 +7,4 @@ export abstract class ArrayHelper {
public static indexOf(array : any[], element : any) : number {
return array.indexOf(element);
}
-
- public static toggleElement(array : any[], element : any) : void {
-
- let index = ArrayHelper.indexOf(array, element);
- console.log(index);
- if(index < 0) {
- console.log("Not in array")
- array.push(element);
- } else {
- console.log("Already in array")
- array.splice(index, 1);
- }
- }
-
}
diff --git a/src/models/Calendar.ts b/src/models/Calendar.ts
index 2a3596d..1c42694 100644
--- a/src/models/Calendar.ts
+++ b/src/models/Calendar.ts
@@ -29,6 +29,10 @@ export class Calendar {
return new Date(this.year, this.month, this.day);
}
+ public getMonthYear(){
+ return `${this.monthsName[this.month]} ${this.year}`;
+ }
+
public setDay(day : number) { this.day = day; }
public datesOfCurrentMonth(){
@@ -73,6 +77,6 @@ export class Calendar {
}
public toString(){
- return this.monthsName[this.month] + " " + this.year;
+ return `${this.day}-${this.monthsName[this.month]}-${this.year}`
}
}
diff --git a/src/models/TimeStamp.ts b/src/models/TimeStamp.ts
new file mode 100644
index 0000000..5aa23bb
--- /dev/null
+++ b/src/models/TimeStamp.ts
@@ -0,0 +1,12 @@
+export class TimeStamp {
+
+ private readonly value : number;
+
+ public constructor(date : Date) {
+ this.value = date.getTime();
+ }
+
+ public getValue() : number{
+ return this.value;
+ }
+}
diff --git a/src/stores/CalendarStore.ts b/src/stores/CalendarStore.ts
index 2b81c85..f49b3f5 100644
--- a/src/stores/CalendarStore.ts
+++ b/src/stores/CalendarStore.ts
@@ -1,23 +1,14 @@
import { defineStore } from 'pinia'
-import { ArrayHelper} from "@/helpers/ArrayHelper.ts";
+import {TimeStamp} from "@/models/TimeStamp.ts";
export const datePickerStore = defineStore('datePicker', {
state: () => {
- return { dates: [] as number[] }
+ return { dates: [] as TimeStamp[] }
},
actions: {
- select(date : Date) {
- toggleElement(this.dates, date.getTime());
+ update(dates : Date[]) {
+ this.dates = dates.map(date => new TimeStamp(date));
console.log(this.dates);
},
},
})
-
-function toggleElement(arr : any[], element:any) : void {
- let index = ArrayHelper.indexOf(arr, element);
- if (index < 0) {
- arr.push(element);
- } else {
- arr.splice(index, 1);
- }
-}