Bug #307 Modificar changeState en ticket.sale
This commit is contained in:
parent
595d878f93
commit
983e66d7ee
|
@ -13,8 +13,10 @@
|
|||
"forceId": false
|
||||
},
|
||||
"updated": {
|
||||
"type": "Date",
|
||||
"required": false
|
||||
"type": "Date"
|
||||
},
|
||||
"alertLevel": {
|
||||
"type": "Number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
@ -32,11 +34,6 @@
|
|||
"type": "belongsTo",
|
||||
"model": "Worker",
|
||||
"foreignKey": "workerFk"
|
||||
},
|
||||
"alertLevel": {
|
||||
"type": "belongsTo",
|
||||
"model": "State",
|
||||
"foreignKey": "alertLevel"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,6 +86,11 @@
|
|||
"type": "hasMany",
|
||||
"model": "TicketObservation",
|
||||
"foreignKey": "ticketFk"
|
||||
},
|
||||
"alertLevel": {
|
||||
"type": "hasOne",
|
||||
"model": "TicketState",
|
||||
"foreignKey": "ticketFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"You don't have enough privileges to change the state of this ticket": "You don't have enough privileges to change the state of this ticket"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"You don't have enough privileges to change the state of this ticket": "No tienes permisos para cambiar el estado de este ticket"
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('changeState', {
|
||||
description: 'Change the state of a ticket',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'params',
|
||||
type: 'object',
|
||||
required: true,
|
||||
description: 'ticketFk',
|
||||
http: {source: 'body'}
|
||||
}],
|
||||
returns: {
|
||||
type: 'string',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/changeState`,
|
||||
verb: 'post'
|
||||
}
|
||||
});
|
||||
|
||||
Self.changeState = async (params, ctx) => {
|
||||
let isEditable = await Self.app.models.Ticket.isEditable(params.ticketFk);
|
||||
if (isEditable)
|
||||
return await Self.app.models.TicketTracking.create(params);
|
||||
|
||||
throw new Error(`You don't have enough privileges to change the state of this ticket`);
|
||||
};
|
||||
};
|
|
@ -1,5 +1,6 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/ticket-tracking/filter')(Self);
|
||||
require('../methods/ticket-tracking/changeState')(Self);
|
||||
|
||||
Self.validatesPresenceOf('stateFk', {message: 'State cannot be blank'});
|
||||
|
||||
|
|
Loading…
Reference in New Issue