Skip to content
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

Add ability to unassign moderators from unscheduled sections #3677

Merged
merged 1 commit into from
Sep 1, 2023
Merged
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
6 changes: 6 additions & 0 deletions esp/public/media/default_styles/scheduling.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ table.sortable thead th:not(.sorttable_sorted):not(.sorttable_sorted_reverse):no
cursor: pointer;
}

td.selected-moderator {
outline: 4px solid yellow;
position: relative;
z-index: 1000;
}

.matrix-cell{
height: 40px;
min-width: 80px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function ModeratorDirectory(el, moderators) {
this.el = el;
this.moderators = moderators;
this.selectedModerator = null;
this.selectedModeratorCell = null;

// Set up filtering
this.filter = {
Expand Down Expand Up @@ -176,7 +177,7 @@ function ModeratorDirectory(el, moderators) {
this.numAvailableSlots = function(moderator) {
var avail_slots = moderator.num_slots;
for(var section of moderator.sections) {
var assignment = this.matrix.sections.scheduleAssignments[section]
var assignment = this.matrix.sections.scheduleAssignments[section];
if(assignment){
avail_slots -= assignment.timeslots.length;
}
Expand Down Expand Up @@ -243,6 +244,7 @@ function ModeratorDirectory(el, moderators) {
}

this.selectedModerator = moderator;
if(this.selectedModeratorCell) this.selectedModeratorCell.el.addClass("selected-moderator");
this.matrix.sectionInfoPanel.displayModerator(moderator);
this.availableTimeslots = this.getAvailableTimeslots(moderator);
this.matrix.highlightTimeslots(this.availableTimeslots, null, moderator);
Expand All @@ -256,6 +258,10 @@ function ModeratorDirectory(el, moderators) {
this.matrix.sectionInfoPanel.hide();
this.matrix.sectionInfoPanel.override = override;
this.matrix.unhighlightTimeslots(this.availableTimeslots, this.selectedModerator);
if(this.selectedModeratorCell) {
this.selectedModeratorCell.el.removeClass("selected-moderator");
this.selectedModeratorCell = null;
}
this.selectedModerator = null;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ function Scheduler(
// set up handler for selecting moderators
$j("body").on("click", "td.moderator-cell", function(evt, ui) {
var moderatorCell = $j(evt.currentTarget).data("moderatorCell");
this.moderatorDirectory.selectedModeratorCell = moderatorCell;
this.moderatorDirectory.selectModerator(moderatorCell.moderator);
}.bind(this));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ function SectionInfoPanel(el, sections, togglePanel, sectionCommentDialog) {
var getModeratorLinks = function(section) {
var moderator_links_list = []
$j.each(section.moderator_data, function(index, moderator) {
moderator_links_list.push("<a href='#' class='moderator-link' data-moderator='" + moderator.id + "'>" + moderator.first_name + " " + moderator.last_name + "</a>");
moderator_links_list.push("<a href='#' class='moderator-link' data-moderator='" + moderator.id + "'>" + moderator.first_name + " " + moderator.last_name +
"</a> <button class='moderator-remove' data-moderator='" + moderator.id + "' data-section='" + section.id + "'>Remove</button>");
});
var moderator_links = moderator_links_list.join(", ");
return $j(moderator_links);
Expand Down Expand Up @@ -184,6 +185,14 @@ function SectionInfoPanel(el, sections, togglePanel, sectionCommentDialog) {
this.el.append(getHeader(section));
this.el.append(getToolbar(section));
this.el.append(getContent(section));
if(has_moderator_module === "True") {
$j(".moderator-remove").on("click", function(evt) {
var mod = this.sections.matrix.moderatorDirectory.getById($j(evt.target).data("moderator"));
var sec = this.sections.getById($j(evt.target).data("section"));
this.sections.matrix.moderatorDirectory.selectedModerator = mod;
this.sections.matrix.moderatorDirectory.unassignModerator(sec);
}.bind(this));
}
};

var getModeratorHeader = function(moderator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,15 @@ <h3>{{ program.getModeratorTitle }} Filters</h3>
<tr>
<td class="matrix-cell disabled-cell"></td><td>Classroom is not available</td>
</tr>
<tr>
<td class="selected-section"></td><td>Selected section{% if has_moderator_module %}/{{ program.getModeratorTitle|lower }}{% endif %}</td>
</tr>
<tr>
<td class="locked-cell"></td><td>Locked section</td>
</tr>
</table>
<h3>When scheduling sections:</h3>
<table width="100%">
<tr>
<td class="selected-section"></td><td>Selected section</td>
</tr>
<tr>
<td class="matrix-cell teacher-available-cell"></td><td>All teachers{% if has_moderator_module %}/{{ program.getModeratorTitle|lower }}s{% endif %} available</td>
</tr>
Expand Down
Loading