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.

56 lines
1.7 KiB

  1. <script lang="ts">
  2. import type { ProjectResult } from "../models/project";
  3. import selectionStore from "../stores/selection";
  4. import ProjectEntry from "./ProjectEntry.svelte";
  5. import QlList from "./QLList.svelte";
  6. export let projects: ProjectResult[];
  7. let expiringProjects: ProjectResult[];
  8. let activeProjects: ProjectResult[];
  9. let completedProjects: ProjectResult[];
  10. let project: ProjectResult = null;
  11. $: project = $selectionStore.hash.startsWith("P") ? projects.find(p => p.id === $selectionStore.hash) : null;
  12. $: expiringProjects = projects.filter(p => p.active && p.endTime).sort((a,b) => Date.parse(a.endTime) - Date.parse(b.endTime));
  13. $: activeProjects = projects.filter(p => p.active && !p.endTime).sort((a,b) => a.name.localeCompare(b.name));
  14. $: completedProjects = projects.filter(p => !p.active).sort((a,b) => a.name.localeCompare(b.name));
  15. $: {
  16. if (project === null && projects.length > 0) {
  17. project = expiringProjects[0] || activeProjects[0] || completedProjects[0] || null;
  18. if (project !== null) {
  19. selectionStore.change("hash", project.id);
  20. }
  21. }
  22. }
  23. </script>
  24. <div class="quest-log">
  25. <div class="list">
  26. <QlList label="Deadlines" projects={expiringProjects} />
  27. <QlList label="Active" projects={activeProjects} />
  28. <QlList label="Completed" projects={completedProjects} />
  29. </div>
  30. <div class="body">
  31. {#if project != null}
  32. <ProjectEntry hideIcon project={project} showAllOptions />
  33. {/if}
  34. </div>
  35. </div>
  36. <style>
  37. div.quest-log {
  38. display: flex;
  39. flex-direction: row;
  40. }
  41. div.list {
  42. flex-shrink: 0;
  43. width: 32ch;
  44. }
  45. div.body {
  46. flex-grow: 1;
  47. margin: 1em 1ch;
  48. }
  49. </style>