fix: display preselected drives correctly in individual storage slots

- Fixed createOptionGrid to properly handle preselected storage values
- Added updateStorageSummary function to aggregate storage selections
- Individual slots now show the correct preselected drives
- Storage summary displays proper counts (4x Crucial + 2x Kioxia)
- Each slot shows as "Configured" instead of "None selected"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2025-12-06 01:49:24 +04:00
Unverified
parent 0c8ee87ce2
commit 70ad44f81b

View File

@@ -4671,7 +4671,12 @@ var wpcf7 = {
container.appendChild(visualContainer); container.appendChild(visualContainer);
// Create individual option grid for this slot // Create individual option grid for this slot
container.appendChild(createOptionGrid(opt, true, -1, isInstant, preselected)); // For instant customization, we need to pass the specific preselected value for this slot
const slotPreselected = {};
if (isInstant && preselected[opt.id]) {
slotPreselected[opt.id] = preselected[opt.id];
}
container.appendChild(createOptionGrid(opt, true, -1, isInstant, slotPreselected));
}); });
} else { } else {
// Group storage options by signature for custom servers // Group storage options by signature for custom servers
@@ -5030,6 +5035,31 @@ var wpcf7 = {
if(specStorage) specStorage.innerHTML = pillsHtml; if(specStorage) specStorage.innerHTML = pillsHtml;
}; };
// Function to update storage summary
function updateStorageSummary() {
// Collect all selected drives
const storageCount = {};
let storageSummary = [];
Object.values(storageSelection).forEach(drive => {
if (drive.name && !drive.name.toLowerCase().includes('none')) {
storageCount[drive.name] = (storageCount[drive.name] || 0) + 1;
}
});
// Build summary text with counts
Object.entries(storageCount).forEach(([name, count]) => {
storageSummary.push(`${count}x ${name}`);
});
const storageText = storageSummary.length > 0 ? storageSummary.join(' + ') : 'None';
document.getElementById('summaryStorage').textContent = storageText;
// Update Tech Specs
const specStorage = document.getElementById('spec-storage-config-hero');
if (specStorage) specStorage.innerText = storageText;
}
function createOptionGrid(opt, isWide, storageIndex = -1, isInstant = false, preselected = {}) { function createOptionGrid(opt, isWide, storageIndex = -1, isInstant = false, preselected = {}) {
const grid = document.createElement('div'); const grid = document.createElement('div');
grid.className = isWide ? 'config-grid wide' : 'config-grid'; grid.className = isWide ? 'config-grid wide' : 'config-grid';
@@ -5069,12 +5099,21 @@ var wpcf7 = {
const specNet = document.getElementById('spec-network-speed-hero'); const specNet = document.getElementById('spec-network-speed-hero');
if(specNet) specNet.innerText = val.text; if(specNet) specNet.innerText = val.text;
} }
// For storage, we need to aggregate // For storage, we need to aggregate
if (opt.type === 'storage') { if (opt.type === 'storage') {
const displayName = val.text.replace(/\s?\(.*?\)/, ''); // Clean text
// Store selection for this "bay" (opt.id) // Store selection for this "bay" (opt.id)
storageSelection[opt.id] = { name: val.text, price: val.price }; storageSelection[opt.id] = { name: displayName, price: val.price };
updateDynamicStorageVisual(storageIndex, val.text, isInstant);
// For instant customization with individual slots, update the slot visual
if (isInstant && storageIndex >= 0) {
updateDynamicStorageVisual(storageIndex, displayName, isInstant);
}
// Always update the storage summary
updateStorageSummary();
} }
} }