vikunja-frontend/src/models/team.ts
Dominik Pschenitschni 1a11b43ca8 feat: improve models
2022-09-13 14:59:02 +00:00

34 lines
No EOL
909 B
TypeScript

import AbstractModel from './abstractModel'
import UserModel from './user'
import TeamMemberModel from './teamMember'
import {RIGHTS, type Right} from '@/constants/rights'
import type {ITeam} from '@/modelTypes/ITeam'
import type {ITeamMember} from '@/modelTypes/ITeamMember'
import type {IUser} from '@/modelTypes/IUser'
export default class TeamModel extends AbstractModel<ITeam> implements ITeam {
id = 0
name = ''
description = ''
members: ITeamMember[] = []
right: Right = RIGHTS.READ
createdBy: IUser = {} // FIXME: seems wrong
created: Date = null
updated: Date = null
constructor(data: Partial<ITeam>) {
super()
this.assignData(data)
// Make the members to usermodels
this.members = this.members.map(m => {
return new TeamMemberModel(m)
})
this.createdBy = new UserModel(this.createdBy)
this.created = new Date(this.created)
this.updated = new Date(this.updated)
}
}