Made TimeType selector in modal respond to last entry

This commit is contained in:
2024-09-03 18:14:21 +02:00
parent f712291bdd
commit 0e98d1e711
3 changed files with 6 additions and 5 deletions

View File

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

View File

@@ -67,7 +67,7 @@
</ion-modal> </ion-modal>
</ion-item> </ion-item>
<ion-item> <ion-item>
<ion-select label="Stempeltyp" value="login" cancel-text="Abbrechen" [(ngModel)]="modalMode"> <ion-select label="Stempeltyp" value="login" cancel-text="Abbrechen" [(ngModel)]="currentAction">
<ion-select-option value="login">Einstempeln</ion-select-option> <ion-select-option value="login">Einstempeln</ion-select-option>
<ion-select-option value="logout">Ausstempeln</ion-select-option> <ion-select-option value="logout">Ausstempeln</ion-select-option>
<ion-select-option value="start-drive">Dienstreise starten</ion-select-option> <ion-select-option value="start-drive">Dienstreise starten</ion-select-option>

View File

@@ -30,7 +30,6 @@ export class TimePage {
@ViewChild('createModal') modal: IonModal | undefined; @ViewChild('createModal') modal: IonModal | undefined;
public modalDate: any; public modalDate: any;
public modalMode: TimeType = 'login';
public currentDate: any; public currentDate: any;
constructor() { constructor() {
@@ -127,7 +126,7 @@ export class TimePage {
this.data.push({ this.data.push({
registeredAt: date, registeredAt: date,
type: this.modalMode type: this.currentAction
}); });
this.data.sort((a: TimeEntry, b: TimeEntry) => { this.data.sort((a: TimeEntry, b: TimeEntry) => {
return a.registeredAt.getTime() - b.registeredAt.getTime(); return a.registeredAt.getTime() - b.registeredAt.getTime();
@@ -138,8 +137,10 @@ export class TimePage {
this.shouldAnimate.push(false); this.shouldAnimate.push(false);
} }
this.updateCurrentAction();
this.saveData(); this.saveData();
this.modal?.dismiss(null, 'submit'); this.modal?.dismiss(null, 'submit');
this.modalDate = undefined;
} }
public isToday(): boolean { public isToday(): boolean {