2018-09-06 15:46:20 +00:00
|
|
|
<!--
|
2018-09-19 16:30:15 +00:00
|
|
|
import rfcProps from '../../models/rfcProps';
|
2018-09-06 15:46:20 +00:00
|
|
|
* @copyright Copyright (c) 2018 Team Popcorn <teampopcornberlin@gmail.com>
|
|
|
|
*
|
|
|
|
* @author Team Popcorn <teampopcornberlin@gmail.com>
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
-
|
|
|
|
- This program is free software: you can redistribute it and/or modify
|
|
|
|
- it under the terms of the GNU Affero General Public License as
|
|
|
|
- published by the Free Software Foundation, either version 3 of the
|
|
|
|
- License, or (at your option) any later version.
|
|
|
|
-
|
|
|
|
- This program is distributed in the hope that it will be useful,
|
|
|
|
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
- GNU Affero General Public License for more details.
|
|
|
|
-
|
|
|
|
- You should have received a copy of the GNU Affero General Public License
|
|
|
|
- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
-
|
|
|
|
-->
|
|
|
|
|
|
|
|
<template>
|
2018-09-20 14:36:59 +00:00
|
|
|
<div id="contact-header-avatar" :class="{'maximised':maximizeAvatar }">
|
2018-09-13 15:47:47 +00:00
|
|
|
<div class="contact-avatar-background" />
|
2018-09-20 14:36:59 +00:00
|
|
|
<img v-if="contact.photo" :src="contact.photo"
|
|
|
|
class="contact-header-avatar__picture"
|
2018-09-25 15:38:14 +00:00
|
|
|
@click="toggleSize">
|
2018-09-20 14:36:59 +00:00
|
|
|
<div class="avatar-options">
|
|
|
|
<input id="contact-avatar-upload" type="file" class="hidden"
|
|
|
|
accept="image/*" @change="processFile">
|
|
|
|
<label v-tooltip.auto="t('contacts', 'Upload a new picture')" for="contact-avatar-upload" class="icon-upload-white" />
|
|
|
|
<div v-if="maximizeAvatar" class="icon-delete-white" @click="removePhoto" />
|
|
|
|
<div v-if="maximizeAvatar" class="icon-fullscreen-white" @click="minimizePhoto" />
|
|
|
|
<div v-if="maximizeAvatar" class="icon-download-white" @click="downloadPhoto" />
|
2018-09-18 15:49:42 +00:00
|
|
|
</div>
|
2018-09-13 15:47:47 +00:00
|
|
|
</div>
|
2018-09-06 15:46:20 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-09-19 16:30:15 +00:00
|
|
|
|
2018-09-06 15:46:20 +00:00
|
|
|
export default {
|
2018-09-13 15:47:47 +00:00
|
|
|
name: 'ContactAvatar',
|
2018-09-06 15:46:20 +00:00
|
|
|
|
2018-09-13 15:47:47 +00:00
|
|
|
props: {
|
|
|
|
contact: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
}
|
2018-09-18 15:49:42 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
maximizeAvatar: false
|
|
|
|
}
|
2018-09-13 15:47:47 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
processFile(event) {
|
|
|
|
let file = event.target.files[0]
|
2018-09-06 15:46:20 +00:00
|
|
|
let reader = new FileReader()
|
|
|
|
let self = this
|
2018-09-25 14:06:26 +00:00
|
|
|
// need if contact.photo to check if already there, if it is use updatePropertyWithValue
|
2018-09-06 15:46:20 +00:00
|
|
|
reader.onload = function(e) {
|
2018-09-19 16:30:15 +00:00
|
|
|
self.contact.vCard.addPropertyWithValue('photo', reader.result)
|
|
|
|
self.$store.dispatch('updateContact', self.contact)
|
2018-09-13 15:47:47 +00:00
|
|
|
}
|
2018-09-06 15:46:20 +00:00
|
|
|
reader.readAsDataURL(file)
|
2018-09-18 15:49:42 +00:00
|
|
|
},
|
2018-09-25 14:06:26 +00:00
|
|
|
toggleSize() {
|
2018-09-18 15:49:42 +00:00
|
|
|
// maximise avatar photo
|
2018-09-25 15:38:14 +00:00
|
|
|
this.maximizeAvatar = !this.maximizeAvatar
|
2018-09-18 15:49:42 +00:00
|
|
|
},
|
|
|
|
removePhoto() {
|
2018-09-25 14:06:26 +00:00
|
|
|
// self.contact.vCard.removePropertyWithValue('photo', reader.result)
|
2018-09-18 15:49:42 +00:00
|
|
|
// remove avatar photo
|
2018-09-20 14:36:59 +00:00
|
|
|
console.log("remove") // eslint-disable-line
|
2018-09-18 15:49:42 +00:00
|
|
|
},
|
|
|
|
downloadPhoto() {
|
|
|
|
// download avatar photo
|
2018-09-25 14:06:26 +00:00
|
|
|
// same as opening in new tab, use contact.url?photo to create download link
|
|
|
|
// look at download addressbook
|
2018-09-20 14:36:59 +00:00
|
|
|
console.log("download") // eslint-disable-line
|
2018-09-06 15:46:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
</script>
|