Skip to content

Commit

Permalink
Hide annotations in speedgrader (#2227)
Browse files Browse the repository at this point in the history
* initial iteration works

* make hide behavior more consistent

* Fix user view
  • Loading branch information
jlge authored Nov 15, 2024
1 parent 72d658b commit 14d5a5e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
25 changes: 23 additions & 2 deletions app/assets/javascripts/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -1342,8 +1342,10 @@ var submitNewAnnotation = function (comment, shared_comment, global_comment, val

// Logic to render annotation boxes, not applicable to global annotations
if (!global_comment) {
$("#annotation-line-" + lineInd).append(newAnnotationBox(data));
refreshAnnotations();
if (!commentsVisible()) {
$("#annotation-line-" + lineInd).append(newAnnotationBox(data));
refreshAnnotations();
}

if (!annotationsByPositionByLine[currentHeaderPos]) {
annotationsByPositionByLine[currentHeaderPos] = {};
Expand Down Expand Up @@ -1569,3 +1571,22 @@ function renderPdf() {
console.log("Error occurred", error);
});
}

function commentsVisible() {
let hideButton = document.getElementById("hideAnnotations");
return window.getComputedStyle(hideButton).display === "none";
}

function hideAnnotations() {
document.getElementById("hideAnnotations").style.display = "none";
document.getElementById("showAnnotations").style.display = "inline-flex";
$(".annotation-line").not(".base-annotation-line").remove();
refreshAnnotations();
}

function showAnnotations() {
document.getElementById("showAnnotations").style.display = "none";
document.getElementById("hideAnnotations").style.display = "inline-flex";
displayAnnotations();
refreshAnnotations();
}
4 changes: 4 additions & 0 deletions app/views/submissions/view.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@
<a href="<%= download_file_url(@submission) %>" class="btn small" title="Download">Download</a>
<button class="btn small" onclick="resetLayout()">Reset Layout</button>
<%= render "release_grades" %>
<button id="hideAnnotations" class="btn small" onclick="hideAnnotations()">Hide Comments</button>
<button id="showAnnotations" style="display: none;" class="btn small" onclick="showAnnotations()">Show Comments</button>
</div>

<div class="col s2 center-align">
Expand All @@ -144,6 +146,8 @@
<div class="row">
<div class="col s12 center-align valign-wrapper">
<button class="btn small" onclick="resetLayout()">Reset Layout</button>
<button id="hideAnnotations" class="btn small" onclick="hideAnnotations()">Hide Comments</button>
<button id="showAnnotations" style="display: none;" class="btn small" onclick="showAnnotations()">Show Comments</button>
</div>
</div>

Expand Down

0 comments on commit 14d5a5e

Please sign in to comment.