diff --git a/atlas/templates/atlas/case_display_block.html b/atlas/templates/atlas/case_display_block.html
index f7180230..81076723 100755
--- a/atlas/templates/atlas/case_display_block.html
+++ b/atlas/templates/atlas/case_display_block.html
@@ -493,60 +493,6 @@
Move selected series
-
{% else %}
Case move options are unavailable in this view.
{% endif %}
@@ -1090,9 +1036,9 @@
const moveSeriesForm = document.getElementById("move-selected-series-form");
if (moveSeriesForm) {
+ console.log("Move series form found, setting up event listeners");
const hiddenInput = moveSeriesForm.querySelector("[name='destination_case']");
const moveSubmitButton = document.getElementById("move-selected-series-submit");
- const moveSearchResults = document.getElementById("move-series-case-search-results");
const selectionLabel = document.getElementById("selected-move-case");
function syncMoveSeriesSubmitState() {
@@ -1113,39 +1059,23 @@
selectionLabel.classList.remove("text-muted");
}
- if (moveSearchResults) {
- moveSearchResults.querySelectorAll(".list-group-item").forEach((item) => {
- item.classList.toggle("active", String(item.getAttribute("data-case-pk")) === String(casePk));
- });
- }
-
syncMoveSeriesSubmitState();
}
- if (moveSearchResults) {
- moveSearchResults.addEventListener("click", function(event) {
- const item = event.target.closest(".list-group-item[data-case-pk]");
- if (!item || !moveSearchResults.contains(item)) {
- return;
- }
- if (event.target.closest("a,button,form,input")) {
- return;
- }
-
- const casePk = item.getAttribute("data-case-pk");
- const titleEl = item.querySelector("h6");
- const caseTitle = titleEl ? titleEl.textContent.trim() : ("Case #" + casePk);
- setSelectedDestination(casePk, caseTitle);
- });
- }
-
- moveSeriesForm.addEventListener("case:selected", function(event) {
- if (!hiddenInput || !event.detail) {
+ // Mirror user_uploads pattern: listen at body level for case_search_widget selection events.
+ document.body.addEventListener("case:selected", async function(event) {
+ console.log("case:selected event received in case display block", event);
+ const detail = event.detail || {};
+ if (!detail.casePk) {
return;
}
+ // Ignore case selections from other widgets on the page.
+ //if (!event.target || !event.target.closest("#move-selected-series-form")) {
+ // return;
+ //}
- const casePk = event.detail.casePk;
- const caseTitle = event.detail.caseTitle || ("Case #" + casePk);
+ const casePk = detail.casePk;
+ const caseTitle = detail.caseTitle || ("Case #" + casePk);
setSelectedDestination(casePk, caseTitle);
});