From b96fe74db18fc8ea2f80d754edc215fae16bf416 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Fri, 31 Jul 2026 10:46:24 +0300 Subject: [PATCH] adjust filters --- app/views/shared/_classes.html.erb | 2 +- app/views/submissions_archived/index.html.erb | 2 +- .../_applied_filters.html.erb | 54 ++++++++++++++----- .../_filter_button.html.erb | 8 +-- app/views/submissions_filters/status.html.erb | 6 +-- .../index.html.erb | 6 +-- 6 files changed, 53 insertions(+), 25 deletions(-) diff --git a/app/views/shared/_classes.html.erb b/app/views/shared/_classes.html.erb index 6a2b14a5..e36c5fe5 100644 --- a/app/views/shared/_classes.html.erb +++ b/app/views/shared/_classes.html.erb @@ -1 +1 @@ -<% 'stats stat stat-figure stat-title stat-value text-accent w-fit hover:bg-white dropdown-open border-base-content/30 before:border-base-content/30 order-none order-1 order-2 order-3 order-4 order-5 lg:inline lg:hidden' %> +<% 'stats stat stat-figure stat-title stat-value text-accent w-fit hover:bg-white dropdown-open border-base-content/30 before:border-base-content/30 order-1 order-2 order-3 order-4 order-5 lg:inline lg:hidden' %> diff --git a/app/views/submissions_archived/index.html.erb b/app/views/submissions_archived/index.html.erb index 67380d50..a51b8099 100644 --- a/app/views/submissions_archived/index.html.erb +++ b/app/views/submissions_archived/index.html.erb @@ -17,7 +17,7 @@
- <%= render 'submissions_filters/applied_filters', filter_params: %> + <%= render 'submissions_filters/applied_filters', filter_params:, with_status: true %> <%= render 'submissions_filters/filter_button', filter_params: %>
diff --git a/app/views/submissions_filters/_applied_filters.html.erb b/app/views/submissions_filters/_applied_filters.html.erb index 07cc0049..5cfd4063 100644 --- a/app/views/submissions_filters/_applied_filters.html.erb +++ b/app/views/submissions_filters/_applied_filters.html.erb @@ -3,20 +3,15 @@ <% ordered_filters = request.query_parameters.keys.filter_map { |key| filter_names.find { |name| key.start_with?(name) } }.uniq %> <% chip_order = ordered_filters.reverse.each_with_index.to_h { |name, index| [name, index + 1] } %> <% chip_order.default = ordered_filters.size + 1 %> - - <% if local_assigns[:with_status] %> - <% status_icons = { 'all' => 'list', 'pending' => 'clock', 'completed' => 'circle_check', 'partially_completed' => 'clock_edit', 'sent' => 'send', 'opened' => 'mail_opened', 'declined' => 'x_circle', 'expired' => 'clock_cancel' } %> - <% current_status = status_icons.key?(params[:status].to_s) ? params[:status] : 'all' %> - - <%= svg_icon(status_icons[current_status], class: 'w-5 h-5 shrink-0') %> - <%= t(current_status) %> - <%= svg_icon('chevron_down', class: 'w-4 h-4 shrink-0') %> - - <% end %> - <% if icon = { 'declined' => 'x_circle', 'expired' => 'clock_cancel', 'partially_completed' => 'clock_edit', 'sent' => 'send', 'opened' => 'mail_opened' }[params[:status]] %> -
+<% status_icon = { 'declined' => 'x_circle', 'expired' => 'clock_cancel', 'partially_completed' => 'clock_edit', 'sent' => 'send', 'opened' => 'mail_opened' }[params[:status]] %> +<% status_icons = { 'all' => 'list', 'pending' => 'clock', 'completed' => 'circle_check' } %> +<% current_status = status_icons.key?(params[:status].to_s) ? params[:status].to_s : 'all' %> +<% with_status_button = local_assigns[:with_status] && status_icon.blank? %> +<% chips_html = capture do %> + <% if status_icon %> +
<%= link_to submissions_filter_path('status', query_params.merge(path: url_for, with_remove: true)), data: { turbo_frame: 'modal' }, class: 'flex items-center space-x-1 flex-1 min-w-0 pr-1' do %> - <%= svg_icon(icon, class: 'w-5 h-5 shrink-0') %> + <%= svg_icon(status_icon, class: 'w-5 h-5 shrink-0') %> <%= t(params[:status]) %> <% end %> <%= link_to url_for(params: request.query_parameters.except('status')), class: 'rounded-lg ml-1 shrink-0 hover:bg-base-content hover:text-white' do %> @@ -82,4 +77,35 @@ <% end %>
<% end %> - +<% end %> +<% if with_status_button && chips_html.blank? %> + +<% end %> +<% if chips_html.present? %> + + <% if with_status_button %> + + <%= svg_icon(status_icons[current_status], class: 'w-5 h-5 shrink-0') %> + <%= t(current_status) %> + <%= svg_icon('chevron_down', class: 'w-4 h-4 shrink-0') %> + + <% end %> + <%= chips_html %> + +<% end %> diff --git a/app/views/submissions_filters/_filter_button.html.erb b/app/views/submissions_filters/_filter_button.html.erb index ec20c1ee..601b2d02 100644 --- a/app/views/submissions_filters/_filter_button.html.erb +++ b/app/views/submissions_filters/_filter_button.html.erb @@ -1,9 +1,11 @@ <% query_params = params.permit(:q).merge(filter_params) %> <% advanced_filters = filter_params.then { |f| f[:status].in?(%w[pending completed]) ? f.except(:status) : f } %> -
- <%= render 'submissions_filters/applied_filters', filter_params: %> -
+
+ <%= render 'submissions_filters/applied_filters', filter_params:, with_status: true %> +