Translation of the recipe edit page
This commit is contained in:
parent
f059d3c61f
commit
8b4b788562
7 changed files with 112 additions and 53 deletions
|
|
@ -7,7 +7,6 @@ use crate::{
|
|||
consts,
|
||||
data::model,
|
||||
hash::{hash, verify_password},
|
||||
services::user,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ pub struct User {
|
|||
pub lang: String,
|
||||
}
|
||||
|
||||
#[derive(FromRow)]
|
||||
#[derive(Debug, FromRow)]
|
||||
pub struct UserLoginInfo {
|
||||
pub last_login_datetime: DateTime<Utc>,
|
||||
pub ip: String,
|
||||
pub user_agent: String,
|
||||
}
|
||||
|
||||
#[derive(FromRow)]
|
||||
#[derive(Debug, FromRow)]
|
||||
pub struct Recipe {
|
||||
pub id: i64,
|
||||
pub user_id: i64,
|
||||
|
|
@ -36,7 +36,7 @@ pub struct Recipe {
|
|||
pub groups: Vec<Group>,
|
||||
}
|
||||
|
||||
#[derive(FromRow)]
|
||||
#[derive(Debug, FromRow)]
|
||||
pub struct Group {
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
|
|
@ -46,7 +46,7 @@ pub struct Group {
|
|||
pub steps: Vec<Step>,
|
||||
}
|
||||
|
||||
#[derive(FromRow)]
|
||||
#[derive(Debug, FromRow)]
|
||||
pub struct Step {
|
||||
pub id: i64,
|
||||
pub action: String,
|
||||
|
|
@ -55,7 +55,7 @@ pub struct Step {
|
|||
pub ingredients: Vec<Ingredient>,
|
||||
}
|
||||
|
||||
#[derive(FromRow)]
|
||||
#[derive(Debug, FromRow)]
|
||||
pub struct Ingredient {
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ pub async fn edit_recipe(
|
|||
current_id: Some(recipe_id),
|
||||
};
|
||||
|
||||
dbg!(&recipe);
|
||||
|
||||
Ok(RecipeEditTemplate {
|
||||
user: Some(user),
|
||||
tr,
|
||||
|
|
|
|||
|
|
@ -80,6 +80,31 @@ pub enum Sentence {
|
|||
RecipeNotAllowedToEdit,
|
||||
RecipeNotAllowedToView,
|
||||
RecipeNotFound,
|
||||
RecipeTitle,
|
||||
RecipeDescription,
|
||||
RecipeServings,
|
||||
RecipeEstimatedTime,
|
||||
RecipeDifficulty,
|
||||
RecipeDifficultyEasy,
|
||||
RecipeDifficultyMedium,
|
||||
RecipeDifficultyHard,
|
||||
RecipeTags,
|
||||
RecipeLanguage,
|
||||
RecipeIsPublished,
|
||||
RecipeDelete,
|
||||
RecipeAddAGroup,
|
||||
RecipeRemoveGroup,
|
||||
RecipeGroupName,
|
||||
RecipeGroupComment,
|
||||
RecipeAddAStep,
|
||||
RecipeRemoveStep,
|
||||
RecipeStepAction,
|
||||
RecipeAddAnIngredient,
|
||||
RecipeRemoveIngredient,
|
||||
RecipeIngredientName,
|
||||
RecipeIngredientQuantity,
|
||||
RecipeIngredientUnit,
|
||||
RecipeIngredientComment,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
|
|||
|
|
@ -9,64 +9,47 @@
|
|||
{% block content %}
|
||||
|
||||
<div class="content" id="recipe-edit">
|
||||
<label for="input-title">Title</label>
|
||||
<label for="input-title">{{ tr.t(Sentence::RecipeTitle) }}</label>
|
||||
<input
|
||||
id="input-title"
|
||||
type="text"
|
||||
value="{{ recipe.title }}"
|
||||
autofocus="true" />
|
||||
|
||||
<label for="text-area-description">Description</label>
|
||||
<label for="text-area-description">{{ tr.t(Sentence::RecipeDescription) }}</label>
|
||||
<textarea
|
||||
id="text-area-description">{{ recipe.description }}</textarea>
|
||||
|
||||
<label for="input-servings">Servings</label>
|
||||
<label for="input-servings">{{ tr.t(Sentence::RecipeServings) }}</label>
|
||||
<input
|
||||
id="input-servings"
|
||||
type="number"
|
||||
step="1" min="1" max="100"
|
||||
value="
|
||||
{% match recipe.servings %}
|
||||
{% when Some with (s) %}
|
||||
{% if let Some(s) = recipe.servings %}
|
||||
{{ s }}
|
||||
{% when None %}
|
||||
{% endif %}"/>
|
||||
|
||||
{% endmatch %}"/>
|
||||
|
||||
<label for="input-estimated-time">Estimated time [min]</label>
|
||||
<label for="input-estimated-time">{{ tr.t(Sentence::RecipeEstimatedTime) }}</label>
|
||||
<input
|
||||
id="input-estimated-time"
|
||||
type="number"
|
||||
step="1" min="0" max="1000"
|
||||
step="10" min="0" max="1000"
|
||||
value="
|
||||
{% match recipe.estimated_time %}
|
||||
{% when Some with (t) %}
|
||||
{% if let Some(t) = recipe.estimated_time %}
|
||||
{{ t }}
|
||||
{% when None %}
|
||||
{% endif %}"/>
|
||||
|
||||
{% endmatch %}"/>
|
||||
|
||||
<label for="select-difficulty">Difficulty</label>
|
||||
<label for="select-difficulty">{{ tr.t(Sentence::RecipeDifficulty) }}</label>
|
||||
<select id="select-difficulty">
|
||||
<option value="0" {%+ call is_difficulty(common::ron_api::Difficulty::Unknown) %}> - </option>
|
||||
<option value="1" {%+ call is_difficulty(common::ron_api::Difficulty::Easy) %}>Easy</option>
|
||||
<option value="2" {%+ call is_difficulty(common::ron_api::Difficulty::Medium) %}>Medium</option>
|
||||
<option value="3" {%+ call is_difficulty(common::ron_api::Difficulty::Hard) %}>Hard</option>
|
||||
<option value="1" {%+ call is_difficulty(common::ron_api::Difficulty::Easy) %}>{{ tr.t(Sentence::RecipeDifficultyEasy) }}</option>
|
||||
<option value="2" {%+ call is_difficulty(common::ron_api::Difficulty::Medium) %}>{{ tr.t(Sentence::RecipeDifficultyMedium) }}</option>
|
||||
<option value="3" {%+ call is_difficulty(common::ron_api::Difficulty::Hard) %}>{{ tr.t(Sentence::RecipeDifficultyHard) }}</option>
|
||||
</select>
|
||||
|
||||
<!--
|
||||
* Event on 'input':
|
||||
* Trim left
|
||||
* for all w in "<word> ":
|
||||
* Call recipe/add_tags with all w
|
||||
* Add all w to tag list (DOM)
|
||||
* Event on 'click' on del tag button:
|
||||
* Call recipe/rm_tags
|
||||
* Remove the tag to the html list (DOM)
|
||||
* 'enter' key to add the current tag
|
||||
-->
|
||||
<div id="container-tags">
|
||||
<label for="input-tags" >Tags</label>
|
||||
<label for="input-tags" >{{ tr.t(Sentence::RecipeTags) }}</label>
|
||||
<span class="tags"></span>
|
||||
<input
|
||||
id="input-tags"
|
||||
|
|
@ -74,7 +57,7 @@
|
|||
value="" />
|
||||
</div>
|
||||
|
||||
<label for="select-language">Language</label>
|
||||
<label for="select-language">{{ tr.t(Sentence::RecipeLanguage) }}</label>
|
||||
<select id="select-language">
|
||||
{% for lang in languages %}
|
||||
<option value="{{ lang.1 }}"
|
||||
|
|
@ -92,55 +75,55 @@
|
|||
checked
|
||||
{% endif %}
|
||||
>
|
||||
<label for="input-is-published">Is published</label>
|
||||
<label for="input-is-published">{{ tr.t(Sentence::RecipeIsPublished) }}</label>
|
||||
|
||||
<input id="input-delete" type="button" value="Delete recipe" />
|
||||
<input id="input-delete" type="button" value="{{ tr.t(Sentence::RecipeDelete) }}" />
|
||||
|
||||
<div id="groups-container">
|
||||
|
||||
</div>
|
||||
<input id="input-add-group" type="button" value="Add a group" />
|
||||
<input id="input-add-group" type="button" value="{{ tr.t(Sentence::RecipeAddAGroup) }}" />
|
||||
|
||||
<div id="hidden-templates">
|
||||
<div class="group">
|
||||
<label for="input-group-name">Name</label>
|
||||
<label for="input-group-name">{{ tr.t(Sentence::RecipeGroupName) }}</label>
|
||||
<input class="input-group-name" type="text" />
|
||||
|
||||
<label for="input-group-comment">Comment</label>
|
||||
<label for="input-group-comment">{{ tr.t(Sentence::RecipeGroupComment) }}</label>
|
||||
<input class="input-group-comment" type="text" />
|
||||
|
||||
<input class="input-group-delete" type="button" value="Remove group" />
|
||||
<input class="input-group-delete" type="button" value="{{ tr.t(Sentence::RecipeRemoveGroup) }}" />
|
||||
|
||||
<div class="steps"></div>
|
||||
|
||||
<input class="input-add-step" type="button" value="Add a step" />
|
||||
<input class="input-add-step" type="button" value="{{ tr.t(Sentence::RecipeAddAStep) }}" />
|
||||
</div>
|
||||
|
||||
<div class="step">
|
||||
<label for="text-area-step-action">Action</label>
|
||||
<label for="text-area-step-action">{{ tr.t(Sentence::RecipeStepAction) }}</label>
|
||||
<textarea class="text-area-step-action"></textarea>
|
||||
|
||||
<input class="input-step-delete" type="button" value="Remove step" />
|
||||
<input class="input-step-delete" type="button" value="{{ tr.t(Sentence::RecipeRemoveStep) }}" />
|
||||
|
||||
<div class="ingredients"></div>
|
||||
|
||||
<input class="input-add-ingredient" type="button" value="Add an ingredient"/>
|
||||
<input class="input-add-ingredient" type="button" value="{{ tr.t(Sentence::RecipeAddAnIngredient) }}"/>
|
||||
</div>
|
||||
|
||||
<div class="ingredient">
|
||||
<label for="input-ingredient-name">Name</label>
|
||||
<label for="input-ingredient-name">{{ tr.t(Sentence::RecipeIngredientName) }}</label>
|
||||
<input class="input-ingredient-name" type="text" />
|
||||
|
||||
<label for="input-ingredient-quantity">Quantity</label>
|
||||
<label for="input-ingredient-quantity">{{ tr.t(Sentence::RecipeIngredientQuantity) }}</label>
|
||||
<input class="input-ingredient-quantity" type="number" step="0.1" min="0" max="10000" />
|
||||
|
||||
<label for="input-ingredient-unit">Unit</label>
|
||||
<label for="input-ingredient-unit">{{ tr.t(Sentence::RecipeIngredientUnit) }}</label>
|
||||
<input class="input-ingredient-unit" type="text" />
|
||||
|
||||
<label for="input-ingredient-comment">Comment</label>
|
||||
<label for="input-ingredient-comment">{{ tr.t(Sentence::RecipeIngredientComment) }}</label>
|
||||
<input class="input-ingredient-comment" type="text" />
|
||||
|
||||
<input class="input-ingredient-delete" type="button" value="Remove ingredient" />
|
||||
<input class="input-ingredient-delete" type="button" value="{{ tr.t(Sentence::RecipeRemoveIngredient) }}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -68,6 +68,31 @@
|
|||
RecipeNotAllowedToEdit: "Not allowed to edit this recipe",
|
||||
RecipeNotAllowedToView: "Not allowed the view the recipe {}",
|
||||
RecipeNotFound: "Recipe not found",
|
||||
RecipeTitle : "Title",
|
||||
RecipeDescription : "Description",
|
||||
RecipeServings : "Servings",
|
||||
RecipeEstimatedTime : "Estimated time [min]",
|
||||
RecipeDifficulty : "Difficulty",
|
||||
RecipeDifficultyEasy : "Easy",
|
||||
RecipeDifficultyMedium : "Medium",
|
||||
RecipeDifficultyHard : "Hard",
|
||||
RecipeTags : "Tags",
|
||||
RecipeLanguage : "Language",
|
||||
RecipeIsPublished : "Is published",
|
||||
RecipeDelete : "Delete recipe",
|
||||
RecipeAddAGroup : "Add a group",
|
||||
RecipeRemoveGroup : "Remove group",
|
||||
RecipeGroupName : "Name",
|
||||
RecipeGroupComment : "Comment",
|
||||
RecipeAddAStep : "Add a step",
|
||||
RecipeRemoveStep : "Remove step",
|
||||
RecipeStepAction : "Action",
|
||||
RecipeAddAnIngredient : "Add an ingredient",
|
||||
RecipeRemoveIngredient : "Remove ingredient",
|
||||
RecipeIngredientName : "Name",
|
||||
RecipeIngredientQuantity : "Quantity",
|
||||
RecipeIngredientUnit : "Unit",
|
||||
RecipeIngredientComment : "Comment",
|
||||
}
|
||||
),
|
||||
(
|
||||
|
|
@ -139,6 +164,31 @@
|
|||
RecipeNotAllowedToEdit: "Vous n'êtes pas autorisé à éditer cette recette",
|
||||
RecipeNotAllowedToView: "Vous n'êtes pas autorisé à voir la recette {}",
|
||||
RecipeNotFound: "Recette non-trouvée",
|
||||
RecipeTitle : "Titre",
|
||||
RecipeDescription : "Description",
|
||||
RecipeServings : "Nombre de personnes",
|
||||
RecipeEstimatedTime : "Temps estimé",
|
||||
RecipeDifficulty : "Difficulté",
|
||||
RecipeDifficultyEasy : "Facile",
|
||||
RecipeDifficultyMedium : "Moyen",
|
||||
RecipeDifficultyHard : "Difficile",
|
||||
RecipeTags : "Tags",
|
||||
RecipeLanguage : "Langue",
|
||||
RecipeIsPublished : "Est publié",
|
||||
RecipeDelete : "Supprimer la recette",
|
||||
RecipeAddAGroup : "Ajouter un groupe",
|
||||
RecipeRemoveGroup : "Supprimer le groupe",
|
||||
RecipeGroupName : "Nom",
|
||||
RecipeGroupComment : "Commentaire",
|
||||
RecipeAddAStep : "Ajouter une étape",
|
||||
RecipeRemoveStep : "Supprimer l'étape",
|
||||
RecipeStepAction : "Action",
|
||||
RecipeAddAnIngredient : "Ajouter un ingrédient",
|
||||
RecipeRemoveIngredient : "Supprimer l'ingrédient",
|
||||
RecipeIngredientName : "Nom",
|
||||
RecipeIngredientQuantity : "Quantité",
|
||||
RecipeIngredientUnit : "Unité",
|
||||
RecipeIngredientComment : "Commentaire",
|
||||
}
|
||||
)
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue