fix: use new assignData method for default data

This commit is contained in:
Dominik Pschenitschni 2022-08-14 12:15:45 +02:00
parent 8be1f81848
commit 8416b1f448
No known key found for this signature in database
GPG key ID: B257AC0149F43A77
34 changed files with 317 additions and 615 deletions

View file

@ -18,20 +18,21 @@ export interface INamespace extends IAbstract {
}
export default class NamespaceModel extends AbstractModel implements INamespace {
id!: number
title!: string
description!: string
owner: IUser
lists: IList[]
isArchived!: boolean
hexColor!: string
subscription!: ISubscription
id = 0
title = ''
description = ''
owner: IUser = UserModel
lists: IList[] = []
isArchived = false
hexColor = ''
subscription: ISubscription = null
created: Date
updated: Date
created: Date = null
updated: Date = null
constructor(data) {
super(data)
constructor(data: Partial<INamespace>) {
super()
this.assignData(data)
if (this.hexColor !== '' && this.hexColor.substring(0, 1) !== '#') {
this.hexColor = '#' + this.hexColor
@ -50,21 +51,4 @@ export default class NamespaceModel extends AbstractModel implements INamespace
this.created = new Date(this.created)
this.updated = new Date(this.updated)
}
// Default attributes that define the 'empty' state.
defaults() {
return {
id: 0,
title: '',
description: '',
owner: UserModel,
lists: [],
isArchived: false,
hexColor: '',
subscription: null,
created: null,
updated: null,
}
}
}