salix/modules/ticket/back/methods/state/editableStates.js

34 lines
969 B
JavaScript
Raw Normal View History

const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
2019-08-08 06:33:27 +00:00
module.exports = Self => {
Self.remoteMethodCtx('editableStates', {
description: 'Gets the editable states according the user role ',
accessType: 'READ',
2020-03-26 11:00:07 +00:00
accepts: {
arg: 'filter',
type: 'object'
},
2019-08-08 06:33:27 +00:00
returns: {
type: ['object'],
2019-08-08 06:33:27 +00:00
root: true
},
http: {
path: `/editableStates`,
verb: 'GET'
}
});
Self.editableStates = async(ctx, filter, options) => {
const models = Self.app.models;
const myOptions = {...(options || {})};
const seeEditableStates = await models.ACL.checkAccessAcl(ctx, 'State', 'seeEditableStates', 'READ');
2019-08-08 06:33:27 +00:00
if (!seeEditableStates)
2023-05-19 06:02:17 +00:00
filter = mergeFilters(filter, {where: {alertLevel: 0}});
const states = await models.State.find(filter, myOptions);
2019-08-08 06:33:27 +00:00
return states;
2019-08-08 06:33:27 +00:00
};
};