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.

110 lines
3.0 KiB

  1. <script lang="ts">
  2. import { tick } from "svelte";
  3. import { navigate } from "svelte-routing";
  4. import type { ProjectGroupResult } from "../models/projectgroup";
  5. import modalStore from "../stores/modal";
  6. import projectGroupStore from "../stores/projectGroup";
  7. import { sortProjects } from "../utils/sorters";
  8. import ColoredNumber from "./ColoredNumber.svelte";
  9. export let groups: ProjectGroupResult[] = [];
  10. export let selected: string;
  11. let failedCount = 0;
  12. function onClickAdd() {
  13. modalStore.set({name: "projectgroup.add"});
  14. }
  15. function onNavigate(group: ProjectGroupResult) {
  16. if (group.projects.length === 0) {
  17. navigate(`/questlog/${group.id}`);
  18. } else {
  19. const projetcs = [...group.projects].sort(sortProjects);
  20. navigate(`/questlog/${group.id}/${projetcs[0].id}`);
  21. // There's some weirdness with navigate. This hack will just do a
  22. // groups = [...groups] in the sttore to get the page to update.
  23. tick().then(() => {
  24. projectGroupStore.fakeRefresh();
  25. })
  26. }
  27. }
  28. </script>
  29. <div class="group-menu">
  30. {#each groups as group (group.id)}
  31. <div class="group-entry" on:click={() => onNavigate(group)} class:selected={selected === group.id}>
  32. <div class="name">{group.abbreviation}</div>
  33. <div class="counts">
  34. <ColoredNumber selected={selected === group.id} status="active" number={group.projectCounts["active"]} />
  35. <ColoredNumber selected={selected === group.id} status="background" number={group.projectCounts["background"]} />
  36. <ColoredNumber selected={selected === group.id} status="progress" number={group.projectCounts["progress"]} />
  37. <ColoredNumber selected={selected === group.id} status="to do" number={group.projectCounts["to do"]} />
  38. <ColoredNumber selected={selected === group.id} status="on hold" number={group.projectCounts["on hold"]} />
  39. </div>
  40. </div>
  41. {/each}
  42. <div class="group-entry add" on:click={onClickAdd}>
  43. <div>+</div>
  44. </div>
  45. </div>
  46. <style>
  47. div.group-menu {
  48. display: flex;
  49. flex-direction: row;
  50. padding: 0 2ch;
  51. border-bottom: 1px solid #333;
  52. margin-bottom: 0.5em;
  53. -webkit-user-select: none;
  54. -moz-user-select: none;
  55. }
  56. div.group-entry {
  57. padding: 0.05em 1ch;
  58. padding-bottom: 0.15em;
  59. margin-right: 2ch;
  60. border: 1px solid #333;
  61. border-bottom: none;
  62. border-top-left-radius: 0.5em;
  63. border-top-right-radius: 0.5em;
  64. cursor: pointer;
  65. color: #777;
  66. font-weight: 300;
  67. }
  68. div.group-entry.add {
  69. color: #333;
  70. }
  71. div.group-entry.add > div {
  72. font-size: 2em;
  73. line-height: 1em;
  74. }
  75. div.group-entry.selected {
  76. background-color: #191919;
  77. color: #AAA;
  78. }
  79. div.group-entry:hover {
  80. color: #CCC;
  81. background-color: #222222;
  82. }
  83. div.name {
  84. text-align: center;
  85. padding: 0em 0.4ch;
  86. }
  87. div.counts {
  88. font-size: 0.666em;
  89. font-weight: 400;
  90. text-align: center;
  91. }
  92. div.counts :global(div) {
  93. display: inline-block;
  94. padding: 0em 0.2ch;
  95. }
  96. </style>