6755-restoreRefactor #2158

Merged
carlossa merged 20 commits from 6755-restoreRefactor into dev 2024-03-14 08:56:10 +00:00
2 changed files with 30 additions and 16 deletions
Showing only changes of commit 879adfaac8 - Show all commits

View File

@ -86,6 +86,7 @@
translate> translate>
Delete ticket Delete ticket
</vn-item> </vn-item>
{{$ctrl.canRestoreTicket}}
<vn-item <vn-item
ng-click="restoreConfirmation.show()" ng-click="restoreConfirmation.show()"
ng-show="$ctrl.canRestoreTicket" ng-show="$ctrl.canRestoreTicket"

View File

@ -8,7 +8,6 @@ class Controller extends Section {
this.vnReport = vnReport; this.vnReport = vnReport;
this.vnEmail = vnEmail; this.vnEmail = vnEmail;
this.vnFile = vnFile; this.vnFile = vnFile;
this.restoreTicket = vnRestoreTicket;
} }
get ticketId() { get ticketId() {
@ -36,6 +35,35 @@ class Controller extends Section {
}); });
} }
}); });
const filter = {
fields: ['originFk', 'creationDate', 'newInstance'],
where: {
originFk: value,
newInstance: {like: '%"isDeleted":true%'}
},
order: 'creationDate DESC'
};
this.$http.get(`TicketLogs/findOne`, {filter})
.then(res => {
console.log(res);
carlossa marked this conversation as resolved
Review

els LOOOOOGs

els LOOOOOGs
console.log(res.data.creationDate);
if (res && res.data) {
console.log(res.data);
const now = Date.vnNew();
const maxDate = new Date(res.data.creationDate);
maxDate.setHours(maxDate.getHours() + 1);
console.log(now, maxDatenow);
console.log(now.getTime(), maxDate.getTime());
if (now <= maxDate)
return this.canRestoreTicket = true;
}
this.canRestoreTicket = false;
})
.catch(() => {
console.log('ENTRY');
this.canRestoreTicket = false;
});
} }
get isInvoiced() { get isInvoiced() {
@ -172,21 +200,6 @@ class Controller extends Section {
}); });
} }
get canRestoreTicket() {
const isDeleted = this.ticket.isDeleted;
const now = Date.vnNew();
const maxDate = new Date(this.ticket.updated);
maxDate.setHours(maxDate.getHours() + 1);
return isDeleted && (now <= maxDate);
// return this.$http.get(`TicketLogs`).then(res => {
// if (res && res.data.length)
// console.log(res.data);
// console.log(res);
// return true;
// });
}
restoreTicket() { restoreTicket() {
return this.$http.post(`Tickets/${this.id}/restore`) return this.$http.post(`Tickets/${this.id}/restore`)
.then(() => this.reload()) .then(() => this.reload())