2022-07-21 00:42:36 +02:00
|
|
|
import AbstractModel, { type IAbstract } from './abstractModel'
|
|
|
|
import UserModel, { type IUser } from './user'
|
|
|
|
import TaskModel, { type ITask } from './task'
|
2020-04-26 01:11:34 +02:00
|
|
|
|
2022-07-21 00:42:36 +02:00
|
|
|
export interface IBucket extends IAbstract {
|
2022-06-23 03:22:21 +02:00
|
|
|
id: number
|
|
|
|
title: string
|
|
|
|
listId: number
|
|
|
|
limit: number
|
2022-07-21 00:42:36 +02:00
|
|
|
tasks: ITask[]
|
2022-06-23 03:22:21 +02:00
|
|
|
isDoneBucket: boolean
|
|
|
|
position: number
|
|
|
|
|
2022-07-21 00:42:36 +02:00
|
|
|
createdBy: IUser
|
|
|
|
created: Date
|
|
|
|
updated: Date
|
|
|
|
}
|
|
|
|
|
|
|
|
export default class BucketModel extends AbstractModel implements IBucket {
|
|
|
|
declare id: number
|
|
|
|
declare title: string
|
|
|
|
declare listId: number
|
|
|
|
declare limit: number
|
|
|
|
declare tasks: ITask[]
|
|
|
|
declare isDoneBucket: boolean
|
|
|
|
declare position: number
|
|
|
|
|
|
|
|
createdBy: IUser
|
2022-06-23 03:22:21 +02:00
|
|
|
created: Date
|
|
|
|
updated: Date
|
|
|
|
|
2020-04-26 01:11:34 +02:00
|
|
|
constructor(bucket) {
|
|
|
|
super(bucket)
|
|
|
|
|
|
|
|
this.tasks = this.tasks.map(t => new TaskModel(t))
|
|
|
|
|
|
|
|
this.createdBy = new UserModel(this.createdBy)
|
|
|
|
this.created = new Date(this.created)
|
|
|
|
this.updated = new Date(this.updated)
|
|
|
|
}
|
|
|
|
|
|
|
|
defaults() {
|
|
|
|
return {
|
|
|
|
id: 0,
|
|
|
|
title: '',
|
|
|
|
listId: 0,
|
2020-09-04 22:01:02 +02:00
|
|
|
limit: 0,
|
2020-04-26 01:11:34 +02:00
|
|
|
tasks: [],
|
2021-03-24 21:16:56 +01:00
|
|
|
isDoneBucket: false,
|
2021-07-28 22:46:33 +02:00
|
|
|
position: 0,
|
2020-04-26 01:11:34 +02:00
|
|
|
|
|
|
|
createdBy: null,
|
|
|
|
created: null,
|
|
|
|
updated: null,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|