Skip to content

Commit

Permalink
SAK-45995 GBNG selecting 'hide this category' for a partially shown c…
Browse files Browse the repository at this point in the history
…ategory will actually 'show this category' (sakaiproject#9568)
  • Loading branch information
bjones86 authored Aug 24, 2021
1 parent ccd54ae commit 2b3d9d9
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions gradebookng/tool/src/webapp/scripts/gradebook-gbgrade-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,8 @@ GbGradeTable.setupToggleGradeItems = function() {
var $group = $itemFilter.closest(".gb-item-filter-group");
var $label = $group.find(".gb-item-category-filter label");
var $input = $group.find(".gb-item-category-filter input");
const $hideThisCategory = $group.find(".gb-hide-this-category");
const $showThisCategory = $group.find(".gb-show-this-category");

var checkedItemFilters = $group.find(".gb-item-filter :input:checked, .gb-item-category-score-filter :input:checked").length;
var itemFilters = $group.find(".gb-item-filter :input, .gb-item-category-score-filter :input").length;
Expand All @@ -1793,16 +1795,19 @@ GbGradeTable.setupToggleGradeItems = function() {
removeClass("off").
find(".gb-filter-partial-signal").remove();

if (checkedItemFilters == 0) {
if (checkedItemFilters === 0) {
$input.prop("checked", false);
$label.addClass("off");
} else if (checkedItemFilters == itemFilters) {
$hideThisCategory.hide();
} else if (checkedItemFilters === itemFilters) {
$input.prop("checked", true);
$showThisCategory.hide();
} else {
$input.prop("checked", false);
$label.addClass("partial");
$label.find(".gb-item-filter-signal").
append($("<span>").addClass("gb-filter-partial-signal"));
$label.find(".gb-item-filter-signal").append($("<span>").addClass("gb-filter-partial-signal"));
$hideThisCategory.show();
$showThisCategory.show();
}
};

Expand Down Expand Up @@ -1879,6 +1884,10 @@ GbGradeTable.setupToggleGradeItems = function() {
.attr("data-suppress-update-view-preferences", "true")
.trigger("click");

// Everything in every category is shown, so we should hide the "show this category" menu options
$panel.find(".gb-show-this-category").hide();
$panel.find(".gb-hide-this-category").show();

GbGradeTable.updateViewPreferences();
};

Expand All @@ -1889,6 +1898,10 @@ GbGradeTable.setupToggleGradeItems = function() {
.attr("data-suppress-update-view-preferences", "true")
.trigger("click");

// Everything in every category is hidden, so we should hide the "hide this category" menu options
$panel.find(".gb-hide-this-category").hide();
$panel.find(".gb-show-this-category").show();

GbGradeTable.updateViewPreferences();
};

Expand Down Expand Up @@ -2034,8 +2047,17 @@ GbGradeTable.setupToggleGradeItems = function() {
on("click", ".gb-toggle-this-category", function(event) {
event.preventDefault();

var $filter = $(event.target).closest(".gb-item-category-filter");
$filter.find(":input").trigger("click");
const hide = event.target.className.includes("hide");
const $filter = $(event.target).closest(".gb-item-filter-group");
if (hide) {
$filter.find("div.gb-filter").not(".off").find(":input").trigger("click");
$filter.find(".gb-hide-this-category").hide();
$filter.find(".gb-show-this-category").show();
} else {
$filter.find("div.off").find(":input").trigger("click");
$filter.find(".gb-hide-this-category").show();
$filter.find(".gb-show-this-category").hide();
}
$(this).focus();
}).
on("click", ".gb-toggle-this-item", function(event) {
Expand Down

0 comments on commit 2b3d9d9

Please sign in to comment.