|
|
@ -1,7 +1,7 @@ |
|
|
|
<script lang="ts"> |
|
|
|
import stuffLogClient from "../clients/stufflog"; |
|
|
|
|
|
|
|
import type { ProjectResult } from "../models/project"; |
|
|
|
import type { ProjectResult, ProjectUpdate } from "../models/project"; |
|
|
|
import type { TaskResult } from "../models/task"; |
|
|
|
import markStale from "../stores/markStale"; |
|
|
|
import type { ModalData } from "../stores/modal"; |
|
|
@ -37,15 +37,13 @@ import stuffLogClient from "../clients/stufflog"; |
|
|
|
let toggling = false; |
|
|
|
let canComplete = false; |
|
|
|
|
|
|
|
function toggleFavorite() { |
|
|
|
function updateProject(update: ProjectUpdate) { |
|
|
|
if (toggling) { |
|
|
|
return |
|
|
|
} |
|
|
|
toggling = true |
|
|
|
|
|
|
|
stuffLogClient.updateProject(project.id, { |
|
|
|
favorite: !project.favorite, |
|
|
|
}).then(() => { |
|
|
|
stuffLogClient.updateProject(project.id, {...update}).then(() => { |
|
|
|
markStale("project"); |
|
|
|
}).catch(err => { |
|
|
|
console.warn("Failed to toggle favorite:", err); |
|
|
@ -54,21 +52,23 @@ import stuffLogClient from "../clients/stufflog"; |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
function markCompleted() { |
|
|
|
if (toggling) { |
|
|
|
return |
|
|
|
function toggleFavorite() { |
|
|
|
updateProject({ |
|
|
|
favorite: !project.favorite, |
|
|
|
}); |
|
|
|
} |
|
|
|
toggling = true |
|
|
|
|
|
|
|
stuffLogClient.updateProject(project.id, { |
|
|
|
function markCompleted() { |
|
|
|
updateProject({ |
|
|
|
statusTag: "completed", |
|
|
|
active: false, |
|
|
|
}).then(() => { |
|
|
|
markStale("project"); |
|
|
|
}).catch(err => { |
|
|
|
console.warn("Failed to mark completed:", err); |
|
|
|
}).finally(() => { |
|
|
|
toggling = false; |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
function markFailed() { |
|
|
|
updateProject({ |
|
|
|
statusTag: "failed", |
|
|
|
active: false, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
@ -117,7 +117,8 @@ import stuffLogClient from "../clients/stufflog"; |
|
|
|
<Option open={mdProjectEdit}>Edit</Option> |
|
|
|
<Option open={mdProjectDelete}>Delete</Option> |
|
|
|
{#if canComplete} |
|
|
|
<Option disabled={!toggling} green on:click={markCompleted}>Complete Project</Option> |
|
|
|
<Option disabled={!toggling} color="green" on:click={markCompleted}>Complete Project</Option> |
|
|
|
<Option disabled={!toggling} color="red" on:click={markFailed}>Fail Project</Option> |
|
|
|
{/if} |
|
|
|
</OptionRow> |
|
|
|
{/if} |
|
|
|