Commit 6f569b3f authored by Floréal Cabanettes's avatar Floréal Cabanettes

Improve panel recipe form + refactoring

parent 9450b0f4
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-11-12 22:26+0100\n"
"PO-Revision-Date: 2017-11-12 22:27+0100\n"
"POT-Creation-Date: 2018-01-07 19:17+0100\n"
"PO-Revision-Date: 2018-01-07 19:18+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fr\n"
......@@ -18,24 +18,24 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 1.8.7.1\n"
#: api/functions.py:32 api/functions.py:89
#: api/functions.py:47 api/functions.py:104
msgid "Category does not exists: "
msgstr "La catégorie n'existe pas : "
#: api/functions.py:36
#: api/functions.py:51
msgid "User not found. Please contact an administrator"
msgstr "Utilisateur non trouvé. Veuillez contacter un administrateur"
#: api/functions.py:95
#: api/functions.py:110
msgid "Author not found. Please contact an administrator"
msgstr "Auteur non trouvé. Veuillez contacter un administrateur"
#: api/views/RecipeById.py:46
#: api/views/RecipeById.py:47
msgid "Unexpected error: "
msgstr "Erreur inattendue :"
#. Translators: recipe is the parent tag of a recipe
#: api/views/RecipeById.py:48 api/views/RecipeList.py:39 panel/urls.py:47
#: api/views/RecipeById.py:49 api/views/RecipeList.py:39 panel/urls.py:47
#: templates/website/index.html:18 website/urls.py:22
msgid "recipe"
msgstr "recette"
......@@ -119,89 +119,89 @@ msgid "Categories"
msgstr "Catégories"
#. Translators : recipe fields
#: main/models/Recipe.py:15
#: main/models/Recipe.py:16
msgid "title"
msgstr "titre"
#: main/models/Recipe.py:16
#: main/models/Recipe.py:17
msgid "description"
msgstr "description"
#: main/models/Recipe.py:17
#: main/models/Recipe.py:18
msgid "prep time"
msgstr "temps de préparation"
#: main/models/Recipe.py:18
#: main/models/Recipe.py:19
msgid "break time"
msgstr "temps de repos"
#: main/models/Recipe.py:20
#: main/models/Recipe.py:21
msgid "cook time"
msgstr "temps de cuisson"
#: main/models/Recipe.py:21
#: main/models/Recipe.py:22
msgid "Picture file"
msgstr "fichier d'illustration"
#: main/models/Recipe.py:23
#: main/models/Recipe.py:24
msgid "number of people"
msgstr "nombre de personnes"
#: main/models/Recipe.py:24
#: main/models/Recipe.py:25
msgid "max number of people"
msgstr "nombre de personnes max"
#: main/models/Recipe.py:27
#: main/models/Recipe.py:28
msgid "precision"
msgstr "précision"
#: main/models/Recipe.py:29
#: main/models/Recipe.py:30
msgid "publication date"
msgstr "date de publication"
#: main/models/Recipe.py:30
#: main/models/Recipe.py:31
msgid "last modification"
msgstr "dernière modification"
#. Translators: author url
#: main/models/Recipe.py:31 templates/website/recipe.html:6
#: main/models/Recipe.py:32 templates/website/recipe.html:6
#: templates/website/recipe.html:26 templates/website/recipe.html:39
msgid "author"
msgstr "auteur"
#: main/models/Recipe.py:32
#: main/models/Recipe.py:33
msgid "category"
msgstr "catégorie"
#: main/models/Recipe.py:34
#: main/models/Recipe.py:35
msgid "equipment"
msgstr "Matériel nécessaire"
#: main/models/Recipe.py:35
#: main/models/Recipe.py:36
msgid "excerpt"
msgstr "résumé"
#: main/models/Recipe.py:36
#: main/models/Recipe.py:37
msgid "enable comments"
msgstr "activer les commentaires"
#: main/models/Recipe.py:37
#: main/models/Recipe.py:38
msgid "published"
msgstr "publié"
#: main/models/Recipe.py:38 panel/urls.py:22 panel/urls.py:24
#: main/models/Recipe.py:39 panel/urls.py:22 panel/urls.py:24
msgid "trash"
msgstr "corbeille"
#: main/models/Recipe.py:39
#: main/models/Recipe.py:40
msgid "slug"
msgstr "slug"
#: main/models/Recipe.py:56 templates/panel/recipe.html:16
#: main/models/Recipe.py:57 templates/panel/recipe.html:16
msgid "Recipe"
msgstr "Recette"
#: main/models/Recipe.py:57 templates/panel/index.html:23
#: main/models/Recipe.py:58 templates/panel/index.html:23
#: templates/panel/recipe.html:20 templates/panel/recipes.html:16
#: templates/panel/recipes.html:20 templates/panel/sidebar.html:30
msgid "Recipes"
......@@ -228,12 +228,12 @@ msgctxt "url"
msgid "published"
msgstr "publie"
#: panel/views/IndexView.py:34 panel/views/RecipesView.py:110
#: panel/views/IndexView.py:37 panel/views/RecipesView.py:113
#: templates/website/header.html:20
msgid "User panel"
msgstr "Panel utilisateur"
#: panel/views/RecipeView.py:34
#: panel/views/RecipeView.py:37
msgid "Edit"
msgstr "Éditer"
......@@ -339,15 +339,27 @@ msgstr "Publié"
msgid "Draft"
msgstr "Brouillon"
#: templates/panel/recipe.html:135
msgid "Save & Quit"
msgstr "Enregistrer & Quitter"
#: templates/panel/recipe.html:136
msgid "Save"
msgstr "Enregistrer"
#: templates/panel/recipe.html:137
msgid "Cancel"
msgstr "Annuler"
#: templates/panel/recipe.html:139
msgid "Want to edit the full recipe? Please use the"
msgstr "Vous souhaitez éditer la recette complète ? Veuillez utiliser le"
#: templates/panel/recipe.html:137
#: templates/panel/recipe.html:140
msgid "QRecipeWriter software"
msgstr "logiciel QRecipeWriter"
#: templates/panel/recipe.html:138
#: templates/panel/recipe.html:141
msgid "(available for Windows and Linux)"
msgstr "(disponible pour Windows et Linux)"
......@@ -604,7 +616,7 @@ msgstr "header-categories-fr.png"
#. Translators: category url
#: templates/website/sidebar.html:11 website/urls.py:15 website/urls.py:16
#: website/views/RecipeView.py:84
#: website/views/RecipeView.py:87
msgctxt "category url"
msgid "category"
msgstr "categorie"
......@@ -634,7 +646,7 @@ msgctxt "author url"
msgid "author"
msgstr "auteur"
#: website/views/IndexView.py:50
#: website/views/IndexView.py:53
msgid "Author:"
msgstr "Auteur :"
......
......@@ -224,4 +224,19 @@ input[type=button].add-new-recipe {
margin-left: 20px;
font-size: 15pt;
line-height: 30px;
}
form#recipe-form table {
margin-bottom: 15px;
}
form#recipe-form {
margin-bottom: 10px;
}
a.show-recipe {
background-color: #00a65a;
color: #ffffff;
padding: 5px;
margin-left: 3px;
}
\ No newline at end of file
pywebcooking = {};
pywebcooking.init = function (page, ...args) {
if (page === "panel") {
pywebcooking.panel.init(...args);
}
else if (page === "panel-recipes") {
pywebcooking.panel.recipes.init(...args);
}
else if (page === "panel-recipe") {
pywebcooking.panel.recipe.init(...args);
}
};
\ No newline at end of file
panel = {};
if (!pywebcooking) {
throw "pywebcooking was not included!"
}
panel.init = function(csrftoken) {
panel.csrftoken = csrftoken;
pywebcooking.panel = {};
pywebcooking.panel.init = function(csrftoken) {
pywebcooking.panel.csrftoken = csrftoken;
};
panel.notify = function(message, type="info", delay=5000, url=null) {
pywebcooking.panel.notify = function(message, type="info", delay=5000, url=null) {
$.notify({
message: message,
url: url,
......
if (!panel) {
if (!pywebcooking || !pywebcooking.panel) {
throw "panel was not included!"
}
panel.recipe = {};
pywebcooking.panel.recipe = {};
panel.recipe.init = function (lang) {
panel.recipe.init_events(lang);
pywebcooking.panel.recipe.init = function (lang) {
pywebcooking.panel.recipe.init_events(lang);
};
panel.recipe.init_events = function (lang) {
pywebcooking.panel.recipe.init_events = function (lang) {
// Datetime picker:
$(".datepicker").datetimepicker({
format: "DD/MM/YYYY HH:mm",
locale: lang
......@@ -21,4 +22,19 @@ panel.recipe.init_events = function (lang) {
placeholder: placeholder,
alias: "dd/mm/yyyy"
});
// Save & quit:
// Save:
// Cancel:
$("form#recipe-form input[type=button]#cancel").click(pywebcooking.panel.recipe.exit);
};
pywebcooking.panel.recipe.exit = function () {
window.location.href = "/panel/" + django.gettext("recipes")
};
pywebcooking.panel.recipe.save = function(exit=true) {
};
\ No newline at end of file
if (!panel) {
if (!pywebcooking || !pywebcooking.panel) {
throw "panel was not included!"
}
panel.recipes = {};
pywebcooking.panel.recipes = {};
panel.recipes.init = function () {
panel.recipes.init_events();
pywebcooking.panel.recipes.init = function () {
pywebcooking.panel.recipes.init_events();
};
panel.recipes.init_events = function () {
pywebcooking.panel.recipes.init_events = function () {
$("div.list-recipes table thead tr th:first-child input[type=checkbox], div.list-recipes table tfoot tr th:first-child input[type=checkbox]").click(function () {
panel.recipes.check_all(this.checked);
pywebcooking.panel.recipes.check_all(this.checked);
});
$("div.form-apply-recipes form.grouped-actions").submit(function(e) {
e.preventDefault();
panel.recipes.submit_grouped_actions(parseInt($(this).find("select").val()));
pywebcooking.panel.recipes.submit_grouped_actions(parseInt($(this).find("select").val()));
});
$("div.form-apply-recipes form#sel-filters").submit(function(e) {
e.preventDefault();
panel.recipes.submit_filter_form();
pywebcooking.panel.recipes.submit_filter_form();
});
$("button#empty-trash").click(panel.recipes.empty_trash);
$("button#empty-trash").click(pywebcooking.panel.recipes.empty_trash);
let list_recipes = $("div.list-recipes");
list_recipes.find("table").find("tr").mouseover(function() {
$(this).find(".actions-a-recipe").show();
......@@ -37,27 +37,27 @@ panel.recipes.init_events = function () {
break;
}
}
panel.recipes.apply_action_to_recipe(this, action);
pywebcooking.panel.recipes.apply_action_to_recipe(this, action);
});
$("input.add-new-recipe").click(function() {
panel.notify(django.gettext("To add a new recipe, please use the <b>QRecipeWriter software</b>!<br/>Available for Windows and Linux (click here to install)"),
pywebcooking.panel.notify(django.gettext("To add a new recipe, please use the <b>QRecipeWriter software</b>!<br/>Available for Windows and Linux (click here to install)"),
"info", 0, "https://gite.flo-art.fr/cooking/qrecipewriter");
})
};
panel.recipes.apply_action_to_recipe = function (link, action) {
pywebcooking.panel.recipes.apply_action_to_recipe = function (link, action) {
let id_recipe = $(link).closest("tr").find("input.select-recipe").val();
panel.recipes.submit_grouped_actions(action, [id_recipe])
pywebcooking.panel.recipes.submit_grouped_actions(action, [id_recipe])
};
panel.recipes.check_all = function (check) {
pywebcooking.panel.recipes.check_all = function (check) {
$("div.list-recipes table tr td:first-child input[type=checkbox]," +
"div.list-recipes table tr th:first-child input[type=checkbox]").prop("checked", check);
};
panel.recipes.submit_grouped_actions = function (action, selected=[]) {
pywebcooking.panel.recipes.submit_grouped_actions = function (action, selected=[]) {
if (action === 0) {
panel.notify(django.gettext("Please select an action to do!"), "warning", 1000)
pywebcooking.panel.notify(django.gettext("Please select an action to do!"), "warning", 1000)
}
else {
// Get selected recipes:
......@@ -71,37 +71,37 @@ panel.recipes.submit_grouped_actions = function (action, selected=[]) {
{
selection: selected,
action: action,
csrfmiddlewaretoken: panel.csrftoken
csrfmiddlewaretoken: pywebcooking.panel.csrftoken
},
function(data, status) {
if (data["success"]) {
location.reload();
}
else {
panel.notify("message" in data ? data["message"] : django.gettext("An error has occurred!"), "error")
pywebcooking.panel.notify("message" in data ? data["message"] : django.gettext("An error has occurred!"), "error")
}
})
}
};
panel.recipes.submit_filter_form = function() {
pywebcooking.panel.recipes.submit_filter_form = function() {
let filter_month = $("#sel-filter-month").val();
let filter_cat = $("#sel-filter-cats").val();
window.location.href = `?filter-month=${filter_month}&filter-cat=${filter_cat}`
};
panel.recipes.empty_trash = function () {
pywebcooking.panel.recipes.empty_trash = function () {
$.post("/panel/recipes/change/",
{
action: "empty_trash",
csrfmiddlewaretoken: panel.csrftoken
csrfmiddlewaretoken: pywebcooking.panel.csrftoken
},
function (data, status) {
if (data["success"]) {
window.location.href = "/panel/recipes/"
}
else {
panel.notify("message" in data ? data["message"] : django.gettext("An error has occurred!"), "error")
pywebcooking.panel.notify("message" in data ? data["message"] : django.gettext("An error has occurred!"), "error")
}
});
};
\ No newline at end of file
......@@ -28,7 +28,7 @@
<!-- main style -->
<link rel="stylesheet" type="text/css" href="{% static 'css/style_panel.css' %}">
</head>
<body class="hold-transition skin-red sidebar-mini" onload='{% block onload %}panel.init("{{ csrf_token }}");{% endblock %}'>
<body class="hold-transition skin-red sidebar-mini" onload='{% block onload %}pywebcooking.panel.init("{{ csrf_token }}");{% endblock %}'>
<div class="wrapper">
<!-- Main Header -->
{% include "panel/header.html" %}
......@@ -69,8 +69,10 @@
<script src="{% static 'js/fastclick.js' %}" type="text/javascript"></script>
<!-- AdminLTE App -->
<script src="{% static 'adminlte/js/adminlte.min.js' %}" type="text/javascript"></script>
<!-- Pywebcooking JS -->
<script src="{% static 'js/pywebcooking.js' %}" defer></script>
<!-- Panel javascript -->
<script src="{% static 'js/panel.js' %}" defer></script>
<script src="{% static 'js/pywebcooking.panel.js' %}" defer></script>
{% endblock %}
</body>
</html>
\ No newline at end of file
......@@ -4,11 +4,11 @@
{% load i18n %}
{% block scripts %}
{{ block.super }}
<script src="{% static 'js/panel.recipe.js' %}" defer></script>
<script src="{% static 'js/pywebcooking.panel.recipe.js' %}" defer></script>
{% endblock %}
{% block onload %}
{{ block.super }}
panel.recipe.init("{{ lang }}");
pywebcooking.init("panel-recipe", "{{ lang }}");
{% endblock %}
{% block content %}
<section class="content-header">
......@@ -26,9 +26,9 @@
<h2 class="subtitle-recipe">
{{ recipe.title }}
</h2>
<a href="{% url "website_recipe" slug=recipe.slug %}" target="show-recipe">{% trans "Show recipe" %}</a>
<a href="{% url "website_recipe" slug=recipe.slug %}" target="show-recipe" class="show-recipe">{% trans "Show recipe" %}</a>
</div>
<form id="recipe-form">
<form id="recipe-form" action="">
<table>
<tbody>
<tr>
......@@ -132,6 +132,9 @@
</tr>
</tbody>
</table>
<input type="button" id="save-and-quit" value="{% trans "Save & Quit" %}">
<input type="button" id="save" value="{% trans "Save" %}">
<input type="button" id="cancel" value="{% trans "Cancel" %}">
</form>
<p>{% trans "Want to edit the full recipe? Please use the" %}
<a href="https://gite.flo-art.fr/cooking/qrecipewriter" target="qrecipewriter">{% trans "QRecipeWriter software" %}</a>
......
......@@ -4,11 +4,11 @@
{% load i18n %}
{% block scripts %}
{{ block.super }}
<script src="{% static 'js/panel.recipes.js' %}" defer></script>
<script src="{% static 'js/pywebcooking.panel.recipes.js' %}" defer></script>
{% endblock %}
{% block onload %}
{{ block.super }}
panel.recipes.init();
pywebcooking.init("panel-recipes");
{% endblock %}
{% block content %}
<section class="content-header">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment