resolved bug with alert level nonexistent

This commit is contained in:
gerard 2018-08-29 12:43:44 +02:00
parent 2e8f8109e7
commit 7853236f2b
1 changed files with 3 additions and 2 deletions

View File

@ -20,9 +20,10 @@ module.exports = Self => {
});
Self.isEditable = async ticketFk => {
let state = await Self.app.models.TicketState.findOne({where: {ticketFk: ticketFk}, fields: 'alertLevel'});
let state = await Self.app.models.TicketState.findOne({where: {ticketFk: ticketFk}});
let alertLevel = state ? state.alertLevel : null;
let exists = await Self.app.models.Ticket.findOne({where: {id: ticketFk}, fields: 'isDeleted'});
if (!exists || exists.isDeleted == 1 || state.alertLevel > 0)
if (!exists || exists.isDeleted == 1 || (alertLevel && alertLevel > 0))
return false;
return true;