resolving redacting for submission view issue,

show my_text prefill on submitter pdf download and view
pull/150/merge^2
iozeey 2 years ago
parent 5e532764fc
commit 1bfb35f560

@ -20,7 +20,7 @@ class SubmissionsPreviewController < ApplicationController
if total_pages < PRELOAD_ALL_PAGES_AMOUNT
ActiveRecord::Associations::Preloader.new(
records: @submission.template_schema_documents,
associations: [:blob, { preview_images_attachments: :blob }]
associations: [:blob, { preview_secured_images_attachments: :blob }]
).call
end

@ -26,11 +26,11 @@
<div
v-else-if="field.type === 'my_text'"
class="flex absolute"
:style="{ ...computedStyle, backgroundColor: 'white' }"
:class="{ 'cursor-default ': !submittable, 'border ': submittable, 'z-0 ': isActive && submittable, 'bg-opacity-100 ': (isActive || isValueSet) && submittable }"
:style="{ ...computedStyle, backgroundColor: 'transparent' }"
:class="{ 'cursor-default ': !submittable, 'z-0 ': isActive && submittable, 'bg-opacity-100 ': (isActive || isValueSet) && submittable }"
>
<span
style="border-width: 2px; --tw-bg-opacity: 1; --tw-border-opacity: 0.2;"
style="border-width: 2px; --tw-bg-opacity: 1; --tw-border-opacity: 0.2; font-size: 1.4rem"
class="!text-2xl w-full h-full"
v-text="showLocalText"
/>

@ -116,13 +116,13 @@
<div
v-else-if="field.type === 'my_text'"
class="flex items-center justify-center h-full w-full"
style="background-color: rgb(185, 185, 185);"
style="background-color: transparent;"
>
<textarea
:id="field.uuid"
ref="textarea"
:value="myLocalText"
style="border-width: 2px; --tw-bg-opacity: 1; --tw-border-opacity: 0.2;"
style="border-width: 2px; --tw-bg-opacity: 1; --tw-border-opacity: 0.2; background-color: transparent;"
class="!text-2xl w-full h-full"
:placeholder="`type here`"
:name="`values[${field.uuid}]`"

@ -34,7 +34,11 @@
<div class="flex items-center px-0.5">
<%= l(Date.parse(value), format: :long, locale: local_assigns[:locale]) %>
</div>
<% elsif field['type'] == 'redact' %>
<div class="flex absolute" style="width: 100%; height: 100%;" :style="{ backgroundColor: 'black' }"></div>
<% elsif field['type'] == 'my_text' %>
<div style="letter-spacing: 1.1px; padding-bottom: 1.1px; font-size: 1.4rem;" class="flex items-center px-0.5 whitespace-pre-wrap"><%= Array.wrap(value).join(', ') %></div>
<% else %>
<div class="flex items-center px-0.5 whitespace-pre-wrap"><%= Array.wrap(value).join(', ') %></div>
<div style="letter-spacing: 1.1px; padding-bottom: 1.1px;" class="flex items-center px-0.5 whitespace-pre-wrap"><%= Array.wrap(value).join(', ') %></div>
<% end %>
</div>

@ -59,7 +59,11 @@
<%= render 'submissions/annotation', annot: %>
<% end %>
<% fields_index.dig(document.uuid, index)&.each do |(area, field)| %>
<% value = values[field['uuid']] %>
<% if ['my_text'].include?(field['type']) %>
<% value = @submission.template.values[field['uuid']] %>
<% else %>
<% value = values[field['uuid']] %>
<% end %>
<% next if value.blank? %>
<%= render 'submissions/value', area:, field:, attachments_index:, value:, locale: @submission.template.account.locale %>
<% end %>

@ -6,6 +6,7 @@
<p>Alternatively, you can review and download your copy using:</p>
<p>
<%= link_to @submitter.template.name, submissions_preview_url(@submitter.submission.slug) %>
<%# link_to @submitter.template.name, submitter_download_index_path(@submitter.submission.slug), download: true %>
</p>
<p>
Thanks,<br><%= @current_account.name %>

@ -33,8 +33,9 @@ module Submissions
pdfs_index = build_pdfs_index(submitter)
submitter.submission.template_fields.each do |field|
next if field['submitter_uuid'] != submitter.uuid
unless ['my_text'].include?(field['type'])
next if field['submitter_uuid'] != submitter.uuid
end
field.fetch('areas', []).each do |area|
pdf = pdfs_index[area['attachment_uuid']]
@ -50,7 +51,7 @@ module Submissions
layouter = HexaPDF::Layout::TextLayouter.new(valign: :center, font: pdf.fonts.add(FONT_NAME), font_size:)
value = submitter.values[field['uuid']]
value = submitter.values[field['uuid']] || template.values[field['uuid']]
if !field['type']=='redact'
next if Array.wrap(value).compact_blank.blank?
@ -166,6 +167,24 @@ module Submissions
canvas.fill_color(0, 0, 0) # Set fill color to black
canvas.rectangle(x, y, w, h)
canvas.fill
when 'my_text'
x = area['x'] * width
y = height - (area['y'] * height) - (area['h'] * height)
w = area['w'] * width * 1.01
h = area['h'] * height
font_size_my_text = (font_size / 0.75).to_i
layouter_my_text = HexaPDF::Layout::TextLayouter.new(valign: :top, font: pdf.fonts.add(FONT_NAME), font_size: font_size_my_text)
value_my_text = submitter.values[field['uuid']] || template.values[field['uuid']]
text_my_text = HexaPDF::Layout::TextFragment.create(Array.wrap(value_my_text).join(', '), font: pdf.fonts.add(FONT_NAME), font_size: font_size_my_text)
lines_my_text = layouter_my_text.fit([text_my_text], w, h).lines
box_height_my_text = lines_my_text.sum(&:height)
height_diff_my_text = [0, box_height_my_text - h].max
layouter_my_text.fit([text_my_text], w, height_diff_my_text.positive? ? box_height_my_text : h)
.draw(canvas, x + TEXT_LEFT_MARGIN, y - height_diff_my_text + 17)
else
value = I18n.l(Date.parse(value), format: :default, locale: account.locale) if field['type'] == 'date'

Loading…
Cancel
Save