2022-08-14 12:15:09 +02:00
|
|
|
import AbstractModel, { type IAbstract } from './abstractModel'
|
2022-07-21 00:42:36 +02:00
|
|
|
import ListModel, { type IList } from './list'
|
|
|
|
import UserModel, { type IUser } from './user'
|
|
|
|
import SubscriptionModel, { type ISubscription } from '@/models/subscription'
|
2019-03-02 11:25:10 +01:00
|
|
|
|
2022-08-14 12:15:09 +02:00
|
|
|
export interface INamespace extends IAbstract {
|
2022-06-23 03:22:21 +02:00
|
|
|
id: number
|
|
|
|
title: string
|
|
|
|
description: string
|
2022-07-21 00:42:36 +02:00
|
|
|
owner: IUser
|
|
|
|
lists: IList[]
|
2022-06-23 03:22:21 +02:00
|
|
|
isArchived: boolean
|
|
|
|
hexColor: string
|
2022-07-21 00:42:36 +02:00
|
|
|
subscription: ISubscription
|
|
|
|
|
|
|
|
created: Date
|
|
|
|
updated: Date
|
|
|
|
}
|
|
|
|
|
|
|
|
export default class NamespaceModel extends AbstractModel implements INamespace {
|
2022-08-13 15:38:41 +02:00
|
|
|
id!: number
|
|
|
|
title!: string
|
|
|
|
description!: string
|
2022-07-21 00:42:36 +02:00
|
|
|
owner: IUser
|
|
|
|
lists: IList[]
|
2022-08-13 15:38:41 +02:00
|
|
|
isArchived!: boolean
|
|
|
|
hexColor!: string
|
|
|
|
subscription!: ISubscription
|
2022-06-23 03:22:21 +02:00
|
|
|
|
|
|
|
created: Date
|
|
|
|
updated: Date
|
|
|
|
|
2019-03-02 11:25:10 +01:00
|
|
|
constructor(data) {
|
|
|
|
super(data)
|
|
|
|
|
2020-04-12 23:54:46 +02:00
|
|
|
if (this.hexColor !== '' && this.hexColor.substring(0, 1) !== '#') {
|
|
|
|
this.hexColor = '#' + this.hexColor
|
2020-03-25 22:27:29 +01:00
|
|
|
}
|
|
|
|
|
2019-03-02 11:25:10 +01:00
|
|
|
this.lists = this.lists.map(l => {
|
|
|
|
return new ListModel(l)
|
|
|
|
})
|
2021-02-14 20:18:51 +01:00
|
|
|
|
2019-03-02 11:25:10 +01:00
|
|
|
this.owner = new UserModel(this.owner)
|
2020-02-08 14:16:06 +01:00
|
|
|
|
2021-02-14 20:18:51 +01:00
|
|
|
if(typeof this.subscription !== 'undefined' && this.subscription !== null) {
|
|
|
|
this.subscription = new SubscriptionModel(this.subscription)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// Default attributes that define the 'empty' state.
|
|
|
|
defaults() {
|
|
|
|
return {
|
|
|
|
id: 0,
|
2020-05-16 12:31:16 +02:00
|
|
|
title: '',
|
2019-03-02 11:25:10 +01:00
|
|
|
description: '',
|
|
|
|
owner: UserModel,
|
|
|
|
lists: [],
|
2020-04-12 23:54:46 +02:00
|
|
|
isArchived: false,
|
|
|
|
hexColor: '',
|
2021-02-14 20:18:51 +01:00
|
|
|
subscription: null,
|
2019-03-02 11:25:10 +01:00
|
|
|
|
2020-02-08 14:16:06 +01:00
|
|
|
created: null,
|
|
|
|
updated: null,
|
2019-03-02 11:25:10 +01:00
|
|
|
}
|
|
|
|
}
|
2021-07-26 23:09:49 +02:00
|
|
|
}
|