2022-08-14 12:15:09 +02:00
|
|
|
import AbstractModel, { type IAbstract } from './abstractModel'
|
2022-07-21 00:42:36 +02:00
|
|
|
import UserModel, { type IUser } from './user'
|
|
|
|
import TeamMemberModel, { type ITeamMember } from './teamMember'
|
2022-08-13 15:26:57 +02:00
|
|
|
import {RIGHTS, type Right} from '@/constants/rights'
|
2019-03-02 11:25:10 +01:00
|
|
|
|
2022-08-14 12:15:09 +02:00
|
|
|
export interface ITeam extends IAbstract {
|
2022-07-21 00:42:36 +02:00
|
|
|
id: number
|
2022-06-23 03:22:21 +02:00
|
|
|
name: string
|
|
|
|
description: string
|
2022-07-21 00:42:36 +02:00
|
|
|
members: ITeamMember[]
|
2022-06-23 03:22:21 +02:00
|
|
|
right: Right
|
|
|
|
|
2022-07-21 00:42:36 +02:00
|
|
|
createdBy: IUser
|
|
|
|
created: Date
|
|
|
|
updated: Date
|
|
|
|
}
|
|
|
|
|
|
|
|
export default class TeamModel extends AbstractModel implements ITeam {
|
2022-08-14 12:15:45 +02:00
|
|
|
id = 0
|
|
|
|
name = ''
|
|
|
|
description = ''
|
|
|
|
members: ITeamMember[] = []
|
|
|
|
right: Right = RIGHTS.READ
|
2022-07-21 00:42:36 +02:00
|
|
|
|
2022-08-14 12:15:45 +02:00
|
|
|
createdBy: IUser = {} // FIXME: seems wrong
|
|
|
|
created: Date = null
|
|
|
|
updated: Date = null
|
2022-06-23 03:22:21 +02:00
|
|
|
|
2022-08-14 12:15:45 +02:00
|
|
|
constructor(data: Partial<ITeam>) {
|
|
|
|
super()
|
|
|
|
this.assignData(data)
|
2020-09-05 22:35:52 +02:00
|
|
|
|
2019-03-02 11:25:10 +01:00
|
|
|
// Make the members to usermodels
|
|
|
|
this.members = this.members.map(m => {
|
|
|
|
return new TeamMemberModel(m)
|
|
|
|
})
|
|
|
|
this.createdBy = new UserModel(this.createdBy)
|
2020-02-08 14:16:06 +01:00
|
|
|
|
|
|
|
this.created = new Date(this.created)
|
|
|
|
this.updated = new Date(this.updated)
|
2019-03-02 11:25:10 +01:00
|
|
|
}
|
|
|
|
}
|