mirror of
https://github.com/DCsunset/taskwarrior-webui.git
synced 2025-08-21 04:43:06 +02:00
feat(frontend): add progress for projects
This commit is contained in:
parent
711bef5084
commit
ba67268b1b
1 changed files with 24 additions and 2 deletions
|
@ -15,6 +15,16 @@
|
||||||
style="max-width: 120px"
|
style="max-width: 120px"
|
||||||
hide-details
|
hide-details
|
||||||
/>
|
/>
|
||||||
|
<div class="ml-6 d-flex align-center">
|
||||||
|
<v-progress-circular
|
||||||
|
:size="54"
|
||||||
|
:width="5"
|
||||||
|
:value="progress"
|
||||||
|
color="primary"
|
||||||
|
>
|
||||||
|
{{ progress }}%
|
||||||
|
</v-progress-circular>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<v-spacer />
|
<v-spacer />
|
||||||
|
@ -69,7 +79,7 @@ export default defineComponent({
|
||||||
project.value = '';
|
project.value = '';
|
||||||
});
|
});
|
||||||
|
|
||||||
const tasks = computed(() => {
|
const tasks: ComputedRef<Task[]> = computed(() => {
|
||||||
if (mode.value === 'Tasks')
|
if (mode.value === 'Tasks')
|
||||||
return context.root.$store.state.tasks;
|
return context.root.$store.state.tasks;
|
||||||
|
|
||||||
|
@ -81,13 +91,25 @@ export default defineComponent({
|
||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const progress = computed(() => {
|
||||||
|
if (mode.value === 'Projects' && project.value) {
|
||||||
|
const completed = tasks.value.reduce((acc: number, task) => task.status === 'completed' ? acc + 1 : acc, 0);
|
||||||
|
const pending = tasks.value.reduce((acc: number, task) => task.status === 'pending' ? acc + 1 : acc, 0);
|
||||||
|
return completed + pending === 0
|
||||||
|
? 100
|
||||||
|
: Math.ceil(100 * completed / (completed + pending));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mode,
|
mode,
|
||||||
allModes,
|
allModes,
|
||||||
TaskList,
|
TaskList,
|
||||||
tasks,
|
tasks,
|
||||||
projects,
|
projects,
|
||||||
project
|
project,
|
||||||
|
progress
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue