mirror of https://github.com/docusealco/docuseal
parent
a315674421
commit
e406620044
@ -0,0 +1,64 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class SubmissionEventsController < ApplicationController
|
||||||
|
SUBMISSION_EVENT_ICONS = {
|
||||||
|
'view_form' => 'eye',
|
||||||
|
'start_form' => 'player_play',
|
||||||
|
'complete_form' => 'check',
|
||||||
|
'send_email' => 'mail_forward',
|
||||||
|
'click_email' => 'hand_click',
|
||||||
|
'api_complete_form' => 'check',
|
||||||
|
'send_reminder_email' => 'mail_forward',
|
||||||
|
'send_2fa_sms' => '2fa',
|
||||||
|
'send_sms' => 'send',
|
||||||
|
'phone_verified' => 'phone_check',
|
||||||
|
'click_sms' => 'hand_click',
|
||||||
|
'decline_form' => 'x',
|
||||||
|
'start_verification' => 'player_play',
|
||||||
|
'complete_verification' => 'check',
|
||||||
|
'invite_party' => 'user_plus'
|
||||||
|
}.freeze
|
||||||
|
|
||||||
|
load_and_authorize_resource :submission
|
||||||
|
|
||||||
|
# rubocop:disable Metrics
|
||||||
|
def index
|
||||||
|
submitters = @submission.submitters
|
||||||
|
submitters_uuids = (@submission.template_submitters || @submission.template.submitters).pluck('uuid')
|
||||||
|
|
||||||
|
@events_data = @submission.submission_events.sort_by(&:event_timestamp).map do |event|
|
||||||
|
submitter = submitters.find { |e| e.id == event.submitter_id }
|
||||||
|
submitter_name =
|
||||||
|
if event.event_type.include?('sms') || event.event_type.include?('phone')
|
||||||
|
event.data['phone'] || submitter.phone
|
||||||
|
else
|
||||||
|
submitter.name || submitter.email || submitter.phone
|
||||||
|
end
|
||||||
|
|
||||||
|
text =
|
||||||
|
if event.event_type == 'complete_verification'
|
||||||
|
helpers.t('submission_event_names.complete_verification_by_html', provider: event.data['method'],
|
||||||
|
submitter_name:)
|
||||||
|
elsif event.event_type == 'invite_party' &&
|
||||||
|
(invited_submitter = submitters.find { |e| e.uuid == event.data['uuid'] }) &&
|
||||||
|
(name = submission.template_submitters.find { |e| e['uuid'] == event.data['uuid'] }&.dig('name'))
|
||||||
|
invited_submitter_name = [invited_submitter.name || invited_submitter.email || invited_submitter.phone,
|
||||||
|
name].join(' ')
|
||||||
|
helpers.t('submission_event_names.invite_party_by_html', invited_submitter_name:,
|
||||||
|
submitter_name:)
|
||||||
|
elsif event.event_type.include?('send_')
|
||||||
|
helpers.t("submission_event_names.#{event.event_type}_to_html", submitter_name:)
|
||||||
|
else
|
||||||
|
helpers.t("submission_event_names.#{event.event_type}_by_html", submitter_name:)
|
||||||
|
end
|
||||||
|
|
||||||
|
{
|
||||||
|
timestamp: event.event_timestamp.in_time_zone(current_account.timezone),
|
||||||
|
event_type: event.event_type,
|
||||||
|
submitter_index: submitters_uuids.index(submitter.uuid),
|
||||||
|
text:
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# rubocop:enable Metrics
|
||||||
|
end
|
||||||
|
After Width: | Height: | Size: 426 B |
|
After Width: | Height: | Size: 397 B |
|
After Width: | Height: | Size: 711 B |
|
After Width: | Height: | Size: 484 B |
|
After Width: | Height: | Size: 382 B |
|
After Width: | Height: | Size: 261 B |
@ -0,0 +1,38 @@
|
|||||||
|
<% event_colors = %w[bg-red-200 bg-sky-200 bg-emerald-200 bg-yellow-300 bg-purple-200 bg-pink-200 bg-cyan-200 bg-orange-200 bg-lime-200 bg-indigo-200] %>
|
||||||
|
<%= render 'shared/turbo_modal_large', title: t('event_log') do %>
|
||||||
|
<div class="pl-8 pr-4 py-4">
|
||||||
|
<ol class="relative border-s border-neutral-300 space-y-10">
|
||||||
|
<li class="ml-6">
|
||||||
|
<span class="absolute flex items-center justify-center w-6 h-6 rounded-full -start-3 ring-8 ring-base-100 text-base-content bg-gray-200">
|
||||||
|
<%= svg_icon('file_text', class: 'w-3.5 h-3.5') %>
|
||||||
|
</span>
|
||||||
|
<p class="text-sm leading-none text-base-content/60 pt-1">
|
||||||
|
<%= l(@submission.created_at.in_time_zone(current_account.timezone), format: :long, locale: current_account.locale) %>
|
||||||
|
</p>
|
||||||
|
<p class="text-base-content/80 mt-2">
|
||||||
|
<% if @submission.source == 'invite' %>
|
||||||
|
<%= t('submission_created_by_email_invite_html', email: @submission.created_by_user.email) %>
|
||||||
|
<% elsif @submission.created_by_user %>
|
||||||
|
<%= t('submission_created_by_email_via_source_html', email: @submission.created_by_user.email, source: t("submission_sources.#{@submission.source}")) %>
|
||||||
|
<% else %>
|
||||||
|
<%= t('submission_created_via_source_html', source: t("submission_sources.#{@submission.source}")) %>
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
<% @events_data.each do |row| %>
|
||||||
|
<% bg_class = event_colors[row[:submitter_index] % event_colors.length] %>
|
||||||
|
<li class="ml-6">
|
||||||
|
<span class="absolute flex items-center justify-center w-6 h-6 rounded-full -start-3 ring-8 ring-base-100 text-base-content <%= bg_class %>">
|
||||||
|
<%= svg_icon(SubmissionEventsController::SUBMISSION_EVENT_ICONS.fetch(row[:event_type], 'circle_dot'), class: 'w-3.5 h-3.5') %>
|
||||||
|
</span>
|
||||||
|
<p class="text-sm leading-none text-base-content/60 pt-1">
|
||||||
|
<%= l(row[:timestamp], format: :long, locale: current_account.locale) %>
|
||||||
|
</p>
|
||||||
|
<p class="text-base-content/80 mt-2">
|
||||||
|
<%= row[:text] %>
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
Loading…
Reference in new issue