Skip to content

Commit

Permalink
feat: Filters
Browse files Browse the repository at this point in the history
  • Loading branch information
mathhulk committed Apr 25, 2024
1 parent 0d5ccf4 commit 3f63ced
Show file tree
Hide file tree
Showing 20 changed files with 750 additions and 299 deletions.
10 changes: 4 additions & 6 deletions backend/src/modules/catalog/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CourseModel, CourseType } from "../../models/course";
import { SectionModel } from "../../models/section";
import { formatClass, formatCourse, formatSection } from "./formatter";
import { getCourseKey, getCsCourseId } from "../../utils/course";
import { isNil } from "lodash";
import { isNil, some } from "lodash";
import { GraphQLResolveInfo } from "graphql";
import { getChildren } from "../../utils/graphql";

Expand All @@ -24,8 +24,8 @@ export async function getCatalog(term: TermInput, info: GraphQLResolveInfo): Pro
const classes = await ClassModel
.find({
"session.term.name": termToString(term),
"aggregateEnrollmentStatus.maxEnroll": { $gt: 0 },
"anyPrintInScheduleOfClasses": true
// "aggregateEnrollmentStatus.maxEnroll": { $gt: 0 },
anyPrintInScheduleOfClasses: true
})
.lean()

Expand All @@ -44,7 +44,7 @@ export async function getCatalog(term: TermInput, info: GraphQLResolveInfo): Pro
filter by fromDate and then sort to find the
most recent course.
*/
fromDate: { $lte: getTermStartMonth(term) },
// fromDate: { $lte: getTermStartMonth(term) },
},
{
_updatedAt: 1,
Expand Down Expand Up @@ -162,8 +162,6 @@ export async function getCatalog(term: TermInput, info: GraphQLResolveInfo): Pro
catalog[id].classes = catalog[id].classes.filter((c: any) => c.primarySection?.ccn)

if (catalog[id].classes.length === 0) {
console.log("delete")

delete catalog[id]
}
}
Expand Down
4 changes: 2 additions & 2 deletions backend/src/modules/catalog/typedefs/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ type Section {
}
type Instructor {
familyName: String!
givenName: String!
familyName: String
givenName: String
}
type EnrollmentDay {
Expand Down
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-hover-card": "^1.0.7",
"@radix-ui/react-scroll-area": "^1.0.5",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-tooltip": "^1.0.7",
"@shopify/draggable": "^1.1.3",
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/app/Catalog/Class/Sections/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ export default function Sections({
<div className={styles.root}>
<div className={styles.menu}>
{types.map((type) => (
<div className={styles.item}>
{type === "Laboratory" ? "Lab" : "Discussion"}s
</div>
<div className={styles.item}>{type}</div>
))}
</div>
<div className={styles.view}>
Expand All @@ -56,8 +54,7 @@ export default function Sections({
<div className={styles.header}>
<div className={styles.text}>
<p className={styles.title}>
{section.kind === "Laboratory" ? "Lab" : section.kind}{" "}
{section.number}
{section.kind} {section.number}
</p>
<CCN ccn={section.ccn} />
</div>
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/Schedules/Calendar/Event/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import classNames from "classnames";

import { ISection } from "@/lib/api";
import { getY } from "@/lib/schedule";
import { kinds } from "@/lib/section";

import styles from "./Event.module.scss";

Expand Down Expand Up @@ -47,7 +46,7 @@ export default function Event({
{course.subject} {course.number}
</div>
<div className={styles.description}>
{kinds[kind]?.name ?? kind} {number}
{kind} {number}
</div>
</div>
</HoverCard.Trigger>
Expand Down
15 changes: 6 additions & 9 deletions frontend/src/app/Schedules/SideBar/Class/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import AverageGrade from "@/components/AverageGrade";
import Capacity from "@/components/Capacity";
import Units from "@/components/Units";
import { IClass, ISection } from "@/lib/api";
import { kinds } from "@/lib/section";

import styles from "./Class.module.scss";
import Section from "./Section";
Expand Down Expand Up @@ -35,7 +34,7 @@ export default function Class({
onSectionMouseOver,
onSectionMouseOut,
}: ClassProps & IClass) {
const groups = useMemo(
const kinds = useMemo(
() => Array.from(new Set(sections.map((section) => section.kind))),
[sections]
);
Expand Down Expand Up @@ -83,9 +82,7 @@ export default function Class({
</div>
{expanded && (
<div className={styles.group}>
<p className={styles.label}>
{kinds[primarySection.kind]?.name ?? primarySection.kind}
</p>
<p className={styles.label}>{primarySection.kind}</p>
<Section
active={selectedSections.some(
(selectedSection) => selectedSection.ccn === primarySection.ccn
Expand All @@ -97,14 +94,14 @@ export default function Class({
</div>
)}
{expanded &&
groups.map((group) => {
kinds.map((kind) => {
const sortedSections = sections
.filter((section) => section.kind === group)
.filter((section) => section.kind === kind)
.sort((a, b) => a.number.localeCompare(b.number));

return (
<div className={styles.group} key={group}>
<p className={styles.label}>{kinds[group]?.name ?? group}</p>
<div className={styles.group} key={kind}>
<p className={styles.label}>{kind}</p>
{sortedSections.map((section) => {
const active = selectedSections.some(
(selectedSection) => selectedSection.ccn === section.ccn
Expand Down
106 changes: 75 additions & 31 deletions frontend/src/components/Browser/Filters/Filters.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
width: 384px;
flex-shrink: 0;
overflow: auto;
padding: 24px;
display: flex;
flex-direction: column;
background-color: var(--foreground-color);

&:not(.block) {
Expand All @@ -16,53 +13,100 @@
}

&.overlay {
padding-top: 72px;
position: absolute;
height: 100%;
z-index: 1;
}
z-index: 2;

.label {
font-size: 14px;
color: var(--label-color);
line-height: 1;
margin-bottom: 12px;
.header {
padding: 12px 12px 24px;
}

&:not(:first-child) {
margin-top: 24px;
.body {
padding-top: 0;
}
}

.row {
.body {
display: flex;
align-items: center;
gap: 12px;
flex-direction: column;
padding: 24px;

& + .row {
.button {
display: flex;
align-items: center;
gap: 12px;
font-size: 14px;
color: var(--blue-500);
line-height: 1;
cursor: pointer;
font-weight: 500;
margin-top: 12px;
transition: all 100ms ease-in-out;

&:hover {
color: var(--blue-600);
}
}

.description {
.label {
font-size: 14px;
color: var(--paragraph-color);
font-weight: 500;
color: var(--label-color);
line-height: 1;
margin-bottom: 12px;

&:not(:first-child) {
margin-top: 24px;
}
}

.checkbox {
width: 16px;
height: 16px;
display: grid;
place-items: center;
border-radius: 4px;
.filter {
display: flex;
align-items: center;
gap: 12px;

&[data-state="checked"] {
background-color: var(--blue-500);
color: white;
& + .filter {
margin-top: 12px;
}

&[data-state="unchecked"] {
border: 2px solid var(--border-color);
&:hover .text .value {
color: var(--heading-color);
}

&:hover .checkbox:not([data-state="checked"]) {
border-color: var(--heading-color);
}

.text {
font-size: 14px;
color: var(--label-color);
line-height: 1;
flex-grow: 1;

.value {
font-weight: 500;
color: var(--paragraph-color);
}
}

.checkbox {
width: 16px;
height: 16px;
display: grid;
place-items: center;
border-radius: 4px;

&[data-state="checked"] {
background-color: var(--blue-500);
color: white;

& + .text .value {
color: var(--heading-color);
}
}

&[data-state="unchecked"] {
border: 2px solid var(--paragraph-color);
}
}
}
}
Expand Down
Loading

0 comments on commit 3f63ced

Please sign in to comment.