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