Move field

This commit is contained in:
zandercymatics 2024-06-24 10:20:49 -06:00
parent 227d378f8d
commit 1cd69aa12f
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7

View file

@ -405,12 +405,16 @@ function initializeWidgetOnList(list, parentId) {
document.addEventListener('DOMContentLoaded', function() {
let statusSelect = document.getElementById('id_status');
function moveStatusChangelog(actionNeededReasonFormGroup, statusSelect) {
let flexContainer = actionNeededReasonFormGroup.querySelector('.flex-container');
function moveStatusChangelog(actionNeededReasonFormGroup, rejectionReasonFormGroup, statusSelect) {
let flexContainerActionNeeded = actionNeededReasonFormGroup.querySelector('.flex-container');
let flexContainerRejected = rejectionReasonFormGroup.querySelector('.flex-container');
let statusChangelog = document.getElementById('dja-status-changelog');
if (statusSelect.value === "action needed") {
flexContainer.parentNode.insertBefore(statusChangelog, flexContainer.nextSibling);
} else {
flexContainerActionNeeded.parentNode.insertBefore(statusChangelog, flexContainerActionNeeded.nextSibling);
} else if (statusSelect.value === "rejected"){
flexContainerRejected.parentNode.insertBefore(statusChangelog, flexContainerRejected.nextSibling);
}
else {
// Move the changelog back to its original location
let statusFlexContainer = statusSelect.closest('.flex-container');
statusFlexContainer.parentNode.insertBefore(statusChangelog, statusFlexContainer.nextSibling);
@ -418,11 +422,11 @@ function initializeWidgetOnList(list, parentId) {
}
// Call the function on page load
moveStatusChangelog(actionNeededReasonFormGroup, statusSelect);
moveStatusChangelog(actionNeededReasonFormGroup, rejectionReasonFormGroup, statusSelect);
// Add event listener to handle changes to the selector itself
statusSelect.addEventListener('change', function() {
moveStatusChangelog(actionNeededReasonFormGroup, statusSelect);
moveStatusChangelog(actionNeededReasonFormGroup, rejectionReasonFormGroup, statusSelect);
})
});
})();