vikunja-frontend/src/models/user.js
konrad 2a56c84e94 Add settings for user search (#458)
Co-authored-by: kolaente <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/458
Co-authored-by: konrad <konrad@kola-entertainments.de>
Co-committed-by: konrad <konrad@kola-entertainments.de>
2021-04-07 19:31:14 +00:00

39 lines
No EOL
704 B
JavaScript

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