From b0e35aae72d70a0338d4cc0878076bd5560b10e7 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Mon, 17 Apr 2023 21:13:08 +0200 Subject: [PATCH] breaktime is part of records now --- src/modules/record/interfaces/recordable.ts | 1 + src/modules/record/stores/useTaskRecordStore.ts | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/modules/record/interfaces/recordable.ts b/src/modules/record/interfaces/recordable.ts index 2fa05a1..d4ecc1b 100644 --- a/src/modules/record/interfaces/recordable.ts +++ b/src/modules/record/interfaces/recordable.ts @@ -7,4 +7,5 @@ export interface Recordable { end?: ISODate stepRecords: Record notes: string + breakTime?: TimeRange } diff --git a/src/modules/record/stores/useTaskRecordStore.ts b/src/modules/record/stores/useTaskRecordStore.ts index c9a43fc..e40b8ed 100644 --- a/src/modules/record/stores/useTaskRecordStore.ts +++ b/src/modules/record/stores/useTaskRecordStore.ts @@ -7,15 +7,13 @@ import { TaskRecord } from '../models/task-record' export interface TaskRecordStoreState { currentStepId: string | null records: { [recordId: string]: Recordable } - breaktime: TimeRange | null } export const useTaskRecordStore = defineStore('task-record-store', { persist: true, state: (): TaskRecordStoreState => ({ currentStepId: null, - records: {}, - breaktime: null + records: {} }), actions: { addRecord(taskId: string) { @@ -118,24 +116,24 @@ export const useTaskRecordStore = defineStore('task-record-store', { this.records[taskId].stepRecords = {} this.records[taskId].end = undefined }, - pause() { - if (this.breaktime) { + pause(recordId: string) { + if (this.records[recordId]?.breakTime) { return } - this.breaktime = { + this.records[recordId].breakTime = { start: toISODate(new Date()) } }, resume(recordId: string) { console.log(recordId) - if (!this.breaktime) { + if (!this.records[recordId].breakTime) { return } // TODO: remove the time of the break for all steps of the record - this.breaktime = null + this.records[recordId].breakTime = undefined } }, getters: {