Skip to content

Commit 5ef066c

Browse files
Merge pull request #295 from AndreWohnsland/dev
Do not show ingredients that have no amount
2 parents 510e5c9 + 2da9deb commit 5ef066c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/ui/setup_cocktail_selection.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ def update_cocktail_data(self):
114114
self.LAlkoholgehalt.setText(f"{self.cocktail.adjusted_alcohol:.1f}%")
115115
display_data = self.cocktail.machineadds
116116
hand = self.cocktail.handadds
117+
# remove ingredients that have amount of 0
118+
hand = [ing for ing in hand if ing.amount > 0]
119+
display_data = [ing for ing in display_data if ing.amount > 0]
117120
# Activates or deactivates the virgin checkbox, depending on the virgin flag
118121
self.virgin_checkbox.setEnabled(self.cocktail.virgin_available)
119122
# Styles does not work on strikeout, so we use internal qt things
@@ -124,6 +127,10 @@ def update_cocktail_data(self):
124127
display_data.extend([Ingredient(-1, "", 0, 0, 0, False, 100, 100), *hand])
125128
fields_ingredient = self.get_labels_maker_ingredients()
126129
fields_volume = self.get_labels_maker_volume()
130+
# clean the ui elements
131+
for field_ingredient, field_volume in zip(fields_ingredient, fields_volume):
132+
field_ingredient.setText("")
133+
field_volume.setText("")
127134
for field_ingredient, field_volume, ing in zip(fields_ingredient, fields_volume, display_data):
128135
# -1 indicates no ingredient
129136
if ing.id == -1:

web_client/src/components/cocktail/CocktailSelection.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,11 @@ const CocktailSelection: React.FC<CocktailModalProps> = ({ selectedCocktail, han
8585
});
8686
};
8787

88-
const machineIngredients = displayCocktail.ingredients
88+
const ingredientsWithAmount = displayCocktail.ingredients.filter((ingredient) => ingredient.amount > 0);
89+
const machineIngredients = ingredientsWithAmount
8990
.filter((ingredient) => !ingredient.hand)
9091
.sort((a, b) => b.amount - a.amount);
91-
const handIngredients = displayCocktail.ingredients
92+
const handIngredients = ingredientsWithAmount
9293
.filter((ingredient) => ingredient.hand)
9394
.sort((a, b) => b.amount - a.amount);
9495

0 commit comments

Comments
 (0)