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:
@ -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