fix(client): fixed some issues on the client-side
This commit is contained in:
parent
04a999147c
commit
b77f4aee76
4 changed files with 34 additions and 8 deletions
|
|
@ -55,7 +55,7 @@ public class IngredientListCell extends OrderedEditableListCell<RecipeIngredient
|
|||
|
||||
// initialize the current unit if it is present
|
||||
unit.ifPresent(unitChoice::setValue);
|
||||
unitChoice.setItems(FXCollections.observableArrayList(Unit.GRAMME, Unit.KILOGRAMME, Unit.TONNE, Unit.INFORMAL));
|
||||
unitChoice.setItems(FXCollections.observableArrayList(Unit.values()));
|
||||
|
||||
// calls makeInputLine to create the inline edit container
|
||||
HBox container = makeInputLine(ingredient, amountInput, unitChoice);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import client.utils.DefaultValueFactory;
|
|||
import client.utils.LocaleAware;
|
||||
import client.utils.LocaleManager;
|
||||
import com.google.inject.Inject;
|
||||
import commons.FormalIngredient;
|
||||
import commons.Recipe;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -102,12 +103,13 @@ public class IngredientListCtrl implements LocaleAware {
|
|||
* @param event The action event.
|
||||
*/
|
||||
private void handleIngredientAdd(ActionEvent event) {
|
||||
this.ingredients.add(DefaultValueFactory.getDefaultFormalIngredient());
|
||||
FormalIngredient newIngredient = DefaultValueFactory.getDefaultFormalIngredient();
|
||||
this.ingredients.add(newIngredient);
|
||||
this.refresh();
|
||||
this.updateCallback.accept(this.ingredients);
|
||||
|
||||
var select = this.ingredientListView.getSelectionModel();
|
||||
select.select(this.ingredients.size() - 1);
|
||||
select.select(newIngredient);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
|||
* @see DefaultValueFactory#getDefaultVagueIngredient()
|
||||
*/
|
||||
public class DefaultValueFactory {
|
||||
private static final Ingredient defaultIngredient = new Ingredient(0L, "default ingredient", 0., 0., 0.);
|
||||
/**
|
||||
* Instantiates a recipe with a default name and null-ID.
|
||||
* The ID is <code>null</code> such that it can be updated
|
||||
|
|
@ -37,7 +38,7 @@ public class DefaultValueFactory {
|
|||
*/
|
||||
public static FormalIngredient getDefaultFormalIngredient() {
|
||||
return new FormalIngredient(
|
||||
new Ingredient(0L, "default ingredient", 0., 0., 0.),
|
||||
defaultIngredient,
|
||||
0.0,
|
||||
Unit.GRAMME.suffix
|
||||
);
|
||||
|
|
@ -50,8 +51,7 @@ public class DefaultValueFactory {
|
|||
*/
|
||||
public static VagueIngredient getDefaultVagueIngredient() {
|
||||
return new VagueIngredient(
|
||||
new Ingredient(null,
|
||||
"default ingredient", 0., 0., 0.),
|
||||
defaultIngredient,
|
||||
"Some");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue