mobilizon/js/src/components/Account/Identities.vue

82 lines
1.9 KiB
Vue
Raw Normal View History

2019-04-26 15:22:16 +02:00
<template>
<section>
<h1 class="title">
{{ $t('My identities') }}
2019-04-26 15:22:16 +02:00
</h1>
<ul class="identities">
<li v-for="identity in identities" :key="identity.id">
<router-link
:to="{ name: 'UpdateIdentity', params: { identityName: identity.preferredUsername } }"
class="media identity" v-bind:class="{ 'is-current-identity': isCurrentIdentity(identity) }"
>
2019-04-26 15:22:16 +02:00
<div class="media-left">
<figure class="image is-48x48" v-if="identity.avatar">
<img class="is-rounded" :src="identity.avatar.url">
2019-04-26 15:22:16 +02:00
</figure>
</div>
<div class="media-content">
{{ identity.displayName() }}
</div>
</router-link>
2019-04-26 15:22:16 +02:00
</li>
</ul>
<router-link :to="{ name: 'CreateIdentity' }" class="button create-identity is-primary" >
{{ $t('Create a new identity') }}
</router-link>
2019-04-26 15:22:16 +02:00
</section>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { IDENTITIES } from '@/graphql/actor';
import { IPerson, Person } from '@/types/actor';
2019-04-26 15:22:16 +02:00
@Component({
apollo: {
identities: {
query: IDENTITIES,
update (result) {
return result.identities.map(i => new Person(i));
2019-04-26 15:22:16 +02:00
},
},
},
})
export default class Identities extends Vue {
@Prop({ type: String }) currentIdentityName!: string;
2019-04-26 15:22:16 +02:00
identities: Person[] = [];
errors: string[] = [];
2019-04-26 15:22:16 +02:00
isCurrentIdentity(identity: IPerson) {
return identity.preferredUsername === this.currentIdentityName;
2019-04-26 15:22:16 +02:00
}
}
2019-04-26 15:22:16 +02:00
</script>
<style lang="scss" scoped>
.identities {
border-right: 1px solid grey;
padding: 15px 0;
}
.media.identity {
align-items: center;
font-size: 1.3rem;
padding-bottom: 0;
margin-bottom: 15px;
color: #000;
&.is-current-identity {
background-color: rgba(0, 0, 0, 0.1);
}
}
.title {
margin-bottom: 30px;
}
</style>