about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-08-25 23:33:34 +0200
committerGitHub <noreply@github.com>2022-08-25 23:33:34 +0200
commit5b0e8cc92b9ca0ab0dc24366d95f67a88c470173 (patch)
treee25c081fa76f34436d859b1f9674287d790bc657 /app/models
parentd696f729f1dc27c9d92b896c651e1ea73bf93d75 (diff)
Add ability to select all accounts matching search for batch actions (#19053)
Diffstat (limited to 'app/models')
-rw-r--r--app/models/custom_filter_status.rb2
-rw-r--r--app/models/form/account_batch.rb13
2 files changed, 12 insertions, 3 deletions
diff --git a/app/models/custom_filter_status.rb b/app/models/custom_filter_status.rb
index b6bea1394..e748d6963 100644
--- a/app/models/custom_filter_status.rb
+++ b/app/models/custom_filter_status.rb
@@ -5,7 +5,7 @@
 #
 #  id               :bigint(8)        not null, primary key
 #  custom_filter_id :bigint(8)        not null
-#  status_id        :bigint(8)        default(""), not null
+#  status_id        :bigint(8)        not null
 #  created_at       :datetime         not null
 #  updated_at       :datetime         not null
 #
diff --git a/app/models/form/account_batch.rb b/app/models/form/account_batch.rb
index 98f2cad3e..5cfcf7205 100644
--- a/app/models/form/account_batch.rb
+++ b/app/models/form/account_batch.rb
@@ -6,7 +6,8 @@ class Form::AccountBatch
   include AccountableConcern
   include Payloadable
 
-  attr_accessor :account_ids, :action, :current_account
+  attr_accessor :account_ids, :action, :current_account,
+                :select_all_matching, :query
 
   def save
     case action
@@ -60,7 +61,11 @@ class Form::AccountBatch
   end
 
   def accounts
-    Account.where(id: account_ids)
+    if select_all_matching?
+      query
+    else
+      Account.where(id: account_ids)
+    end
   end
 
   def approve!
@@ -118,4 +123,8 @@ class Form::AccountBatch
     log_action(:approve, account.user)
     account.user.approve!
   end
+
+  def select_all_matching?
+    select_all_matching == '1'
+  end
 end