breaktime is part of records now
This commit is contained in:
@@ -7,4 +7,5 @@ export interface Recordable {
|
||||
end?: ISODate
|
||||
stepRecords: Record<string, TimeRange>
|
||||
notes: string
|
||||
breakTime?: TimeRange
|
||||
}
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user