From 5d75ee2e4750c6f068987e161988e0e9f016c875 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Tue, 2 Sep 2025 21:17:25 +0300 Subject: [PATCH] filter export --- app/controllers/submissions_export_controller.rb | 3 +++ app/views/submissions_export/new.html.erb | 5 +++-- app/views/templates/show.html.erb | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/submissions_export_controller.rb b/app/controllers/submissions_export_controller.rb index c12a2e6e..bfbb7359 100644 --- a/app/controllers/submissions_export_controller.rb +++ b/app/controllers/submissions_export_controller.rb @@ -10,6 +10,9 @@ class SubmissionsExportController < ApplicationController attachments_attachments: :blob }) .order(id: :asc) + submissions = Submissions.search(current_user, submissions, params[:q], search_values: true) + submissions = Submissions::Filter.call(submissions, current_user, params) + expires_at = Accounts.link_expires_at(current_account) if params[:format] == 'csv' diff --git a/app/views/submissions_export/new.html.erb b/app/views/submissions_export/new.html.erb index 93a33c6e..7b2df9b6 100644 --- a/app/views/submissions_export/new.html.erb +++ b/app/views/submissions_export/new.html.erb @@ -1,6 +1,7 @@ +<% filter_params = params.permit(:q, *Submissions::Filter::ALLOWED_PARAMS) %> <%= render 'shared/turbo_modal', title: t('export'), close_after_submit: false do %>
- <%= button_to template_submissions_export_index_path(@template), params: { format: :xlsx }, method: :get, data: { turbo_frame: :_top } do %> + <%= button_to template_submissions_export_index_path(@template), params: { format: :xlsx, **filter_params }, method: :get, data: { turbo_frame: :_top } do %>
<%= svg_icon('download', class: 'w-12 h-12 stroke-2 mr-2') %> @@ -14,7 +15,7 @@
<% end %> - <%= button_to template_submissions_export_index_path(@template), params: { format: :csv }, method: :get, data: { turbo_frame: :_top } do %> + <%= button_to template_submissions_export_index_path(@template), params: { format: :csv, **filter_params }, method: :get, data: { turbo_frame: :_top } do %>
<%= svg_icon('download', class: 'w-12 h-12 stroke-2 mr-2') %> diff --git a/app/views/templates/show.html.erb b/app/views/templates/show.html.erb index c749ef1f..82ffb69e 100644 --- a/app/views/templates/show.html.erb +++ b/app/views/templates/show.html.erb @@ -13,7 +13,7 @@ <% if params[:q].present? || params[:status].present? || filter_params.present? || @pagy.pages > 1 %> <%= render 'shared/search_input', title_selector: 'h2' %> <% end %> - <%= link_to new_template_submissions_export_path(@template), class: 'hidden md:flex btn btn-ghost text-base', data: { turbo_frame: 'modal' } do %> + <%= link_to new_template_submissions_export_path(@template, params.permit(:q, *Submissions::Filter::ALLOWED_PARAMS)), class: 'hidden md:flex btn btn-ghost text-base', data: { turbo_frame: 'modal' } do %> <%= svg_icon('download', class: 'w-6 h-6 stroke-2') %> <%= t('export') %> <% end %>