From dc2f1b8d1592fbd8f805746a4ec5effa107cc2f7 Mon Sep 17 00:00:00 2001 From: Haydn Ewers <27211+haydn@users.noreply.github.com> Date: Sun, 31 Dec 2023 16:25:46 +1100 Subject: [PATCH] feat: add sorting by columns to the issues table --- pages/index.page.tsx | 122 +++++++++++++++++++++++++++++-------------- 1 file changed, 82 insertions(+), 40 deletions(-) diff --git a/pages/index.page.tsx b/pages/index.page.tsx index ef885f2..a681fcf 100644 --- a/pages/index.page.tsx +++ b/pages/index.page.tsx @@ -1,11 +1,16 @@ import type { NextPage } from "next"; -import { useContext } from "react"; +import { useContext, useState } from "react"; import ComparisonValue from "../components/ComparisonValue"; import Layout from "../components/Layout"; import RelationshipGraph from "../components/RelationshipGraph"; import CoreContext from "../core/CoreContext"; const IndexPage: NextPage = () => { + const [sortColumn, setSortColumn] = useState<{ + column: "priority" | "effort" | "value"; + direction: "asc" | "desc"; + }>({ column: "priority", direction: "desc" }); + const { state, updateIssueEstimate } = useContext(CoreContext); const { issueSummaries, scales, stats } = state; @@ -82,46 +87,81 @@ const IndexPage: NextPage = () => {
| Key | -Project | -Cycle | -Title | -Rank | -
- Effort
- - Count - |
-
- Value
- - Count - |
-
- Effort
- - Rating - |
-
- Value
- - Rating - |
- Dependencies | -
- Linear
- - Estimate - |
+ {(
+ [
+ { key: "key", label: "Key" },
+ { key: "project", label: "Project" },
+ { key: "cycle", label: "Cycle" },
+ { key: "title", label: "Title" },
+ { key: "priority", label: "Priority", sortColumn: "priority" },
+ { key: "effort", label: "Effort", sortColumn: "effort" },
+ { key: "value", label: "Value", sortColumn: "value" },
+ { key: "dependencies", label: "Dependencies" },
+ {
+ key: "linear-estimate",
+ label: (
+ <>
+ Linear
+ { + setSortColumn((current) => ({ + column: col.sortColumn, + direction: + current.column !== col.sortColumn || + current.direction === "asc" + ? "desc" + : "asc", + })); + } + : undefined + } + > + {col.label} + {"sortColumn" in col ? ( + <> + + {sortColumn.column === col.sortColumn + ? sortColumn.direction === "desc" + ? "↓" + : "↑" + : "↕"} + > + ) : null} + | + ))}
|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -133,17 +173,19 @@ const IndexPage: NextPage = () => { | {issue.title} | {priority(id).toFixed(2)} |
+ {scales.effort(stats.effort[id].rating).toFixed(2)} (
|
+ {scales.value(stats.value[id].rating).toFixed(2)} (
|
- {scales.effort(stats.value[id].rating).toFixed(2)} | -{scales.value(stats.value[id].rating).toFixed(2)} |
|