2019-09-26 16:38:58 +02:00
|
|
|
<template>
|
2020-02-18 08:57:00 +01:00
|
|
|
<div class="identity-picker">
|
|
|
|
<div
|
|
|
|
v-if="inline"
|
|
|
|
class="inline box"
|
|
|
|
:class="{ 'has-background-grey-lighter': masked }"
|
|
|
|
@click="isComponentModalActive = true"
|
|
|
|
>
|
|
|
|
<div class="media">
|
|
|
|
<div class="media-left">
|
|
|
|
<figure class="image is-48x48" v-if="currentIdentity.avatar">
|
2020-06-17 15:54:24 +02:00
|
|
|
<img class="image is-rounded" :src="currentIdentity.avatar.url" alt="" />
|
2020-02-18 08:57:00 +01:00
|
|
|
</figure>
|
|
|
|
<b-icon v-else size="is-large" icon="account-circle" />
|
|
|
|
</div>
|
|
|
|
<div class="media-content" v-if="currentIdentity.name">
|
|
|
|
<p class="is-4">{{ currentIdentity.name }}</p>
|
|
|
|
<p class="is-6 has-text-grey">
|
|
|
|
{{ `@${currentIdentity.preferredUsername}` }}
|
|
|
|
<span v-if="masked">{{ $t("(Masked)") }}</span>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div class="media-content" v-else>
|
|
|
|
{{ `@${currentIdentity.preferredUsername}` }}
|
|
|
|
</div>
|
|
|
|
<b-button type="is-text" @click="isComponentModalActive = true">
|
|
|
|
{{ $t("Change") }}
|
|
|
|
</b-button>
|
|
|
|
</div>
|
2019-09-26 16:38:58 +02:00
|
|
|
</div>
|
2020-02-18 08:57:00 +01:00
|
|
|
<span v-else class="block" @click="isComponentModalActive = true">
|
2020-06-17 15:54:24 +02:00
|
|
|
<figure class="image is-48x48" v-if="currentIdentity.avatar">
|
|
|
|
<img class="is-rounded" :src="currentIdentity.avatar.url" alt="" />
|
|
|
|
</figure>
|
2020-02-18 08:57:00 +01:00
|
|
|
<b-icon v-else size="is-large" icon="account-circle" />
|
|
|
|
</span>
|
|
|
|
<b-modal :active.sync="isComponentModalActive" has-modal-card>
|
|
|
|
<identity-picker v-model="currentIdentity" @input="relay" />
|
|
|
|
</b-modal>
|
|
|
|
</div>
|
2019-09-26 16:38:58 +02:00
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
2020-02-18 08:57:00 +01:00
|
|
|
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
|
|
import { IActor } from "../../types/actor";
|
|
|
|
import IdentityPicker from "./IdentityPicker.vue";
|
2019-09-26 16:38:58 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
components: { IdentityPicker },
|
|
|
|
})
|
|
|
|
export default class IdentityPickerWrapper extends Vue {
|
|
|
|
@Prop() value!: IActor;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2019-11-15 18:36:47 +01:00
|
|
|
@Prop({ default: true, type: Boolean }) inline!: boolean;
|
2020-02-18 08:57:00 +01:00
|
|
|
|
|
|
|
@Prop({ type: Boolean, required: false, default: false }) masked = false;
|
|
|
|
|
|
|
|
isComponentModalActive = false;
|
|
|
|
|
2019-09-26 16:38:58 +02:00
|
|
|
currentIdentity: IActor = this.value;
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
@Watch("value")
|
|
|
|
updateCurrentActor(value: IActor) {
|
2019-11-18 16:06:24 +01:00
|
|
|
this.currentIdentity = value;
|
|
|
|
}
|
|
|
|
|
2019-09-26 16:38:58 +02:00
|
|
|
relay(identity: IActor) {
|
|
|
|
this.currentIdentity = identity;
|
2020-02-18 08:57:00 +01:00
|
|
|
this.$emit("input", identity);
|
2019-09-26 16:38:58 +02:00
|
|
|
this.isComponentModalActive = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style lang="scss">
|
2020-02-18 08:57:00 +01:00
|
|
|
.identity-picker {
|
|
|
|
.block {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
.inline {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2020-06-23 17:20:09 +02:00
|
|
|
|
|
|
|
.media {
|
|
|
|
border-top: none;
|
|
|
|
padding-top: 0;
|
|
|
|
}
|
2020-02-18 08:57:00 +01:00
|
|
|
}
|
2019-11-18 16:06:24 +01:00
|
|
|
</style>
|