fix: vague ingredient description now persists
This commit is contained in:
parent
0da9490a60
commit
aec8a6bc17
1 changed files with 6 additions and 4 deletions
|
|
@ -64,18 +64,21 @@ public class IngredientListCell extends OrderedEditableListCell<RecipeIngredient
|
|||
|
||||
Optional<Double> templateAmount = Optional.empty();
|
||||
Optional<Unit> unit = Optional.empty();
|
||||
|
||||
TextField amountInput;
|
||||
// Initialize the input fields with some initial data if we get a formal ingredient
|
||||
if (ingredient.getClass().equals(FormalIngredient.class)) {
|
||||
FormalIngredient formal = (FormalIngredient) ingredient;
|
||||
templateAmount = Optional.of(formal.getAmount());
|
||||
unit = Optional.of(Unit.fromString(formal.getUnitSuffix()).orElseThrow(
|
||||
() -> new RuntimeException("FormalIngredient whereas invalid unit")));
|
||||
amountInput = new TextField(templateAmount.map(Object::toString).orElse(null));
|
||||
} else {
|
||||
assert ingredient instanceof VagueIngredient;
|
||||
amountInput = new TextField(((VagueIngredient) ingredient).getDescription());
|
||||
}
|
||||
// TODO initialize some other data in the case of vague ingredient
|
||||
|
||||
// Initialize the input boxes
|
||||
TextField amountInput = new TextField(templateAmount.map(Object::toString).orElse(null));
|
||||
|
||||
ChoiceBox<Unit> unitChoice = new ChoiceBox<>();
|
||||
|
||||
// initialize the current unit if it is present
|
||||
|
|
@ -115,7 +118,6 @@ public class IngredientListCell extends OrderedEditableListCell<RecipeIngredient
|
|||
menu.setText(getLocaleString("app.prompt.new-ingredient")); // otherwise the text label on menu refuses to update
|
||||
selectedIngredient.setValue(null); // indicate null to signal a new ingredient creation
|
||||
logger.info("Making new ingredient");
|
||||
// TODO printError() integration
|
||||
TextField newIngredientNameInput = makeNewIngredientNameField(selectedIngredient::set);
|
||||
container.getChildren().add(newIngredientNameInput);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue