Some progress on user image uploading
This commit is contained in:
71
app/imports/client/ui/components/global/SmartImageInput.vue
Normal file
71
app/imports/client/ui/components/global/SmartImageInput.vue
Normal 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>
|
||||
@@ -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);
|
||||
});
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user