Browse Source

Implement trashed;

feature/tasks
stingl 4 years ago
parent
commit
4088105156
  1. 20
      js/app.js

20
js/app.js

@ -20,6 +20,7 @@ const TimeTrack = {
}, },
tickets: [], tickets: [],
archive: [], archive: [],
trashed: null,
worktimeTracker: { worktimeTracker: {
tracking: false, tracking: false,
number: 'Worktime', number: 'Worktime',
@ -337,12 +338,16 @@ const TimeTrack = {
return number.indexOf('#') >= 0; return number.indexOf('#') >= 0;
}, },
deleteTracker(index, archive = false) { deleteTracker(index, archive = false) {
let component = this;
let message = ''; let message = '';
if (archive) { if (archive) {
Object.assign(this.trashed, this.archive[index]);
let name = this.archive[index].number; let name = this.archive[index].number;
message = 'Tracker "' + name + '" wurde gelöscht'; message = 'Tracker "' + name + '" wurde gelöscht';
this.archive.splice(index, 1); this.archive.splice(index, 1);
} else { } else {
Object.assign(this.trashed, this.tickets[index]);
let name = this.tickets[index].number; let name = this.tickets[index].number;
message = 'Tracker "' + name + '" wurde gelöscht'; message = 'Tracker "' + name + '" wurde gelöscht';
this.tickets.splice(index, 1); this.tickets.splice(index, 1);
@ -350,11 +355,24 @@ const TimeTrack = {
iziToast.show({ iziToast.show({
message: message, message: message,
color: 'blue' color: 'blue',
buttons: [
['<button><i class="fas fa-undo"></i></button>', function (instance, toast) {
component.restoreTrashed();
}, true]
],
timeout: 12000
}); });
this.updateStorage(); this.updateStorage();
}, },
restoreTrashed() {
let restoredTracker = null;
Object.assign(restoredTracker, this.trashed);
this.trashed = null;
this.tickets.push(restoredTracker);
},
archiveTracker(index) { archiveTracker(index) {
if (this.tickets[index].tracking) { if (this.tickets[index].tracking) {
this.stopActiveTracker(); this.stopActiveTracker();