Skip to content

Commit 99ed975

Browse files
HollaGZhangYiJiang
andauthored
New UI Feature: Show the # of active units in Timetable (#3460)
Co-authored-by: Zhang Yi Jiang <[email protected]>
1 parent ffdd5ca commit 99ed975

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

website/src/views/timetable/ModulesTableFooter.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,17 @@ type Props = {
3030
semester: Semester;
3131
moduleTableOrder: ModuleTableOrder;
3232
modules: Module[];
33+
hiddenInTimetable: string[];
3334

3435
setModuleTableOrder: (moduleTableOrder: ModuleTableOrder) => void;
3536
};
3637

3738
const ModulesTableFooter: React.FC<Props> = (props) => {
3839
const totalMCs = sumBy(props.modules, (module) => parseFloat(module.moduleCredit));
40+
const shownMCs = sumBy(
41+
props.modules.filter((module) => !props.hiddenInTimetable.includes(module.moduleCode)),
42+
(module) => parseFloat(module.moduleCredit),
43+
);
3944

4045
return (
4146
<div className={classnames(styles.footer, 'row align-items-center')}>
@@ -49,7 +54,14 @@ const ModulesTableFooter: React.FC<Props> = (props) => {
4954
<hr />
5055
</div>
5156
<div className="col">
52-
Total Units: <strong>{renderMCs(totalMCs)}</strong>
57+
{shownMCs !== totalMCs && (
58+
<div>
59+
Active Units: <strong>{renderMCs(shownMCs)}</strong>
60+
</div>
61+
)}
62+
<div>
63+
Total Units: <strong>{renderMCs(totalMCs)}</strong>
64+
</div>
5365
</div>
5466
<div className={classnames(styles.moduleOrder, 'col no-export')}>
5567
<label htmlFor="moduleOrder">Order</label>

website/src/views/timetable/TimetableContent.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,16 @@ class TimetableContent extends React.Component<Props, State> {
269269
}
270270

271271
render() {
272-
const { semester, modules, colors, activeLesson, timetableOrientation, showTitle, readOnly } =
273-
this.props;
272+
const {
273+
semester,
274+
modules,
275+
colors,
276+
activeLesson,
277+
timetableOrientation,
278+
showTitle,
279+
readOnly,
280+
hiddenInTimetable,
281+
} = this.props;
274282

275283
const { showExamCalendar } = this.state;
276284

@@ -417,7 +425,11 @@ class TimetableContent extends React.Component<Props, State> {
417425
{this.renderModuleSections(addedModules, !isVerticalOrientation)}
418426
</div>
419427
<div className="col-12">
420-
<ModulesTableFooter modules={addedModules} semester={semester} />
428+
<ModulesTableFooter
429+
modules={addedModules}
430+
semester={semester}
431+
hiddenInTimetable={hiddenInTimetable}
432+
/>
421433
</div>
422434
</div>
423435
</div>

0 commit comments

Comments
 (0)