Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'is false (or not set)' condition for apply rules #1436

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion application/views/helpers/FormDataFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ protected function element(FilterExpression $filter = null)
$filter->setExpression(json_decode($filter->getExpression()));
}

if ($filter->getExpression() === true) {
if (($filter->getExpression() === true) || ($filter->getExpression() === false)) {
return '';
}
$dummy = IcingaObject::createByType($type);
Expand Down Expand Up @@ -307,6 +307,7 @@ protected function selectSign(FilterExpression $filter = null)
'in' => 'in',
'contains' => 'contains',
'true' => 'is true (or set)',
'false' => 'is false (or not set)',
);

if ($filter === null) {
Expand All @@ -318,6 +319,8 @@ protected function selectSign(FilterExpression $filter = null)
$expression = json_decode($filter->getExpression());
if ($expression === true) {
$sign = 'true';
} elseif ($expression === false) {
$sign = 'false';
} elseif (is_array($expression)) {
$sign = 'in';
} else {
Expand Down
6 changes: 6 additions & 0 deletions library/Director/IcingaConfig/AssignRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ protected function renderFilterExpression(FilterExpression $filter)
if ($rawExpression === true) {
return $column;
}
if ($rawExpression === false) {
return sprintf(
'! %s',
$column
);
}
if (strpos($expression, '*') === false) {
return $this->renderEquals($column, $expression);
} else {
Expand Down
6 changes: 6 additions & 0 deletions library/Director/Web/Form/Element/DataFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ protected function entryToFilterExpression($entry)
'=',
json_encode(true)
);
} elseif ($entry['sign'] === 'false') {
return Filter::expression(
$entry['column'],
'=',
json_encode(false)
);
} elseif ($entry['sign'] === 'in') {
if (array_key_exists('value', $entry)) {
if (is_array($entry['value'])) {
Expand Down