Skip to content

Add star button to activity description #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/components/ActivityButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { Timeslot } from "../lib/activity";
import type { Class, SectionLockOption, Sections } from "../lib/class";
import { LockOption } from "../lib/class";
import { WEEKDAY_STRINGS, TIMESLOT_STRINGS, Slot } from "../lib/dates";
import { StarButton } from "./ClassTable";
import { HydrantContext } from "../lib/hydrant";

/**
Expand Down Expand Up @@ -258,6 +259,13 @@ export function ClassButtons(props: { cls: Class }) {
return (
<Flex direction="column" gap={2}>
<ButtonGroup wrap="wrap">
<StarButton
cls={cls}
onStarToggle={() => {
const event = new CustomEvent("refreshStarCells");
window.dispatchEvent(event);
}}
/>
<Button
onClick={() => {
state.toggleActivity(cls);
Expand Down
16 changes: 15 additions & 1 deletion src/components/ClassTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ function ClassFlags(props: {
);
}

const StarButton = ({
export const StarButton = ({
cls,
onStarToggle,
}: {
Expand Down Expand Up @@ -456,6 +456,20 @@ export function ClassTable() {

const gridRef = useRef<AgGridReact<ClassTableRow>>(null);

useEffect(() => {
const refreshCells = () => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
gridRef.current?.api?.refreshCells({
force: true,
columns: ["number"],
});
};
window.addEventListener("refreshStarCells", refreshCells);
return () => {
window.removeEventListener("refreshStarCells", refreshCells);
};
}, []);

// Setup table columns
const columnDefs: ColDef<ClassTableRow, string>[] = useMemo(() => {
const initialSort = "asc" as const;
Expand Down