diff --git a/.erb-lint.yml b/.erb_lint.yml similarity index 100% rename from .erb-lint.yml rename to .erb_lint.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55d7a256..1a28aa8e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,7 @@ jobs: bundle config path vendor/bundle bundle install --jobs 4 --retry 4 - name: Run Erblint - run: bundle exec erblint ./app + run: bundle exec erb_lint ./app eslint: name: ESLint diff --git a/Gemfile.lock b/Gemfile.lock index da75225a..de6e71b3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -327,7 +327,7 @@ GEM mysql2 (0.5.6) net-http-persistent (4.0.5) connection_pool (~> 2.2) - net-imap (0.5.3) + net-imap (0.5.6) date net-protocol net-pop (0.1.2) @@ -386,7 +386,7 @@ GEM puma (6.5.0) nio4r (~> 2.0) racc (1.8.1) - rack (3.1.8) + rack (3.1.10) rack-proxy (0.7.7) rack rack-session (2.0.0) diff --git a/app/controllers/submission_events_controller.rb b/app/controllers/submission_events_controller.rb new file mode 100644 index 00000000..9dbd57ed --- /dev/null +++ b/app/controllers/submission_events_controller.rb @@ -0,0 +1,25 @@ +# 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 + + def index; end +end diff --git a/app/views/icons/_2fa.html.erb b/app/views/icons/_2fa.html.erb new file mode 100644 index 00000000..5dfebef1 --- /dev/null +++ b/app/views/icons/_2fa.html.erb @@ -0,0 +1,6 @@ + + + + + + diff --git a/app/views/icons/_circle_dot.html.erb b/app/views/icons/_circle_dot.html.erb new file mode 100644 index 00000000..b6b36b41 --- /dev/null +++ b/app/views/icons/_circle_dot.html.erb @@ -0,0 +1,5 @@ + + + + + diff --git a/app/views/icons/_hand_click.html.erb b/app/views/icons/_hand_click.html.erb new file mode 100644 index 00000000..016556b9 --- /dev/null +++ b/app/views/icons/_hand_click.html.erb @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/app/views/icons/_logs.html.erb b/app/views/icons/_logs.html.erb new file mode 100644 index 00000000..88ecf439 --- /dev/null +++ b/app/views/icons/_logs.html.erb @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/app/views/icons/_phone_check.html.erb b/app/views/icons/_phone_check.html.erb new file mode 100644 index 00000000..8b57c41e --- /dev/null +++ b/app/views/icons/_phone_check.html.erb @@ -0,0 +1,4 @@ + + + + diff --git a/app/views/icons/_player_play.html.erb b/app/views/icons/_player_play.html.erb new file mode 100644 index 00000000..947124b3 --- /dev/null +++ b/app/views/icons/_player_play.html.erb @@ -0,0 +1,3 @@ + + + diff --git a/app/views/submission_events/index.html.erb b/app/views/submission_events/index.html.erb new file mode 100644 index 00000000..4b318cfb --- /dev/null +++ b/app/views/submission_events/index.html.erb @@ -0,0 +1,49 @@ +<% event_colors = %w[bg-red-200 bg-sky-200 bg-emerald-200 bg-yellow-200 bg-purple-200 bg-pink-200 bg-cyan-200 bg-orange-200 bg-lime-200 bg-indigo-200] %> +<% submitters_uuids = (@submission.template_submitters || @submission.template.submitters).pluck('uuid') %> +<%= render 'shared/turbo_modal_large', title: t('event_log') do %> +
+
    +
  1. + + <%= svg_icon('file_text', class: 'w-4 h-4') %> + +

    + <%= l(@submission.created_at.in_time_zone(current_account.timezone), format: :long, locale: current_account.locale) %> +

    +

    + <% if @submission.source == 'invite' %> + <%= t('submission_created_by_email_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 %> +

    +
  2. + <% @submission.submission_events.order(:event_timestamp).each do |event| %> + <% submitter = @submission.submitters.find { |e| e.id == event.submitter_id } %> + <% bg_class = event_colors[submitters_uuids.index(submitter.uuid) % event_colors.length] %> + <% submitter_name = event.event_type.include?('sms') || event.event_type.include?('phone') ? (event.data['phone'] || submitter.phone) : (submitter.name || submitter.email || submitter.phone) %> +
  3. + + <%= svg_icon(SubmissionEventsController::SUBMISSION_EVENT_ICONS.fetch(event.event_type, 'circle_dot'), class: 'w-4 h-4') %> + +

    + <%= l(event.event_timestamp.in_time_zone(current_account.timezone), format: :long, locale: current_account.locale) %> +

    +

    + <% if event.event_type == 'complete_verification' %> + <%= t('submission_event_names.complete_verification_by_html', provider: event.data['method'], submitter_name:) %> + <% elsif event.event_type == 'invite_party' && (invited_submitter = @submission.submitters.find { |e| e.uuid == event.data['uuid'] }) && (name = @submission.template_submitters.find { |e| e['uuid'] == event.data['uuid'] }&.dig('name')) %> + <%= t('submission_event_names.invite_party_by_html', invited_submitter_name: [invited_submitter.name || invited_submitter.email || invited_submitter.phone, name].join(' '), submitter_name:) %> + <% elsif event.event_type.include?('send_') %> + <%= t("submission_event_names.#{event.event_type}_to_html", submitter_name:) %> + <% else %> + <%= t("submission_event_names.#{event.event_type}_by_html", submitter_name:) %> + <% end %> +

    +
  4. + <% end %> +
+
+<% end %> diff --git a/app/views/submissions/_send_email.html.erb b/app/views/submissions/_send_email.html.erb index ae6f9bc1..43617218 100644 --- a/app/views/submissions/_send_email.html.erb +++ b/app/views/submissions/_send_email.html.erb @@ -37,13 +37,13 @@ <% config = AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY) %>