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 end?: ISODate
stepRecords: Record<string, TimeRange> stepRecords: Record<string, TimeRange>
notes: string notes: string
breakTime?: TimeRange
} }

View File

@@ -7,15 +7,13 @@ import { TaskRecord } from '../models/task-record'
export interface TaskRecordStoreState { export interface TaskRecordStoreState {
currentStepId: string | null currentStepId: string | null
records: { [recordId: string]: Recordable } records: { [recordId: string]: Recordable }
breaktime: TimeRange | null
} }
export const useTaskRecordStore = defineStore('task-record-store', { export const useTaskRecordStore = defineStore('task-record-store', {
persist: true, persist: true,
state: (): TaskRecordStoreState => ({ state: (): TaskRecordStoreState => ({
currentStepId: null, currentStepId: null,
records: {}, records: {}
breaktime: null
}), }),
actions: { actions: {
addRecord(taskId: string) { addRecord(taskId: string) {
@@ -118,24 +116,24 @@ export const useTaskRecordStore = defineStore('task-record-store', {
this.records[taskId].stepRecords = {} this.records[taskId].stepRecords = {}
this.records[taskId].end = undefined this.records[taskId].end = undefined
}, },
pause() { pause(recordId: string) {
if (this.breaktime) { if (this.records[recordId]?.breakTime) {
return return
} }
this.breaktime = { this.records[recordId].breakTime = {
start: toISODate(new Date()) start: toISODate(new Date())
} }
}, },
resume(recordId: string) { resume(recordId: string) {
console.log(recordId) console.log(recordId)
if (!this.breaktime) { if (!this.records[recordId].breakTime) {
return return
} }
// TODO: remove the time of the break for all steps of the record // TODO: remove the time of the break for all steps of the record
this.breaktime = null this.records[recordId].breakTime = undefined
} }
}, },
getters: { getters: {