Signature block (img) (#39)
* Signature block (img) * Singature input UI changes * Style the signature input Co-authored-by: Julien Nahum <jhumanj@MacBook-Pro-de-Julien.local>
This commit is contained in:
53
resources/js/components/forms/SignatureInput.vue
Normal file
53
resources/js/components/forms/SignatureInput.vue
Normal file
@@ -0,0 +1,53 @@
|
||||
<template>
|
||||
<div :class="wrapperClass">
|
||||
<label v-if="label" :for="id?id:name"
|
||||
:class="[theme.CodeInput.label,{'uppercase text-xs':uppercaseLabels, 'text-sm':!uppercaseLabels}]"
|
||||
>
|
||||
{{ label }}
|
||||
<span v-if="required" class="text-red-500 required-dot">*</span>
|
||||
</label>
|
||||
|
||||
<VueSignaturePad ref="signaturePad"
|
||||
:class="[theme.default.input,{ 'ring-red-500 ring-2': hasValidation && form.errors.has(name), 'cursor-not-allowed bg-gray-200':disabled }]" height="150px"
|
||||
:name="name"
|
||||
:options="{ onEnd }"
|
||||
/>
|
||||
|
||||
<div class="flex">
|
||||
<small v-if="help" :class="theme.default.help" class="flex-grow">
|
||||
<slot name="help"><span class="field-help" v-html="help" /></slot>
|
||||
</small>
|
||||
<small v-else class="flex-grow" />
|
||||
<small :class="theme.default.help">
|
||||
<a :class="theme.default.help" href="#" @click.prevent="clear">Clear</a>
|
||||
</small>
|
||||
</div>
|
||||
<has-error v-if="hasValidation" :form="form" :field="name" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Vue from 'vue'
|
||||
import VueSignaturePad from 'vue-signature-pad'
|
||||
import inputMixin from '~/mixins/forms/input'
|
||||
|
||||
Vue.use(VueSignaturePad)
|
||||
|
||||
export default {
|
||||
name: 'SignatureInput',
|
||||
|
||||
components: {},
|
||||
mixins: [inputMixin],
|
||||
|
||||
methods: {
|
||||
clear () {
|
||||
this.$refs.signaturePad.clearSignature()
|
||||
this.onEnd()
|
||||
},
|
||||
onEnd () {
|
||||
const { isEmpty, data } = this.$refs.signaturePad.saveSignature()
|
||||
this.$set(this.form, this.name, (!isEmpty && data) ? data : null)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
1
resources/js/components/forms/index.js
vendored
1
resources/js/components/forms/index.js
vendored
@@ -38,6 +38,7 @@ import ToggleSwitchInput from './ToggleSwitchInput'
|
||||
})
|
||||
|
||||
// Lazy load some heavy component
|
||||
Vue.component('SignatureInput', () => import('./SignatureInput'))
|
||||
Vue.component('RichTextAreaInput', () => import('./RichTextAreaInput'))
|
||||
Vue.component('DateInput', () => import('./DateInput'))
|
||||
Vue.component('SimpleDateInput', () => import('./SimpleDateInput'))
|
||||
|
||||
Reference in New Issue
Block a user