From 31616b76dc9d0bb38804c45f40c82b728a07fd71 Mon Sep 17 00:00:00 2001 From: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> Date: Fri, 13 Dec 2024 11:41:47 +0200 Subject: [PATCH] add default conditions hash for dynamic filters (#324) --- docs/3.0/dynamic-filters.md | 89 ++++++++++++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 10 deletions(-) diff --git a/docs/3.0/dynamic-filters.md b/docs/3.0/dynamic-filters.md index f94d7b41..e33f742e 100644 --- a/docs/3.0/dynamic-filters.md +++ b/docs/3.0/dynamic-filters.md @@ -69,9 +69,19 @@ For instance, in the text filter example above, the `Contains` condition and the - Is false - Is null - Is not null + +```ruby +{ + is_true: "Is true", + is_false: "Is false", + is_null: "Is null", + is_not_null: "Is not null", +}.invert +``` +
- - + +
Test it on [avodemo](https://main.avodemo.com/avo/resources/users?filters[is_admin?][is_true][]=), check the [source code](https://github.com/avo-hq/main.avodemo.com/blob/main/app/avo/resources/user.rb#L38) @@ -81,17 +91,29 @@ Test it on [avodemo](https://main.avodemo.com/avo/resources/users?filters[is_adm ### Conditions - - Is - - Is not - - Is on or before - - Is on or after - - Is within +- Is +- Is not +- Is on or before +- Is on or after +- Is within - Is null - - Is not null +- Is not null + +```ruby +{ + is: "Is", + is_not: "Is not", + lte: "Is on or before", + gte: "Is on or after", + is_within: "Is within", + is_null: "Is null", + is_not_null: "Is not null", +}.invert +```
- - + +
Test it on [avodemo](https://main.avodemo.com/avo/resources/teams?filters[created_at][lte][]=2024-07-02%2012%3A00), check the [source code](https://github.com/avo-hq/main.avodemo.com/blob/main/app/avo/resources/team.rb#L50) @@ -111,6 +133,20 @@ Test it on [avodemo](https://main.avodemo.com/avo/resources/teams?filters[create - Is null - Is not null +```ruby +{ + is: "=", + is_not: "!=", + gt: ">", + gte: ">=", + lt: "<", + lte: "<=", + is_within: "Is within", + is_null: "Is null", + is_not_null: "Is not null", +}.invert +``` +
@@ -128,6 +164,15 @@ Test it on [avodemo](https://main.avodemo.com/avo/resources/teams?filters[id][gt - Is null - Is not null +```ruby +{ + is: "Is", + is_not: "Is not", + is_null: "Is null", + is_not_null: "Is not null", +}.invert +``` +
@@ -151,6 +196,21 @@ Test it on [avodemo](https://main.avodemo.com/avo/resources/courses?filters[coun - Is present - Is blank +```ruby +{ + contains: "Contains", + does_not_contain: "Does not contain", + is: "Is", + is_not: "Is not", + starts_with: "Starts with", + ends_with: "Ends with", + is_null: "Is null", + is_not_null: "Is not null", + is_present: "Is present", + is_blank: "Is blank", +}.invert +``` +
@@ -167,6 +227,15 @@ Test it on [avodemo](https://main.avodemo.com/avo/resources/users?filters[first_ - Overlap - Contained in ([`active_record_extended`](https://github.com/GeorgeKaraszi/ActiveRecordExtended) gem required) + ```ruby +{ + array_is: "Are", + array_contains: "Contain", + array_overlap: "Overlap", + array_contained_in: "Contained in" # (active_record_extended gem required) +}.invert +``` + :::warning Contained in will not work when using the `acts-as-taggable-on` gem. :::