mirror of https://github.com/docusealco/docuseal
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
193 lines
12 KiB
193 lines
12 KiB
<%= render 'title', template: @template %>
|
|
<% is_filter_active = params.slice(:author, :created_at, :completed_at).to_unsafe_h.any?(&:present?) %>
|
|
<% is_show_tabs = @pagy.pages > 1 || params[:q].present? || params[:status].present? || is_filter_active %>
|
|
<% if !@pagy.count.zero? || params[:q].present? || params[:status].present? || is_filter_active %>
|
|
<div class="<%= is_show_tabs ? 'mb-4' : 'mb-6' %>">
|
|
<div class="flex justify-between items-center md:items-end">
|
|
<div>
|
|
<h2 class="text-3xl font-bold md:block <%= 'hidden' if params[:q].present? %>">
|
|
<%= t('submissions') %>
|
|
</h2>
|
|
</div>
|
|
<div class="flex justify-end space-x-2">
|
|
<% if params[:q].present? || params[:status].present? || is_filter_active || @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') %>
|
|
<span><%= t('export') %></span>
|
|
<% end %>
|
|
<% if !@template.archived_at? && can?(:create, Submission) %>
|
|
<%= link_to new_template_submission_path(@template), 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 %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
<% if is_show_tabs %>
|
|
<div class="flex items-center flex-col md:flex-row md:flex-wrap gap-2 justify-between mb-4">
|
|
<div class="flex items-center md:items-end flex-col md:flex-row gap-2 w-full md:w-fit">
|
|
<a href="<%= url_for(params.to_unsafe_h.except(:status)) %>" class="<%= params[:status].blank? ? 'border-neutral-700' : 'border-neutral-300' %> flex h-10 px-2 py-1 text-lg items-center justify-between border text-center text-neutral font-semibold rounded-xl w-full md:w-48 hover:border-neutral-700">
|
|
<div class="flex items-center space-x-1">
|
|
<%= svg_icon('list', class: 'w-5 h-5') %>
|
|
<span class="font-normal"><%= t('all') %></span>
|
|
</div>
|
|
<div class="badge badge-neutral badge-outline font-medium">
|
|
<%= params[:status].blank? ? @pagy.count : @base_submissions.count %>
|
|
</div>
|
|
</a>
|
|
<a href="<%= url_for(params.to_unsafe_h.merge(status: :pending)) %>" class="<%= params[:status] == 'pending' ? 'border-neutral-700' : 'border-neutral-300' %> flex h-10 px-2 py-1 text-lg items-center justify-between border text-center text-neutral font-semibold rounded-xl w-full md:w-48 hover:border-neutral-700">
|
|
<div class="flex items-center space-x-1">
|
|
<%= svg_icon('clock', class: 'w-5 h-5') %>
|
|
<span class="font-normal"><%= t('pending') %></span>
|
|
</div>
|
|
<div class="badge badge-neutral badge-outline font-medium">
|
|
<%= params[:status] == 'pending' ? @pagy.count : @base_submissions.pending.count %>
|
|
</div>
|
|
</a>
|
|
<a href="<%= url_for(params.to_unsafe_h.merge(status: :completed)) %>" class="<%= params[:status] == 'completed' ? 'border-neutral-700' : 'border-neutral-300' %> flex h-10 px-2 py-1 text-lg items-center justify-between border text-center text-neutral font-semibold rounded-xl w-full md:w-48 hover:border-neutral-700">
|
|
<div class="flex items-center space-x-1">
|
|
<%= svg_icon('circle_check', class: 'w-5 h-5') %>
|
|
<span class="font-normal"><%= t('completed') %></span>
|
|
</div>
|
|
<div class="badge badge-neutral badge-outline font-medium">
|
|
<%= params[:status] == 'completed' ? @pagy.count : @base_submissions.completed.count %>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
<div class="flex items-end flex-col md:flex-row gap-2 w-full md:w-fit">
|
|
<% if completed_at_range.present? %>
|
|
<div class="tooltip tooltip-bottom flex h-10 px-2 py-1 text-lg items-center justify-between border text-center text-neutral font-semibold rounded-xl w-full md:w-34 border-neutral-700" data-tip="<%= t('completed_at') %>">
|
|
<%= link_to filter_templates_path(params.to_unsafe_h.except(:controller, :action).merge(filter: 'completed_at')), data: { turbo_frame: 'modal' }, class: 'flex items-center space-x-1' do %>
|
|
<%= svg_icon('calendar_check', class: 'w-5 h-5 shrink-0') %>
|
|
<span class="flex flex-row md:flex-col font-normal text-left md:text-center md:text-xs">
|
|
<% if completed_at_range.begin&.to_date == completed_at_range.end&.to_date %>
|
|
<span><%= l(completed_at_range.begin.to_date, locale: current_account.locale) %></span>
|
|
<% else %>
|
|
<span><%= completed_at_range.begin ? l(completed_at_range.begin.to_date, locale: current_account.locale) : '∞' %></span>
|
|
<span class="px-1 md:px-0 md:hidden">-</span>
|
|
<span><%= completed_at_range.end ? l(completed_at_range.end.to_date, locale: current_account.locale) : t('today') %></span>
|
|
<% end %>
|
|
</span>
|
|
<% end %>
|
|
<%= link_to url_for(params.to_unsafe_h.except(:completed_at)), class: 'rounded-lg ml-1 hover:bg-neutral-700 hover:text-white' do %>
|
|
<%= svg_icon('x', class: 'w-5 h-5') %>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
<% if @created_at_range.present? %>
|
|
<div class="tooltip tooltip-bottom flex h-10 px-2 py-1 text-lg items-center justify-between border text-center text-neutral font-semibold rounded-xl w-full md:w-34 border-neutral-700" data-tip="<%= t('created_at') %>">
|
|
<%= link_to filter_templates_path(params.to_unsafe_h.except(:controller, :action).merge(filter: 'created_at')), data: { turbo_frame: 'modal' }, class: 'flex items-center space-x-1' do %>
|
|
<%= svg_icon('calendar', class: 'w-5 h-5 shrink-0') %>
|
|
<span class="flex flex-row md:flex-col font-normal text-left md:text-center md:text-xs">
|
|
<% if created_at_range.begin&.to_date == created_at_range.end&.to_date %>
|
|
<span><%= l(created_at_range.begin.to_date, locale: current_account.locale) %></span>
|
|
<% else %>
|
|
<span><%= created_at_range.begin ? l(created_at_range.begin.to_date, locale: current_account.locale) : '∞' %></span>
|
|
<span class="px-1 md:px-0 md:hidden">-</span>
|
|
<span><%= created_at_range.end ? l(created_at_range.end.to_date, locale: current_account.locale) : t('today') %></span>
|
|
<% end %>
|
|
</span>
|
|
<% end %>
|
|
<%= link_to url_for(params.to_unsafe_h.except(:created_at)), class: 'rounded-lg ml-1 hover:bg-neutral-700 hover:text-white' do %>
|
|
<%= svg_icon('x', class: 'w-5 h-5') %>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
<% if params[:author].present? %>
|
|
<div class="tooltip tooltip-bottom flex h-10 px-2 py-1 text-lg items-center justify-between border text-center text-neutral font-semibold rounded-xl w-full md:w-34 border-neutral-700" data-tip="<%= t('author') %>">
|
|
<%= link_to filter_templates_path(params.to_unsafe_h.except(:controller, :action).merge(filter: 'author')), data: { turbo_frame: 'modal' }, class: 'flex items-center space-x-1 w-full md:w-36' do %>
|
|
<%= svg_icon('user', class: 'w-5 h-5 shrink-0') %>
|
|
<span class="font-normal truncate"><%= params[:author] %></span>
|
|
<% end %>
|
|
<%= link_to url_for(params.to_unsafe_h.except(:author)), class: 'rounded-lg ml-1 hover:bg-neutral-700 hover:text-white' do %>
|
|
<%= svg_icon('x', class: 'w-5 h-5') %>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
<div class="dropdown dropdown-end">
|
|
<label tabindex="0" class="flex h-10 px-2 py-1 space-x-1 text-lg items-center justify-between border text-center text-neutral font-semibold rounded-xl border-neutral-300 hover:border-neutral-700">
|
|
<%= svg_icon('filter', class: 'w-5 h-5 flex-shrink-0 stroke-2') %>
|
|
<span class="<%= is_filter_active ? 'md:hidden' : '' %>">Filter</span>
|
|
</label>
|
|
<ul tabindex="0" class="z-10 dropdown-content p-2 mt-2 shadow menu text-base bg-base-100 rounded-box min-w-[180px] text-right">
|
|
<li class="flex">
|
|
<%= link_to filter_templates_path(params.to_unsafe_h.except(:controller, :action).merge(filter: 'author')), data: { turbo_frame: 'modal' } do %>
|
|
<%= svg_icon('user', class: 'w-5 h-5 flex-shrink-0 stroke-2') %>
|
|
<span><%= t('author') %></span>
|
|
<% end %>
|
|
</li>
|
|
<li class="flex">
|
|
<%= link_to filter_templates_path(params.to_unsafe_h.except(:controller, :action).merge(filter: 'created_at')), data: { turbo_frame: 'modal' } do %>
|
|
<%= svg_icon('calendar', class: 'w-5 h-5 flex-shrink-0 stroke-2') %>
|
|
<span><%= t('created_at') %></span>
|
|
<% end %>
|
|
</li>
|
|
<li class="flex">
|
|
<%= link_to filter_templates_path(params.to_unsafe_h.except(:controller, :action).merge(filter: 'completed_at')), data: { turbo_frame: 'modal' } do %>
|
|
<%= svg_icon('calendar_check', class: 'w-5 h-5 flex-shrink-0 stroke-2') %>
|
|
<span><%= t('completed_at') %></span>
|
|
<% end %>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
<% if @submissions.present? %>
|
|
<div class="space-y-4">
|
|
<%= render partial: 'submission', collection: @submissions, locals: { template: @template } %>
|
|
</div>
|
|
<% else %>
|
|
<div class="card bg-base-200">
|
|
<div class="card-body text-center px-4 py-16">
|
|
<div class="max-w-lg mx-auto">
|
|
<p class="text-3xl font-bold text-base-content">
|
|
<%= t('there_are_no_submissions') %>
|
|
</p>
|
|
<% if @template.archived_at.blank? && params[:q].blank? %>
|
|
<div class="mt-4">
|
|
<p><%= t('send_an_invitation_to_fill_and_complete_the_form') %></p>
|
|
<div class="space-y-2 flex flex-col">
|
|
<% if can?(:create, Submission) %>
|
|
<%= link_to new_template_submission_path(@template, with_link: true), class: 'base-button mt-6', data: { turbo_frame: 'modal' } do %>
|
|
<%= svg_icon('plus', class: 'w-6 h-6 stroke-2') %>
|
|
<span class="mr-1"><%= t('send_to_recipients') %></span>
|
|
<% end %>
|
|
<% end %>
|
|
<% if @template.submitters.size == 1 %>
|
|
<%= link_to start_form_url(slug: @template.slug), class: 'white-button mt-6', target: '_blank', rel: 'noopener' do %>
|
|
<%= svg_icon('writing', class: 'w-6 h-6') %>
|
|
<span class="mr-1"><%= t('sign_it_yourself') %></span>
|
|
<% end %>
|
|
<% else %>
|
|
<%= link_to new_template_submission_path(@template, selfsign: true), class: 'white-button mt-6', data: { turbo_frame: 'modal' } do %>
|
|
<%= svg_icon('writing', class: 'w-6 h-6') %>
|
|
<span class="mr-1"><%= t('sign_it_yourself') %></span>
|
|
<% end %>
|
|
<% end %>
|
|
</did>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
<% view_archived_html = capture do %>
|
|
<% if @template.submissions.where.not(archived_at: nil).exists? && !@template.archived_at? %>
|
|
<div>
|
|
<a href="<%= template_archived_index_path(@template) %>" class="link text-sm"><%= t('view_archived') %></a>
|
|
</div>
|
|
<% end %>
|
|
<% end %>
|
|
<% if @pagy.pages > 1 %>
|
|
<%= render 'shared/pagination', pagy: @pagy, items_name: 'submissions', left_additional_html: view_archived_html %>
|
|
<% else %>
|
|
<div class="mt-2">
|
|
<%= view_archived_html %>
|
|
</div>
|
|
<% end %>
|