2022-08-04 18:57:43 +00:00
|
|
|
import AbstractModel from './abstractModel'
|
|
|
|
import TaskModel from '@/models/task'
|
|
|
|
import UserModel from '@/models/user'
|
|
|
|
import SubscriptionModel from '@/models/subscription'
|
2022-07-20 22:42:36 +00:00
|
|
|
|
2022-11-13 21:04:57 +00:00
|
|
|
import type {IProject} from '@/modelTypes/IProject'
|
2022-08-04 18:57:43 +00:00
|
|
|
import type {IUser} from '@/modelTypes/IUser'
|
|
|
|
import type {ITask} from '@/modelTypes/ITask'
|
|
|
|
import type {INamespace} from '@/modelTypes/INamespace'
|
|
|
|
import type {ISubscription} from '@/modelTypes/ISubscription'
|
2019-03-02 10:25:10 +00:00
|
|
|
|
2022-11-13 21:04:57 +00:00
|
|
|
export default class ProjectModel extends AbstractModel<IProject> implements IProject {
|
2022-08-14 10:15:45 +00:00
|
|
|
id = 0
|
|
|
|
title = ''
|
|
|
|
description = ''
|
|
|
|
owner: IUser = UserModel
|
|
|
|
tasks: ITask[] = []
|
|
|
|
namespaceId: INamespace['id'] = 0
|
|
|
|
isArchived = false
|
|
|
|
hexColor = ''
|
|
|
|
identifier = ''
|
2022-10-04 10:48:23 +00:00
|
|
|
backgroundInformation: unknown | null = null
|
2022-08-14 10:15:45 +00:00
|
|
|
isFavorite = false
|
|
|
|
subscription: ISubscription = null
|
|
|
|
position = 0
|
|
|
|
backgroundBlurHash = ''
|
2022-07-20 22:42:36 +00:00
|
|
|
|
2022-08-14 10:15:45 +00:00
|
|
|
created: Date = null
|
|
|
|
updated: Date = null
|
2020-09-05 20:35:52 +00:00
|
|
|
|
2022-11-13 21:04:57 +00:00
|
|
|
constructor(data: Partial<IProject> = {}) {
|
2022-08-14 10:15:45 +00:00
|
|
|
super()
|
|
|
|
this.assignData(data)
|
2020-03-25 21:27:29 +00:00
|
|
|
|
2022-02-13 18:57:12 +00:00
|
|
|
this.owner = new UserModel(this.owner)
|
|
|
|
|
2019-03-02 10:25:10 +00:00
|
|
|
// Make all tasks to task models
|
|
|
|
this.tasks = this.tasks.map(t => {
|
|
|
|
return new TaskModel(t)
|
|
|
|
})
|
2022-02-13 18:57:12 +00:00
|
|
|
|
|
|
|
if (this.hexColor !== '' && this.hexColor.substring(0, 1) !== '#') {
|
|
|
|
this.hexColor = '#' + this.hexColor
|
2021-02-14 19:18:51 +00:00
|
|
|
}
|
|
|
|
|
2022-02-13 18:57:12 +00:00
|
|
|
if (typeof this.subscription !== 'undefined' && this.subscription !== null) {
|
|
|
|
this.subscription = new SubscriptionModel(this.subscription)
|
|
|
|
}
|
2022-02-13 17:11:26 +00:00
|
|
|
|
2020-02-08 13:16:06 +00:00
|
|
|
this.created = new Date(this.created)
|
|
|
|
this.updated = new Date(this.updated)
|
2019-03-02 10:25:10 +00:00
|
|
|
}
|
|
|
|
}
|