28 lines
744 B
JavaScript
28 lines
744 B
JavaScript
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;
|
|
};
|
|
};
|