diff --git a/src/Control/SearchBar/ValidatedOperator.php b/src/Control/SearchBar/ValidatedOperator.php index 05e569a8..b28c82c4 100644 --- a/src/Control/SearchBar/ValidatedOperator.php +++ b/src/Control/SearchBar/ValidatedOperator.php @@ -22,9 +22,11 @@ public static function fromFilterCondition(Filter\Condition $condition) { switch (true) { case $condition instanceof Filter\Unequal: + case $condition instanceof Filter\HasNotValue: $operator = '!='; break; case $condition instanceof Filter\Equal: + case $condition instanceof Filter\HasValue: $operator = '='; break; case $condition instanceof Filter\GreaterThan: diff --git a/src/Control/SearchEditor.php b/src/Control/SearchEditor.php index 5657822d..62217399 100644 --- a/src/Control/SearchEditor.php +++ b/src/Control/SearchEditor.php @@ -175,8 +175,16 @@ protected function applyChanges(Filter\Rule $rule, array &$values, array $path = if ($newOperator !== null && QueryString::getRuleSymbol($rule) !== $newOperator) { switch ($newOperator) { case '=': + if ($rule->getValue() === '*') { + return Filter::hasValue($rule->getColumn(), $rule->getValue()); + } + return Filter::equal($rule->getColumn(), $rule->getValue()); case '!=': + if ($rule->getValue() === '*') { + return Filter::hasNotValue($rule->getColumn(), $rule->getValue()); + } + return Filter::unequal($rule->getColumn(), $rule->getValue()); case '>': return Filter::greaterThan($rule->getColumn(), $rule->getValue()); diff --git a/src/Filter/Parser.php b/src/Filter/Parser.php index 23fcb64e..72a27830 100644 --- a/src/Filter/Parser.php +++ b/src/Filter/Parser.php @@ -516,8 +516,16 @@ protected function createCondition($column, $operator, $value) switch ($operator) { case '=': + if ($value === '*') { + return Filter::hasValue($column, $value); + } + return Filter::equal($column, $value); case '!=': + if ($value === '*') { + return Filter::hasNotValue($column, $value); + } + return Filter::unequal($column, $value); case '>': return Filter::greaterThan($column, $value); diff --git a/src/Filter/QueryString.php b/src/Filter/QueryString.php index d1ec1880..5b2b2ecd 100644 --- a/src/Filter/QueryString.php +++ b/src/Filter/QueryString.php @@ -67,8 +67,10 @@ public static function getRuleSymbol(Filter\Rule $rule) { switch (true) { case $rule instanceof Filter\Unequal: + case $rule instanceof Filter\HasNotValue: return '!='; case $rule instanceof Filter\Equal: + case $rule instanceof Filter\HasValue: return '='; case $rule instanceof Filter\GreaterThan: return '>'; diff --git a/src/Filter/Renderer.php b/src/Filter/Renderer.php index 28267439..d249a0bf 100644 --- a/src/Filter/Renderer.php +++ b/src/Filter/Renderer.php @@ -152,9 +152,11 @@ protected function renderCondition(Filter\Condition $condition) switch (true) { case $condition instanceof Filter\Unequal: + case $condition instanceof Filter\HasNotValue: $this->string .= '!='; break; case $condition instanceof Filter\Equal: + case $condition instanceof Filter\HasValue: $this->string .= '='; break; case $condition instanceof Filter\GreaterThan: