take some notes while doing a task

This commit is contained in:
Julien Calixte
2023-04-13 00:30:40 +02:00
parent 049b52d6b1
commit 5888ea49e7
4 changed files with 35 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ const task = computed(() => taskStore.getTask(props.taskId))
const record = computed(() =>
recordStore.createAndRetrieveTaskRecord(props.taskId, props.recordId)
)
const recordNotes = computed(() => recordStore.getRecordNotes(props.recordId))
const { duration } = useTaskRecordMetadata(record)
const getNextStepId = () => {
@@ -137,6 +138,18 @@ const isSuperiorToEstimation = computed(() => {
than expected.
</span>
</div>
<textarea
name="record-notes"
id="record-notes"
cols="30"
rows="10"
:value="recordNotes"
@input="
//@ts-ignore
recordStore.updateRecordNotes(recordId, $event.target?.value)
"
placeholder="notes"
></textarea>
</main>
</template>

View File

@@ -11,4 +11,5 @@ export interface Recordable {
start: ISODate
end?: ISODate
stepRecords: Record<string, StepRecordable>
notes: string
}

View File

@@ -6,6 +6,7 @@ export class TaskRecord implements Recordable {
public start: ISODate = toISODate(new Date())
public end: ISODate | undefined = undefined
public stepRecords: Record<string, StepRecordable> = {}
public notes = ''
public constructor(
public readonly id: string,

View File

@@ -85,6 +85,21 @@ export const useTaskRecordStore = defineStore('task-record-store', {
endRecord(recordId: string) {
this.records[recordId].end = toISODate(new Date())
this.currentStepId = null
},
updateRecordNotes(recordId: string, notes: string) {
const record = this.records[recordId]
if (record) {
this.$patch({
records: {
...this.records,
[recordId]: {
...record,
notes
}
}
})
}
}
},
getters: {
@@ -109,11 +124,14 @@ export const useTaskRecordStore = defineStore('task-record-store', {
}
},
getRecord() {
return (recordId: string) => this.records?.[recordId] ?? null
return (recordId: string) => this.records[recordId] ?? null
},
getStepRecord() {
return (recordId: string, stepId: string): StepRecordable | null =>
this.records?.[recordId]?.stepRecords[stepId] ?? null
this.records[recordId]?.stepRecords[stepId] ?? null
},
getRecordNotes() {
return (recordId: string): string => this.records[recordId]?.notes ?? ''
}
}
})