diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index dd6d6cb60f..d9253d57a9 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1301,6 +1301,10 @@ def account_numbers end def email + @message = Ahoy::Message.find(params[:message_id]) + end + + def email_html @message_id = params[:message_id] respond_to do |format| @@ -1323,7 +1327,6 @@ def emails @count = messages.count @messages = messages.page(@page).per(@per).order(sent_at: :desc) - end def unknown_merchants diff --git a/app/views/admin/email.html.erb b/app/views/admin/email.html.erb new file mode 100644 index 0000000000..01fc112694 --- /dev/null +++ b/app/views/admin/email.html.erb @@ -0,0 +1,14 @@ +<%# +We're doing this crazy level of nesting to prevent excess web requests. + +emails (index page) -> lazy turboframe with inside iframe -> email_html action + +This is because just having iframes on the index page causes a huge number of +web requests from browser extensions, etc. So, we lazy load the iframes. + +And, Rails has a hard time with the email HTML when passed through ERB, so we +respond with the email HTML directly in the controller action. +%> +<%= turbo_frame_tag dom_id(@message) do %> + +<% end %> diff --git a/app/views/admin/emails.html.erb b/app/views/admin/emails.html.erb index e69c99e480..17a51bff44 100644 --- a/app/views/admin/emails.html.erb +++ b/app/views/admin/emails.html.erb @@ -3,8 +3,7 @@ <%= form_with local: true, url: emails_admin_index_path, method: :get do |form| %> <%= form.text_field :q, value: params[:q], placeholder: "Search" %> <%= form.text_field :to, value: params[:to], placeholder: "Email address (to)" %> - - <%= form.collection_select(:user_id, User.all.order(Arel.sql("COALESCE(preferred_name, full_name, email) ASC")), :id, :admin_dropdown_description, { include_blank: "Select a user", selected: @user_id }, { width: 250, style: "max-width: 250px" }) %> + <%= form.text_field :user_id, value: params[:user_id], placeholder: "User ID" %>