5638-ticket.summary_states #1538
|
@ -20,21 +20,17 @@ module.exports = Self => {
|
||||||
Self.editableStates = async(ctx, filter, options) => {
|
Self.editableStates = async(ctx, filter, options) => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const userId = ctx.req.accessToken.userId;
|
const userId = ctx.req.accessToken.userId;
|
||||||
|
|
||||||
const myOptions = {...(options || {})};
|
const myOptions = {...(options || {})};
|
||||||
vicent marked this conversation as resolved
|
|||||||
|
|
||||||
const isProduction = await models.VnUser.hasRole(userId, 'production', myOptions);
|
const isProduction = await models.VnUser.hasRole(userId, 'production', myOptions);
|
||||||
const isSalesPerson = await models.VnUser.hasRole(userId, 'salesPerson', myOptions);
|
|
||||||
const isAdministrative = await models.VnUser.hasRole(userId, 'administrative', myOptions);
|
const isAdministrative = await models.VnUser.hasRole(userId, 'administrative', myOptions);
|
||||||
|
|
||||||
let where = {alertLevel: 0};
|
const where = (isProduction || isAdministrative) ? undefined : {alertLevel: 0};
|
||||||
vicent marked this conversation as resolved
Outdated
alexm
commented
Refactor, ho tens en rocket Refactor, ho tens en rocket
|
|||||||
if (isSalesPerson)
|
|
||||||
where = {or: [{alertLevel: 0}, {code: 'PICKER_DESIGNED'}]};
|
|
||||||
else if (isProduction || isAdministrative)
|
|
||||||
where = undefined;
|
|
||||||
|
|
||||||
filter = mergeFilters(filter, {where});
|
filter = mergeFilters(filter, {where});
|
||||||
|
|
||||||
return models.State.find(filter, myOptions);
|
const states = await models.State.find(filter, myOptions);
|
||||||
|
|
||||||
|
return states;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Revisar