} pdfFiles - An array of PDF filenames.
*/
function modalManagerPopulatePdfList(pdfListDiv, projectName, pdfFiles) {
pdfListDiv.innerHTML = ''; // Clear loading/previous state
if (pdfFiles && pdfFiles.length > 0) {
pdfFiles.forEach(filename => {
const listItem = document.createElement('div');
listItem.className = 'list-group-item d-flex justify-content-between align-items-center';
const nameSpan = document.createElement('span');
nameSpan.textContent = filename;
nameSpan.title = filename; // Show full name on hover
nameSpan.style.overflow = 'hidden';
nameSpan.style.textOverflow = 'ellipsis';
nameSpan.style.whiteSpace = 'nowrap';
nameSpan.style.marginRight = '10px';
const deleteButton = document.createElement('button');
deleteButton.className = 'btn btn-danger btn-sm flex-shrink-0 pdf-delete-btn'; // Add class for event delegation
deleteButton.textContent = 'Delete';
deleteButton.title = `Delete ${filename}`;
deleteButton.dataset.filename = filename; // Store filename in data attribute
deleteButton.dataset.project = projectName; // Store projectname in data attribute
// Remove inline onclick, use event delegation in events.js
// deleteButton.onclick = () => handleDeletePdfClick(projectName, filename);
listItem.appendChild(nameSpan);
listItem.appendChild(deleteButton);
pdfListDiv.appendChild(listItem);
});
} else {
pdfListDiv.innerHTML = 'No PDF files found for this project.
';
}
}
/**
* Updates the title of the Manage Files modal.
* @param {string} projectName - The name of the selected project.
*/
function modalManagerUpdateManageFilesTitle(projectName) {
const manageFilesModalElement = document.getElementById('manageFilesModal');
if (!manageFilesModalElement) return;
manageFilesModalElement.querySelectorAll('.project-name-display').forEach(span => {
span.textContent = projectName || '...'; // Handle null/empty projectName
});
}
// --- Export (if using modules in the future) ---
// export { initializeModals, modalManagerShowDetails, modalManagerPopulatePdfList, modalManagerUpdateManageFilesTitle, modalManagerHide };