refs #6755 restore fix
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Carlos Satorres 2024-03-08 14:59:33 +01:00
parent 8a16c24245
commit 879adfaac8
2 changed files with 30 additions and 16 deletions

View File

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

View File

@ -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);
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())