Some progress on user image uploading

This commit is contained in:
Thaum Rystra
2024-04-17 09:03:21 +02:00
parent 7b662a647a
commit 78266a93ee
5 changed files with 128 additions and 1 deletions

View File

@@ -0,0 +1,71 @@
<template>
<div>
<v-text-field
ref="input"
v-bind="$attrs"
class="dc-text-field"
:loading="loading"
:error-messages="errors"
:value="safeValue"
:disabled="isDisabled"
:outlined="!regular"
@input="input"
@focus="focused = true"
@blur="focused = false"
@keyup="e => $emit('keyup', e)"
>
<template #append>
<slot name="value" />
</template>
<template #prepend>
<slot name="prepend" />
</template>
<template #append-inner>
<input
type="file"
@change="handleFileChange"
@dragover="handleDragOver"
@drop="handleDrop"
>
</template>
</v-text-field>
<input
v-model="url"
type="text"
@change="handleUrlChange"
>
</div>
</template>
<script lang="js">
import SmartInput from '/imports/client/ui/components/global/SmartInputMixin';
export default {
mixins: [SmartInput],
data() {
return {
url: '',
};
},
methods: {
handleUrlChange() {
this.$emit('change', this.url);
},
handleFileChange(event) {
const file = event.target.files[0];
this.uploadFile(file);
},
handleDragOver(event) {
event.preventDefault();
},
handleDrop(event) {
event.preventDefault();
const file = event.dataTransfer.files[0];
this.uploadFile(file);
},
uploadFile(file) {
// Implement your file upload logic here
},
},
};
</script>

View File

@@ -34,6 +34,7 @@
</template>
<script lang="js">
import removeUserImage from '/imports/api/files/UserImages/methods/removeUserImage';
export default {
props: {
@@ -50,7 +51,9 @@ export default {
},
methods: {
remove() {
removeUserImage.call({ fileId: this.model._id }, (error) => {
if (error) console.error(error);
});
},
},
}