From 30dd129038b6af925df2d3f90676766412eef8be Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Tue, 25 Jun 2024 15:29:13 +0200 Subject: [PATCH 1/2] Allow expand/collapse of targeted feedback groups --- app/assets/javascripts/submission.ts | 11 +++++++++++ app/assets/stylesheets/models/submissions.css.scss | 7 +------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/submission.ts b/app/assets/javascripts/submission.ts index aeaea84829..59c41f5bc6 100644 --- a/app/assets/javascripts/submission.ts +++ b/app/assets/javascripts/submission.ts @@ -7,6 +7,7 @@ function initSubmissionShow(parentClass: string, mediaPath: string, token: strin initTabLinks(); initCollapseButtons(); initHideCorrect(); + initTabSummaryLinks(); contextualizeMediaPaths(parentClass, mediaPath, token); } @@ -38,6 +39,16 @@ function initSubmissionShow(parentClass: string, mediaPath: string, token: strin }); } + function initTabSummaryLinks(): void { + document.querySelectorAll(".tab-summary-icons a").forEach(l => { + l.addEventListener("click", () => { + const groupId = l.attributes["href"].value; + const group = document.getElementById(groupId.substring(1)); + group.classList.remove("collapsed"); + }); + }); + } + function initHideCorrect(): void { document.querySelectorAll(".correct-switch-buttons .btn").forEach( b => { b.addEventListener("click", e => { diff --git a/app/assets/stylesheets/models/submissions.css.scss b/app/assets/stylesheets/models/submissions.css.scss index 5fdf51f77d..fddb928332 100644 --- a/app/assets/stylesheets/models/submissions.css.scss +++ b/app/assets/stylesheets/models/submissions.css.scss @@ -118,12 +118,7 @@ } } - &:target .btn-collapse { - pointer-events: none; - } - - // if a group is the target, never collapse - &.collapsed:not(:target) { + &.collapsed { .card-supporting-text { display: none; } From 873ede25569f6a3dfb5eda2a44caccb2df8099b1 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Wed, 26 Jun 2024 09:07:55 +0200 Subject: [PATCH 2/2] Add comment --- app/assets/javascripts/submission.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/submission.ts b/app/assets/javascripts/submission.ts index 59c41f5bc6..53d6c91048 100644 --- a/app/assets/javascripts/submission.ts +++ b/app/assets/javascripts/submission.ts @@ -42,8 +42,10 @@ function initSubmissionShow(parentClass: string, mediaPath: string, token: strin function initTabSummaryLinks(): void { document.querySelectorAll(".tab-summary-icons a").forEach(l => { l.addEventListener("click", () => { - const groupId = l.attributes["href"].value; - const group = document.getElementById(groupId.substring(1)); + // The href is a hash followed by the id of the group + // We remove the hash and get the group by id + const groupId = l.attributes["href"].value.substring(1); + const group = document.getElementById(groupId); group.classList.remove("collapsed"); }); });