/** * Class model for Task Interface */ import type { TaskInterface, TaskSubtask, TaskAttachment, TaskRecurrence } from "@/types/task"; export class TaskObject implements TaskInterface { _data!: TaskInterface; constructor() { this._data = { type: 'task', version: 0, urid: null, created: null, modified: null, label: null, description: null, startsOn: null, dueOn: null, completedOn: null, status: null, priority: null, progress: null, color: null, recurrence: null, subtasks: {}, attachments: {}, tags: [], notes: null, }; } fromJson(data: TaskInterface): TaskObject { this._data = data; return this; } toJson(): TaskInterface { return this._data; } clone(): TaskObject { const cloned = new TaskObject(); cloned._data = JSON.parse(JSON.stringify(this._data)); return cloned; } /** Properties */ get type(): string { return this._data.type; } get version(): number { return this._data.version; } set version(value: number) { this._data.version = value; } get urid(): string | null { return this._data.urid; } set urid(value: string | null) { this._data.urid = value; } get created(): Date | null { return this._data.created; } set created(value: Date | null) { this._data.created = value; } get modified(): Date | null { return this._data.modified; } set modified(value: Date | null) { this._data.modified = value; } get label(): string | null { return this._data.label; } set label(value: string | null) { this._data.label = value; } get description(): string | null { return this._data.description; } set description(value: string | null) { this._data.description = value; } get startsOn(): Date | null { return this._data.startsOn; } set startsOn(value: Date | null) { this._data.startsOn = value; } get dueOn(): Date | null { return this._data.dueOn; } set dueOn(value: Date | null) { this._data.dueOn = value; } get completedOn(): Date | null { return this._data.completedOn; } set completedOn(value: Date | null) { this._data.completedOn = value; } get status(): string | null { return this._data.status; } set status(value: string | null) { this._data.status = value; } get priority(): number | null { return this._data.priority; } set priority(value: number | null) { this._data.priority = value; } get progress(): number | null { return this._data.progress; } set progress(value: number | null) { this._data.progress = value; } get color(): string | null { return this._data.color; } set color(value: string | null) { this._data.color = value; } get recurrence(): TaskRecurrence | null { return this._data.recurrence; } set recurrence(value: TaskRecurrence | null) { this._data.recurrence = value; } get subtasks(): Record { return this._data.subtasks; } set subtasks(value: Record) { this._data.subtasks = value; } get attachments(): Record { return this._data.attachments; } set attachments(value: Record) { this._data.attachments = value; } get tags(): string[] { return this._data.tags; } set tags(value: string[]) { this._data.tags = value; } get notes(): string | null { return this._data.notes; } set notes(value: string | null) { this._data.notes = value; } }