This commit is contained in:
William Nolin 2019-08-22 20:20:28 -04:00
parent b6ec6c8f3b
commit 7903c97ff5
7 changed files with 48 additions and 44 deletions

View File

@ -34,9 +34,9 @@ public class RecipeCreatorController {
* @return La page à afficher.
*/
@GetMapping(CREATOR_RECIPE)
public String showCreationPage(Model model) {
public String showCreationPage(Model model, Recipe recipe) {
model.addAttribute(COMPANIES, companyService.getAll());
model.addAttribute(RECIPE, recipe == null ? new Recipe() : recipe);
return CREATOR_RECIPE;
}
@ -64,7 +64,7 @@ public class RecipeCreatorController {
return CREATOR_RECIPE_SUCCESS;
} else {
model.addAttribute(RESPONSE_ERROR, ERROR_SAVING);
return showCreationPage(model);
return showCreationPage(model, recipe);
}
}
}

View File

@ -67,4 +67,8 @@ mix.edit.title=Editing a mix
mix.edit.subtitle=Editing a mix for the recipe {0} ({1})
password.ask=What is your password?
password.notValid=Your password is not valid
error.serverError=An error occurred while sending data to the server.
error.serverError=An error occurred while sending data to the server.
recipe.add.title=Add a recipe
recipe.sucess.saved=The recipe {0} has been saved. You can now add ingredients.
keyword.continue=Continue
recipe.edit.title=Editing {0}

View File

@ -68,3 +68,7 @@ mix.edit.subtitle=Modifier un mélange pour la recette {0} ({1})
password.ask=Quel est votre mot de passe?
password.notValid=Votre mot de passe n'est pas valide
error.serverError=Une erreur est survenue lors de l'envoie des informations vers le serveur.
recipe.add.title=Ajout d'une recette
recipe.sucess.saved=La recette {0} à été enregistrée. Vous pouvez maintenant ajouter les ingrédients.
keyword.continue=Continuer
recipe.edit.title=Modification de {0}

View File

@ -2,7 +2,7 @@
<html lang="fr" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="fragments.html :: head(#{app.title})"></th:block>
<title>Ajout d'une recette</title>
<title th:text="#{recipe.add.title}"></title>
<link href="/css/main.css" rel="stylesheet"/>
</head>
@ -14,9 +14,9 @@
<section>
<p class="error" th:text="${error}"></p>
<h1>Ajout d'une recette</h1>
<p th:text="'La recette ' + ${recipeCode} + ' à été enregistrée. Vous pouvez maintenant ajouter les ingrédients.'"></p>
<button th:onclick="'document.location.href=\'/recipe/editor/' + ${recipeID} + '\''">Continuer</button>
<h1 th:text="#{recipe.add.title}"></h1>
<p th:text="#{recipe.sucess.saved(${recipeCode})}"></p>
<button th:onclick="'document.location.href=\'/recipe/editor/' + ${recipeID} + '\''" th:text="#{keyword.continue}"></button>
</section>
<!-- Fragment du pied de page -->
<footer th:include="fragments.html :: footer(null)"></footer>

View File

@ -1,8 +1,7 @@
<!DOCTYPE html>
<html lang="fr" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="fragments.html :: head(#{app.title})"></th:block>
<title>Ajout d'une recette</title>
<th:block th:include="fragments.html :: head(#{recipe.add.title})"></th:block>
<link href="/css/main.css" rel="stylesheet"/>
<link href="/css/forms.css" rel="stylesheet"/>
@ -14,44 +13,43 @@
<section>
<p class="error" th:text="${error}"></p>
<h1>Ajout d'une recette</h1>
<h1 th:text="#{recipe.add.title}"></h1>
<div class="form">
<form action="/recipe/creator" class="requireAuth" id="recipe-form" method="POST">
<form th:action="@{/recipe/creator}" th:object="${recipe}" class="requireAuth" id="recipe-form" method="POST">
<table>
<tr>
<td><label for="recipeCode">Couleur: </label></td>
<td><input id="recipeCode" name="recipeCode" required type="text"/></td>
<td><label th:for="${#ids.next('recipeCode')}" th:text="#{recipe.color} + ':'"></label></td>
<td><input type="text" th:field="*{recipeCode}" required/></td>
</tr>
<tr>
<td><label for="company">Bannière: </label></td>
<td><select id="company" name="company">
<th:block th:each="company : ${companies}">
<option th:text="${company.companyName}" th:value="${company.companyID}"></option>
</th:block>
<td><label th:for="${#ids.next('company')}" th:text="#{keyword.company} + ':'"></label></td>
<td><select th:field="*{company}">
<option th:each="company : ${companies}" th:text="${company.companyName}"
th:value="${company.companyID}"></option>
</select></td>
</tr>
<tr>
<td><label for="recipeDescription">Courte description: </label></td>
<td><input id="recipeDescription" name="recipeDescription" required type="text"/></td>
<td><label th:for="${#ids.next('recipeDescription')}" th:text="#{recipe.description} + ':'"></label></td>
<td><input type="text" th:field="*{recipeDescription}" required /></td>
</tr>
<tr>
<td><label for="sample">Échantillon: </label></td>
<td><input id="sample" name="sample" required type="number"/></td>
<td><label th:for="${#ids.next('sample')}" th:text="#{recipe.sample} + ':'"></label></td>
<td><input type="number" th:field="*{sample}" required /></td>
</tr>
<tr>
<td><label for="approbationDate">Date d'approbation: </label></td>
<td><input id="approbationDate" name="approbationDate" type="date"/></td>
<td><label th:for="${#ids.next('approbationDate')}" th:text="#{recipe.approbationDate} + ':'"></label></td>
<td><input type="date" th:field="*{approbationDate}" /></td>
</tr>
<tr>
<td><label for="remark">Remarque: </label></td>
<td><textarea cols="30" form="recipe-form" id="remark" name="remark" rows="10"></textarea></td>
<td><label th:for="${#ids.next('remark')}" th:text="#{recipe.remark}"></label></td>
<td><textarea cols="30" form="recipe-form" rows="10" th:field="*{remark}"></textarea></td>
</tr>
<tr>
<td>
<button class="returnIndex" type="button">Retour</button>
<button class="returnIndex" type="button" th:text="#{keyword.back}"></button>
</td>
<td>
<button type="submit">Enregistrer</button>
<button type="submit" th:text="#{keyword.save}"></button>
</td>
</tr>
</table>

View File

@ -1,10 +1,8 @@
<!DOCTYPE html>
<html lang="fr" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="fragments.html :: head(#{app.title})"></th:block>
<title th:text="'Modification de ' + ${recipe.recipeCode}"></title>
<th:block th:include="fragments.html :: head(#{recipe.edit.title(${recipe.recipeCode})})"></th:block>
<link href="/css/main.css" rel="stylesheet"/>
<link href="/css/forms.css" rel="stylesheet"/>
<style>
@ -32,29 +30,29 @@
<section>
<p class="error" th:text="${error}"></p>
<h1 th:text="'Modification de ' + ${recipe.recipeCode}"></h1>
<button id="gotoRecipe" type="button">Voir</button>
<h1 th:text="#{recipe.edit.title(${recipe.recipeCode})}"></h1>
<button id="gotoRecipe" type="button" th:text="#{keyword.see}"></button>
<br/>
<br/>
<div class="form">
<form action="/recipe/editor" class="requireAuth" method="POST">
<input id="recipeID" name="recipeID" th:value="${recipe.recipeID}" type="hidden"/>
<input name="recipeCode" th:value="${recipe.recipeCode}" type="hidden"/>
<form th:action="@{/recipe/editor}" th:object="${recipe}" class="requireAuth" method="POST">
<input type="hidden" th:field="*{recipeID}"/>
<input type="hidden" th:field="*{recipeCode}"/>
<table class="mainTable">
<tr>
<td>
<table>
<tr>
<td><label for="company">Bannière: </label></td>
<td><label th:for="${#ids.next('company')}" th:text="#{keyword.company} + ':'"></label>
</td>
<td>
<select id="company" name="company">
<th:block th:each="company : ${companies}">
<option th:selected="${recipe.company.equals(company)}"
th:text="${company.companyName}"
th:value="${company.companyID}"></option>
</th:block>
<select th:field="*{company}">
<option th:each="company : ${companies}"
th:selected="${recipe.company.equals(company)}"
th:text="${company.companyName}"
th:value="${company.companyID}"></option>
</select>
</td>
</tr>

Binary file not shown.