X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=ext%2Fsearch%2Fang%2FcrmSearchAdmin%2FcrmSearchClause.component.js;h=de5ce60e43d8c1b0e222941f0d179fa76c9063f2;hb=d830d3ae5b3b6c936835fcb9c5dfdb1b62cb5612;hp=3c196a440b10307565874a4d2bf0cb01a1027ca7;hpb=b681360457fdcc903c5e646da567d90ccb0c68bc;p=civicrm-core.git diff --git a/ext/search/ang/crmSearchAdmin/crmSearchClause.component.js b/ext/search/ang/crmSearchAdmin/crmSearchClause.component.js index 3c196a440b..de5ce60e43 100644 --- a/ext/search/ang/crmSearchAdmin/crmSearchClause.component.js +++ b/ext/search/ang/crmSearchAdmin/crmSearchClause.component.js @@ -83,12 +83,24 @@ } }; - // Add/remove value if operator allows for one this.changeClauseOperator = function(clause) { + // Add/remove value if operator allows for one if (_.contains(clause[1], 'NULL')) { clause.length = 2; - } else if (clause.length === 2) { - clause.push(''); + } else { + if (clause.length === 2) { + clause.push(''); + } + // Change multi/single value to/from an array + var shouldBeArray = (clause[1] === 'IN' || clause[1] === 'NOT IN' || clause[1] === 'BETWEEN' || clause[1] === 'NOT BETWEEN'); + if (!_.isArray(clause[2]) && shouldBeArray) { + clause[2] = []; + } else if (_.isArray(clause[2]) && !shouldBeArray) { + clause[2] = ''; + } + if (clause[1] === 'BETWEEN' || clause[1] === 'NOT BETWEEN') { + clause[2].length = 2; + } } };