Add showing and modifying user name (#306)
Make sure to use the user name field everywhere Add showing and modifying user name Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/306 Co-Authored-By: konrad <konrad@kola-entertainments.de> Co-Committed-By: konrad <konrad@kola-entertainments.de>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="content has-text-centered">
|
||||
<h2>Hi {{ userInfo.username }}!</h2>
|
||||
<h2>Hi {{ userInfo.name !== '' ? userInfo.name : userInfo.username }}!</h2>
|
||||
<template v-if="!hasTasks">
|
||||
<p>Click on a list or namespace on the left to get started.</p>
|
||||
<router-link
|
||||
|
@ -346,7 +346,7 @@
|
||||
|
||||
<!-- Created / Updated [by] -->
|
||||
<p class="created">
|
||||
Created <span v-tooltip="formatDate(task.created)">{{ formatDateSince(task.created) }}</span> by {{ task.createdBy.username }}
|
||||
Created <span v-tooltip="formatDate(task.created)">{{ formatDateSince(task.created) }}</span> by {{ task.createdBy.getDisplayName() }}
|
||||
<template v-if="+new Date(task.created) !== +new Date(task.updated)">
|
||||
<br/>
|
||||
<!-- Computed properties to show the actual date every time it gets updated -->
|
||||
|
@ -106,7 +106,7 @@
|
||||
<table class="table is-striped is-hoverable is-fullwidth">
|
||||
<tbody>
|
||||
<tr :key="m.id" v-for="m in team.members">
|
||||
<td>{{ m.username }}</td>
|
||||
<td>{{ m.getDisplayName() }}</td>
|
||||
<td>
|
||||
<template v-if="m.id === userInfo.id">
|
||||
<b class="is-success">You</b>
|
||||
|
@ -106,6 +106,38 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Name -->
|
||||
<div class="card">
|
||||
<header class="card-header">
|
||||
<p class="card-header-title">
|
||||
Update your name
|
||||
</p>
|
||||
</header>
|
||||
<div class="card-content">
|
||||
<div class="content">
|
||||
<div class="field">
|
||||
<label class="label" for="newEmail">Name</label>
|
||||
<div class="control">
|
||||
<input
|
||||
@keyup.enter="updateName"
|
||||
class="input"
|
||||
id="newEmail"
|
||||
placeholder="The new name"
|
||||
type="text"
|
||||
v-model="name"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bigbuttons">
|
||||
<button :class="{ 'is-loading': userNameService.loading}" @click="updateName()"
|
||||
class="button is-primary is-fullwidth">
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Avatar -->
|
||||
<avatar-settings/>
|
||||
|
||||
@ -234,6 +266,8 @@ import EmailUpdateService from '../../services/emailUpdate'
|
||||
import EmailUpdateModel from '../../models/emailUpdate'
|
||||
import TotpModel from '../../models/totp'
|
||||
import TotpService from '../../services/totp'
|
||||
import UserNameService from '../../services/userName'
|
||||
import UserNameModel from '../../models/userName'
|
||||
|
||||
import {mapState} from 'vuex'
|
||||
|
||||
@ -260,6 +294,9 @@ export default {
|
||||
totpDisablePassword: '',
|
||||
|
||||
caldavUrl: '',
|
||||
|
||||
name: '',
|
||||
userNameService: UserNameService,
|
||||
}
|
||||
},
|
||||
components: {
|
||||
@ -275,6 +312,9 @@ export default {
|
||||
this.totpService = new TotpService()
|
||||
this.totp = new TotpModel()
|
||||
|
||||
this.userNameService = new UserNameService()
|
||||
this.name = this.$store.state.auth.info.name
|
||||
|
||||
this.totpStatus()
|
||||
this.buildCaldavUrl()
|
||||
},
|
||||
@ -359,6 +399,16 @@ export default {
|
||||
})
|
||||
.catch(e => this.error(e, this))
|
||||
},
|
||||
updateName() {
|
||||
const name = new UserNameModel({name: this.name})
|
||||
|
||||
this.userNameService.update(name)
|
||||
.then(() => {
|
||||
this.$store.commit('auth/setUserName', this.name)
|
||||
this.success({message: 'The name was successfully changed.'}, this)
|
||||
})
|
||||
.catch(e => this.error(e, this))
|
||||
},
|
||||
buildCaldavUrl() {
|
||||
const apiBase = window.API_URL.replace('/api/v1', '')
|
||||
this.caldavUrl = `${apiBase}/dav/principals/${this.userInfo.username}/`
|
||||
|
Reference in New Issue
Block a user