|
|
@ -7,25 +7,25 @@ import logStore from "../stores/logs"; |
|
|
|
import projectStore, { fpProjectStore } from "../stores/project"; |
|
|
|
import { formatFormTime } from "../utils/time"; |
|
|
|
|
|
|
|
const md = $modalStore; |
|
|
|
if (md.name !== "log.add") { |
|
|
|
throw new Error("Wrong form"); |
|
|
|
} |
|
|
|
const task = md.task; |
|
|
|
|
|
|
|
let loggedTime = formatFormTime(new Date); |
|
|
|
let taskName = ""; |
|
|
|
let description = ""; |
|
|
|
let markInactive = false; |
|
|
|
let markInactive = task.completedAmount >= (task.itemAmount - 1); |
|
|
|
let error = null; |
|
|
|
|
|
|
|
function onSubmit() { |
|
|
|
const md = $modalStore; |
|
|
|
if (md.name !== "log.add") { |
|
|
|
throw new Error("Wrong form"); |
|
|
|
} |
|
|
|
|
|
|
|
stuffLogClient.createLog({ |
|
|
|
taskId: md.task.id, |
|
|
|
taskId: task.id, |
|
|
|
loggedTime: new Date(loggedTime).toISOString(), |
|
|
|
description, |
|
|
|
}).then(() => { |
|
|
|
if (markInactive) { |
|
|
|
return stuffLogClient.updateTask(md.task.id, {active: false}) |
|
|
|
return stuffLogClient.updateTask(task.id, {active: false}) |
|
|
|
} |
|
|
|
}).then(() => { |
|
|
|
modalStore.close(); |
|
|
@ -43,19 +43,12 @@ import logStore from "../stores/logs"; |
|
|
|
function onClose() { |
|
|
|
modalStore.close(); |
|
|
|
} |
|
|
|
|
|
|
|
$: { |
|
|
|
const md = $modalStore; |
|
|
|
if (md.name === "log.add") { |
|
|
|
taskName = md.task.name; |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<Modal show title="Add Log" error={error} closable on:close={onClose}> |
|
|
|
<form on:submit|preventDefault={onSubmit}> |
|
|
|
<label for="taskName">Task</label> |
|
|
|
<input disabled name="taskName" type="text" bind:value={taskName} /> |
|
|
|
<input disabled name="taskName" type="text" bind:value={task.name} /> |
|
|
|
|
|
|
|
<label for="loggedTime">Logged Time</label> |
|
|
|
<input name="loggedTime" type="datetime-local" bind:value={loggedTime} /> |
|
|
|