Fixed value parameter for between time calculation
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user