frontend/src/models/user.js
konrad 3343b1c240 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: vikunja/frontend#306
Co-Authored-By: konrad <konrad@kola-entertainments.de>
Co-Committed-By: konrad <konrad@kola-entertainments.de>
2020-11-21 21:25:00 +00:00

32 lines
537 B
JavaScript

import AbstractModel from './abstractModel'
export default class UserModel extends AbstractModel {
constructor(data) {
super(data)
this.created = new Date(this.created)
this.updated = new Date(this.updated)
}
defaults() {
return {
id: 0,
email: '',
username: '',
name: '',
created: null,
updated: null,
}
}
getAvatarUrl(size = 50) {
return `${window.API_URL}/${this.username}/avatar?size=${size}`
}
getDisplayName() {
if (this.name !== '') {
return this.name
}
return this.username
}
}