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,25 +18,23 @@ export interface ILabel extends IAbstract {
}
export default class LabelModel extends AbstractModel implements ILabel {
id!: number
title!: string
hexColor!: string
description!: string
createdBy!: IUser
listId!: number
textColor!: string
id = 0
title = ''
// FIXME: this should be empty and be definied in the client.
// that way it get's never send to the server db and is easier to change in future versions.
hexColor = DEFAULT_LABEL_BACKGROUND_COLOR
description = ''
createdBy: IUser
listId = 0
textColor = ''
created: Date
updated: Date
created: Date = null
updated: Date = null
constructor(data: Partial<ILabel>) {
super()
this.assignData(data)
constructor(data) {
super(data)
// FIXME: this should be empty and be definied in the client.
// that way it get's never send to the server db and is easier to change in future versions.
// Set the default color
if (this.hexColor === '') {
this.hexColor = DEFAULT_LABEL_BACKGROUND_COLOR
}
if (this.hexColor.substring(0, 1) !== '#') {
this.hexColor = '#' + this.hexColor
}
@ -46,19 +44,4 @@ export default class LabelModel extends AbstractModel implements ILabel {
this.created = new Date(this.created)
this.updated = new Date(this.updated)
}
defaults() {
return {
id: 0,
title: '',
hexColor: '',
description: '',
createdBy: UserModel,
listId: 0,
textColor: '',
created: null,
updated: null,
}
}
}