fix: resolve download client filter element ID mismatch and bind Select All/Deselect All (closes #38)
Build and Push Docker Image / build (push) Successful in 40s
Licence Check / Licence compatibility and copyright header verification (push) Successful in 1m34s
CI / Security audit (push) Successful in 1m52s
CI / Swagger Validation & Coverage (push) Successful in 2m19s
CI / Tests & coverage (push) Successful in 2m31s
Build and Push Docker Image / build (push) Successful in 40s
Licence Check / Licence compatibility and copyright header verification (push) Successful in 1m34s
CI / Security audit (push) Successful in 1m52s
CI / Swagger Validation & Coverage (push) Successful in 2m19s
CI / Tests & coverage (push) Successful in 2m31s
This commit is contained in:
+35
-11
@@ -5,9 +5,10 @@ import { saveDownloadClients } from '../utils/storage.js';
|
||||
import { renderDownloads } from './downloads.js';
|
||||
|
||||
export function initDownloadClientFilter() {
|
||||
const filterBtn = document.getElementById('download-client-filter-btn');
|
||||
const filterDropdown = document.getElementById('download-client-filter-dropdown');
|
||||
const filterClose = document.getElementById('download-client-filter-close');
|
||||
const filterBtn = document.getElementById('download-client-dropdown-btn');
|
||||
const filterDropdown = document.getElementById('download-client-dropdown');
|
||||
const selectAllBtn = document.getElementById('download-client-select-all');
|
||||
const deselectAllBtn = document.getElementById('download-client-deselect-all');
|
||||
|
||||
if (!filterBtn || !filterDropdown) return;
|
||||
|
||||
@@ -16,13 +17,16 @@ export function initDownloadClientFilter() {
|
||||
filterDropdown.classList.toggle('open');
|
||||
});
|
||||
|
||||
filterClose.addEventListener('click', () => {
|
||||
filterDropdown.classList.remove('open');
|
||||
});
|
||||
if (selectAllBtn) {
|
||||
selectAllBtn.addEventListener('click', () => toggleAllClients(true));
|
||||
}
|
||||
if (deselectAllBtn) {
|
||||
deselectAllBtn.addEventListener('click', () => toggleAllClients(false));
|
||||
}
|
||||
|
||||
// Close dropdown when clicking outside
|
||||
document.addEventListener('click', (e) => {
|
||||
if (!filterDropdown.contains(e.target) && e.target !== filterBtn) {
|
||||
if (!filterDropdown.contains(e.target) && e.target !== filterBtn && !filterBtn.contains(e.target)) {
|
||||
filterDropdown.classList.remove('open');
|
||||
}
|
||||
});
|
||||
@@ -35,7 +39,7 @@ export function initDownloadClientFilter() {
|
||||
}
|
||||
|
||||
export function updateDownloadClientFilter() {
|
||||
const filterList = document.getElementById('download-client-filter-list');
|
||||
const filterList = document.getElementById('download-client-options');
|
||||
if (!filterList) return;
|
||||
|
||||
filterList.innerHTML = '';
|
||||
@@ -75,13 +79,33 @@ export function toggleClientSelection(index) {
|
||||
renderDownloads();
|
||||
}
|
||||
|
||||
export function toggleAllClients(select) {
|
||||
if (select) {
|
||||
state.selectedDownloadClients = state.downloadClients.map((_, index) => index);
|
||||
} else {
|
||||
state.selectedDownloadClients = [];
|
||||
}
|
||||
saveDownloadClients(state.selectedDownloadClients);
|
||||
updateDownloadClientFilter();
|
||||
renderDownloads();
|
||||
}
|
||||
|
||||
export function updateSelectedCountDisplay() {
|
||||
const countDisplay = document.getElementById('download-client-filter-count');
|
||||
const countDisplay = document.getElementById('download-client-selected-text');
|
||||
if (!countDisplay) return;
|
||||
|
||||
if (state.selectedDownloadClients.length === 0) {
|
||||
countDisplay.textContent = 'All';
|
||||
countDisplay.textContent = 'All clients';
|
||||
} else if (state.selectedDownloadClients.length === state.downloadClients.length) {
|
||||
countDisplay.textContent = 'All clients';
|
||||
} else {
|
||||
countDisplay.textContent = state.selectedDownloadClients.length;
|
||||
const names = state.selectedDownloadClients
|
||||
.map(idx => state.downloadClients[idx]?.name || state.downloadClients[idx]?.type || '')
|
||||
.filter(Boolean);
|
||||
if (names.length === 1) {
|
||||
countDisplay.textContent = names[0];
|
||||
} else {
|
||||
countDisplay.textContent = `${state.selectedDownloadClients.length} clients`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user