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