feat: add friends in account setting

This commit is contained in:
Julien Calixte
2019-08-26 23:38:53 +02:00
parent 42d58f58ca
commit d7e6d3044e
3 changed files with 73 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
<template>
<div class="account-user-new">
<h3 class="subtitle is-3">{{ $tc('account.friends', localeUsers.length, { count: localeUsers.length }) }}</h3>
<user-new v-if="user" v-model="user" />
<h3 v-if="showTitle" class="subtitle is-3">{{ $tc('account.friends', localeUsers.length, { count: localeUsers.length }) }}</h3>
<user-new v-if="user && defaultUser" v-model="user" />
<div v-for="(user, k) in localeUsers" :key="k">
<user-new v-model="localeUsers[k]" @remove="() => remove(k)" />
</div>
@@ -24,7 +24,7 @@
</template>
<script lang="ts">
import { Component, Model, Vue, Watch } from 'vue-property-decorator'
import { Component, Model, Prop, Vue, Watch } from 'vue-property-decorator'
import { Getter } from 'vuex-class'
import IUser from '@/models/IUser'
@@ -38,6 +38,10 @@ export default class HelloWorld extends Vue {
public user!: IUser | null
@Model('input', { type: Array, required: true })
public users!: IUser[]
@Prop({ type: Boolean, default: true })
public defaultUser!: boolean
@Prop({ type: Boolean, default: true })
public showTitle!: boolean
public localeUsers: IUser[] = []
public userId: string = ''
public newUserId: string = ''
@@ -72,6 +76,11 @@ export default class HelloWorld extends Vue {
this.localeUsers.pop()
}
@Watch('users')
public onUsersChange(users: IUser[]): void {
this.localeUsers = users
}
@Watch('localeUsers')
public onUserChange(users: IUser[]): void {
this.$emit('input', users)