Add the possibility to create a negated rule on segments

This commit is contained in:
humancopy 2018-07-02 14:26:59 +02:00
parent 206e7a5b52
commit ceba65a098
3 changed files with 32 additions and 1 deletions

View file

@ -327,6 +327,7 @@ module.exports.createRule = (segmentId, rule, callback) => {
break;
default:
value = {
negate: Number(rule.negate) ? 1 : 0,
value: rule.value
};
}
@ -491,6 +492,7 @@ module.exports.updateRule = (id, rule, callback) => {
break;
default:
value = {
negate: Number(rule.negate) ? 1 : 0,
value: rule.value
};
}
@ -573,7 +575,8 @@ module.exports.getQuery = (id, prefix, callback) => {
segment.rules.forEach(rule => {
switch (rule.columnType.type) {
case 'string':
query.push(prefix + '`' + rule.columnType.column + '` LIKE ?');
let condition = rule.value.negate ? 'NOT LIKE' : 'LIKE';
query.push(prefix + '`' + rule.columnType.column + '` ' + condition + ' ?');
values.push(rule.value.value);
break;
case 'boolean':

View file

@ -23,6 +23,20 @@
</div>
{{#if columnTypeString}}
<div class="form-group">
<label for="negate" class="col-sm-2 control-label">{{#translate}}Condition{{/translate}}</label>
<div class="col-sm-10">
<select name="negate" id="negate" class="form-control">
<option value="0">
{{#translate}}Equals{{/translate}}
</option>
<option value="1" {{#if value.negate}} selected {{/if}}>
{{#translate}}Not squals{{/translate}}
</option>
</select>
</div>
</div>
<div class="form-group">
<label for="value" class="col-sm-2 control-label">{{#translate}}Value{{/translate}}</label>
<div class="col-sm-10">

View file

@ -28,6 +28,20 @@
</div>
{{#if columnTypeString}}
<div class="form-group">
<label for="negate" class="col-sm-2 control-label">{{#translate}}Condition{{/translate}}</label>
<div class="col-sm-10">
<select name="negate" id="negate" class="form-control">
<option value="0">
{{#translate}}Equals{{/translate}}
</option>
<option value="1" {{#if value.negate}} selected {{/if}}>
{{#translate}}Not squals{{/translate}}
</option>
</select>
</div>
</div>
<div class="form-group">
<label for="value" class="col-sm-2 control-label">{{#translate}}Value{{/translate}}</label>
<div class="col-sm-10">