test ok
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
2630fa8c43
commit
4a7a4f6dcf
|
@ -1,16 +1,13 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.observe('before save', async ctx => {
|
||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||
const httpCtx = {req: loopBackContext.active};
|
||||
const models = Self.app.models;
|
||||
let changes = ctx.currentInstance || ctx.instance;
|
||||
if (changes) {
|
||||
let ticketId = changes.ticketFk;
|
||||
let isEditable = await models.Ticket.isEditable(httpCtx, ticketId);
|
||||
if (!isEditable)
|
||||
let isLocked = await models.Ticket.isLocked(ticketId);
|
||||
if (isLocked)
|
||||
throw new UserError(`The current ticket can't be modified`);
|
||||
|
||||
if (changes.ticketServiceTypeFk) {
|
||||
|
@ -21,13 +18,11 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.observe('before delete', async ctx => {
|
||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||
const httpCtx = {req: loopBackContext.active};
|
||||
const models = Self.app.models;
|
||||
const service = await models.TicketService.findById(ctx.where.id);
|
||||
const isEditable = await models.Ticket.isEditable(httpCtx, service.ticketFk);
|
||||
const isLocked = await models.Ticket.isLocked(service.ticketFk);
|
||||
|
||||
if (!isEditable)
|
||||
if (isLocked)
|
||||
throw new UserError(`The current ticket can't be modified`);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -17073,9 +17073,9 @@
|
|||
}
|
||||
},
|
||||
"ssri": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.1.tgz",
|
||||
"integrity": "sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==",
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.2.tgz",
|
||||
"integrity": "sha512-cepbSq/neFK7xB6A50KHN0xHDotYzq58wWCa5LeWqnPrHG8GzfEjO/4O8kpmcGW+oaxkvhEJCWgbgNk4/ZV93Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"figgy-pudding": "^3.5.1"
|
||||
|
|
Loading…
Reference in New Issue