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
2.0 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>
  2. import { get } from "svelte/store";
  3. import pluralize from "pluralize";
  4. import Boi from "../components/Boi.svelte";
  5. import AddBoi from "../components/AddBoi.svelte";
  6. import Link from "../components/Link.svelte";
  7. import Table from "../components/Table.svelte";
  8. import GoalTable from "../components/tables/GoalTable.svelte";
  9. import LogTable from "../components/tables/LogTable.svelte";
  10. import stufflog from "../stores/stufflog";
  11. import modal from "../stores/modal";
  12. import items from "../stores/items";
  13. import dateStr from "../utils/dateStr";
  14. function getPeriod(id) {
  15. return get(stufflog).periods.find(a => a.id === id)
  16. }
  17. </script>
  18. <div class="page">
  19. <AddBoi top on:click={() => modal.open("period.create")}>Period</AddBoi>
  20. {#each $stufflog.periods as period (period.id)}
  21. <Boi header={period.name}>
  22. <Table headers={["From", "To", "Options"]} percentages={[25, 25, 50]}>
  23. <td>{dateStr(period.from)}</td>
  24. <td>{dateStr(period.to)}</td>
  25. <td>
  26. <Link on:click={() => modal.open("period.edit", {period: getPeriod(period.id)})}>Edit Period</Link>,
  27. <Link on:click={() => modal.open("periodgoal.add", {period: getPeriod(period.id)})}>Add Goal</Link>,
  28. {#if period.goals.length > 0}
  29. <Link on:click={() => modal.open("periodlog.add", {period: getPeriod(period.id)})}>Add Log</Link>,
  30. {/if}
  31. <Link on:click={() => modal.open("period.delete", {period: getPeriod(period.id)})}>Delete Period</Link>
  32. </td>
  33. </Table>
  34. <GoalTable
  35. activities={$stufflog.activities}
  36. period={period}
  37. on:option={(e) => modal.open(e.detail.name, e.detail)}
  38. />
  39. <LogTable
  40. activities={$stufflog.activities}
  41. items={$items}
  42. period={period}
  43. on:option={(e) => modal.open(e.detail.name, e.detail)}
  44. />
  45. </Boi>
  46. {/each}
  47. </div>
  48. <style>
  49. div.page {
  50. width: 100ch;
  51. max-width: 90%;
  52. margin: auto;
  53. }
  54. </style>