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 = { @@ -20,6 +20,7 @@ const TimeTrack = {
},
tickets: [],
archive: [],
trashed: null,
worktimeTracker: {
tracking: false,
number: 'Worktime',
@ -337,12 +338,16 @@ const TimeTrack = { @@ -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 = { @@ -350,11 +355,24 @@ const TimeTrack = {
iziToast.show({
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();
},
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();