Skip to content

Commit

Permalink
Added attachment related code
Browse files Browse the repository at this point in the history
  • Loading branch information
edwin-jebaraj committed Jan 8, 2025
1 parent c2cd3fa commit e627c28
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
12 changes: 12 additions & 0 deletions app/controllers/support/cases/email_evaluators_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
module Support
class Cases::EmailEvaluatorsController < Cases::ApplicationController
helper_method :back_to_url_b64

content_security_policy do |policy|
policy.style_src_attr :unsafe_inline
end

before_action :set_current_case
before_action :set_email_addresses
before_action :set_documents
Expand Down Expand Up @@ -36,6 +42,12 @@ def update
end
end

def back_to_url_b64
return Base64.encode64(edit_support_case_message_thread_path(case_id: current_case.id, id: params[:id])) if action_name == "submit"

current_url_b64
end

private

def set_current_case
Expand Down
27 changes: 25 additions & 2 deletions app/views/support/cases/email_evaluators/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
<%= form_with model: @email_evaluators, scope: :email_evaluators, url: support_case_email_evaluators_path(@current_case, id: @support_email_id), method: :patch do |form| %>
<% unique_id = "A#{SecureRandom.uuid}" %>
<% turbo_frame = "messages-frame" %>
<%= form_with model: @email_evaluators, scope: :email_evaluators, url: support_case_email_evaluators_path(@current_case, id: @support_email_id), method: :patch,
html: {
"data-controller" => "draft-email",
"data-draft-email-list-attachments-endpoint-value" => attachments_messages_path(message_id: @support_email_id),
"data-draft-email-upload-attachments-endpoint-value" => attachments_messages_path(message_id: @support_email_id),
"data-draft-email-remove-attachments-endpoint-value" => attachments_remove_messages_path(message_id: @support_email_id),
"data-draft-email-update-endpoint-value" => messages_path(message_id: @support_email_id, unique_id: unique_id),
"data-draft-email-target" => "form"
} do |form| %>

<%= render "email_list" %>
<%= render "document_list"%>
Expand All @@ -15,8 +25,21 @@
<%= form.hidden_field :id, value: @support_email_id %>

<div class="govuk-button-group flex-align-center">
<%= form.submit I18n.t("support.cases.email_evaluators.submit"), class: "govuk-button" %>
<%= form.submit I18n.t("support.cases.email_evaluators.submit"), class: "govuk-button" , "data-prevent-double-click" => true, "data-draft-email-target" => "btnSubmit" %>
<%= link_to I18n.t("generic.button.cancel"), @back_url, class: "govuk-link govuk-link--no-visited-state" %>
</div>

<h2 class="govuk-heading-s govuk-!-margin-bottom-2 govuk-!-display-none"><%= I18n.t("support.emails.attachments.attach_files") %></h2>
<ul class="govuk-list govuk-!-display-none">
<li><%= govuk_link_to I18n.t("support.emails.attachments.email_attachments"), attach_email_attachments_path(message_id: @support_email_id, back_to: back_to_url_b64, turbo_frame: turbo_frame), no_visited_state: true, "data-draft-email-target": "emailAttachmentsLink" %></li>
<li><%= govuk_link_to I18n.t("support.emails.attachments.case_files"), attach_case_files_path(message_id: @support_email_id, back_to: back_to_url_b64, turbo_frame: turbo_frame), no_visited_state: true, "data-draft-email-target": "caseFilesLink" %></li>
<li>
<span class="fake-link" role="link" data-draft-email-target="btnDisplayFileDialog">
<%= I18n.t("support.emails.attachments.files_from_your_computer") %>
</span>
</li>
</ul>

<%= render "components/draft_email_attachments" %>

<% end %>

0 comments on commit e627c28

Please sign in to comment.