Browse Source

fix import for legcy

modals-to-spa
neroignis@gmail.com 4 years ago
parent
commit
0e26c72048
  1. 32
      js/app.js

32
js/app.js

@ -217,14 +217,40 @@ const TimeTrack = { @@ -217,14 +217,40 @@ const TimeTrack = {
importData() {
let json = JSON.parse(this.inputs.importJson);
this.tickets = json.tickets;
this.archive = json.archive;
this.ticketSystemUrl = json.ticketSystemUrl;
if (json.trackedTickets) {
this.tickets = this.extractTicketsFromLegacyJson(json.trackedTickets);
this.archived = this.extractArchivedTicketsFromLegacyJson(json.trackedTickets);
} else {
this.tickets = json.tickets;
this.archive = json.archive ?? [];
}
this.ticketSystemUrl = json.redmineUrl ?? json.ticketSystemUrl;
this.showPT = json.showPT;
this.theme = json.theme;
this.updateStorage();
location.reload();
},
extractTicketsFromLegacyJson(tickets) {
return this.extractTickets(tickets);
},
extractArchivedTicketsFromLegacyJson(tickets) {
return this.extractTickets(tickets, true);
},
extractTickets(ticketCollection, forArchive = false) {
let tickets = [];
let archive = [];
ticketCollection.forEach((ticket) => {
if (ticket.archived || (ticket.active && ticket.active === false)) {
archive.push(ticket);
} else {
tickets.push(ticket)
}
});
return forArchive ? archive : tickets;
},
copy2Clipboard() {
let copyText = document.getElementById("exportJsonInput");