touch signature attachment

master^2
Pete Matsyburka 2 days ago
parent 80be5d2cf5
commit ee2400a5c5

@ -395,7 +395,9 @@
v-model="values[currentField.uuid]"
:reason="values[currentField.preferences?.reason_field_uuid]"
:field="currentField"
:values="values"
:previous-value="previousSignatureValueFor(currentField) || previousSignatureValue"
:touch-attachment-uuid="previousSignatureValue"
:with-typed-signature="withTypedSignature"
:remember-signature="rememberSignature"
:attachments-index="attachmentsIndex"
@ -407,6 +409,7 @@
:submitter="submitter"
:show-field-names="showFieldNames"
@update:reason="values[currentField.preferences?.reason_field_uuid] = $event"
@touch-attachment="attachmentsIndex[previousSignatureValue] ? attachmentsIndex[previousSignatureValue].created_at = new Date() : null"
@attached="attachments.push($event)"
@start="scrollIntoField(currentField)"
@minimize="minimizeForm"

@ -127,6 +127,12 @@
type="hidden"
:name="`values[${field.uuid}]`"
>
<input
v-if="isTouchAttachment"
:value="touchAttachmentUuid"
type="hidden"
name="touch_attachment_uuid"
>
<img
v-if="modelValue || computedPreviousValue"
:src="attachmentsIndex[modelValue || computedPreviousValue].url"
@ -334,6 +340,10 @@ export default {
type: Object,
required: true
},
values: {
type: Object,
required: true
},
requireSigningReason: {
type: Boolean,
required: false,
@ -388,6 +398,11 @@ export default {
required: false,
default: ''
},
touchAttachmentUuid: {
type: String,
required: false,
default: ''
},
reason: {
type: String,
required: false,
@ -399,13 +414,14 @@ export default {
default: ''
}
},
emits: ['attached', 'update:model-value', 'start', 'minimize', 'update:reason'],
emits: ['attached', 'update:model-value', 'start', 'minimize', 'update:reason', 'touch-attachment'],
data () {
return {
isSignatureStarted: false,
isShowQr: false,
isOtherReason: false,
isUsePreviousValue: true,
isTouchAttachment: false,
isTextSignature: this.field.preferences?.format === 'typed' || this.field.preferences?.format === 'typed_or_upload',
uploadImageInputKey: Math.random().toString()
}
@ -731,6 +747,13 @@ export default {
},
async submit () {
if (this.modelValue || this.computedPreviousValue) {
if (this.touchAttachmentUuid && this.computedPreviousValue === this.touchAttachmentUuid && !Object.values(this.values).includes(this.touchAttachmentUuid)) {
this.isTouchAttachment = true
this.$emit('touch-attachment', this.touchAttachmentUuid)
} else {
this.isTouchAttachment = false
}
if (this.computedPreviousValue) {
this.$emit('update:model-value', this.computedPreviousValue)
}

@ -48,6 +48,10 @@ module Submitters
maybe_set_signature_reason!(values, submitter, params)
validate_values!(values, submitter, params, request)
if (touch_attachment_uuid = params[:touch_attachment_uuid].presence)
ActiveStorage::Attachment.where(uuid: touch_attachment_uuid, record: submitter).touch_all(:created_at)
end
SubmissionEvents.create_with_tracking_data(submitter, 'complete_form', request) if params[:completed] == 'true'
submitter.save!

Loading…
Cancel
Save