Added moba feature

This commit is contained in:
2025-02-26 19:44:29 +01:00
parent 70101b8d9b
commit 970e018ec2
5 changed files with 42 additions and 15 deletions

View File

@@ -76,7 +76,8 @@ export class AnalysisPage {
const lastEntry = this.timeData[this.timeData.length - 1];
const diff = this.time.calculateTimespanInMinutes(lastEntry, {
type: undefined,
registeredAt: new Date(Date.now())
registeredAt: new Date(Date.now()),
isMoba: false
});
if (lastEntry.type == "login") {

View File

@@ -27,6 +27,7 @@
<section class="time-entries">
<ion-item class="entry" *ngFor="let entry of getEntriesOfToday(); let index = index" (click)="removeEntry(entry, index)" [ngClass]="{'animate': shouldAnimate[index]}">
<div class="circle"></div>
<ion-icon name="home" *ngIf="entry.isMoba" />
<ion-label class="type">{{getTypeText(entry.type)}}</ion-label>
<span class="time">{{formatEntry(entry.registeredAt.getHours(), entry.registeredAt.getMinutes())}}</span>
<ion-icon name="trash" *ngIf="isToday()" />
@@ -37,7 +38,10 @@
</section>
<div class="button-container" *ngIf="isToday()">
<ion-button (click)="addEntry()">{{translateCurrentAction()}}</ion-button>
<ion-button (click)="addEntry()">
<ion-icon name="home" *ngIf="currentlyMoba" style="margin-right: 0.5rem" />
{{translateCurrentAction()}}
</ion-button>
<ion-button shape="round" class="icon-button" (click)="openModal()">
<ion-icon slot="icon-only" name="add"></ion-icon>
</ion-button>
@@ -50,7 +54,6 @@
<ion-buttons slot="start">
<ion-button (click)="modal?.dismiss(null, 'cancel')">Abbrechen</ion-button>
</ion-buttons>
<ion-title>Welcome</ion-title>
<ion-buttons slot="end">
<ion-button [strong]="true" (click)="addModalEntry()">Speichern</ion-button>
</ion-buttons>
@@ -75,6 +78,9 @@
<ion-select-option value="end-drive">Dienstreise beenden</ion-select-option>
</ion-select>
</ion-item>
<ion-item *ngIf="!currentAction.endsWith('-drive')">
<ion-checkbox [(ngModel)]="modalMoba">Mobieles Arbeiten</ion-checkbox>
</ion-item>
</ion-content>
</ng-template>
</ion-modal>

View File

@@ -5,23 +5,21 @@ import {
IonTitle,
IonContent,
IonButton,
IonList,
IonItem,
IonLabel,
IonIcon,
IonModal,
IonButtons,
IonInput,
IonDatetime,
IonDatetimeButton,
IonSelect,
IonSelectOption,
AlertController
AlertController, ViewDidEnter, IonCheckbox
} from '@ionic/angular/standalone';
import {TimeEntry, TimeType} from "../../models/timeEntry";
import {NgClass, NgForOf, NgIf} from "@angular/common";
import {addIcons} from "ionicons";
import {add, trash} from "ionicons/icons";
import {add, home, trash} from "ionicons/icons";
import {FormsModule} from "@angular/forms";
import {TimeService} from "../../services/time.service";
import {AppComponent} from "../app.component";
@@ -31,9 +29,9 @@ import {AppComponent} from "../app.component";
templateUrl: 'time.page.html',
styleUrls: ['time.page.scss'],
standalone: true,
imports: [IonHeader, IonToolbar, IonTitle, IonContent, NgForOf, IonButton, IonList, IonItem, IonLabel, NgIf, NgClass, IonIcon, IonModal, IonButtons, IonInput, IonDatetime, IonDatetimeButton, IonSelect, IonSelectOption, FormsModule],
imports: [IonHeader, IonToolbar, IonTitle, IonContent, NgForOf, IonButton, IonItem, IonLabel, NgIf, NgClass, IonIcon, IonModal, IonButtons, IonDatetime, IonDatetimeButton, IonSelect, IonSelectOption, FormsModule, IonCheckbox],
})
export class TimePage {
export class TimePage implements ViewDidEnter {
public data: TimeEntry[] = [];
public today: TimeEntry[] = [];
public shouldAnimate: boolean[] = [];
@@ -42,6 +40,8 @@ export class TimePage {
public modalDate: any;
public currentDate: any;
public modalMoba: boolean;
public currentlyMoba: boolean;
constructor(private timeService: TimeService, private alerts: AlertController) {
this.data = timeService.loadEntries();
@@ -52,7 +52,7 @@ export class TimePage {
this.updateCurrentAction();
addIcons({add, trash});
addIcons({add, trash, home});
}
ionViewDidEnter() {
@@ -115,7 +115,8 @@ export class TimePage {
this.data.push({
registeredAt: new Date(Date.now()),
type: this.currentAction
type: this.currentAction,
isMoba: this.currentlyMoba
});
this.data.sort((a: TimeEntry, b: TimeEntry) => {
return a.registeredAt.getTime() - b.registeredAt.getTime();
@@ -156,9 +157,9 @@ export class TimePage {
if (this.data.length == 0) {
this.currentAction = 'login';
}else {
const lastAction = this.data[this.data.length - 1].type;
const lastEntry = this.data[this.data.length - 1]
switch (lastAction) {
switch (lastEntry.type) {
case "start-drive":
this.currentAction = 'end-drive';
break;
@@ -176,6 +177,8 @@ export class TimePage {
this.currentAction = 'login';
break;
}
this.currentlyMoba = lastEntry.isMoba && lastEntry.type == "login";
}
}
@@ -215,7 +218,8 @@ export class TimePage {
this.data.push({
registeredAt: date,
type: action || this.currentAction
type: action || this.currentAction,
isMoba: this.modalMoba
});
this.data.sort((a: TimeEntry, b: TimeEntry) => {
return a.registeredAt.getTime() - b.registeredAt.getTime();

View File

@@ -1,6 +1,7 @@
export interface TimeEntry {
registeredAt: Date;
type: TimeType;
isMoba: boolean;
}
export type TimeType = 'login' | 'logout' | 'start-drive' | 'end-drive';