Skip to content

Commit ee2400a

Browse files
committed
touch signature attachment
1 parent 80be5d2 commit ee2400a

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

app/javascript/submission_form/form.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,9 @@
395395
v-model="values[currentField.uuid]"
396396
:reason="values[currentField.preferences?.reason_field_uuid]"
397397
:field="currentField"
398+
:values="values"
398399
:previous-value="previousSignatureValueFor(currentField) || previousSignatureValue"
400+
:touch-attachment-uuid="previousSignatureValue"
399401
:with-typed-signature="withTypedSignature"
400402
:remember-signature="rememberSignature"
401403
:attachments-index="attachmentsIndex"
@@ -407,6 +409,7 @@
407409
:submitter="submitter"
408410
:show-field-names="showFieldNames"
409411
@update:reason="values[currentField.preferences?.reason_field_uuid] = $event"
412+
@touch-attachment="attachmentsIndex[previousSignatureValue] ? attachmentsIndex[previousSignatureValue].created_at = new Date() : null"
410413
@attached="attachments.push($event)"
411414
@start="scrollIntoField(currentField)"
412415
@minimize="minimizeForm"

app/javascript/submission_form/signature_step.vue

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@
127127
type="hidden"
128128
:name="`values[${field.uuid}]`"
129129
>
130+
<input
131+
v-if="isTouchAttachment"
132+
:value="touchAttachmentUuid"
133+
type="hidden"
134+
name="touch_attachment_uuid"
135+
>
130136
<img
131137
v-if="modelValue || computedPreviousValue"
132138
:src="attachmentsIndex[modelValue || computedPreviousValue].url"
@@ -334,6 +340,10 @@ export default {
334340
type: Object,
335341
required: true
336342
},
343+
values: {
344+
type: Object,
345+
required: true
346+
},
337347
requireSigningReason: {
338348
type: Boolean,
339349
required: false,
@@ -388,6 +398,11 @@ export default {
388398
required: false,
389399
default: ''
390400
},
401+
touchAttachmentUuid: {
402+
type: String,
403+
required: false,
404+
default: ''
405+
},
391406
reason: {
392407
type: String,
393408
required: false,
@@ -399,13 +414,14 @@ export default {
399414
default: ''
400415
}
401416
},
402-
emits: ['attached', 'update:model-value', 'start', 'minimize', 'update:reason'],
417+
emits: ['attached', 'update:model-value', 'start', 'minimize', 'update:reason', 'touch-attachment'],
403418
data () {
404419
return {
405420
isSignatureStarted: false,
406421
isShowQr: false,
407422
isOtherReason: false,
408423
isUsePreviousValue: true,
424+
isTouchAttachment: false,
409425
isTextSignature: this.field.preferences?.format === 'typed' || this.field.preferences?.format === 'typed_or_upload',
410426
uploadImageInputKey: Math.random().toString()
411427
}
@@ -731,6 +747,13 @@ export default {
731747
},
732748
async submit () {
733749
if (this.modelValue || this.computedPreviousValue) {
750+
if (this.touchAttachmentUuid && this.computedPreviousValue === this.touchAttachmentUuid && !Object.values(this.values).includes(this.touchAttachmentUuid)) {
751+
this.isTouchAttachment = true
752+
this.$emit('touch-attachment', this.touchAttachmentUuid)
753+
} else {
754+
this.isTouchAttachment = false
755+
}
756+
734757
if (this.computedPreviousValue) {
735758
this.$emit('update:model-value', this.computedPreviousValue)
736759
}

lib/submitters/submit_values.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def update_submitter!(submitter, params, request, validate_required: true)
4848
maybe_set_signature_reason!(values, submitter, params)
4949
validate_values!(values, submitter, params, request)
5050

51+
if (touch_attachment_uuid = params[:touch_attachment_uuid].presence)
52+
ActiveStorage::Attachment.where(uuid: touch_attachment_uuid, record: submitter).touch_all(:created_at)
53+
end
54+
5155
SubmissionEvents.create_with_tracking_data(submitter, 'complete_form', request) if params[:completed] == 'true'
5256

5357
submitter.save!

0 commit comments

Comments
 (0)