Skip to content

Commit 32c3498

Browse files
authored
fix: control panel selection (#319)
1 parent 2cb9322 commit 32c3498

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

infrastructure/control-panel/src/lib/ui/Table/Table.svelte

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,43 @@
100100
selectedRow = undefined;
101101
102102
let checkAll = $state(false);
103-
let checkItems = $derived<boolean[]>(tableData.map(() => false));
103+
let checkItems = $state<boolean[]>(tableData.map(() => false));
104+
105+
// Update checkItems when tableData changes
106+
$effect(() => {
107+
checkItems = tableData.map(() => false);
108+
});
104109
105110
// Sync checkbox states with selectedIndices prop
106111
$effect(() => {
112+
console.log('🔄 Table sync effect triggered');
113+
console.log('selectedIndices:', selectedIndices);
114+
console.log('tableData.length:', tableData.length);
115+
console.log('Current checkItems:', checkItems);
116+
107117
if (selectedIndices && selectedIndices.length > 0) {
118+
console.log('📝 Updating checkboxes for selected indices');
108119
// Update individual checkboxes based on selectedIndices
109120
checkItems.forEach((_, index) => {
110-
checkItems[index] = selectedIndices.includes(index);
121+
const shouldBeChecked = selectedIndices.includes(index);
122+
checkItems[index] = shouldBeChecked;
123+
console.log(`Checkbox ${index}: ${shouldBeChecked ? '' : ''}`);
111124
});
112125
113126
// Update header checkbox state
114127
checkAll = selectedIndices.length === tableData.length;
128+
console.log('Header checkbox (checkAll):', checkAll);
115129
} else {
130+
console.log('🧹 Clearing all selections');
116131
// Clear all selections
117132
checkItems.forEach((_, index) => {
118133
checkItems[index] = false;
119134
});
120135
checkAll = false;
121136
}
137+
138+
console.log('Final checkItems:', checkItems);
139+
console.log('Final checkAll:', checkAll);
122140
});
123141
124142
function toggleCheckAll(checked: boolean) {

infrastructure/control-panel/src/routes/+page.svelte

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,32 +90,44 @@
9090
9191
// Handle select all eVaults
9292
function handleSelectAllEVaults(checked: boolean) {
93+
console.log('🎯 handleSelectAllEVaults called with:', checked);
94+
console.log('evaults.length:', evaults.length);
95+
9396
if (checked) {
9497
// Select all eVaults
9598
selectedEVaults = Array.from({ length: evaults.length }, (_, i) => i);
99+
console.log('✅ Selected all eVaults, selectedEVaults:', selectedEVaults);
96100
} else {
97101
// Deselect all eVaults
98102
selectedEVaults = [];
103+
console.log('❌ Deselected all eVaults, selectedEVaults:', selectedEVaults);
99104
}
100105
101106
// Store selections immediately in sessionStorage
102107
const selectedEVaultData = selectedEVaults.map((i) => evaults[i]);
103108
sessionStorage.setItem('selectedEVaults', JSON.stringify(selectedEVaultData));
109+
console.log('💾 Stored in sessionStorage:', selectedEVaultData);
104110
}
105111
106112
// Handle select all platforms
107113
function handleSelectAllPlatforms(checked: boolean) {
114+
console.log('🎯 handleSelectAllPlatforms called with:', checked);
115+
console.log('platforms.length:', platforms.length);
116+
108117
if (checked) {
109118
// Select all platforms
110119
selectedPlatforms = Array.from({ length: platforms.length }, (_, i) => i);
120+
console.log('✅ Selected all platforms, selectedPlatforms:', selectedPlatforms);
111121
} else {
112122
// Deselect all platforms
113123
selectedPlatforms = [];
124+
console.log('❌ Deselected all platforms, selectedPlatforms:', selectedPlatforms);
114125
}
115126
116127
// Store selections immediately in sessionStorage
117128
const selectedPlatformData = selectedPlatforms.map((i) => platforms[i]);
118129
sessionStorage.setItem('selectedPlatforms', JSON.stringify(selectedPlatformData));
130+
console.log('💾 Stored in sessionStorage:', selectedPlatformData);
119131
}
120132
121133
// Clear eVault selection

0 commit comments

Comments
 (0)