Commit fa097f51 authored by Alfredo Sumaran's avatar Alfredo Sumaran

Use previously defined constants to compare level types

parent 05ca553b
...@@ -141,21 +141,21 @@ ...@@ -141,21 +141,21 @@
var userId = parseInt(dataFromInputs[i].user_id); var userId = parseInt(dataFromInputs[i].user_id);
if (userId) { if (userId) {
adding = 'user'; adding = LEVEL_TYPES.USER;
inState = _.findWhere(this.state[`${accessLevel}_attributes`], { user_id: userId }); inState = _.findWhere(this.state[`${accessLevel}_attributes`], { user_id: userId });
} else { } else {
adding = 'role'; adding = LEVEL_TYPES.ROLE;
inState = _.findWhere(this.state[`${accessLevel}_attributes`], { access_level: parseInt(dataFromInputs[i].access_level) }); inState = _.findWhere(this.state[`${accessLevel}_attributes`], { access_level: parseInt(dataFromInputs[i].access_level) });
} }
if (inState) { if (inState) {
accessLevelData.push(inState); accessLevelData.push(inState);
} else { } else {
if (adding === 'user') { if (adding === LEVEL_TYPES.USER) {
accessLevelData.push({ accessLevelData.push({
user_id: parseInt(dataFromInputs[i].user_id) user_id: parseInt(dataFromInputs[i].user_id)
}); });
} else if (adding === 'role') { } else if (adding === LEVEL_TYPES.ROLE) {
accessLevelData.push({ accessLevelData.push({
access_level: parseInt(dataFromInputs[i].access_level) access_level: parseInt(dataFromInputs[i].access_level)
}); });
...@@ -185,9 +185,9 @@ ...@@ -185,9 +185,9 @@
const id = parseInt($el.data('id')); const id = parseInt($el.data('id'));
let obj = {}; let obj = {};
if (type === 'role') { if (type === LEVEL_TYPES.ROLE) {
obj.access_level = value obj.access_level = value
} else if (type === 'user') { } else if (type === LEVEL_TYPES.USER) {
obj.user_id = value; obj.user_id = value;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment