mirror of https://github.com/nextcloud/contacts
added code for preview and merged in work on uploading photo from other branch, still needs full styling
This commit is contained in:
commit
649e370f68
|
@ -21,44 +21,99 @@
|
|||
*
|
||||
*/
|
||||
|
||||
// AVATAR
|
||||
#contact-header-avatar {
|
||||
position: relative;
|
||||
height: 75px;
|
||||
width: 75px;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
margin: 0 22px 0 44px;
|
||||
.contact-avatar-background {
|
||||
background-color: var(--color-background-dark);
|
||||
opacity: .2;
|
||||
z-index: 0;
|
||||
}
|
||||
img {
|
||||
z-index: 1;
|
||||
}
|
||||
label.icon-upload-white {
|
||||
opacity: .5;
|
||||
z-index: 2;
|
||||
&:hover,
|
||||
a:active,
|
||||
a:focus {
|
||||
opacity: .7;
|
||||
}
|
||||
}
|
||||
img + label.icon-upload-white {
|
||||
opacity: 0;
|
||||
}
|
||||
.contact-avatar-background,
|
||||
img,
|
||||
label.icon-upload-white {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
&__picture {
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
// AVATAR
|
||||
#contact-header-avatar {
|
||||
position: relative;
|
||||
height: 75px;
|
||||
width: 75px;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
margin: 0 22px 0 44px;
|
||||
.contact-avatar-background {
|
||||
background-color: var(--color-background-dark);
|
||||
opacity: .2;
|
||||
z-index: 0;
|
||||
}
|
||||
img {
|
||||
z-index: 10;
|
||||
}
|
||||
label.icon-upload-white {
|
||||
opacity: .5;
|
||||
z-index: 2;
|
||||
&:hover,
|
||||
a:active,
|
||||
a:focus {
|
||||
opacity: .7;
|
||||
}
|
||||
}
|
||||
img + label.icon-upload-white {
|
||||
opacity: 0;
|
||||
}
|
||||
.contact-avatar-background,
|
||||
img,
|
||||
label.icon-upload-white {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.avatar-options {
|
||||
top: 0;
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
#contact-header-avatar.maximised {
|
||||
position: fixed;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
border-radius: 0;
|
||||
padding: 20px;
|
||||
background-color: rgba(0, 0, 0, 0.9);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
z-index: 200;
|
||||
padding-top: 65px;
|
||||
img {
|
||||
width: auto;
|
||||
height: auto;
|
||||
border-radius: 0;
|
||||
max-height: calc(100% - 40px);
|
||||
max-width: 100%;
|
||||
align-self: center;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
.avatar-options {
|
||||
height: 40px;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
top: calc(100% - 40px);
|
||||
left: 0;
|
||||
display: flex;
|
||||
opacity: 1;
|
||||
padding: 0;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-around;
|
||||
}
|
||||
.avatar-options > [class^='icon-'] {
|
||||
min-width: 25%;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.contact-header-avatar-options {
|
||||
top: 0;
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -190,8 +190,7 @@ export default {
|
|||
sortedProperties() {
|
||||
return this.contact.properties.slice(0).sort((a, b) => {
|
||||
return (
|
||||
rfcProps.fieldOrder.indexOf(a.name)
|
||||
- rfcProps.fieldOrder.indexOf(b.name)
|
||||
rfcProps.fieldOrder.indexOf(a.name) - rfcProps.fieldOrder.indexOf(b.name)
|
||||
)
|
||||
})
|
||||
},
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<!--
|
||||
import rfcProps from '../../models/rfcProps';
|
||||
* @copyright Copyright (c) 2018 Team Popcorn <teampopcornberlin@gmail.com>
|
||||
*
|
||||
* @author Team Popcorn <teampopcornberlin@gmail.com>
|
||||
|
@ -21,24 +22,24 @@
|
|||
-->
|
||||
|
||||
<template>
|
||||
<div id="contact-header-avatar">
|
||||
<div :class="{'maximized': maximizeAvatar}" class="contact-avatar-background" />
|
||||
<img v-click="maximise" v-if="contact.photo !==undefined" :id="contact.key"
|
||||
class="avatar__picture"
|
||||
src="">
|
||||
<div class="contact-header-avatar__options">
|
||||
<input id="contact-header-avatar__upload" type="file" class="hidden"
|
||||
accept="image/*"
|
||||
@change="uploadPhoto">
|
||||
<label v-tooltip.auto="t('contacts', 'Upload a new picture')" for="avatar-upload" class="icon-upload-white" />
|
||||
<div v-click="removePhoto" v-if="contact.photo !==undefined" class="icon-delete-white" />
|
||||
<div v-click="openPhoto" v-if="contact.photo !==undefined" class="icon-fullscreen-white" />
|
||||
<div v-click="downloadPhoto" v-if="contact.photo !==undefined" class="icon-download-white" />
|
||||
<div id="contact-header-avatar" :class="{'maximised':maximizeAvatar }">
|
||||
<div class="contact-avatar-background" />
|
||||
<img v-if="contact.photo" :src="contact.photo"
|
||||
class="contact-header-avatar__picture"
|
||||
@click="maximise">
|
||||
<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" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'ContactAvatar',
|
||||
|
||||
|
@ -52,34 +53,15 @@ export default {
|
|||
return {
|
||||
maximizeAvatar: false
|
||||
}
|
||||
},
|
||||
mounted: {
|
||||
|
||||
},
|
||||
methods: {
|
||||
processFile(event) {
|
||||
let file = event.target.files[0]
|
||||
/* console.log(event.target.files)
|
||||
alert(JSON.stringify(file, undefined, 2))
|
||||
WIP */
|
||||
let reader = new FileReader()
|
||||
/* let selectedAddressbook = this.selectedAddressbook
|
||||
this.$store.dispatch('changeStage', 'parsing')
|
||||
this.$store.dispatch('setAddressbook', selectedAddressbook.displayName)
|
||||
WIP */
|
||||
let self = this
|
||||
reader.onload = function(e) {
|
||||
/* self.$store.dispatch('importContactsIntoAddressbook', { vcf: reader.result, addressbook: selectedAddressbook })
|
||||
WIP */
|
||||
console.log(reader.result) // eslint-disable-line
|
||||
if (!self.contact.vCard.hasProperty('avatar')) {
|
||||
let property = self.contact.vCard.addPropertyWithValue('avatar', reader.result)
|
||||
// ^WIP: need to research how to set type as 'text' same as in following example:
|
||||
// ["version", {…}, "text", "4.0", __ob__: Observer]
|
||||
property.setParameter('type', 'text')
|
||||
// ^WIP: need to research what above function is doing
|
||||
console.log(self.contact.vCard) // eslint-disable-line
|
||||
}
|
||||
self.contact.vCard.addPropertyWithValue('photo', reader.result)
|
||||
self.$store.dispatch('updateContact', self.contact)
|
||||
}
|
||||
reader.readAsDataURL(file)
|
||||
},
|
||||
|
@ -89,9 +71,11 @@ export default {
|
|||
},
|
||||
uploadPhoto() {
|
||||
// upload avatar photo
|
||||
console.log("upload") // eslint-disable-line
|
||||
},
|
||||
removePhoto() {
|
||||
// remove avatar photo
|
||||
console.log("remove") // eslint-disable-line
|
||||
},
|
||||
minimizePhoto() {
|
||||
// minimize avatar photo
|
||||
|
@ -99,6 +83,7 @@ export default {
|
|||
},
|
||||
downloadPhoto() {
|
||||
// download avatar photo
|
||||
console.log("download") // eslint-disable-line
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,6 +113,26 @@ export default class Contact {
|
|||
return this.uid + '@' + this.addressbook.id
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the photo
|
||||
*
|
||||
* @readonly
|
||||
* @memberof Contact
|
||||
*/
|
||||
get photo() {
|
||||
return this.vCard.getFirstPropertyValue('photo')
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the photo
|
||||
*
|
||||
* @memberof Contact
|
||||
*/
|
||||
set photo(photo) {
|
||||
this.vCard.updatePropertyWithValue('photo', photo)
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the groups
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue