mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-11-03 20:48:07 +00:00 
			
		
		
		
	These fixes are all auto generated and can be merged directly Fixes the following issues 1. Event used on components should be hypenated 2. Attribute orders in components 3. Use `unmounted` instead of `destroyed` 4. Add explicit `emits` declarations for components, autofixed [using this script](https://gist.github.com/scmmishra/6f549109b96400006bb69bbde392eddf) We ignore the top level v-if for now, we will fix it later
		
			
				
	
	
		
			81 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
			
		
		
	
	
			81 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
<script>
 | 
						|
export default {
 | 
						|
  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="avatar-delete-btn">
 | 
						|
      <woot-button
 | 
						|
        color-scheme="alert"
 | 
						|
        variant="hollow"
 | 
						|
        size="tiny"
 | 
						|
        type="button"
 | 
						|
        @click="onAvatarDelete"
 | 
						|
      >
 | 
						|
        {{ $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/jpg, image/gif, image/webp"
 | 
						|
        @change="handleImageUpload"
 | 
						|
      />
 | 
						|
      <slot />
 | 
						|
    </label>
 | 
						|
  </div>
 | 
						|
</template>
 | 
						|
 | 
						|
<style lang="scss" scoped>
 | 
						|
.avatar-delete-btn {
 | 
						|
  margin-top: var(--space-smaller);
 | 
						|
  margin-bottom: var(--space-smaller);
 | 
						|
}
 | 
						|
</style>
 |