When trying to create a data comparison condition the negate option/operator is missing.

I tried several combinations including != as the operator, but it wasn't until I exported the config using Configuration Update Manager that I noticed the negate option in the YAML. By changing the option from false to true and re-importing my Rule triggers correctly, but there is no negate option inside the UI

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

intrafusion created an issue. See original summary.

intrafusion’s picture

Issue summary: View changes
coderdan’s picture

manicato’s picture

Works for me. Thanks.

keboca’s picture

hey @intrafusion, thank for the heads-up!
It works perfectly!

keboca’s picture

Status: Needs review » Reviewed & tested by the community
keboca’s picture

Status: Reviewed & tested by the community » Needs work
keboca’s picture

I am not sure, if someone has merged it or created a pull request for this patch. Reason why I re-defined "Needs works" status back.

gsquirrel’s picture

Also wanted to negate a rule - thanks for the tip on export/import

jonathan1055’s picture

Status: Needs work » Needs review

@keboca This has not been merged yet, so setting to 'Needs Review' and re-queuing the patch. This issue will also need a github pull request, which I can do if no-one above wants to.

jonathan1055’s picture

Based entirely on coderdan's patch in #3 the only change to that code is to use 'fieldset' instead of 'details' so that the elements of the form are consisent, i.e. the negate section renders the same as the data. operator and comparison value.

During manual testing I realised I did not know 'contains' and 'in' were allowed values, until I had read the source code. Hence I have added these valid values to form description in src/Plugin/Condition/DataComparison.php and ensured that the operator name is not case-sensitive.

I also added test coverage of negating a rule condition in ConfigureAndExecuteTest.php

Github commit https://github.com/jonathan1055/rules/commit/1f755660e9a63dd28ee5b42b49d...
Travis build https://travis-ci.org/jonathan1055/rules/builds/289699733
Pull request https://github.com/fago/rules/pull/494

Jonathan

fago’s picture

Status: Needs review » Fixed

Great work, thank you! Merged!

  • coderdan authored 9e7d52b on 8.x-3.x
    Issue #2827106 by coderdan, jonathan1055: Add Negate option to...
jonathan1055’s picture

Thanks fago. I'm getting the hang of Travis, Github and Pull Requests now.
I am going to look at some other issues which had patches from a long time ago, which will need a re-roll and restesting.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.