Browse Source

add mark as completed button when the project has only completed and failed tasks.

main
Gisle Aune 4 years ago
parent
commit
7dc9b9cc40
  1. 11
      svelte-ui/src/components/Option.svelte
  2. 24
      svelte-ui/src/components/ProjectEntry.svelte

11
svelte-ui/src/components/Option.svelte

@ -4,6 +4,8 @@
import modalStore from "../stores/modal";
export let open: ModalData = {name: "none"};
export let green: boolean = false;
export let disabled: boolean = false;
const dispatch = createEventDispatcher();
@ -16,7 +18,7 @@
}
</script>
<div on:click={handleClick} class="option"><slot></slot></div>
<div on:click={handleClick} class="option" class:green class:disabled><slot></slot></div>
<style>
div.option {
@ -35,4 +37,11 @@
color: #FC1;
text-decoration: underline;
}
div.option.green {
color: #484;
}
div.option.green:hover {
color: #78ff78;
}
</style>

24
svelte-ui/src/components/ProjectEntry.svelte

@ -35,6 +35,7 @@ import stuffLogClient from "../clients/stufflog";
let failedTasks: TaskResult[] = [];
let nonHiddenTasks: TaskResult[] = [];
let toggling = false;
let canComplete = false;
function toggleFavorite() {
if (toggling) {
@ -53,6 +54,24 @@ import stuffLogClient from "../clients/stufflog";
})
}
function markCompleted() {
if (toggling) {
return
}
toggling = true
stuffLogClient.updateProject(project.id, {
statusTag: "completed",
active: false,
}).then(() => {
markStale("project");
}).catch(err => {
console.warn("Failed to mark completed:", err);
}).finally(() => {
toggling = false;
})
}
$: mdAddTask = {name:"task.add", project};
$: mdProjectEdit = {name:"project.edit", project};
$: mdProjectDelete = {name:"project.delete", project};
@ -69,6 +88,8 @@ import stuffLogClient from "../clients/stufflog";
nonHiddenTasks = [...activeTasks, ...todoTasks, ...onholdTasks];
}
$: canComplete = project.active && completedTasks.length + failedTasks.length === project.tasks.length;
$: linkTarget = IS_MOBILE ? `/projects#${project.id}` : `/questlog#${project.id}`
</script>
@ -95,6 +116,9 @@ import stuffLogClient from "../clients/stufflog";
<Option open={mdAddTask}>Add Task</Option>
<Option open={mdProjectEdit}>Edit</Option>
<Option open={mdProjectDelete}>Delete</Option>
{#if canComplete}
<Option disabled={!toggling} green on:click={markCompleted}>Complete Project</Option>
{/if}
</OptionRow>
{/if}
{#if hideInactive}

Loading…
Cancel
Save