mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-11-04 04:57:51 +00:00 
			
		
		
		
	Added the ability to update the contact's avatar via API and Dashboard. - Contact create and update APIs can now accept avatar attachment parameters [form data]. - Contact create and update endpoints can now accept the avatar_url parameter.[json] - API endpoint to remove a contact avatar. - Updated Contact create/edit UI components with avatar support Fixes: #3428
		
			
				
	
	
		
			80 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
			
		
		
	
	
			80 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
<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="avatar-delete-btn">
 | 
						|
      <woot-button
 | 
						|
        color-scheme="alert"
 | 
						|
        variant="hollow"
 | 
						|
        size="tiny"
 | 
						|
        type="button"
 | 
						|
        @click="onAvatarDelete"
 | 
						|
      >
 | 
						|
        {{ this.$t('INBOX_MGMT.DELETE.AVATAR_DELETE_BUTTON_TEXT') }}
 | 
						|
      </woot-button>
 | 
						|
    </div>
 | 
						|
    <label>
 | 
						|
      <input
 | 
						|
        id="file"
 | 
						|
        ref="file"
 | 
						|
        type="file"
 | 
						|
        accept="image/png, image/jpeg, image/gif"
 | 
						|
        @change="handleImageUpload"
 | 
						|
      />
 | 
						|
      <slot />
 | 
						|
    </label>
 | 
						|
  </div>
 | 
						|
</template>
 | 
						|
 | 
						|
<script>
 | 
						|
export default {
 | 
						|
  props: {
 | 
						|
    label: {
 | 
						|
      type: String,
 | 
						|
      default: '',
 | 
						|
    },
 | 
						|
    src: {
 | 
						|
      type: String,
 | 
						|
      default: '',
 | 
						|
    },
 | 
						|
    usernameAvatar: {
 | 
						|
      type: String,
 | 
						|
      default: '',
 | 
						|
    },
 | 
						|
    deleteAvatar: {
 | 
						|
      type: Boolean,
 | 
						|
      default: false,
 | 
						|
    },
 | 
						|
  },
 | 
						|
  watch: {},
 | 
						|
  methods: {
 | 
						|
    handleImageUpload(event) {
 | 
						|
      const [file] = event.target.files;
 | 
						|
 | 
						|
      this.$emit('change', {
 | 
						|
        file,
 | 
						|
        url: file ? URL.createObjectURL(file) : null,
 | 
						|
      });
 | 
						|
    },
 | 
						|
    onAvatarDelete() {
 | 
						|
      this.$refs.file.value = null;
 | 
						|
      this.$emit('onAvatarDelete');
 | 
						|
    },
 | 
						|
  },
 | 
						|
};
 | 
						|
</script>
 | 
						|
 | 
						|
<style lang="scss" scoped>
 | 
						|
.avatar-delete-btn {
 | 
						|
  margin-top: var(--space-smaller);
 | 
						|
  margin-bottom: var(--space-smaller);
 | 
						|
}
 | 
						|
</style>
 |