vikunja-frontend/src/models/team.ts

34 lines
909 B
TypeScript
Raw Normal View History

2022-08-04 20:57:43 +02:00
import AbstractModel from './abstractModel'
import UserModel from './user'
import TeamMemberModel from './teamMember'
2022-06-23 03:22:21 +02:00
2022-08-04 20:57:43 +02:00
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'
2022-07-21 00:42:36 +02:00
2022-09-06 11:36:01 +02:00
export default class TeamModel extends AbstractModel<ITeam> implements ITeam {
id = 0
name = ''
description = ''
members: ITeamMember[] = []
right: Right = RIGHTS.READ
2022-07-21 00:42:36 +02:00
createdBy: IUser = {} // FIXME: seems wrong
created: Date = null
updated: Date = null
2022-06-23 03:22:21 +02:00
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)
}
}