fix and/or expressions in permissions builder (#119)

This commit is contained in:
Rikin Kachhia
2018-07-12 00:51:26 +05:30
committed by Shahidh K Muhammed
parent 32750d65fb
commit 45cd97f9b8
3 changed files with 11 additions and 16 deletions

1
console/.gitignore vendored
View File

@@ -9,3 +9,4 @@ webpack-stats.json
npm-debug.log
*.swp
coverage
.idea/*

View File

@@ -59,10 +59,7 @@ class PermissionBuilder extends React.Component {
const operation = prefixSplit[0];
if (prefixSplit.length !== 1) {
if (
operation === boolOperators.$or ||
operation === boolOperators.$and
) {
if (operation === boolOperators.or || operation === boolOperators.and) {
const position = parseInt(prefixSplit[1], 10);
_where[operation] = conditions[operation];
_where[operation][position] = getFilter(
@@ -73,7 +70,7 @@ class PermissionBuilder extends React.Component {
if (Object.keys(_where[operation][position]).length === 0) {
_where[operation].splice(position, 1);
}
} else if (operation === boolOperators.$not) {
} else if (operation === boolOperators.not) {
_where[operation] = getFilter(
conditions[operation],
prefixSplit.slice(1).join('.'),
@@ -99,11 +96,11 @@ class PermissionBuilder extends React.Component {
if (operation === '--') {
// blank where
} else if (
operation === boolOperators.$or ||
operation === boolOperators.$and
operation === boolOperators.or ||
operation === boolOperators.and
) {
_where[operation] = [];
} else if (operation === boolOperators.$not) {
} else if (operation === boolOperators.not) {
_where[operation] = {};
} else if (arrayColumnOperators.indexOf(operation) !== -1) {
_where[operation] = value || [];
@@ -405,10 +402,7 @@ class PermissionBuilder extends React.Component {
let boolExpValue = null;
if (operation) {
const newPrefix = addToPrefix(prefix, operation);
if (
operation === boolOperators.$or ||
operation === boolOperators.$and
) {
if (operation === boolOperators.or || operation === boolOperators.and) {
boolExpValue = renderBoolExpArray(
dispatchFunc,
condition[operation],
@@ -416,7 +410,7 @@ class PermissionBuilder extends React.Component {
tableSchemas,
newPrefix
);
} else if (operation === boolOperators.$not) {
} else if (operation === boolOperators.not) {
boolExpValue = renderBoolExp(
dispatchFunc,
condition[operation],

View File

@@ -1,7 +1,7 @@
export const boolOperators = {
_and: '_and',
_not: '_not',
_or: '_or',
and: '_and',
not: '_not',
or: '_or',
};
export const columnOperators = [