diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 7cd01cc8f..8b766b25f 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -18,6 +18,16 @@ class SubmissionsController < ApplicationController 'payment' => 'credit_card', 'verification' => 'id', 'kba' => 'user_scan' }.freeze + STATUS_BADGES = { + 'awaiting' => 'badge-info', 'sent' => 'badge-info', 'completed' => 'badge-success', + 'opened' => 'badge-warning', 'declined' => 'badge-error' + }.freeze + + STATUS_ICONS = { + 'awaiting' => 'clock', 'sent' => 'send', 'completed' => 'circle_check', + 'opened' => 'mail_opened', 'declined' => 'x_circle' + }.freeze + def show @submission = Submissions.preload_with_pages(@submission) diff --git a/app/views/shared/_classes.html.erb b/app/views/shared/_classes.html.erb index e36c5fe5b..ce41dd0c4 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-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 badge-info badge-success badge-warning badge-error' %> diff --git a/app/views/templates/_submission.html.erb b/app/views/templates/_submission.html.erb index 228e09053..9262b14e7 100644 --- a/app/views/templates/_submission.html.erb +++ b/app/views/templates/_submission.html.erb @@ -1,8 +1,7 @@ -<% status_badges = { 'awaiting' => 'badge-info', 'sent' => 'badge-info', 'completed' => 'badge-success', 'opened' => 'badge-warning', 'declined' => 'badge-error' } %>
<% if local_assigns[:with_template] %> <% template = submission.template %> - +
-
+
<%= svg_icon('user', class: 'w-4 h-4 flex-shrink-0') %> - <%= (submission.created_by_user || template.author).full_name.presence || (submission.created_by_user || template.author).email.to_s.sub(/\+\w+@/, '@') %> + <%= (submission.created_by_user || template.author).full_name.presence || (submission.created_by_user || template.author).email.to_s.sub(/\+\w+@/, '@') %> <%= svg_icon('calendar', class: 'w-4 h-4 flex-shrink-0') %> @@ -26,14 +25,14 @@
<% end %> -
+
<% submitters = (submission.template_submitters || submission.template.submitters).filter_map { |item| submission.submitters.find { |e| e.uuid == item['uuid'] } } %> <% is_submission_completed = submission.completed_at? %> <% if submitters.size == 1 %> -
+
<% submitter = submitters.first %>
- + <% if submission.expired? && !submitter.completed_at? && !submitter.declined_at? %>
@@ -42,17 +41,17 @@
<% else %> - + <%= t(submitter.status) %> <% end %> - - + + <%= submitter.name || submitter.email || submitter.phone %> <% if !submitter.completed_at? && !submission.completed_at? && can?(:update, submission) && !submitter.start_form_submission_events.any? && !submission.archived_at? && !submission.expired? && !submitter.declined_at? %> - + <%= link_to edit_submitter_path(submitter), class: 'shrink-0', data: { turbo_frame: 'modal' } do %> <%= svg_icon('pencil', class: 'w-5 h-5') %> @@ -66,7 +65,7 @@
<% if submitter.completed_at? %> -
+
@@ -82,7 +81,7 @@
<% elsif !submission.archived_at? && !template&.archived_at? && !submission.expired? && !submitter.declined_at? %> <% if current_user.email == submitter.email %> -
+ <% else %> -
- <%= render 'shared/clipboard_copy', text: submit_form_url(slug: submitter.slug, host: form_link_host), class: 'btn btn-sm btn-neutral text-white md:w-36 flex z-[1]', icon_class: 'w-6 h-6 text-white', copy_title: t('copy_link').length < 10 ? t('copy_link') : t('copy'), copy_title_md: t('copy'), copied_title_md: t('copied') %> +
+ <%= render 'shared/clipboard_copy', text: submit_form_url(slug: submitter.slug, host: form_link_host), class: 'btn btn-sm btn-neutral text-white md:w-36 flex z-[1]', icon_class: 'w-6 h-6 text-white', copy_title: t('copy_link').length < 10 ? t('copy_link') : t('copy'), copy_title_md: t('link'), copied_title_md: t('copied') %>
<% end %> <% end %> -
+
<%= t('view') %> @@ -115,12 +114,12 @@ <% end %>
<% else %> -
+
<% if is_submission_completed %> <% latest_submitter = submitters.select(&:completed_at?).max_by(&:completed_at) %> - + <%= t(latest_submitter.status) %> @@ -131,23 +130,24 @@
<% end %> -
+
<% submitters.each_with_index do |submitter, index| %> -
- +
+ <% if !is_submission_completed && !submission.expired? %> - - - <%= t(submitter.status) %> + + + <%= svg_icon(SubmissionsController::STATUS_ICONS[submitter.status], class: 'w-4 h-4 md:hidden') %> + <% end %> - - + + <%= submitter.name || submitter.email || submitter.phone %> <% if !submitter.completed_at? && !submission.completed_at? && can?(:update, submission) && !submitter.start_form_submission_events.any? && !submission.archived_at? && !submission.expired? && !submitter.declined_at? %> - + <%= link_to edit_submitter_path(submitter), class: 'shrink-0', data: { turbo_frame: 'modal' } do %> <%= svg_icon('pencil', class: 'w-5 h-5') %> @@ -158,29 +158,27 @@ <% if submitter.completed_at? && !is_submission_completed %> - + <%= svg_icon('download', class: 'w-4 h-4 stroke-2') %> - <%= t('download') %> + <% elsif !template&.archived_at? && !submission.archived_at? && !is_submission_completed && !submission.expired? && !submitter.declined_at? %> -
+
<% if current_user.email == submitter.email %> - + - <% if t('sign_now').length < 12 %> - <%= svg_icon('writing_sign', class: 'w-4 h-4 stroke-2') %> - <% end %> - <%= t('sign_now') %> + <%= svg_icon('writing_sign', class: "w-4 h-4 stroke-2 #{'md:hidden' if t('sign_now').length >= 12}") %> + <% else %> - <%= render 'shared/clipboard_copy', text: submit_form_url(slug: submitter.slug, host: form_link_host), class: 'absolute md:relative top-0 right-0 btn btn-xs text-xs btn-neutral text-white w-28 md:w-36 flex z-[1]', icon_class: 'w-4 h-4 text-white', copy_title: t('copy_link'), copy_title_md: t('copy_link').length < 10 ? t('copy_link') : t('copy'), copied_title_md: t('copied') %> + <%= render 'shared/clipboard_copy', text: submit_form_url(slug: submitter.slug, host: form_link_host), class: 'relative btn btn-xs text-xs btn-neutral text-white w-12 md:w-36 flex z-[1]', icon_class: 'w-4 h-4 text-white', copy_title: t('copy_link') %> <% end %>
<% end %> @@ -189,10 +187,10 @@
-
+
<% if is_submission_completed %> <% latest_submitter = submitters.select(&:completed_at?).max_by(&:completed_at) %> -
+
@@ -206,8 +204,19 @@
+ <% elsif !template&.archived_at? && !submission.archived_at? && !submission.expired? && (sign_now_submitter = submitters.find { |item| !item.completed_at? && !item.declined_at? && current_user.email == item.email }) %> + <% end %> -