breaktime is part of records now

This commit is contained in:
Julien Calixte
2023-04-17 21:13:08 +02:00
parent 10e6fa0e84
commit b0e35aae72
2 changed files with 7 additions and 8 deletions

View File

@@ -7,4 +7,5 @@ export interface Recordable {
end?: ISODate
stepRecords: Record<string, TimeRange>
notes: string
breakTime?: TimeRange
}

View File

@@ -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: {