From 17080a31fcdf151fd9476dc73553c2dd7b4c5f44 Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Tue, 1 Oct 2024 20:57:28 +0300 Subject: [PATCH 1/7] Bumped avo to 3.13.1 --- Gemfile.lock | 2 +- gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock | 2 +- lib/avo/version.rb | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0105bec49..2d3bbe0bc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -107,7 +107,7 @@ GIT PATH remote: . specs: - avo (3.13.0) + avo (3.13.1) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock b/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock index 30028d401..a487e387f 100644 --- a/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.0) + avo (3.13.1) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock b/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock index 0f653adb1..c6511801d 100644 --- a/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.0) + avo (3.13.1) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock b/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock index 37b7de06e..827a68fa7 100644 --- a/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.0) + avo (3.13.1) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock b/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock index fd88bbdb2..116918a87 100644 --- a/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.0) + avo (3.13.1) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock index 3eb47874a..0686ed0c7 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.0) + avo (3.13.1) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock index 3eb47874a..0686ed0c7 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.0) + avo (3.13.1) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock b/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock index 89af58c7f..c109b91bb 100644 --- a/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock @@ -112,7 +112,7 @@ PATH PATH remote: .. specs: - avo (3.13.0) + avo (3.13.1) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock b/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock index 89af58c7f..c109b91bb 100644 --- a/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock @@ -112,7 +112,7 @@ PATH PATH remote: .. specs: - avo (3.13.0) + avo (3.13.1) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/lib/avo/version.rb b/lib/avo/version.rb index 8bf29b418..3f56d5ade 100644 --- a/lib/avo/version.rb +++ b/lib/avo/version.rb @@ -1,3 +1,3 @@ module Avo - VERSION = "3.13.0" unless const_defined?(:VERSION) + VERSION = "3.13.1" unless const_defined?(:VERSION) end From b49c4017f26a75ee2415c3a4d791ebbb3a4f3821 Mon Sep 17 00:00:00 2001 From: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> Date: Wed, 2 Oct 2024 12:38:46 +0300 Subject: [PATCH 2/7] fix: remove type from query (#3295) --- app/components/avo/index/resource_table_component.rb | 2 +- app/components/avo/views/resource_index_component.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/components/avo/index/resource_table_component.rb b/app/components/avo/index/resource_table_component.rb index 01d33279c..a434a69c3 100644 --- a/app/components/avo/index/resource_table_component.rb +++ b/app/components/avo/index/resource_table_component.rb @@ -14,7 +14,7 @@ def before_render prop :parent_record, _Nilable(_Any) prop :parent_resource, _Nilable(Avo::BaseResource) prop :pagy, _Nilable(Pagy) - prop :query, _Nilable(ActiveRecord::Relation) + prop :query, _Nilable(_Any) prop :actions, _Nilable(_Array(Avo::BaseAction)) def encrypted_query diff --git a/app/components/avo/views/resource_index_component.rb b/app/components/avo/views/resource_index_component.rb index 92779c8c7..c70805a66 100644 --- a/app/components/avo/views/resource_index_component.rb +++ b/app/components/avo/views/resource_index_component.rb @@ -17,7 +17,7 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent prop :parent_record, _Nilable(_Any) prop :parent_resource, _Nilable(Avo::BaseResource) prop :applied_filters, Hash, default: {}.freeze - prop :query, _Nilable(ActiveRecord::Relation), reader: :public + prop :query, _Nilable(_Any), reader: :public # This should be # prop :scopes, _Nilable(_Array(Avo::Advanced::Scopes::BaseScope)), reader: :public # However, Avo::Advanced::Scopes::BaseScope raises an error because From f79963414762556b00c48a3aa50ec28934eef981 Mon Sep 17 00:00:00 2001 From: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> Date: Wed, 2 Oct 2024 18:01:06 +0300 Subject: [PATCH 3/7] chore: allow nilable `overflow` on `Avo::ModalComponent` (#3303) --- app/components/avo/modal_component.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/avo/modal_component.rb b/app/components/avo/modal_component.rb index 2814c2ea8..8a55a587d 100644 --- a/app/components/avo/modal_component.rb +++ b/app/components/avo/modal_component.rb @@ -6,7 +6,7 @@ class Avo::ModalComponent < Avo::BaseComponent prop :width, Symbol, default: :md prop :body_class, _Nilable(String) - prop :overflow, Symbol, default: :auto + prop :overflow, _Nilable(Symbol), default: :auto def width_classes case @width.to_sym From 6084de6a74a614ce66db5e4ce28ea06f4b0ce478 Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Wed, 2 Oct 2024 18:17:51 +0300 Subject: [PATCH 4/7] Bumped avo to 3.13.2 --- Gemfile.lock | 2 +- gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock | 2 +- lib/avo/version.rb | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2d3bbe0bc..a5220659b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -107,7 +107,7 @@ GIT PATH remote: . specs: - avo (3.13.1) + avo (3.13.2) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock b/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock index a487e387f..f8bf03357 100644 --- a/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.1) + avo (3.13.2) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock b/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock index c6511801d..ad3fb8c02 100644 --- a/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.1) + avo (3.13.2) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock b/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock index 827a68fa7..eb0d5e280 100644 --- a/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.1) + avo (3.13.2) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock b/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock index 116918a87..e5e844685 100644 --- a/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.1) + avo (3.13.2) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock index 0686ed0c7..8ac153439 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.1) + avo (3.13.2) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock index 0686ed0c7..8ac153439 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.1) + avo (3.13.2) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock b/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock index c109b91bb..93eff714f 100644 --- a/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock @@ -112,7 +112,7 @@ PATH PATH remote: .. specs: - avo (3.13.1) + avo (3.13.2) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock b/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock index c109b91bb..93eff714f 100644 --- a/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock @@ -112,7 +112,7 @@ PATH PATH remote: .. specs: - avo (3.13.1) + avo (3.13.2) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/lib/avo/version.rb b/lib/avo/version.rb index 3f56d5ade..3ac83e352 100644 --- a/lib/avo/version.rb +++ b/lib/avo/version.rb @@ -1,3 +1,3 @@ module Avo - VERSION = "3.13.1" unless const_defined?(:VERSION) + VERSION = "3.13.2" unless const_defined?(:VERSION) end From c1b7f2bcc45de472945488ceaa476784d6dbee01 Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Thu, 3 Oct 2024 12:05:54 +0300 Subject: [PATCH 5/7] Bumped avo to 3.13.3 --- Gemfile.lock | 2 +- gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock | 2 +- gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock | 2 +- gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock | 2 +- lib/avo/version.rb | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a5220659b..a058686b2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -107,7 +107,7 @@ GIT PATH remote: . specs: - avo (3.13.2) + avo (3.13.3) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock b/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock index f8bf03357..4e6a63dcd 100644 --- a/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_6.1_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.2) + avo (3.13.3) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock b/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock index ad3fb8c02..76f868fc9 100644 --- a/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_6.1_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.2) + avo (3.13.3) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock b/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock index eb0d5e280..f0e9b1a7a 100644 --- a/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_7.1_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.2) + avo (3.13.3) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock b/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock index e5e844685..36b407e43 100644 --- a/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_7.1_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.2) + avo (3.13.3) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock index 8ac153439..7a68e3525 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.1.4.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.2) + avo (3.13.3) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock index 8ac153439..7a68e3525 100644 --- a/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_7.2.0.beta2_ruby_3.3.0.gemfile.lock @@ -13,7 +13,7 @@ PATH PATH remote: .. specs: - avo (3.13.2) + avo (3.13.3) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock b/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock index 93eff714f..d66e88005 100644 --- a/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock +++ b/gemfiles/rails_8.0_ruby_3.1.4.gemfile.lock @@ -112,7 +112,7 @@ PATH PATH remote: .. specs: - avo (3.13.2) + avo (3.13.3) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock b/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock index 93eff714f..d66e88005 100644 --- a/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock +++ b/gemfiles/rails_8.0_ruby_3.3.0.gemfile.lock @@ -112,7 +112,7 @@ PATH PATH remote: .. specs: - avo (3.13.2) + avo (3.13.3) actionview (>= 6.1) active_link_to activerecord (>= 6.1) diff --git a/lib/avo/version.rb b/lib/avo/version.rb index 3ac83e352..4d39a0b84 100644 --- a/lib/avo/version.rb +++ b/lib/avo/version.rb @@ -1,3 +1,3 @@ module Avo - VERSION = "3.13.2" unless const_defined?(:VERSION) + VERSION = "3.13.3" unless const_defined?(:VERSION) end From d8602827086647a2df6bc74a7d6aedb3f0fb1c51 Mon Sep 17 00:00:00 2001 From: Paul Bob <69730720+Paul-Bob@users.noreply.github.com> Date: Fri, 4 Oct 2024 12:32:20 +0300 Subject: [PATCH 6/7] fix: tags filters closing on tag selection (#3306) --- .../js/controllers/toggle_controller.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/app/javascript/js/controllers/toggle_controller.js b/app/javascript/js/controllers/toggle_controller.js index 01b4dff9b..1041e783f 100644 --- a/app/javascript/js/controllers/toggle_controller.js +++ b/app/javascript/js/controllers/toggle_controller.js @@ -6,12 +6,12 @@ export default class extends Controller { static targets = ['panel'] static values = { - // One may want to have an element that is exempt from triggerring the click outside event - exemptionContainer: String, + // One may want to have elements that are exempt from triggering the click outside event + exemptionContainers: Array, } - get exemptionContainerTarget() { - return document.querySelector(this.exemptionContainerValue) + get exemptionContainerTargets() { + return this.exemptionContainersValue.map((selector) => document.querySelector(selector)).filter(Boolean) } connect() { @@ -20,13 +20,9 @@ export default class extends Controller { clickOutside(e) { if (this.hasPanelTarget) { - if (this.hasExemptionContainerValue && this.exemptionContainerTarget) { - const inExemptionContainer = this.exemptionContainerTarget.contains(e.target) + const isInExemptionContainer = this.hasExemptionContainersValue && this.exemptionContainerTargets.some((container) => container.contains(e.target)) - if (!inExemptionContainer) { - leave(this.panelTarget) - } - } else { + if (!isInExemptionContainer) { leave(this.panelTarget) } } From a53f9a002505ec712fc3ca67f57ce3fb0710c5b0 Mon Sep 17 00:00:00 2001 From: Adrian Marin Date: Sat, 5 Oct 2024 17:45:45 +0300 Subject: [PATCH 7/7] feature: process search results (#3310) --- app/controllers/avo/search_controller.rb | 12 ++++++++++-- lib/avo/resources/resource_manager.rb | 9 +++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/controllers/avo/search_controller.rb b/app/controllers/avo/search_controller.rb index d36f56fee..1aa284050 100644 --- a/app/controllers/avo/search_controller.rb +++ b/app/controllers/avo/search_controller.rb @@ -9,14 +9,22 @@ class SearchController < ApplicationController before_action :set_resource, only: :show def show - render json: search_resources([resource]) + render json: search_resources([resource], request:) rescue => error render_error _label: error.message end + def process_results(results, request:) + results + end + private - def search_resources(resources) + def search_resources(resources, request: nil) + process_results search_results(resources, request:), request: + end + + def search_results(resources, request: nil) resources .map do |resource| # Apply authorization diff --git a/lib/avo/resources/resource_manager.rb b/lib/avo/resources/resource_manager.rb index 48b9eb037..8eada1bd1 100644 --- a/lib/avo/resources/resource_manager.rb +++ b/lib/avo/resources/resource_manager.rb @@ -100,6 +100,15 @@ def get_resource_by_name(name) get_resource name.singularize.camelize end + # Returns the Avo resource by singular snake_cased name + # + # get_resource_by_name('z posts') => instance of Avo::Resources::ZPost + def get_resource_by_plural_name(name) + resources.find do |resource| + resource.plural_name == name + end + end + # Returns the Avo resource by singular snake_cased name # From all the resources that use the same model_class, it will fetch the first one in alphabetical order #