You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
763 B

  1. <script lang="ts">
  2. import type { TaskResult } from "../models/task";
  3. import Progress from "./Progress.svelte";
  4. interface ProjectLike {
  5. tasks?: TaskResult[]
  6. statusTag?: string
  7. }
  8. export let project: ProjectLike;
  9. let progressAmount: number;
  10. let progressTarget: number;
  11. $: progressAmount = (project.tasks||[]).map(t => (t.active || t.statusTag === "to do" || t.statusTag === "on hold")
  12. ? Math.min(t.completedAmount, t.itemAmount) * t.item.groupWeight
  13. : t.itemAmount * t.item.groupWeight
  14. ).reduce((n,m) => n+m, 0);
  15. $: progressTarget = Math.max((project.tasks||[]).map(t => t.itemAmount * t.item.groupWeight).reduce((n,m) => n+m, 0), 1);
  16. </script>
  17. <Progress thin contextColor count={progressAmount} target={progressTarget} />