Merge branch 'bugfix/null-amount-name' into 'main'

fix(client/ui): silently fail ingredient input if any is null

Closes #50

See merge request cse1105/2025-2026/teams/csep-team-76!45
This commit is contained in:
Zhongheng Liu 2026-01-10 13:40:20 +01:00
commit cd62192ddc

View file

@ -75,6 +75,10 @@ public class IngredientListCell extends OrderedEditableListCell<RecipeIngredient
String name = nameInput.getText(); String name = nameInput.getText();
if (unit == null || !unit.isFormal()) { if (unit == null || !unit.isFormal()) {
String desc = amountInput.getText(); String desc = amountInput.getText();
if (desc.isEmpty() || name.isEmpty()) {
// TODO printError() integration
return; // The user is forced to kindly try again until something valid comes up.
}
Ingredient newIngredient = new Ingredient(name, 0., 0., 0.); Ingredient newIngredient = new Ingredient(name, 0., 0., 0.);
commitEdit(new VagueIngredient(newIngredient, desc)); commitEdit(new VagueIngredient(newIngredient, desc));
return; return;