Correction: les recettes n'étaient pas mises à jour

This commit is contained in:
FyloZ 2020-03-09 14:54:59 -04:00
parent 499435387e
commit 73f6a97a21
5 changed files with 36 additions and 5 deletions

View File

@ -54,6 +54,17 @@ public class Recipe implements IModel {
@OneToMany(mappedBy = "recipe", cascade = CascadeType.ALL)
private List<RecipeStep> recipeSteps;
public Recipe(Long id, String name, Company company, String description, Integer sample, String approbationDate, String remark, String note) {
this.id = id;
this.name = name;
this.company = company;
this.description = description;
this.sample = sample;
this.approbationDate = approbationDate;
this.remark = remark;
this.note = note;
}
/**
* Récupère les mélanges triés par leur identifiant.
*
@ -79,7 +90,6 @@ public class Recipe implements IModel {
}
/**
* Vérifie si la recette contient un type de mélange.
*
* @param mixType Le type de mélange

View File

@ -1,5 +1,6 @@
package dev.fyloz.trial.colorrecipesexplorer.core.model.dto;
import dev.fyloz.trial.colorrecipesexplorer.core.model.Company;
import dev.fyloz.trial.colorrecipesexplorer.core.model.Recipe;
import lombok.Data;
@ -8,7 +9,26 @@ import java.util.List;
@Data
public class RecipeEditorFormDto {
private Recipe recipe;
private Long id;
private String name;
private Company company;
private String description;
private Integer sample;
private String approbationDate;
private String remark;
private String note;
private List<String> step;
public Recipe getRecipe() {
return new Recipe(id, name, company, description, sample, approbationDate, remark, note);
}
}

View File

@ -59,7 +59,7 @@ public class SimdutService {
public byte[] read(Material material) {
String path = getPath(material);
if (filesService.exists(path)) return new byte[0];
if (!filesService.exists(path)) return new byte[0];
try {
return filesService.readAsBytes(path);

View File

@ -93,7 +93,7 @@ public class RecipeService extends AbstractService<Recipe, RecipeDao> {
public Recipe updateRecipeAndSteps(RecipeEditorFormDto recipeDto) {
Recipe recipe = recipeDto.getRecipe();
stepService.deleteAll(recipe.getRecipeSteps());
stepService.deleteAll(getById(recipe.getId()).getRecipeSteps());
recipe.setRecipeSteps(stepService.createAllForRecipe(recipe, recipeDto.getStep()));
return update(recipe);

View File

@ -164,7 +164,8 @@ function addQuantityInput(quantity, parent) {
value: quantity,
step: 0.001,
min: 0.001,
required: true
required: true,
autocomplete: "off"
});
$(parent).append(input);