Commit before redesign

This commit is contained in:
Dayowe 2025-06-26 12:00:51 +02:00
parent 61b238fdf0
commit e789f481f3

View File

@ -1948,13 +1948,19 @@
return; return;
} }
// Check if this is the only unlocked source (will be forced to fixed percentage) // Check if this source has no flexibility (either only unlocked or no percentage available)
const otherUnlockedSources = this.foodSources.filter((fs, index) => const otherUnlockedSources = this.foodSources.filter((fs, index) =>
fs.id !== id && !fs.isLocked fs.id !== id && !fs.isLocked
); );
if (otherUnlockedSources.length === 0) { // Calculate available percentage for this source
// This is the only unlocked source - don't update display, just call adjustPercentages const lockedSources = this.foodSources.filter(fs => fs.id !== id && fs.isLocked);
const totalLockedPercentage = lockedSources.reduce((sum, fs) => sum + fs.percentage, 0);
const otherUnlockedPercentage = otherUnlockedSources.reduce((sum, fs) => sum + fs.percentage, 0);
const availablePercentage = 100 - totalLockedPercentage - otherUnlockedPercentage;
if (otherUnlockedSources.length === 0 || availablePercentage <= 0) {
// This source has no flexibility - don't update display, just call adjustPercentages
// which will force it to the correct value and update display properly // which will force it to the correct value and update display properly
this.adjustPercentages(id, parseInt(percentageSlider.value)); this.adjustPercentages(id, parseInt(percentageSlider.value));
return; return;