mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-03 20:48:07 +00:00
77 lines
1.4 KiB
Vue
77 lines
1.4 KiB
Vue
<script>
|
|
import NextButton from 'dashboard/components-next/button/Button.vue';
|
|
|
|
export default {
|
|
components: {
|
|
NextButton,
|
|
},
|
|
props: {
|
|
label: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
src: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
usernameAvatar: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
deleteAvatar: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
},
|
|
emits: ['onAvatarSelect', 'onAvatarDelete'],
|
|
watch: {},
|
|
methods: {
|
|
handleImageUpload(event) {
|
|
const [file] = event.target.files;
|
|
|
|
this.$emit('onAvatarSelect', {
|
|
file,
|
|
url: file ? URL.createObjectURL(file) : null,
|
|
});
|
|
},
|
|
onAvatarDelete() {
|
|
this.$refs.file.value = null;
|
|
this.$emit('onAvatarDelete');
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<div>
|
|
<label>
|
|
<span v-if="label">{{ label }}</span>
|
|
</label>
|
|
<woot-thumbnail
|
|
v-if="src"
|
|
size="80px"
|
|
:src="src"
|
|
:username="usernameAvatar"
|
|
/>
|
|
<div v-if="src && deleteAvatar" class="my-1">
|
|
<NextButton
|
|
outline
|
|
xs
|
|
ruby
|
|
:label="$t('INBOX_MGMT.DELETE.AVATAR_DELETE_BUTTON_TEXT')"
|
|
@click="onAvatarDelete"
|
|
/>
|
|
</div>
|
|
<label>
|
|
<input
|
|
id="file"
|
|
ref="file"
|
|
type="file"
|
|
accept="image/png, image/jpeg, image/jpg, image/gif, image/webp"
|
|
@change="handleImageUpload"
|
|
/>
|
|
<slot />
|
|
</label>
|
|
</div>
|
|
</template>
|