refs #5638 fix: solucionado problema con el limit
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2023-05-04 14:51:47 +02:00
parent 8578e3ca49
commit 404acdab6f
1 changed files with 6 additions and 9 deletions

View File

@ -24,20 +24,17 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
let statesList = await models.State.find(filter, 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);
if (isProduction || isAdministrative)
return statesList;
filter.where = {alertLevel: 0};
if (isSalesPerson) {
return statesList = statesList.filter(stateList =>
stateList.alertLevel === 0 || stateList.code === 'PICKER_DESIGNED'
);
}
if (isSalesPerson)
filter.where = {or: [{alertLevel: 0}, {code: 'PICKER_DESIGNED'}]};
return statesList.filter(stateList => stateList.alertLevel === 0);
if (isProduction || isAdministrative) delete filter.where;
return models.State.find(filter, myOptions);
};
};