From 408810515608dc0ab0cba93fd3e74d00d29ae452 Mon Sep 17 00:00:00 2001 From: stingl Date: Fri, 19 Nov 2021 11:43:54 +0100 Subject: [PATCH] Implement trashed; --- js/app.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/js/app.js b/js/app.js index 2ba13ba..053c1db 100644 --- a/js/app.js +++ b/js/app.js @@ -20,6 +20,7 @@ const TimeTrack = { }, tickets: [], archive: [], + trashed: null, worktimeTracker: { tracking: false, number: 'Worktime', @@ -337,12 +338,16 @@ const TimeTrack = { return number.indexOf('#') >= 0; }, deleteTracker(index, archive = false) { + let component = this; let message = ''; + if (archive) { + Object.assign(this.trashed, this.archive[index]); let name = this.archive[index].number; message = 'Tracker "' + name + '" wurde gelöscht'; this.archive.splice(index, 1); } else { + Object.assign(this.trashed, this.tickets[index]); let name = this.tickets[index].number; message = 'Tracker "' + name + '" wurde gelöscht'; this.tickets.splice(index, 1); @@ -350,11 +355,24 @@ const TimeTrack = { iziToast.show({ message: message, - color: 'blue' + color: 'blue', + buttons: [ + ['', function (instance, toast) { + component.restoreTrashed(); + }, true] + ], + timeout: 12000 }); this.updateStorage(); }, + restoreTrashed() { + let restoredTracker = null; + Object.assign(restoredTracker, this.trashed); + this.trashed = null; + + this.tickets.push(restoredTracker); + }, archiveTracker(index) { if (this.tickets[index].tracking) { this.stopActiveTracker();