Recipe edit (WIP)

This commit is contained in:
Greg Burri 2024-12-21 23:13:06 +01:00
parent fce4eade73
commit c6dfff065c
24 changed files with 1157 additions and 971 deletions

View file

@ -1,7 +1,14 @@
{% extends "base_with_header.html" %}
{% macro recipe_item(id, title, class) %}
<a href="/recipe/view/{{ id }}" class="{{ class }}">{{ title }}</a>
<a href="/recipe/view/{{ id }}" class="{{ class }}">
{% if title == "" %}
{# TODO: Translation #}
No title defined
{% else %}
{{ title }}
{% endif %}
</a>
{% endmacro %}
{% block main_container %}
@ -27,7 +34,5 @@
{% endfor %}
</ul>
</nav>
<div class="content">
{% block content %}{% endblock %}
</div>
{% block content %}{% endblock %}
{% endblock %}

View file

@ -2,6 +2,8 @@
{% block content %}
HOME: TODO
<div class="content" id="home">
HOME: TODO
</div>
{% endblock %}

View file

@ -2,17 +2,18 @@
{% block main_container %}
<div class="message">
{% if as_code %}
<pre><code>
{% endif %}
<div class="content" id="message">
{% if as_code %}
<pre><code>
{% endif %}
{{ message|markdown }}
{{ message|markdown }}
{% if as_code %}
</code></pre>
{% endif %}
</div>
{% if as_code %}
</code></pre>
{% endif %}
<a href="/">Go to home</a>
</div>
{% endblock %}

View file

@ -5,10 +5,8 @@
{% match user %}
{% when Some with (user) %}
<div class="content">
<div class="content" id="user-edit">
<h1>Profile</h1>
<form action="/user/edit" method="post">
<label for="input-name">Name</label>

View file

@ -1,23 +1,69 @@
{% extends "base_with_list.html" %}
{% block content %}
<label for="title_field">Title</label>
<input
id="title_field"
type="text"
name="title"
value="{{ recipe.title }}"
autocapitalize="none"
autocomplete="title"
autofocus="autofocus" />
{% macro is_difficulty(diff) %}
{% if recipe.difficulty == diff %}
selected
{% endif %}
{% endmacro %}
{% block content %}
<div class="content" id="recipe-edit">
<label for="input-title">Title</label>
<input
id="input-title"
type="text"
name="title"
value="{{ recipe.title }}"
autocomplete="title"
autofocus="true" />
<label for="input-description">Description</label>
<input
id="input-description"
type="text"
name="description"
value="{{ recipe.description }}"
autocomplete="title" />
<label for="input-description">Estimated time</label>
<input
id="input-estimated-time"
type="number"
name="estimated-time"
value="
{% match recipe.estimated_time %}
{% when Some with (t) %}
{{ t }}
{% when None %}
0
{% endmatch %}"
autocomplete="title" />
<label for="select-difficulty">Difficulty</label>
<select id="select-difficulty" name="difficulty">
<option value="0" {%+ call is_difficulty(crate::data::model::Difficulty::Unknown) %}> - </option>
<option value="1" {%+ call is_difficulty(crate::data::model::Difficulty::Easy) %}>Easy</option>
<option value="2" {%+ call is_difficulty(crate::data::model::Difficulty::Medium) %}>Medium</option>
<option value="3" {%+ call is_difficulty(crate::data::model::Difficulty::Hard) %}>Hard</option>
</select>
<label for="select-language">Language</label>
<select id="select-language" name="language">
{% for lang in languages %}
<option value="{{ lang.1 }}">{{ lang.0 }}</option>
{% endfor %}
</select>
<input
id="input-is-published"
type="checkbox"
name="is-published"
value="{{ recipe.is_published }}" />
<label for="input-is-published">Is published</label>
<div id="groups-container">
</div>
</div>
<label for="description_field">Description</label>
<input
id="title_field"
type="text"
name="title"
value="{{ recipe.description }}"
autocapitalize="none"
autocomplete="title"
autofocus="autofocus" />
{% endblock %}

View file

@ -2,17 +2,18 @@
{% block content %}
<h2 class="recipe-title" >{{ recipe.title }}</h2>
<div class="content" id="recipe-view">
<h2 class="recipe-title" >{{ recipe.title }}</h2>
{% if user.is_some() && recipe.user_id == user.as_ref().unwrap().id %}
<a class="edit-recipe" href="/recipe/edit/{{ recipe.id }}" >Edit</a>
{% endif %}
{% if user.is_some() && recipe.user_id == user.as_ref().unwrap().id %}
<a class="edit-recipe" href="/recipe/edit/{{ recipe.id }}" >Edit</a>
{% endif %}
{% if !recipe.description.is_empty() %}
<div class="recipe-description" >
{{ recipe.description.clone()|markdown }}
</div>
{% endif %}
{% if !recipe.description.is_empty() %}
<div class="recipe-description" >
{{ recipe.description.clone()|markdown }}
</div>
{% endif %}
</div>
{% endblock %}

View file

@ -1,20 +1,22 @@
{% extends "base_with_header.html" %}
{% block main_container %}
<div class="content">
<form action="/reset_password" method="post">
<label for="password_field_1">Choose a new password (minimum 8 characters)</label>
<input id="password_field_1" type="password" name="password_1" />
<label for="password_field_1">Re-enter password</label>
<input id="password_field_2" type="password" name="password_2" />
{{ message_password }}
<div class="content" id="reset-password">
<form action="/reset_password" method="post">
<label for="password_field_1">Choose a new password (minimum 8 characters)</label>
<input id="password_field_1" type="password" name="password_1" />
<input type="hidden" name="reset_token" value="{{ reset_token }}" />
<label for="password_field_1">Re-enter password</label>
<input id="password_field_2" type="password" name="password_2" />
{{ message_password }}
<input type="hidden" name="reset_token" value="{{ reset_token }}" />
<input type="submit" name="commit" value="Reset password" />
</form>
{{ message }}
</div>
<input type="submit" name="commit" value="Reset password" />
</form>
{{ message }}
</div>
{% endblock %}

View file

@ -2,7 +2,7 @@
{% block main_container %}
<div id="sign-in" class="content">
<div class="content" id="sign-in">
<h1>Sign in</h1>

View file

@ -1,7 +1,8 @@
{% extends "base_with_header.html" %}
{% block main_container %}
<div class="content">
<div class="content" id="sign-up">
<h1>Sign up</h1>
@ -23,4 +24,5 @@
</form>
{{ message }}
</div>
{% endblock %}