2019-03-02 11:25:10 +01:00
|
|
|
import AbstractModel from './abstractModel'
|
|
|
|
import ListModel from './list'
|
|
|
|
import UserModel from './user'
|
|
|
|
|
|
|
|
export default class NamespaceModel extends AbstractModel {
|
|
|
|
constructor(data) {
|
|
|
|
super(data)
|
|
|
|
|
2020-03-25 22:27:29 +01:00
|
|
|
if (this.hex_color !== '' && this.hex_color.substring(0, 1) !== '#') {
|
|
|
|
this.hex_color = '#' + this.hex_color
|
|
|
|
}
|
|
|
|
|
2019-03-02 11:25:10 +01:00
|
|
|
this.lists = this.lists.map(l => {
|
|
|
|
return new ListModel(l)
|
|
|
|
})
|
|
|
|
this.owner = new UserModel(this.owner)
|
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,
|
|
|
|
name: '',
|
|
|
|
description: '',
|
|
|
|
owner: UserModel,
|
|
|
|
lists: [],
|
2020-03-22 21:40:13 +01:00
|
|
|
is_archived: false,
|
2020-03-25 22:27:29 +01:00
|
|
|
hex_color: '',
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|