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.

67 lines
1.9 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
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 item = null;
  14. let activityPoints = 0;
  15. let itemBonus = 0;
  16. let roundingError = 0;
  17. let title = ""
  18. $: activityPoints = log.score.amount * log.score.activityScore;
  19. $: itemBonus = item ? activityPoints * (item.multiplier - 1) : 0;
  20. $: roundingError = (log.score.total) - (Math.floor(activityPoints) + Math.floor(itemBonus) + log.score.dailyBonus);
  21. $: title = `${dateStr(log.date)} - ${(activity||{name:"(Unknown)"}).name} ${(subActivity||{name:"(Unknown)"}).name}`
  22. </script>
  23. <ModalFrame title={title} closable on:close={() => modal.close()}>
  24. <form on:submit|preventDefault={() => modal.close()}>
  25. {#if log.description !== ""}
  26. <Property label="Description">
  27. {log.description}
  28. </Property>
  29. {/if}
  30. <Property label="Activity Points">
  31. {Math.floor(activityPoints + roundingError)} points
  32. {#if (subActivity != null)}
  33. <span>
  34. ({log.score.amount} {pluralize(subActivity.unitName, log.score.amount)})
  35. </span>
  36. {/if}
  37. </Property>
  38. {#if item != null}
  39. <Property label="Sub-Goal">
  40. {Math.floor(itemBonus)} points
  41. ({item.name})
  42. </Property>
  43. {/if}
  44. {#if log.score.dailyBonus != 0}
  45. <Property label="Daily Bonus">
  46. {log.score.dailyBonus} points
  47. </Property>
  48. {/if}
  49. <Property label="Total">
  50. {log.score.total} points
  51. </Property>
  52. <hr />
  53. <button type="submit">Add Goal</button>
  54. </form>
  55. </ModalFrame>
  56. <style>
  57. </style>