require signature in form

pull/105/head
Alex Turchyn 2 years ago
parent a258ca6c79
commit 2c0bed9823

@ -100,7 +100,7 @@
</template> </template>
<script> <script>
import { IconTextSize, IconWriting, IconCalendarEvent, IconPhoto, IconCheckbox, IconPaperclip, IconSelect, IconCircleDot, IconChecks, IconCheck } from '@tabler/icons-vue' import { IconTextSize, IconWritingSign, IconCalendarEvent, IconPhoto, IconCheckbox, IconPaperclip, IconSelect, IconCircleDot, IconChecks, IconCheck } from '@tabler/icons-vue'
export default { export default {
name: 'FieldArea', name: 'FieldArea',
@ -166,7 +166,7 @@ export default {
fieldIcons () { fieldIcons () {
return { return {
text: IconTextSize, text: IconTextSize,
signature: IconWriting, signature: IconWritingSign,
date: IconCalendarEvent, date: IconCalendarEvent,
image: IconPhoto, image: IconPhoto,
file: IconPaperclip, file: IconPaperclip,

@ -215,7 +215,7 @@
<button <button
type="submit" type="submit"
class="base-button w-full flex justify-center" class="base-button w-full flex justify-center"
:disabled="isSubmitting || (currentField.required && ['image', 'file'].includes(currentField.type) && !values[currentField.uuid]?.length)" :disabled="isButtonDisabled"
> >
<span class="flex"> <span class="flex">
<IconInnerShadowTop <IconInnerShadowTop
@ -314,6 +314,11 @@ export default {
currentStepFields () { currentStepFields () {
return this.stepFields[this.currentStep] return this.stepFields[this.currentStep]
}, },
isButtonDisabled () {
return this.isSubmitting ||
(this.currentField.required && ['image', 'file'].includes(this.currentField.type) && !this.values[this.currentField.uuid]?.length) ||
(this.currentField.required && this.currentField.type === 'signature' && !this.values[this.currentField.uuid]?.length && this.$refs.currentStep && !this.$refs.currentStep.isSignatureStarted)
},
currentField () { currentField () {
return this.currentStepFields[0] return this.currentStepFields[0]
}, },

@ -70,11 +70,20 @@ export default {
} }
}, },
emits: ['attached', 'update:model-value'], emits: ['attached', 'update:model-value'],
data () {
return {
isSignatureStarted: false
}
},
mounted () { mounted () {
this.$refs.canvas.width = this.$refs.canvas.parentNode.clientWidth this.$refs.canvas.width = this.$refs.canvas.parentNode.clientWidth
this.$refs.canvas.height = this.$refs.canvas.parentNode.clientWidth / 3 this.$refs.canvas.height = this.$refs.canvas.parentNode.clientWidth / 3
this.pad = new SignaturePad(this.$refs.canvas) this.pad = new SignaturePad(this.$refs.canvas)
this.pad.addEventListener('beginStroke', () => {
this.isSignatureStarted = true
})
}, },
methods: { methods: {
remove () { remove () {
@ -82,6 +91,8 @@ export default {
}, },
clear () { clear () {
this.pad.clear() this.pad.clear()
this.isSignatureStarted = false
}, },
submit () { submit () {
if (this.modelValue) { if (this.modelValue) {

@ -41,7 +41,7 @@
</template> </template>
<script> <script>
import { IconTextSize, IconWriting, IconCalendarEvent, IconPhoto, IconCheckbox, IconPaperclip, IconSelect, IconCircleDot, IconChecks } from '@tabler/icons-vue' import { IconTextSize, IconWritingSign, IconCalendarEvent, IconPhoto, IconCheckbox, IconPaperclip, IconSelect, IconCircleDot, IconChecks } from '@tabler/icons-vue'
export default { export default {
name: 'FiledTypeDropdown', name: 'FiledTypeDropdown',
@ -71,7 +71,7 @@ export default {
fieldIcons () { fieldIcons () {
return { return {
text: IconTextSize, text: IconTextSize,
signature: IconWriting, signature: IconWritingSign,
date: IconCalendarEvent, date: IconCalendarEvent,
image: IconPhoto, image: IconPhoto,
file: IconPaperclip, file: IconPaperclip,

Loading…
Cancel
Save