store multiple submitter results
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
You have been invited to submit template <%= @template.name %>
|
||||
<%= form_for @submission, url: start_form_path(@template.slug), data: { turbo_frame: :_top }, method: :put do |f| %>
|
||||
<%= form_for @submitter, url: start_form_path(@template.slug), data: { turbo_frame: :_top }, method: :put do |f| %>
|
||||
Provide youe email to start
|
||||
<div>
|
||||
<%= f.label :email %>
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<p>Hi</a>
|
||||
<%= @submission.values %>
|
||||
<%= link_to 'Download', submission_download_index_url(@submission.slug) %>
|
||||
@@ -4,16 +4,18 @@
|
||||
<%= @template.name %>
|
||||
<%= link_to 'Edit', template_path(@template), class: 'btn btn-outline btn-sm' %>
|
||||
</h2>
|
||||
<div class="join w-full">
|
||||
<buttun class="btn bg-neutral btn-disabled text-white join-item">
|
||||
Share link
|
||||
</buttun>
|
||||
<input id="share-link-input" autocomplete="off" type="text" class="input input-bordered w-full join-item" value="<%= start_form_url(slug: @template.slug) %>" disabled>
|
||||
<clipboard-copy class="btn btn-neutral btn-square join-item text-white font-bold swap swap-active" for="share-link-input">
|
||||
<%= svg_icon('clipboard', class: 'w-6 h-6 swap-on text-white') %>
|
||||
<%= svg_icon('clipboard_copy', class: 'w-6 h-6 swap-off text-white') %>
|
||||
</clipboard-copy>
|
||||
</div>
|
||||
<% if @template.submitters.size == 1 %>
|
||||
<div class="join w-full">
|
||||
<buttun class="btn bg-neutral btn-disabled text-white join-item">
|
||||
Share link
|
||||
</buttun>
|
||||
<input id="share-link-input" autocomplete="off" type="text" class="input input-bordered w-full join-item" value="<%= start_form_url(slug: @template.slug) %>" disabled>
|
||||
<clipboard-copy class="btn btn-neutral btn-square join-item text-white font-bold swap swap-active" for="share-link-input">
|
||||
<%= svg_icon('clipboard', class: 'w-6 h-6 swap-on text-white') %>
|
||||
<%= svg_icon('clipboard_copy', class: 'w-6 h-6 swap-off text-white') %>
|
||||
</clipboard-copy>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between mb-4">
|
||||
@@ -42,15 +44,22 @@
|
||||
<% @submissions.each do |submission| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= submission.email %>
|
||||
<% submission.submitters.each do |submitter| %>
|
||||
<%= submitter.email %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge badge-info badge-outline">
|
||||
<%= submission.status.humanize %>
|
||||
</span>
|
||||
<% submission.submitters.each do |submitter| %>
|
||||
<div>
|
||||
<span class="badge badge-info badge-outline">
|
||||
<%= submitter.status %>
|
||||
</span>
|
||||
<%= link_to 'Copy', submit_form_url(slug: submitter.slug), title: 'Copy', class: 'btn btn-outline btn-xs' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="flex items-center space-x-2 justify-end">
|
||||
<%= link_to 'View', submission_path(@template), title: 'View', class: 'btn btn-outline btn-xs' %>
|
||||
<%= link_to 'View', submission_path(submission), title: 'View', class: 'btn btn-outline btn-xs' %>
|
||||
<%= button_to 'Remove', submission_path(submission), class: 'btn btn-outline btn-error btn-xs', title: 'Delete', method: :delete, data: { turbo_confirm: 'Are you sure?' } %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,9 +1,41 @@
|
||||
<%= render 'shared/turbo_modal', title: 'New Recepients' do %>
|
||||
<%= form_for '', url: template_submissions_path(@template), html: { class: 'space-y-4' }, data: { turbo_frame: :_top } do |f| %>
|
||||
<div class="form-control">
|
||||
<%= f.label :emails, class: 'label' %>
|
||||
<%= f.text_area :emails, required: true, class: 'base-textarea' %>
|
||||
</div>
|
||||
<% if @template.submitters.size == 1 %>
|
||||
<div class="form-control">
|
||||
<%= f.label :emails, class: 'label' %>
|
||||
<%= f.text_area :emails, required: true, class: 'base-textarea' %>
|
||||
</div>
|
||||
<% else %>
|
||||
<table class="">
|
||||
<thead>
|
||||
<tr>
|
||||
<% @template.submitters.each do |item| %>
|
||||
<th class="w-1/2 text-left">
|
||||
<%= item['name'] %>
|
||||
</th>
|
||||
<% end %>
|
||||
<th>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<% @template.submitters.each do |item| %>
|
||||
<td>
|
||||
<input type="hidden" name="submission[][submitters][][uuid]" value="<%= item['uuid'] %>" >
|
||||
<input type="email" name="submission[][submitters][][email]" value="<%= item['email'] %>" required>
|
||||
</td>
|
||||
<% end %>
|
||||
<td>
|
||||
×
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<button>
|
||||
+ Add new
|
||||
</button>
|
||||
<% end %>
|
||||
<div class="form-control">
|
||||
<%= f.label :send_email, class: 'flex items-center cursor-pointer' do %>
|
||||
<%= f.check_box :send_email, class: 'base-checkbox', onchange: "message_field.classList.toggle('hidden', !event.currentTarget.checked)" %>
|
||||
@@ -12,23 +44,18 @@
|
||||
</div>
|
||||
<div id="message_field" class="card card-compact bg-base-200 hidden">
|
||||
<div class="card-body">
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<span class="label-text">Hi There,</span>
|
||||
</label>
|
||||
<%= f.text_area :message, value: SubmissionMailer::DEFAULT_MESSAGE, required: true, class: 'base-textarea !rounded-lg' %>
|
||||
<label class="label">
|
||||
<span class="label-text">
|
||||
Thanks,
|
||||
</br>
|
||||
<%= current_account.name %>
|
||||
</span>
|
||||
</label>
|
||||
<div class="form-control space-y-2">
|
||||
<span class="label-text">Hi there,</span>
|
||||
<%= f.text_area :message, value: SubmitterMailer::DEFAULT_MESSAGE, required: true, class: 'base-textarea !rounded-lg' %>
|
||||
<span class="label-text">
|
||||
Thanks,
|
||||
</br>
|
||||
<%= current_account.name %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-control">
|
||||
<%= f.button button_title(title: 'Confirm', disabled_with: 'Processing'), class: 'base-button' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="form-control">
|
||||
<%= f.button button_title(title: 'Confirm', disabled_with: 'Processing'), class: 'base-button' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -12,18 +12,6 @@
|
||||
<%= link_to @submission.template.name, template_submissions_path(@submission.template), class: 'link link-hover' %>
|
||||
</dd>
|
||||
</div>
|
||||
<div class="py-6 sm:grid sm:grid-cols-3 sm:gap-4">
|
||||
<dt class="text-sm font-medium leading-6 text-gray-900">URL</dt>
|
||||
<dd class="mt-1 text-sm leading-6 text-gray-700 sm:col-span-2 sm:mt-0">
|
||||
<%= link_to submit_form_url(slug: @submission.slug), submit_form_url(slug: @submission.slug), class: 'link link-hover' %>
|
||||
</dd>
|
||||
</div>
|
||||
<div class="py-6 sm:grid sm:grid-cols-3 sm:gap-4">
|
||||
<dt class="text-sm font-medium leading-6 text-gray-900">Email address</dt>
|
||||
<dd class="mt-1 text-sm leading-6 text-gray-700 sm:col-span-2 sm:mt-0">
|
||||
<%= mail_to @submission.email %>
|
||||
</dd>
|
||||
</div>
|
||||
<%- if @submission.completed_at.present? %>
|
||||
<div class="py-6 sm:grid sm:grid-cols-3 sm:gap-4">
|
||||
<dt class="text-sm font-medium leading-6 text-gray-900">Completed at</dt>
|
||||
@@ -40,35 +28,41 @@
|
||||
<dd class="mt-1 text-sm leading-6 text-gray-700 sm:col-span-2 sm:mt-0">
|
||||
<% if ['image', 'signature'].include?(field['type']) %>
|
||||
<ul role="list" class="divide-y divide-gray-100 rounded-md border border-gray-200">
|
||||
<% Array.wrap(@submission.values[field['uuid']]).each do |uuid| %>
|
||||
<li class="py-4 pl-4 pr-5 text-sm leading-6">
|
||||
<div class="flex w-0 flex-1 items-center">
|
||||
<%= image_tag ActiveStorage::Attachment.find_by(uuid:).url %>
|
||||
</div>
|
||||
</li>
|
||||
<% @submission.submitters.each do |submitter| %>
|
||||
<% Array.wrap(submitter.values[field['uuid']]).each do |uuid| %>
|
||||
<li class="py-4 pl-4 pr-5 text-sm leading-6">
|
||||
<div class="flex w-0 flex-1 items-center">
|
||||
<%= image_tag ActiveStorage::Attachment.find_by(uuid:).url %>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% elsif ['attachment'].include?(field['type']) %>
|
||||
<ul role="list" class="divide-y divide-gray-100 rounded-md border border-gray-200">
|
||||
<% Array.wrap(@submission.values[field['uuid']]).each do |uuid| %>
|
||||
<% attachment = ActiveStorage::Attachment.find_by(uuid:) %>
|
||||
<li class="flex items-center justify-between py-4 pl-4 pr-5 text-sm leading-6">
|
||||
<div class="flex w-0 flex-1 items-center">
|
||||
<%= svg_icon('paperclip', class: 'h-5 w-5 flex-shrink-0 text-gray-300') %>
|
||||
<div class="ml-4 flex min-w-0 flex-1 gap-2">
|
||||
<span class="truncate font-medium">
|
||||
<%= attachment.filename %>
|
||||
</span>
|
||||
<% @submission.submitters.each do |submitter| %>
|
||||
<% Array.wrap(submitter.values[field['uuid']]).each do |uuid| %>
|
||||
<% attachment = ActiveStorage::Attachment.find_by(uuid:) %>
|
||||
<li class="flex items-center justify-between py-4 pl-4 pr-5 text-sm leading-6">
|
||||
<div class="flex w-0 flex-1 items-center">
|
||||
<%= svg_icon('paperclip', class: 'h-5 w-5 flex-shrink-0 text-gray-300') %>
|
||||
<div class="ml-4 flex min-w-0 flex-1 gap-2">
|
||||
<span class="truncate font-medium">
|
||||
<%= attachment.filename %>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ml-4 flex-shrink-0">
|
||||
<%= link_to 'Download', attachment.url, class: "font-medium text-indigo-600 hover:text-indigo-500" %>
|
||||
</div>
|
||||
</li>
|
||||
<div class="ml-4 flex-shrink-0">
|
||||
<%= link_to 'Download', attachment.url, class: "font-medium text-indigo-600 hover:text-indigo-500" %>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% else %>
|
||||
<%= @submission.values[field['uuid']] %>
|
||||
<% @submission.submitters.each do |submitter| %>
|
||||
<%= submitter.values[field['uuid']] %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</dt>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<p>
|
||||
Form completed - thanks!
|
||||
</p>
|
||||
<%= button_to button_title(title: 'Send copy to Email', disabled_with: 'Sending'), send_submission_email_index_path, params: { submission_slug: @submission.slug }, form: { onsubmit: 'event.submitter.disabled = true' } %>
|
||||
<%= button_to button_title(title: 'Download documents', disabled_with: 'Downloading'), submission_download_index_path(@submission.slug), method: :get, form: { onsubmit: 'event.submitter.disabled = true' } %>
|
||||
<%= button_to button_title(title: 'Send copy to Email', disabled_with: 'Sending'), send_submission_email_index_path, params: { submitter_slug: @submitter.slug }, form: { onsubmit: 'event.submitter.disabled = true' } %>
|
||||
<%= button_to button_title(title: 'Download documents', disabled_with: 'Downloading'), submitter_download_index_path(@submitter.slug), method: :get, form: { onsubmit: 'event.submitter.disabled = true' } %>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<% attachment_field_uuids = @submission.template.fields.select { |f| f['type'].in?(%w[image signature attachment]) }.pluck('uuid') %>
|
||||
<% attachments = ActiveStorage::Attachment.where(uuid: @submission.values.values_at(*attachment_field_uuids).flatten).preload(:blob) %>
|
||||
<% attachment_field_uuids = @submitter.submission.template.fields.select { |f| f['type'].in?(%w[image signature attachment]) }.pluck('uuid') %>
|
||||
<% attachments = ActiveStorage::Attachment.where(uuid: @submitter.values.values_at(*attachment_field_uuids).flatten).preload(:blob) %>
|
||||
<div class="mx-auto block" style="max-width: 1000px">
|
||||
<% @submission.template.schema.each do |item| %>
|
||||
<% document = @submission.template.documents.find { |a| a.uuid == item['attachment_uuid'] } %>
|
||||
<% @submitter.submission.template.schema.each do |item| %>
|
||||
<% document = @submitter.submission.template.documents.find { |a| a.uuid == item['attachment_uuid'] } %>
|
||||
<% document.preview_images.sort_by { |a| a.filename.base.to_i }.each_with_index do |page, index| %>
|
||||
<div class="relative">
|
||||
<img src="<%= page.url %>" width="<%= page.metadata['width'] %>" height="<%= page.metadata['height'] %>" loading="lazy">
|
||||
@@ -12,7 +12,7 @@
|
||||
<% end %>
|
||||
<div class="sticky bottom-8 w-full">
|
||||
<div class="bg-white mx-8 md:mx-32 border p-4 rounded">
|
||||
<submission-form data-submission-slug="<%= @submission.slug %>" data-attachments="<%= attachments.to_json(only: %i[uuid], methods: %i[url filename content_type]) %>" data-fields="<%= @submission.template.fields.to_json %>" data-values="<%= @submission.values.to_json %>" data-authenticity-token="<%= form_authenticity_token %>"></submission-form>
|
||||
<submission-form data-submitter-uuid="<%= @submitter.uuid %>" data-submitter-slug="<%= @submitter.slug %>" data-attachments="<%= attachments.to_json(only: %i[uuid], methods: %i[url filename content_type]) %>" data-fields="<%= @submitter.submission.template.fields.to_json %>" data-values="<%= @submitter.values.to_json %>" data-authenticity-token="<%= form_authenticity_token %>"></submission-form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<p>Hi</a>
|
||||
<%= @submitter.values %>
|
||||
<%= link_to 'Download', submitter_download_index_url(@submitter.slug) %>
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
<p>Hi there</p>
|
||||
<p>Hi there,</p>
|
||||
<p>You have been invited to submit a form:</p>
|
||||
<p><%= link_to 'Submit', submit_form_index_url(slug: @submission.slug) %></p>
|
||||
<p><%= link_to 'Submit', submit_form_url(slug: @submitter.slug) %></p>
|
||||
<p>If you didn't request this, please ignore this email.</p>
|
||||
Reference in New Issue
Block a user