<%= render 'title', template: @template %> <% filter_params = params.permit(Submissions::Filter::ALLOWED_PARAMS).compact_blank %> <% is_show_tabs = @pagy.pages > 1 || params[:q].present? || params[:status].present? || filter_params.present? %> <% if @pagy.count.nil? || !@pagy.count.zero? || params[:q].present? || params[:status].present? || filter_params.present? %>

<%= t('submissions') %>

<% 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 %> <%= svg_icon('download', class: 'w-6 h-6 stroke-2') %> <%= t('export') %> <% end %> <% if !@template.archived_at? && can?(:create, Submission) %> <%= link_to new_template_submission_path(@template), id: 'add_recipients_button', class: 'white-button !border', data: { turbo_frame: 'modal' } do %> <%= svg_icon('plus', class: 'w-6 h-6 stroke-2') %> <%= t('add_recipients_html') %> <% end %> <% end %>
<% end %> <% if is_show_tabs %>
<%= svg_icon('list', class: 'w-5 h-5') %> <%= t('all') %>
<% unless can?(:manage, :countless) %>
<%= params[:status].blank? && filter_params.blank? ? @pagy.count : @base_submissions.unscope(:group, :order).select(:id).distinct.count %>
<% end %>
<%= svg_icon('clock', class: 'w-5 h-5') %> <%= t('pending') %>
<% unless can?(:manage, :countless) %>
<%= params[:status] == 'pending' && filter_params.blank? ? @pagy.count : @base_submissions.pending.unscope(:group, :order).select(:id).distinct.count %>
<% end %>
<%= svg_icon('circle_check', class: 'w-5 h-5') %> <%= t('completed') %>
<% unless can?(:manage, :countless) %>
<%= params[:status] == 'completed' && filter_params.blank? ? @pagy.count : @base_submissions.completed.unscope(:group, :order).select(:id).distinct.count %>
<% end %>
<%= render 'submissions_filters/applied_filters', filter_params: %> <%= render 'submissions_filters/filter_button', filter_params: %> <% unless @template.archived_at? %> <%= render 'submissions_filters/actions', filter_params: filter_params.merge(template_id: @template.id) %> <% end %>
<% end %> <% if @submissions.present? %>
<%= render partial: 'submission', collection: @submissions, locals: { template: @template } %>
<% else %>

<%= t('there_are_no_submissions') %>

<% if @template.archived_at.blank? && params[:q].blank? && filter_params.blank? %>

<%= t('send_an_invitation_to_fill_and_complete_the_form') %>

<% if can?(:create, Submission) %> <%= link_to new_template_submission_path(@template, with_link: true), id: 'send_to_recipients_button', class: 'base-button mt-6', data: { turbo_frame: 'modal' } do %> <%= svg_icon('plus', class: 'w-6 h-6 stroke-2') %> <%= t('send_to_recipients') %> <% end %> <% end %> <% if @template.submitters.size == 1 %> <%= button_to start_form_path(@template.slug), params: { selfsign: true }, method: :put, class: 'white-button w-full', form: { style: 'display: inline', target: '_blank', data: { turbo: false } } do %> <%= svg_icon('writing', class: 'w-6 h-6') %> <%= t('sign_it_yourself') %> <% end %> <% else %> <%= link_to new_template_submission_path(@template, selfsign: true), id: 'sign_yourself_button', class: 'white-button mt-6', data: { turbo_frame: 'modal' } do %> <%= svg_icon('writing', class: 'w-6 h-6') %> <%= t('sign_it_yourself') %> <% end %> <% end %>
<% end %>
<% end %> <% view_archived_html = capture do %> <% if @template.submissions.where.not(archived_at: nil).exists? && !@template.archived_at? %>
<%= t('view_archived') %>
<% end %> <% end %> <% if @pagy.pages > 1 %> <%= render 'shared/pagination', pagy: @pagy, items_name: 'submissions', left_additional_html: view_archived_html %> <% else %>
<%= view_archived_html %>
<% end %> <%= render 'shared/app_tour', type: 'template', next_page_path: settings_account_path(params.permit(:tour)) %>