From 0121198f57b71056ae96566e6a71995cd291d04f Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Fri, 14 Jun 2024 13:50:28 -0600 Subject: [PATCH] Fix bug The status changelog logic got removed when shuffling functions. Refer to old commit --- src/registrar/assets/js/get-gov-admin.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/registrar/assets/js/get-gov-admin.js b/src/registrar/assets/js/get-gov-admin.js index 0f3d8b2ad..06ec14caa 100644 --- a/src/registrar/assets/js/get-gov-admin.js +++ b/src/registrar/assets/js/get-gov-admin.js @@ -360,6 +360,30 @@ function initializeWidgetOnList(list, parentId) { sessionStorage.removeItem(name); } } + + document.addEventListener('DOMContentLoaded', function() { + let statusSelect = document.getElementById('id_status'); + + function moveStatusChangelog(actionNeededReasonFormGroup, statusSelect) { + let flexContainer = actionNeededReasonFormGroup.querySelector('.flex-container'); + let statusChangelog = document.getElementById('dja-status-changelog'); + if (statusSelect.value === "action needed") { + flexContainer.parentNode.insertBefore(statusChangelog, flexContainer.nextSibling); + } else { + // Move the changelog back to its original location + let statusFlexContainer = statusSelect.closest('.flex-container'); + statusFlexContainer.parentNode.insertBefore(statusChangelog, statusFlexContainer.nextSibling); + } + } + + // Call the function on page load + moveStatusChangelog(actionNeededReasonFormGroup, statusSelect); + + // Add event listener to handle changes to the selector itself + statusSelect.addEventListener('change', function() { + moveStatusChangelog(actionNeededReasonFormGroup, statusSelect); + }) + }); })(); /** An IIFE for toggling the submit bar on domain request forms