6755-restoreRefactor #2158
|
@ -86,6 +86,7 @@
|
|||
translate>
|
||||
Delete ticket
|
||||
</vn-item>
|
||||
{{$ctrl.canRestoreTicket}}
|
||||
<vn-item
|
||||
ng-click="restoreConfirmation.show()"
|
||||
ng-show="$ctrl.canRestoreTicket"
|
||||
|
|
|
@ -8,7 +8,6 @@ class Controller extends Section {
|
|||
this.vnReport = vnReport;
|
||||
this.vnEmail = vnEmail;
|
||||
this.vnFile = vnFile;
|
||||
this.restoreTicket = vnRestoreTicket;
|
||||
}
|
||||
|
||||
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
|
||||
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() {
|
||||
|
@ -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() {
|
||||
return this.$http.post(`Tickets/${this.id}/restore`)
|
||||
.then(() => this.reload())
|
||||
|
|
Loading…
Reference in New Issue
els LOOOOOGs