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.

29 lines
940 B

  1. <script>
  2. import { createEventDispatcher } from 'svelte';
  3. import pluralize from "pluralize";
  4. import Link from "../Link.svelte";
  5. import Table from "../Table.svelte";
  6. export let activity = {subActivities: []}
  7. const dispatch = createEventDispatcher();
  8. function onOption(name, subId) {
  9. const subActivity = activity.subActivities.find(s => s.id === subId);
  10. dispatch("option", {name, activity, subActivity})
  11. }
  12. </script>
  13. <Table headers={["Sub-Activity", "Value", "Options"]} percentages={[50, 25, 25]}>
  14. {#each activity.subActivities as subActivtiy (subActivtiy.id)}
  15. <tr>
  16. <td>{subActivtiy.name}</td>
  17. <td>{subActivtiy.value} per {pluralize(subActivtiy.unitName, 1)}</td>
  18. <td>
  19. <Link on:click={() => onOption("subactivity.edit", subActivtiy.id)}>Edit</Link>,
  20. <Link on:click={() => onOption("subactivity.remove", subActivtiy.id)}>Delete</Link>
  21. </td>
  22. </tr>
  23. {/each}
  24. </Table>