Skip to content

Commit

Permalink
polish: show +n for multiple course codes in modal, other touchups
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed May 13, 2024
1 parent 724d564 commit b7aa122
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 60 deletions.
26 changes: 5 additions & 21 deletions frontend/src/components/CourseModal/OverviewInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ type CourseInfo = SameCourseOrProfOfferingsQuery['self'][0]['course'];
const profInfoPopover =
(
profInfo: CourseInfo['course_professors'][number]['professor'],
// TODO: use profInfo.courses_taught
numCourses: number,
): OverlayChildren =>
(props) => (
<InfoPopover {...props} id="title-popover" className="d-none d-md-block">
Expand Down Expand Up @@ -79,10 +77,10 @@ const profInfoPopover =
</Col>
<Col md={6}>
<div className="d-flex mx-auto mb-1">
<strong className="mx-auto">{numCourses}</strong>
<strong className="mx-auto">{profInfo.courses_taught}</strong>
</div>
<div className="d-flex mx-auto">
<small className="mx-auto text-center fw-bold">
<small className="mx-auto text-center fw-bold">
Classes Taught
</small>
</div>
Expand Down Expand Up @@ -253,13 +251,7 @@ function Syllabus({
);
}

function Professors({
course,
sameProf,
}: {
readonly course: CourseInfo;
readonly sameProf: SameCourseOrProfOfferingsQuery['sameProf'];
}) {
function Professors({ course }: { readonly course: CourseInfo }) {
return (
<DataField
name="Professor"
Expand All @@ -272,15 +264,7 @@ function Professors({
trigger="click"
rootClose
placement="right"
overlay={profInfoPopover(
professor,
sameProf.filter((o) =>
o.course.course_professors.some(
(p) =>
p.professor.professor_id === professor.professor_id,
),
).length,
)}
overlay={profInfoPopover(professor)}
>
<LinkLikeText>{professor.name}</LinkLikeText>
</OverlayTrigger>
Expand Down Expand Up @@ -361,7 +345,7 @@ function OverviewInfo({
<div className={styles.requirements}>{course.requirements}</div>
)}
<Syllabus course={course} sameCourse={data.sameCourse} />
<Professors course={course} sameProf={data.sameProf} />
<Professors course={course} />
<TimeLocation course={course} />
<DataField name="Section" value={course.section} />
<DataField
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/CourseModal/OverviewRatings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function CourseLink({
}));
const extraText =
filter === 'professor'
? course.listings[0]!.course_code
? `${course.listings[0]!.course_code}${course.listings.length > 1 ? ` +${course.listings.length - 1}` : ''}`
: filter === 'both'
? `Section ${course.section}`
: course.course_professors.length === 0
Expand Down
30 changes: 17 additions & 13 deletions frontend/src/generated/graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "StringArr",
"name": "jsonb",
"ofType": null
}
},
Expand Down Expand Up @@ -1608,7 +1608,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "StringArr",
"name": "jsonb",
"ofType": null
}
},
Expand Down Expand Up @@ -1844,7 +1844,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Crn",
"name": "Int",
"ofType": null
}
},
Expand Down Expand Up @@ -1900,7 +1900,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ExtraInfo",
"name": "String",
"ofType": null
}
},
Expand Down Expand Up @@ -1941,7 +1941,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "StringArr",
"name": "jsonb",
"ofType": null
}
},
Expand Down Expand Up @@ -2118,7 +2118,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "StringArr",
"name": "jsonb",
"ofType": null
}
},
Expand All @@ -2143,9 +2143,13 @@
}
],
"type": {
"kind": "SCALAR",
"name": "ProfessorInfo",
"ofType": null
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "jsonb",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
Expand All @@ -2172,7 +2176,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "StringArr",
"name": "jsonb",
"ofType": null
}
},
Expand Down Expand Up @@ -2284,7 +2288,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Season",
"name": "String",
"ofType": null
}
},
Expand Down Expand Up @@ -2329,7 +2333,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "StringArr",
"name": "jsonb",
"ofType": null
}
},
Expand Down Expand Up @@ -2398,7 +2402,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "TimesByDay",
"name": "json",
"ofType": null
}
},
Expand Down
24 changes: 13 additions & 11 deletions frontend/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ export type StringComparisonExp = {
/** columns and relationships of "computed_listing_info" */
export type ComputedListingInfo = {
__typename?: 'computed_listing_info';
all_course_codes: Scalars['StringArr']['output'];
areas: Scalars['StringArr']['output'];
all_course_codes: Scalars['jsonb']['output'];
areas: Scalars['jsonb']['output'];
average_gut_rating: Maybe<Scalars['float8']['output']>;
average_professor: Maybe<Scalars['float8']['output']>;
average_rating: Maybe<Scalars['float8']['output']>;
Expand All @@ -128,13 +128,13 @@ export type ComputedListingInfo = {
course_code: Scalars['String']['output'];
course_id: Scalars['Int']['output'];
credits: Maybe<Scalars['float8']['output']>;
crn: Scalars['Crn']['output'];
crn: Scalars['Int']['output'];
declined: Maybe<Scalars['Int']['output']>;
description: Scalars['String']['output'];
enrolled: Maybe<Scalars['Int']['output']>;
extra_info: Scalars['ExtraInfo']['output'];
extra_info: Scalars['String']['output'];
final_exam: Maybe<Scalars['String']['output']>;
flag_info: Scalars['StringArr']['output'];
flag_info: Scalars['jsonb']['output'];
fysem: Maybe<Scalars['Boolean']['output']>;
last_enrollment: Maybe<Scalars['Int']['output']>;
last_enrollment_course_id: Maybe<Scalars['Int']['output']>;
Expand All @@ -147,23 +147,23 @@ export type ComputedListingInfo = {
locations_summary: Scalars['String']['output'];
no_response: Maybe<Scalars['Int']['output']>;
number: Scalars['String']['output'];
professor_ids: Scalars['StringArr']['output'];
professor_info: Maybe<Scalars['ProfessorInfo']['output']>;
professor_names: Scalars['StringArr']['output'];
professor_ids: Scalars['jsonb']['output'];
professor_info: Scalars['jsonb']['output'];
professor_names: Scalars['jsonb']['output'];
regnotes: Maybe<Scalars['String']['output']>;
requirements: Scalars['String']['output'];
responses: Maybe<Scalars['Int']['output']>;
rp_attr: Maybe<Scalars['String']['output']>;
same_course_and_profs_id: Scalars['Int']['output'];
same_course_id: Scalars['Int']['output'];
school: Maybe<Scalars['String']['output']>;
season_code: Scalars['Season']['output'];
season_code: Scalars['String']['output'];
section: Scalars['String']['output'];
skills: Scalars['StringArr']['output'];
skills: Scalars['jsonb']['output'];
subject: Scalars['String']['output'];
syllabus_url: Maybe<Scalars['String']['output']>;
sysem: Maybe<Scalars['Boolean']['output']>;
times_by_day: Scalars['TimesByDay']['output'];
times_by_day: Scalars['json']['output'];
times_summary: Scalars['String']['output'];
title: Scalars['String']['output'];
};
Expand Down Expand Up @@ -10416,6 +10416,7 @@ export type SameCourseOrProfOfferingsQuery = {
professor_id: number;
name: string;
email: string | null;
courses_taught: number;
average_rating?: number | null;
};
}>;
Expand Down Expand Up @@ -10557,6 +10558,7 @@ export const SameCourseOrProfOfferingsDocument = gql`
professor_id
name
email
courses_taught
average_rating @include(if: $hasEval)
}
}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/queries/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ query SameCourseOrProfOfferings(
professor_id
name
email
courses_taught
average_rating @include(if: $hasEval)
}
}
Expand Down
14 changes: 0 additions & 14 deletions frontend/src/queries/schema-overrides.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@ scalar TimesByDay
scalar ProfessorInfo

# IMPORTANT: make sure what you add here actually exists on the model!
type computed_listing_info {
crn: Crn!
season_code: Season!
extra_info: ExtraInfo!
all_course_codes: StringArr!
areas: StringArr!
flag_info: StringArr!
skills: StringArr!
professor_ids: StringArr!
professor_info: ProfessorInfo
professor_names: StringArr!
times_by_day: TimesByDay!
}

type listings {
crn: Crn!
season_code: Season!
Expand Down

0 comments on commit b7aa122

Please sign in to comment.