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.

65 lines
1.8 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <script lang="ts">
  2. import type { IconName } from "../external/icons";
  3. import type { GoalResult } from "../models/goal";
  4. import type { ModalData } from "../stores/modal";
  5. import Composition from "./Composition.svelte";
  6. import Option from "./Option.svelte";
  7. import OptionRow from "./OptionRow.svelte";
  8. import ParentEntry from "./ParentEntry.svelte";
  9. import Progress from "./Progress.svelte";
  10. import ProgressNumbers from "./ProgressNumbers.svelte";
  11. import TimeProgress from "./TimeProgress.svelte";
  12. export let goal: GoalResult = null;
  13. export let showAllOptions = false;
  14. export let linkGoal = false;
  15. let mdGoalEdit: ModalData;
  16. let mdGoalDelete: ModalData;
  17. let annotations: IconName[];
  18. $: mdGoalEdit = {name:"goal.edit", goal};
  19. $: mdGoalDelete = {name:"goal.delete", goal};
  20. $: {
  21. annotations = [];
  22. if (goal.unweighted) {
  23. annotations.push("balance_scale")
  24. }
  25. if (goal.taskFilter) {
  26. annotations.push("filter")
  27. }
  28. if (goal.itemFilter) {
  29. annotations.push("filter")
  30. }
  31. }
  32. </script>
  33. <ParentEntry
  34. full={showAllOptions}
  35. entry={goal}
  36. headerLink={linkGoal ? "/goals#"+goal.id : ""}
  37. annotations={annotations}
  38. >
  39. {#if showAllOptions}
  40. <OptionRow>
  41. <Option open={mdGoalEdit}>Edit</Option>
  42. <Option open={mdGoalDelete}>Delete</Option>
  43. </OptionRow>
  44. {/if}
  45. <div slot="post-seprator">
  46. {#if showAllOptions}
  47. <ProgressNumbers goal={goal} />
  48. {/if}
  49. </div>
  50. <div class="progress">
  51. <Progress count={goal.completedAmount} target={goal.amount} />
  52. <TimeProgress startTime={goal.startTime} endTime={goal.endTime} />
  53. </div>
  54. <Composition ignoreZeroWeight logs={goal.logs} mode={goal.compositionMode} />
  55. </ParentEntry>
  56. <style>
  57. div.progress {
  58. padding-top: 0.125em;
  59. font-size: 1.25em;
  60. }
  61. </style>