move new files to correct section

This commit is contained in:
Zhora Shalyapin 2025-03-13 10:17:06 +00:00
parent e4aec83cf2
commit cbbbd8e338

11
main.js
View File

@ -549,7 +549,17 @@
}
function moveNewFilesOnVariantChange() {
document.querySelectorAll(`input[name^="new_file_type"]`).forEach(el => el.addEventListener("change", function() {
let attachmentIndex = this.name.replace(/\D/g,'')
let from = this.value == "l" ? "history" : "legend"
let to = this.value == "l" ? "legend" : "history"
let type = attachmentIndex == 1 ? "photo" : "files"
let newFiles = [...document.querySelectorAll(`.${from}-${type}-container .file-container-new`)]
for (const newFile of newFiles) {
document.querySelector(`.${to}-${type}-container .file-list-container`).appendChild(newFile)
}
}))
}
function removeDeletedFilesFromUglyVersion(removeLink) {
@ -569,6 +579,7 @@
moveInputValues(form, was, became)
prettifyFiles(insertedFileRows)
moveNewFilesOnVariantChange()
$("#cps_main").select2()
makeCoordinatesLinks()
}