Plan stuff. Log stuff.
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.

61 lines
1.8 KiB

4 years ago
  1. <script>
  2. import pluralize from "pluralize";
  3. import ModalFrame from "../components/ModalFrame";
  4. import SubGoalInput from "../components/SubGoalInput";
  5. import Property from "../components/Property";
  6. import modal from "../stores/modal";
  7. import stufflog from "../stores/stufflog";
  8. import dateStr from "../utils/dateStr";
  9. export let period = {};
  10. export let log = {};
  11. export let activity = {};
  12. export let subActivity = {};
  13. export let subGoal = null;
  14. let activityPoints = 0;
  15. let subGoalBonus = 0;
  16. let roundingError = 0;
  17. $: activityPoints = log.score.amount * log.score.activityScore;
  18. $: subGoalBonus = subGoal.multiplier ? activityPoints * (subGoal.multiplier - 1) : 0;
  19. $: roundingError = (log.score.total) - (Math.floor(activityPoints) + Math.floor(subGoalBonus) + log.score.dailyBonus);
  20. </script>
  21. <ModalFrame title={`${dateStr(log.date)} - ${activity.name} ${subActivity.name}`} closable on:close={() => modal.close()}>
  22. <form on:submit|preventDefault={() => modal.close()}>
  23. {#if log.description !== ""}
  24. <Property label="Description">
  25. {log.description}
  26. </Property>
  27. {/if}
  28. <Property label="Activity Points">
  29. {Math.floor(activityPoints + roundingError)} points
  30. ({log.score.amount} {pluralize(subActivity.unitName, log.score.amount)})
  31. </Property>
  32. {#if subGoal.multiplier != null}
  33. <Property label="Sub-Goal">
  34. {Math.floor(subGoalBonus)} points
  35. ({subGoal.name})
  36. </Property>
  37. {/if}
  38. {#if log.score.dailyBonus != 0}
  39. <Property label="Daily Bonus">
  40. {log.score.dailyBonus} points
  41. </Property>
  42. {/if}
  43. <Property label="Total">
  44. {log.score.total} points
  45. </Property>
  46. <hr />
  47. <button type="submit">Add Goal</button>
  48. </form>
  49. </ModalFrame>
  50. <style>
  51. </style>