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",
"version": "0.1.2",
"version": "0.1.3",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {

View File

@@ -30,7 +30,7 @@
<ion-label class="type">{{getTypeText(entry.type)}}</ion-label>
<span class="time">{{formatEntry(entry.registeredAt.getHours(), entry.registeredAt.getMinutes())}}</span>
<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>
</ion-item>
</section>

View File

@@ -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;
}