Bug #307 CR JOAN

This commit is contained in:
gerard 2018-05-17 15:37:09 +02:00
parent 983e66d7ee
commit bbfa066640
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
module.exports = Self => {
Self.remoteMethod('isEditable', {
description: 'Check if a ticket is editable',
accessType: 'READ',
accepts: [{
arg: 'ticketFk',
type: 'number',
required: true,
description: 'ticketFk',
http: {source: 'path'}
}],
returns: {
type: 'boolean',
root: true
},
http: {
path: `/:ticketFk/isEditable`,
verb: 'get'
}
});
Self.isEditable = async ticketFk => {
let state = await Self.app.models.TicketState.findOne({where: {ticketFk: ticketFk}, fields: 'alertLevel'});
return state != null && state.alertLevel == 0;
};
};