mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-14 21:44:08 +02:00
Move field
This commit is contained in:
parent
227d378f8d
commit
1cd69aa12f
1 changed files with 10 additions and 6 deletions
|
@ -405,12 +405,16 @@ function initializeWidgetOnList(list, parentId) {
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
let statusSelect = document.getElementById('id_status');
|
let statusSelect = document.getElementById('id_status');
|
||||||
|
|
||||||
function moveStatusChangelog(actionNeededReasonFormGroup, statusSelect) {
|
function moveStatusChangelog(actionNeededReasonFormGroup, rejectionReasonFormGroup, statusSelect) {
|
||||||
let flexContainer = actionNeededReasonFormGroup.querySelector('.flex-container');
|
let flexContainerActionNeeded = actionNeededReasonFormGroup.querySelector('.flex-container');
|
||||||
|
let flexContainerRejected = rejectionReasonFormGroup.querySelector('.flex-container');
|
||||||
let statusChangelog = document.getElementById('dja-status-changelog');
|
let statusChangelog = document.getElementById('dja-status-changelog');
|
||||||
if (statusSelect.value === "action needed") {
|
if (statusSelect.value === "action needed") {
|
||||||
flexContainer.parentNode.insertBefore(statusChangelog, flexContainer.nextSibling);
|
flexContainerActionNeeded.parentNode.insertBefore(statusChangelog, flexContainerActionNeeded.nextSibling);
|
||||||
} else {
|
} else if (statusSelect.value === "rejected"){
|
||||||
|
flexContainerRejected.parentNode.insertBefore(statusChangelog, flexContainerRejected.nextSibling);
|
||||||
|
}
|
||||||
|
else {
|
||||||
// Move the changelog back to its original location
|
// Move the changelog back to its original location
|
||||||
let statusFlexContainer = statusSelect.closest('.flex-container');
|
let statusFlexContainer = statusSelect.closest('.flex-container');
|
||||||
statusFlexContainer.parentNode.insertBefore(statusChangelog, statusFlexContainer.nextSibling);
|
statusFlexContainer.parentNode.insertBefore(statusChangelog, statusFlexContainer.nextSibling);
|
||||||
|
@ -418,11 +422,11 @@ function initializeWidgetOnList(list, parentId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call the function on page load
|
// Call the function on page load
|
||||||
moveStatusChangelog(actionNeededReasonFormGroup, statusSelect);
|
moveStatusChangelog(actionNeededReasonFormGroup, rejectionReasonFormGroup, statusSelect);
|
||||||
|
|
||||||
// Add event listener to handle changes to the selector itself
|
// Add event listener to handle changes to the selector itself
|
||||||
statusSelect.addEventListener('change', function() {
|
statusSelect.addEventListener('change', function() {
|
||||||
moveStatusChangelog(actionNeededReasonFormGroup, statusSelect);
|
moveStatusChangelog(actionNeededReasonFormGroup, rejectionReasonFormGroup, statusSelect);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue