fix: improve storage pre-filling with better debugging

- Clear storageSelection before pre-filling
- Add detailed logging for slot filling process
- Store filled drives in storageSelection for summary display
- Improve error handling and debugging output

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2025-12-06 02:14:58 +04:00
Unverified
parent 560ecea172
commit 9a145b9c4b

View File

@@ -4840,6 +4840,11 @@ var wpcf7 = {
// Fill slots based on storage requirements
if (storageRequirements && storageRequirements.length > 0) {
console.log("Pre-filling storage with requirements:", storageRequirements);
// Clear storageSelection to start fresh
storageSelection = {};
storageRequirements.forEach(req => {
for (let i = 0; i < req.qty; i++) {
// Find an empty slot
@@ -4849,6 +4854,8 @@ var wpcf7 = {
);
if (emptySlot) {
console.log(`Filling slot ${emptySlot.id} with ${req.spec}`);
// Find matching drive type
const match = emptySlot.values.find(v => {
const vText = v.text.toLowerCase();
@@ -4874,6 +4881,13 @@ var wpcf7 = {
configState[emptySlot.label] = 0; // Included in base price
configIds[emptySlot.id] = match.id;
// Store in storageSelection for summary
const displayName = match.text.replace(/\s?\(.*?\)/, '');
storageSelection[emptySlot.id] = {
name: displayName,
price: 0 // Free for included drives
};
// Track as original drive
window.originalDrives.push({
slotId: emptySlot.id,
@@ -4881,10 +4895,18 @@ var wpcf7 = {
text: match.text,
price: match.price
});
console.log(`✓ Filled with: ${match.text}`);
} else {
console.error(`✗ Could not find matching drive for: ${req.spec}`);
}
} else {
console.error(`✗ No empty slots available for: ${req.spec}`);
}
}
});
console.log("Final storageSelection:", storageSelection);
}
} else {
// Pre-set configState for custom servers