Fixed value parameter for between time calculation

This commit is contained in:
2024-09-07 15:17:55 +02:00
parent 821b22c168
commit b37a9262c3
3 changed files with 8 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "WorkTime", "name": "WorkTime",
"version": "0.1.2", "version": "0.1.3",
"author": "Ionic Framework", "author": "Ionic Framework",
"homepage": "https://ionicframework.com/", "homepage": "https://ionicframework.com/",
"scripts": { "scripts": {

View File

@@ -30,7 +30,7 @@
<ion-label class="type">{{getTypeText(entry.type)}}</ion-label> <ion-label class="type">{{getTypeText(entry.type)}}</ion-label>
<span class="time">{{formatEntry(entry.registeredAt.getHours(), entry.registeredAt.getMinutes())}}</span> <span class="time">{{formatEntry(entry.registeredAt.getHours(), entry.registeredAt.getMinutes())}}</span>
<span *ngIf="index !== 0" class="between"> <span *ngIf="index !== 0" class="between">
<span class="between-content">{{generateSeparatorText(data[index - 1], entry)}}</span> <span class="between-content">{{generateSeparatorText(today[index - 1], entry)}}</span>
</span> </span>
</ion-item> </ion-item>
</section> </section>

View File

@@ -25,6 +25,7 @@ import {FormsModule} from "@angular/forms";
}) })
export class TimePage { export class TimePage {
public data: TimeEntry[] = []; public data: TimeEntry[] = [];
public today: TimeEntry[] = [];
public shouldAnimate: boolean[] = []; public shouldAnimate: boolean[] = [];
public currentAction: TimeType = 'login'; public currentAction: TimeType = 'login';
@ViewChild('createModal') modal: IonModal | undefined; @ViewChild('createModal') modal: IonModal | undefined;
@@ -53,7 +54,8 @@ export class TimePage {
public getEntriesOfToday(): TimeEntry[] { public getEntriesOfToday(): TimeEntry[] {
const today = new Date(this.currentDate || Date.now()).toLocaleDateString(); 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 { public getTypeText(type: TimeType): string {
@@ -119,11 +121,10 @@ export class TimePage {
} }
private updateCurrentAction(): void { private updateCurrentAction(): void {
const today = this.getEntriesOfToday(); if (this.data.length == 0) {
if (today.length == 0) {
this.currentAction = 'login'; this.currentAction = 'login';
}else { }else {
const lastAction = today[today.length - 1].type; const lastAction = this.data[this.data.length - 1].type;
switch (lastAction) { switch (lastAction) {
case "start-drive": case "start-drive":
@@ -188,8 +189,8 @@ export class TimePage {
this.shouldAnimate.push(false); this.shouldAnimate.push(false);
} }
this.updateCurrentAction();
this.saveData(); this.saveData();
this.updateCurrentAction();
this.modal?.dismiss(null, 'submit'); this.modal?.dismiss(null, 'submit');
this.modalDate = undefined; this.modalDate = undefined;
} }