add reset button for files
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Simon Vieille 2023-05-09 20:53:34 +02:00
parent e635a5a13a
commit 9605b8f802
Signed by: deblan
GPG key ID: 579388D585F70417

View file

@ -5,9 +5,13 @@
:for="id" :for="id"
v-text="label" v-text="label"
/> />
<button
class="px-3 py-1 mr-2 text-sm font-medium text-gray-900 bg-white border border-gray-200 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-2 focus:ring-blue-700 focus:text-blue-700 dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:hover:text-white dark:hover:bg-gray-600 dark:focus:ring-blue-500 dark:focus:text-white rounded-md"
v-on:click="reset"
>X</button>
<input <input
:id="id" :id="id"
class="mt-2 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50" class="mt-2 w-50 rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"
type="file" type="file"
:class="$attrs.class" :class="$attrs.class"
@change="convertFileToBase64($event.target.files)" @change="convertFileToBase64($event.target.files)"
@ -35,6 +39,9 @@ export default {
}, },
emits: ['update:modelValue'], emits: ['update:modelValue'],
methods: { methods: {
reset() {
this.$emit('update:modelValue', '')
},
async convertFileToBase64(files) { async convertFileToBase64(files) {
if (files.length) { if (files.length) {
const value = await toBase64(files[0]) const value = await toBase64(files[0])