Skip to content

Commit 0ca3f73

Browse files
author
Mateo
committed
ISSUE-7677: Apply filter to extension column
1 parent 0bef64d commit 0ca3f73

File tree

2 files changed

+55
-36
lines changed

2 files changed

+55
-36
lines changed

app/javascript/Components/groups_manager.jsx

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -559,20 +559,27 @@ class RawGroupsTable extends React.Component {
559559
let extension = this.props.times
560560
.map(key => {
561561
const val = row.original.extension[key];
562-
if (val) {
563-
// don't build these strings dynamically or they will be missed by the i18n-tasks checkers.
564-
if (key === "weeks") {
565-
return `${val} ${I18n.t("durations.weeks", {count: val})}`;
566-
} else if (key === "days") {
567-
return `${val} ${I18n.t("durations.days", {count: val})}`;
568-
} else if (key === "hours") {
569-
return `${val} ${I18n.t("durations.hours", {count: val})}`;
570-
} else if (key === "minutes") {
571-
return `${val} ${I18n.t("durations.minutes", {count: val})}`;
572-
} else {
573-
return "";
574-
}
562+
const lateSubmissionText = row.original.extension.apply_penalty
563+
? `(${I18n.t("groups.late_submissions_accepted")})`
564+
: "";
565+
566+
if (!val) {
567+
return null;
568+
}
569+
// don't build these strings dynamically or they will be missed by the i18n-tasks checkers.
570+
if (key === "weeks") {
571+
return `${val} ${I18n.t("durations.weeks", {count: val})} ${lateSubmissionText}`;
572+
}
573+
if (key === "days") {
574+
return `${val} ${I18n.t("durations.days", {count: val})} ${lateSubmissionText}`;
575575
}
576+
if (key === "hours") {
577+
return `${val} ${I18n.t("durations.hours", {count: val})} ${lateSubmissionText}`;
578+
}
579+
if (key === "minutes") {
580+
return `${val} ${I18n.t("durations.minutes", {count: val})} ${lateSubmissionText}`;
581+
}
582+
return "";
576583
})
577584
.filter(Boolean)
578585
.join(", ");
@@ -599,33 +606,40 @@ class RawGroupsTable extends React.Component {
599606
);
600607
}
601608
},
602-
filterable: false,
603609
sortMethod: durationSort,
604-
},
605-
{
606-
Header: "Penalty",
607-
id: "late_penalty_applied",
608-
accessor: "extension",
609-
Cell: row => {
610-
return row.original.extension.apply_penalty ? (
611-
<FontAwesomeIcon icon="fa-solid fa-square-check" />
612-
) : (
613-
<FontAwesomeIcon icon="fa-solid fa-xmark" />
614-
);
615-
},
616-
minWidth: 30,
617-
filterable: false,
618-
sortMethod: (a, b) => {
619-
// Primary sort: boolean property (true first)
620-
if (a.apply_penalty && !b.apply_penalty) {
621-
return -1; // a (true) comes before b (false)
610+
611+
Filter: selectFilter,
612+
filterMethod: (filter, row) => {
613+
if (filter.value === "all") {
614+
return true;
615+
}
616+
const applyPenalty = row._original.extension.apply_penalty;
617+
const {withExtension, withLateSubmission} = JSON.parse(filter.value);
618+
// If there is an extension applied, the extension object will contain a property called weeks
619+
const hasExtension = Object.hasOwn(row._original.extension, "weeks");
620+
621+
if (!withExtension) {
622+
return !hasExtension;
622623
}
623-
if (!a.apply_penalty && b.apply_penalty) {
624-
return 1; // a (false) comes after b (true)
624+
if (withLateSubmission) {
625+
return hasExtension && applyPenalty;
625626
}
626-
// Secondary sort: numeric property (ascending) if boolean properties are equal
627-
return durationSort(a, b);
627+
return hasExtension && !applyPenalty;
628628
},
629+
filterOptions: [
630+
{
631+
value: JSON.stringify({withExtension: false}),
632+
text: I18n.t("groups.groups_without_extension"),
633+
},
634+
{
635+
value: JSON.stringify({withExtension: true, withLateSubmission: true}),
636+
text: I18n.t("groups.groups_with_extension.with_late_submission"),
637+
},
638+
{
639+
value: JSON.stringify({withExtension: true, withLateSubmission: false}),
640+
text: I18n.t("groups.groups_with_extension.without_late_submission"),
641+
},
642+
],
629643
},
630644
];
631645

config/locales/views/groups/en.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ en:
2323
do_not_have_a_group: You do not currently have a group.
2424
display_inactive: Display inactive groups
2525
due_date_extension: Due Date Extension
26+
late_submissions_accepted: Late Submissions Accepted
27+
groups_without_extension: Groups Without Extension
28+
groups_with_extension:
29+
with_late_submission: Group With Extension and With Late Submission
30+
without_late_submission: Group With Extension and Without Late Submission
2631
duration_extension: Duration Extension
2732
empty: Empty Group
2833
grace_day_over_limit: You have assigned one or more students who has less grace credits than the amount already used by group %{group} for this assignment.

0 commit comments

Comments
 (0)