Improved entry delete UX
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "WorkTime",
|
"name": "WorkTime",
|
||||||
"version": "0.3.2",
|
"version": "0.3.3",
|
||||||
"author": "Ionic Framework",
|
"author": "Ionic Framework",
|
||||||
"homepage": "https://ionicframework.com/",
|
"homepage": "https://ionicframework.com/",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
<div class="circle"></div>
|
<div class="circle"></div>
|
||||||
<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>
|
||||||
|
<ion-icon name="trash" *ngIf="isToday()" />
|
||||||
<span *ngIf="index !== 0" class="between">
|
<span *ngIf="index !== 0" class="between">
|
||||||
<span class="between-content">{{generateSeparatorText(today[index - 1], entry)}}</span>
|
<span class="between-content">{{generateSeparatorText(today[index - 1], entry)}}</span>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -22,6 +22,10 @@
|
|||||||
line-height: 15px;
|
line-height: 15px;
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
|
|
||||||
|
ion-icon {
|
||||||
|
margin-left: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
&.animate {
|
&.animate {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
animation: fade-in 200ms ease-in-out forwards;
|
animation: fade-in 200ms ease-in-out forwards;
|
||||||
|
|||||||
@@ -7,12 +7,21 @@ import {
|
|||||||
IonButton,
|
IonButton,
|
||||||
IonList,
|
IonList,
|
||||||
IonItem,
|
IonItem,
|
||||||
IonLabel, IonIcon, IonModal, IonButtons, IonInput, IonDatetime, IonDatetimeButton, IonSelect, IonSelectOption
|
IonLabel,
|
||||||
|
IonIcon,
|
||||||
|
IonModal,
|
||||||
|
IonButtons,
|
||||||
|
IonInput,
|
||||||
|
IonDatetime,
|
||||||
|
IonDatetimeButton,
|
||||||
|
IonSelect,
|
||||||
|
IonSelectOption,
|
||||||
|
AlertController
|
||||||
} from '@ionic/angular/standalone';
|
} from '@ionic/angular/standalone';
|
||||||
import {TimeEntry, TimeType} from "../../models/timeEntry";
|
import {TimeEntry, TimeType} from "../../models/timeEntry";
|
||||||
import {NgClass, NgForOf, NgIf} from "@angular/common";
|
import {NgClass, NgForOf, NgIf} from "@angular/common";
|
||||||
import {addIcons} from "ionicons";
|
import {addIcons} from "ionicons";
|
||||||
import {add} from "ionicons/icons";
|
import {add, trash} from "ionicons/icons";
|
||||||
import {FormsModule} from "@angular/forms";
|
import {FormsModule} from "@angular/forms";
|
||||||
import {TimeService} from "../../services/time.service";
|
import {TimeService} from "../../services/time.service";
|
||||||
import {AppComponent} from "../app.component";
|
import {AppComponent} from "../app.component";
|
||||||
@@ -34,7 +43,7 @@ export class TimePage {
|
|||||||
public modalDate: any;
|
public modalDate: any;
|
||||||
public currentDate: any;
|
public currentDate: any;
|
||||||
|
|
||||||
constructor(private timeService: TimeService) {
|
constructor(private timeService: TimeService, private alerts: AlertController) {
|
||||||
this.data = timeService.loadEntries();
|
this.data = timeService.loadEntries();
|
||||||
|
|
||||||
for (let i = 0; i < this.data.length; i++) {
|
for (let i = 0; i < this.data.length; i++) {
|
||||||
@@ -43,7 +52,7 @@ export class TimePage {
|
|||||||
|
|
||||||
this.updateCurrentAction();
|
this.updateCurrentAction();
|
||||||
|
|
||||||
addIcons({add});
|
addIcons({add, trash});
|
||||||
}
|
}
|
||||||
|
|
||||||
ionViewDidEnter() {
|
ionViewDidEnter() {
|
||||||
@@ -112,12 +121,33 @@ export class TimePage {
|
|||||||
this.updateCurrentAction();
|
this.updateCurrentAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public removeEntry(entry: TimeEntry, index: number): void {
|
public async removeEntry(entry: TimeEntry, index: number) {
|
||||||
|
if (!this.isToday()) return;
|
||||||
|
|
||||||
|
const alert = await this.alerts.create({
|
||||||
|
header: "Achtung!",
|
||||||
|
message: 'Möchtest du diesen Eintrag wirklich löschen?',
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
text: "Abbrechen",
|
||||||
|
role: "cancel"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "Löschen",
|
||||||
|
role: "destructive"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
await alert.present();
|
||||||
|
const result = await alert.onDidDismiss();
|
||||||
|
|
||||||
|
if (result.role == "destructive") {
|
||||||
this.shouldAnimate.splice(index, 1);
|
this.shouldAnimate.splice(index, 1);
|
||||||
this.data.splice(this.data.indexOf(entry), 1);
|
this.data.splice(this.data.indexOf(entry), 1);
|
||||||
this.saveData();
|
this.saveData();
|
||||||
this.updateCurrentAction();
|
this.updateCurrentAction();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private updateCurrentAction(): void {
|
private updateCurrentAction(): void {
|
||||||
if (this.data.length == 0) {
|
if (this.data.length == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user