fix: use new assignData method for default data
This commit is contained in:
parent
8be1f81848
commit
8416b1f448
34 changed files with 317 additions and 615 deletions
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in a new issue