diff --git a/TODO b/TODO index 7f2710f92..3ac6d2523 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,10 @@ tables should be aware that rows are players who have pids. add bulk/all/select operations at table-level through ... menu - ... -> Bulk select players - if checkboxes are shown by default, still have this to show the "Bulk" button - - only show this if table rows have metadata? or some global prop? + - only show if some table rows have metadata? or some global prop? - is getPlayersNextWatch too slow with select all on a large table? maybe don't do that on menu open? - for header checkbox, only show dropdown if pagination matters (more than 2 options shown), otherwise just toggle immediately? +- if metadata season is career, how does export season work? - controlled mode (selectedRows passed to DataTable and accessible/controlled from outside) - is it possible to do this without fully defining stuff outside, like can we access the state of the child? - can i make a separate instance of useBulkSelectRows and pass everything in easily? @@ -15,7 +16,9 @@ tables should be aware that rows are players who have pids. add bulk/all/select - replace existing links to "compare players" pages - first, make a popup appear when you click the link explaining new UI. set reminder to delete eventually - add to all pages - search for - {showBulkSelectCheckboxes && row.metadata ? ( - + {showBulkSelectCheckboxes ? ( + row.metadata ? ( + + ) : ( + + ) ) : null} {row.data.map((value = null, i) => { // Value is either the value, or an object containing the value as a property diff --git a/src/ui/components/DataTable/index.tsx b/src/ui/components/DataTable/index.tsx index f5626d9d6..4a5aa4840 100644 --- a/src/ui/components/DataTable/index.tsx +++ b/src/ui/components/DataTable/index.tsx @@ -50,7 +50,7 @@ export type SuperCol = { export type DataTableRowMetadata = { type: "player"; pid: number; - season: number; + season: number | "career"; playoffs: "playoffs" | "regularSeason" | "combined"; }; diff --git a/src/ui/views/AwardsRecords.tsx b/src/ui/views/AwardsRecords.tsx index 208765397..2b84bcca4 100644 --- a/src/ui/views/AwardsRecords.tsx +++ b/src/ui/views/AwardsRecords.tsx @@ -4,6 +4,7 @@ import useTitleBar from "../hooks/useTitleBar"; import { getCols, helpers } from "../util"; import type { View } from "../../common/types"; import { wrappedPlayerNameLabels } from "../components/PlayerNameLabels"; +import type { DataTableRow } from "../components/DataTable"; const formatYear = (year: { [key: string]: { team: string; season: number }[]; @@ -57,11 +58,17 @@ const AwardsRecords = ({ }, }); - const rows = awardsRecords.map(a => { + const rows: DataTableRow[] = awardsRecords.map(a => { const yearsGrouped = groupBy(a.years, "team"); return { key: a.pid, + metadata: { + type: "player", + pid: a.pid, + season: a.lastYear, + playoffs: "regularSeason", + }, data: [ wrappedPlayerNameLabels({ pid: a.pid, diff --git a/src/ui/views/Colleges.tsx b/src/ui/views/Colleges.tsx index 1059bfb6b..1da492596 100644 --- a/src/ui/views/Colleges.tsx +++ b/src/ui/views/Colleges.tsx @@ -4,6 +4,7 @@ import { CountryFlag, DataTable } from "../components"; import type { View } from "../../common/types"; import { frivolitiesMenu } from "./Frivolities"; import { wrappedPlayerNameLabels } from "../components/PlayerNameLabels"; +import type { DataTableRow } from "../components/DataTable"; export const genView = ( type: "college" | "country" | "draftPosition" | "jerseyNumbers", @@ -73,7 +74,7 @@ export const genView = ( }, ); - const rows = infos.map(c => { + const rows: DataTableRow[] = infos.map(c => { const p = c.p; const abbrev = teamInfoCache[p.legacyTid]?.abbrev; @@ -82,6 +83,12 @@ export const genView = ( return { key: c.name, + metadata: { + type: "player", + pid: p.pid, + season: "career", + playoffs: "regularSeason", + }, data: [ { + const rowsUndrafted: DataTableRow[] = undrafted.map(p => { const data = [ p.rank, wrappedPlayerNameLabels({ @@ -202,6 +203,12 @@ const Draft = ({ return { key: p.pid, + metadata: { + type: "player", + pid: p.pid, + season, + playoffs: "regularSeason", + }, data, }; }); @@ -217,7 +224,7 @@ const Draft = ({ const teamInfoCache = useLocal(state => state.teamInfoCache); - const rowsDrafted = drafted.map((p, i) => { + const rowsDrafted: DataTableRow[] = drafted.map((p, i) => { const data = [ `${p.draft.round}-${p.draft.pick}`, { @@ -354,6 +361,15 @@ const Draft = ({ return { key: i, + metadata: + p.pid >= 0 + ? { + type: "player", + pid: p.pid, + season, + playoffs: "regularSeason", + } + : undefined, data, classNames: { "table-info": diff --git a/src/ui/views/DraftHistory.tsx b/src/ui/views/DraftHistory.tsx index 746597bda..89fb35cf6 100644 --- a/src/ui/views/DraftHistory.tsx +++ b/src/ui/views/DraftHistory.tsx @@ -7,6 +7,7 @@ import { bySport, PLAYER } from "../../common"; import { wrappedAgeAtDeath } from "../components/AgeAtDeath"; import { wrappedPlayerNameLabels } from "../components/PlayerNameLabels"; import { orderBy } from "../../common/utils"; +import type { DataTableRow } from "../components/DataTable"; const Summary = ({ players, @@ -187,7 +188,7 @@ const ExportButton = ({ season }: { season: number }) => { const [exporting, setExporting] = useState(false); return (