2018-05-04 09:46:03 +00:00
|
|
|
module.exports = Self => {
|
2019-08-08 06:33:27 +00:00
|
|
|
require('../methods/state/editableStates')(Self);
|
|
|
|
|
2018-05-08 07:32:30 +00:00
|
|
|
/**
|
|
|
|
* Checks if the alertLevel of a state is 0.
|
|
|
|
*
|
|
|
|
* @param {Integer} stateId The user id
|
|
|
|
* @return {Boolean} %true if user has the role, %false otherwise
|
|
|
|
*/
|
2018-05-10 11:39:11 +00:00
|
|
|
Self.isAlertLevelZero = async function(stateId) {
|
2018-05-08 07:32:30 +00:00
|
|
|
let result = await Self.rawSql(
|
|
|
|
`SELECT alertLevel
|
|
|
|
FROM vn.state
|
|
|
|
WHERE id = ?`,
|
|
|
|
[stateId]
|
|
|
|
);
|
|
|
|
return result[0].alertLevel == 0;
|
|
|
|
};
|
2019-02-01 16:11:14 +00:00
|
|
|
|
|
|
|
Self.prototype.isEditable = function() {
|
|
|
|
return this.code == 'PICKER_DESIGNED' || this.alertLevel == 0;
|
|
|
|
};
|
2017-10-11 13:36:47 +00:00
|
|
|
};
|