Show prefill date in pdf and view

pull/150/merge^2
iozeey 2 years ago
parent ae570b3e31
commit fece0825f8

@ -48,7 +48,7 @@
class="!text-2xl w-full h-full" class="!text-2xl w-full h-full"
> >
{{ getFormattedDate }} {{ getFormattedDate }}
</span> </span>
</div> </div>
<!-- show mySignature prefill with stored value --> <!-- show mySignature prefill with stored value -->
@ -300,8 +300,7 @@ export default {
data () { data () {
return { return {
textOverflowChars: 0, textOverflowChars: 0,
showLocalText: '', showLocalText: ''
showLocalDate: ''
} }
}, },
computed: { computed: {
@ -393,9 +392,8 @@ export default {
} }
}, },
getFormattedDate () { getFormattedDate () {
if (this.field.type === 'my_date' && this.showLocalDate) { if (this.field.type === 'my_date' && this.templateValues[this.field.uuid]) {
console.log('date returned ___-----', new Intl.DateTimeFormat([], { year: 'numeric', month: 'long', day: 'numeric', timeZone: 'UTC' }).format(new Date(this.showLocalDate))) return new Intl.DateTimeFormat([], { year: 'numeric', month: 'long', day: 'numeric', timeZone: 'UTC' }).format(new Date(this.templateValues[this.field.uuid]))
return new Intl.DateTimeFormat([], { year: 'numeric', month: 'long', day: 'numeric', timeZone: 'UTC' }).format(new Date(this.showLocalDate))
} else { } else {
return '' return ''
} }
@ -435,15 +433,6 @@ export default {
} }
} }
if (this.field.type === 'my_date') {
const fieldUuid = this.field.uuid
if (this.templateValues && this.templateValues[fieldUuid]) {
this.showLocalDate = this.templateValues[fieldUuid]
} else {
this.showLocalDate = ''
}
}
if (this.field.type === 'text' && this.$refs.textContainer) { if (this.field.type === 'text' && this.$refs.textContainer) {
this.$nextTick(() => { this.$nextTick(() => {
this.textOverflowChars = this.$refs.textContainer.scrollHeight > this.$refs.textContainer.clientHeight ? this.modelValue.length : 0 this.textOverflowChars = this.$refs.textContainer.scrollHeight > this.$refs.textContainer.clientHeight ? this.modelValue.length : 0

@ -66,7 +66,7 @@
@focus="$refs.areas.scrollIntoField(currentField)" @focus="$refs.areas.scrollIntoField(currentField)"
/> />
</div> </div>
<div v-if="['my_text', 'my_signature', 'my_initials'].includes(currentField.type)"> <div v-if="['my_text', 'my_signature', 'my_initials', 'my_date'].includes(currentField.type)">
<!-- do nothing on this side just chill for now --> <!-- do nothing on this side just chill for now -->
</div> </div>
<DateStep <DateStep
@ -692,7 +692,7 @@ export default {
stepPromise().then(async () => { stepPromise().then(async () => {
const emptyRequiredField = this.stepFields.find((fields, index) => { const emptyRequiredField = this.stepFields.find((fields, index) => {
if (['redact', 'my_text', 'my_signature', 'my_initials'].includes(fields[0].type)) { if (['redact', 'my_text', 'my_signature', 'my_initials', 'my_date'].includes(fields[0].type)) {
fields[0].required = 'false' fields[0].required = 'false'
return false return false
} else { } else {

@ -39,7 +39,7 @@
@pointerdown.stop @pointerdown.stop
> >
<FieldSubmitter <FieldSubmitter
v-if="!['my_text', 'my_signature', 'my_initials'].includes(field.type)" v-if="!['my_text', 'my_signature', 'my_initials', 'my_date'].includes(field.type)"
v-model="field.submitter_uuid" v-model="field.submitter_uuid"
class="border-r" class="border-r"
:compact="true" :compact="true"
@ -50,7 +50,7 @@
@click="selectedAreaRef.value = area" @click="selectedAreaRef.value = area"
/> />
<FieldType <FieldType
v-if="!['my_text', 'my_signature', 'my_initials'].includes(field.type)" v-if="!['my_text', 'my_signature', 'my_initials', 'my_date'].includes(field.type)"
v-model="field.type" v-model="field.type"
:button-width="27" :button-width="27"
:editable="editable" :editable="editable"
@ -70,7 +70,7 @@
@blur="onNameBlur" @blur="onNameBlur"
>{{ optionIndexText }} {{ field.name || defaultName }}</span> >{{ optionIndexText }} {{ field.name || defaultName }}</span>
<div <div
v-if="isNameFocus && !['checkbox', 'phone', 'redact', 'my_text', 'my_signature', 'my_initials'].includes(field.type)" v-if="isNameFocus && !['checkbox', 'phone', 'redact', 'my_text', 'my_signature', 'my_initials', 'my_date'].includes(field.type)"
class="flex items-center ml-1.5" class="flex items-center ml-1.5"
> >
<input <input

@ -453,7 +453,7 @@ export default {
submitter_uuid: this.selectedSubmitter.uuid, submitter_uuid: this.selectedSubmitter.uuid,
type type
} }
if (['redact', 'my_text', 'my_signature', 'my_initials'].includes(type)) { if (['redact', 'my_text', 'my_signature', 'my_initials', 'my_date'].includes(type)) {
field.required = 'false' field.required = 'false'
} }
if (['select', 'multiple', 'radio'].includes(type)) { if (['select', 'multiple', 'radio'].includes(type)) {
@ -631,7 +631,7 @@ export default {
...this.dragField ...this.dragField
} }
if (['redact', 'my_text', 'my_signature', 'my_initials'].includes(field.type)) { if (['redact', 'my_text', 'my_signature', 'my_initials', 'my_date'].includes(field.type)) {
field.required = 'false' field.required = 'false'
} }
if (['select', 'multiple', 'radio'].includes(field.type)) { if (['select', 'multiple', 'radio'].includes(field.type)) {

@ -164,7 +164,7 @@
Draw New Area Draw New Area
</a> </a>
</li> </li>
<li v-if="field.areas?.length === 1 && ['date', 'signature', 'initials', 'text', 'cells', 'my_text', 'redact', 'my_signature', 'my_initials'].includes(field.type)"> <li v-if="field.areas?.length === 1 && ['date', 'signature', 'initials', 'text', 'cells', 'my_text', 'redact', 'my_signature', 'my_initials', 'my_date'].includes(field.type)">
<a <a
href="#" href="#"
class="text-sm py-1 px-2" class="text-sm py-1 px-2"

@ -292,7 +292,7 @@ export default {
submitter_uuid: this.selectedSubmitter.uuid, submitter_uuid: this.selectedSubmitter.uuid,
type type
} }
if (['redact', 'my_text', 'my_signature', 'my_initials'].includes(type)) { if (['redact', 'my_text', 'my_signature', 'my_initials', 'my_date'].includes(type)) {
field.required = 'false' field.required = 'false'
} }
if (['select', 'multiple', 'radio'].includes(type)) { if (['select', 'multiple', 'radio'].includes(type)) {

@ -34,6 +34,10 @@
<div class="flex items-center px-0.5"> <div class="flex items-center px-0.5">
<%= l(Date.parse(value), format: :long, locale: local_assigns[:locale]) %> <%= l(Date.parse(value), format: :long, locale: local_assigns[:locale]) %>
</div> </div>
<% elsif field['type'] == 'my_date' %>
<div class="flex items-center px-0.5">
<%= l(Date.parse(value), format: :long, locale: local_assigns[:locale]) %>
</div>
<% elsif field['type'] == 'redact' %> <% elsif field['type'] == 'redact' %>
<div class="flex absolute" style="width: 100%; height: 100%;" :style="{ backgroundColor: 'black' }"></div> <div class="flex absolute" style="width: 100%; height: 100%;" :style="{ backgroundColor: 'black' }"></div>
<% elsif field['type'] == 'my_text' %> <% elsif field['type'] == 'my_text' %>

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

@ -33,7 +33,7 @@ module Submissions
pdfs_index = build_pdfs_index(submitter) pdfs_index = build_pdfs_index(submitter)
submitter.submission.template_fields.each do |field| submitter.submission.template_fields.each do |field|
unless ['my_text', 'my_signature', 'my_initials'].include?(field['type']) unless ['my_text', 'my_signature', 'my_initials', 'my_date'].include?(field['type'])
next if field['submitter_uuid'] != submitter.uuid next if field['submitter_uuid'] != submitter.uuid
end end
field.fetch('areas', []).each do |area| field.fetch('areas', []).each do |area|
@ -205,7 +205,7 @@ module Submissions
layouter_my_text.fit([text_my_text], w, height_diff_my_text.positive? ? box_height_my_text : h) 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) .draw(canvas, x + TEXT_LEFT_MARGIN, y - height_diff_my_text + 17)
else else
value = I18n.l(Date.parse(value), format: :default, locale: account.locale) if field['type'] == 'date' value = I18n.l(Date.parse(value), format: :default, locale: account.locale) if field['type'] == 'date'|| field['type'] == 'my_date'
text = HexaPDF::Layout::TextFragment.create(Array.wrap(value).join(', '), font: pdf.fonts.add(FONT_NAME), text = HexaPDF::Layout::TextFragment.create(Array.wrap(value).join(', '), font: pdf.fonts.add(FONT_NAME),
font_size:) font_size:)

Loading…
Cancel
Save