From 4da7f18a79fbe4991a5ad6c5e0a285be36b10e24 Mon Sep 17 00:00:00 2001 From: JEFFREY-Bonson Date: Thu, 29 Feb 2024 17:19:01 +0530 Subject: [PATCH] [WIP] Method list dialog --- app/models/miq_ae_method.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/models/miq_ae_method.rb b/app/models/miq_ae_method.rb index 6a4ea5d32950..48fd37a035f3 100644 --- a/app/models/miq_ae_method.rb +++ b/app/models/miq_ae_method.rb @@ -30,6 +30,22 @@ class MiqAeMethod < ApplicationRecord AVAILABLE_SCOPES = ["class", "instance"] validates_inclusion_of :scope, :in => AVAILABLE_SCOPES + scope :name_path_search, lambda { |search| + where('name ILIKE ? or relative_path ILIKE ?', "%#{search}%", "%#{search}%") if search.present? + } + + scope :domain_search, lambda { |domain_id| + where(:domain_id => domain_id) if domain_id.present? + } + + scope :selected_methods, lambda { |method_ids| + if method_ids.present? + where(:id => method_ids.split(',').map(&:to_i)) + else + where(nil) + end + } + def self.available_languages AVAILABLE_LANGUAGES end