From b37a9262c3152b17b841183f739206ae9de5916c Mon Sep 17 00:00:00 2001 From: Leon Hoppe Date: Sat, 7 Sep 2024 15:17:55 +0200 Subject: [PATCH] Fixed value parameter for between time calculation --- package.json | 2 +- src/app/time/time.page.html | 2 +- src/app/time/time.page.ts | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 7d2e9e9..23652f4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "WorkTime", - "version": "0.1.2", + "version": "0.1.3", "author": "Ionic Framework", "homepage": "https://ionicframework.com/", "scripts": { diff --git a/src/app/time/time.page.html b/src/app/time/time.page.html index 3b53d9b..b2d0bab 100644 --- a/src/app/time/time.page.html +++ b/src/app/time/time.page.html @@ -30,7 +30,7 @@ {{getTypeText(entry.type)}} {{formatEntry(entry.registeredAt.getHours(), entry.registeredAt.getMinutes())}} - {{generateSeparatorText(data[index - 1], entry)}} + {{generateSeparatorText(today[index - 1], entry)}} diff --git a/src/app/time/time.page.ts b/src/app/time/time.page.ts index 6fa1845..b1f883f 100644 --- a/src/app/time/time.page.ts +++ b/src/app/time/time.page.ts @@ -25,6 +25,7 @@ import {FormsModule} from "@angular/forms"; }) export class TimePage { public data: TimeEntry[] = []; + public today: TimeEntry[] = []; public shouldAnimate: boolean[] = []; public currentAction: TimeType = 'login'; @ViewChild('createModal') modal: IonModal | undefined; @@ -53,7 +54,8 @@ export class TimePage { public getEntriesOfToday(): TimeEntry[] { const today = new Date(this.currentDate || Date.now()).toLocaleDateString(); - return this.data.filter(entry => entry.registeredAt.toLocaleDateString() === today); + this.today = this.data.filter(entry => entry.registeredAt.toLocaleDateString() === today); + return this.today; } public getTypeText(type: TimeType): string { @@ -119,11 +121,10 @@ export class TimePage { } private updateCurrentAction(): void { - const today = this.getEntriesOfToday(); - if (today.length == 0) { + if (this.data.length == 0) { this.currentAction = 'login'; }else { - const lastAction = today[today.length - 1].type; + const lastAction = this.data[this.data.length - 1].type; switch (lastAction) { case "start-drive": @@ -188,8 +189,8 @@ export class TimePage { this.shouldAnimate.push(false); } - this.updateCurrentAction(); this.saveData(); + this.updateCurrentAction(); this.modal?.dismiss(null, 'submit'); this.modalDate = undefined; }