2022-08-04 18:57:43 +00:00
|
|
|
import AbstractModel from './abstractModel'
|
2022-11-13 21:04:57 +00:00
|
|
|
import ProjectModel from './project'
|
2022-08-04 18:57:43 +00:00
|
|
|
import UserModel from './user'
|
|
|
|
import SubscriptionModel from '@/models/subscription'
|
|
|
|
|
|
|
|
import type {INamespace} from '@/modelTypes/INamespace'
|
|
|
|
import type {IUser} from '@/modelTypes/IUser'
|
2022-11-13 21:04:57 +00:00
|
|
|
import type {IProject} from '@/modelTypes/IProject'
|
2022-08-04 18:57:43 +00:00
|
|
|
import type {ISubscription} from '@/modelTypes/ISubscription'
|
2022-07-20 22:42:36 +00:00
|
|
|
|
2022-09-06 09:36:01 +00:00
|
|
|
export default class NamespaceModel extends AbstractModel<INamespace> implements INamespace {
|
2022-08-14 10:15:45 +00:00
|
|
|
id = 0
|
|
|
|
title = ''
|
|
|
|
description = ''
|
|
|
|
owner: IUser = UserModel
|
2022-11-13 21:04:57 +00:00
|
|
|
projects: IProject[] = []
|
2022-08-14 10:15:45 +00:00
|
|
|
isArchived = false
|
|
|
|
hexColor = ''
|
|
|
|
subscription: ISubscription = null
|
|
|
|
|
|
|
|
created: Date = null
|
|
|
|
updated: Date = null
|
|
|
|
|
2022-09-06 09:36:01 +00:00
|
|
|
constructor(data: Partial<INamespace> = {}) {
|
2022-08-14 10:15:45 +00:00
|
|
|
super()
|
|
|
|
this.assignData(data)
|
2019-03-02 10:25:10 +00:00
|
|
|
|
2020-04-12 21:54:46 +00:00
|
|
|
if (this.hexColor !== '' && this.hexColor.substring(0, 1) !== '#') {
|
|
|
|
this.hexColor = '#' + this.hexColor
|
2020-03-25 21:27:29 +00:00
|
|
|
}
|
|
|
|
|
2022-11-13 21:04:57 +00:00
|
|
|
this.projects = this.projects.map(l => {
|
|
|
|
return new ProjectModel(l)
|
2019-03-02 10:25:10 +00:00
|
|
|
})
|
2021-02-14 19:18:51 +00:00
|
|
|
|
2019-03-02 10:25:10 +00:00
|
|
|
this.owner = new UserModel(this.owner)
|
2020-02-08 13:16:06 +00:00
|
|
|
|
2021-02-14 19:18:51 +00:00
|
|
|
if(typeof this.subscription !== 'undefined' && this.subscription !== null) {
|
|
|
|
this.subscription = new SubscriptionModel(this.subscription)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2021-07-26 21:09:49 +00:00
|
|
|
}
|