diff --git a/local/modules/Recettes/Config/routing.xml b/local/modules/Recettes/Config/routing.xml
index 056eb3cd..57513eb0 100644
--- a/local/modules/Recettes/Config/routing.xml
+++ b/local/modules/Recettes/Config/routing.xml
@@ -24,5 +24,8 @@
Recettes\Controller\BackController::addProduct
\d+
+
+ Recettes\Controller\BackController::addStep
+
diff --git a/local/modules/Recettes/Controller/BackController.php b/local/modules/Recettes/Controller/BackController.php
index aeb0d9d5..129277ab 100755
--- a/local/modules/Recettes/Controller/BackController.php
+++ b/local/modules/Recettes/Controller/BackController.php
@@ -7,6 +7,7 @@ use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\Exception\PropelException;
use Propel\Runtime\Propel;
use Recettes\Form\RecetteCreateForm;
+use Recettes\Form\StepCreateForm;
use Recettes\Model\Recipe;
use Recettes\Model\RecipeProducts;
use Recettes\Model\RecipeProductsQuery;
@@ -181,4 +182,36 @@ class BackController extends BaseAdminController
return $this->render('includes/related-products', [ 'content_id' => $contentId ]);
}
+
+ public function addStep(Request $request)
+ {
+ $form = new StepCreateForm($request);
+ $errorUrl = "";
+ try {
+ $formValidate = $this->validateForm($form);
+ $data = $formValidate->getData();
+
+ $recipeId = $data['recipe_id'];
+ $step = $data['step'];
+ $description = $data['description'];
+ $errorUrl = $data['error_url'];
+ $successUrl = $data['success_url'];
+ if ($recipeId && $step && $description) {
+ (new RecipeSteps())
+ ->setRecipeId($recipeId)
+ ->setStep($step)
+ ->setDescription($description)
+ ->save();
+
+ return new RedirectResponse(URL::getInstance()->absoluteUrl($successUrl));
+ }
+ else
+ return new RedirectResponse(URL::getInstance()->absoluteUrl($errorUrl));
+
+ } catch (\Exception $e) {
+ $error = $e->getMessage();
+ }
+
+ }
+
}
diff --git a/local/modules/Recettes/Form/StepCreateForm.php b/local/modules/Recettes/Form/StepCreateForm.php
index 4544d6f5..daca93fb 100644
--- a/local/modules/Recettes/Form/StepCreateForm.php
+++ b/local/modules/Recettes/Form/StepCreateForm.php
@@ -2,6 +2,8 @@
namespace Recettes\Form;
+use Recettes\Recettes;
+use Thelia\Core\Translation\Translator;
use Thelia\Form\BaseForm;
/**
@@ -16,12 +18,18 @@ class StepCreateForm extends BaseForm
protected function buildForm()
{
$this->formBuilder
+ ->add(
+ "recipe_id",
+ "integer",
+ [
+ "required" => true
+ ])
->add(
"step",
- "number",
+ "integer",
[
"required" => true,
- "label" => "Step",
+ "label" => $this->trans("Step"),
"label_attr" => ['for' => 'step']
])
->add(
@@ -29,8 +37,8 @@ class StepCreateForm extends BaseForm
"textarea",
[
"required" => true,
- "label" => "Description",
- "label_attr" => ['for' => 'description']
+ "label" => $this->trans("Description"),
+ "label_attr" => ['for' => 'description'],
]);
}
@@ -41,4 +49,14 @@ class StepCreateForm extends BaseForm
{
return "recette-step-create";
}
+
+
+ protected function trans($id, $parameters = [])
+ {
+ if (null === $this->translator) {
+ $this->translator = Translator::getInstance();
+ }
+
+ return $this->translator->trans($id, $parameters, Recettes::MESSAGE_DOMAIN);
+ }
}
diff --git a/local/modules/Recettes/I18n/fr_FR.php b/local/modules/Recettes/I18n/fr_FR.php
index 2132dd59..a43d1ee0 100644
--- a/local/modules/Recettes/I18n/fr_FR.php
+++ b/local/modules/Recettes/I18n/fr_FR.php
@@ -26,4 +26,6 @@ return array(
'Created on' => 'Rédigée le',
'Save recipe' => 'Sauvegarder la recette',
'Create a new step' => 'Ajouter une étape à votre recette',
+ 'No need to step number' => 'Inutile de saisir le numéro de l\'étape dans la description ci-dessus : il sera automatiquement rajouté !',
+
);
diff --git a/local/modules/Recettes/templates/backOffice/default/includes/steps.html b/local/modules/Recettes/templates/backOffice/default/includes/steps.html
index 2c543ca5..dc4caf2b 100644
--- a/local/modules/Recettes/templates/backOffice/default/includes/steps.html
+++ b/local/modules/Recettes/templates/backOffice/default/includes/steps.html
@@ -4,7 +4,6 @@
{intl l="Detail" d="recettes"} |
- {assign var="last_step" value="0"}
{loop name="steps-loop" type="recipe_steps" recipe_id=$recipe_id}
|
@@ -15,12 +14,11 @@
{if $LOOP_COUNT < $LOOP_TOTAL}
{/if} |
- {$DESCRIPTION} |
+ {$DESCRIPTION|unescape:"html" nofilter} |
|
- {if $LOOP_COUNT=$LOOP_TOTAL}{assign var="last_step" value="$STEP"}{/if}
{/loop}
@@ -30,22 +28,3 @@
data-target="#add-step-modal" data-toggle="modal">
-
-{form name="recette-step-create"}
- {capture "step_create"}
- {include file="modal/step-edit.html" form_name="recette-step-create" next_step=($last_step+1)}
- {/capture}
-
- {include file="includes/generic-create-dialog.html"
-
- dialog_id = "add-step-modal"
- dialog_title = {intl l="Create a new step" d="recettes"}
- dialog_body = {$smarty.capture.step_create nofilter}
-
- dialog_ok_label = {intl l="Create"}
- dialog_cancel_label = {intl l="Cancel"}
-
- form_action = {$current_url}
- form_enctype = {form_enctype form=$form}
- }
-{/form}
\ No newline at end of file
diff --git a/local/modules/Recettes/templates/backOffice/default/modal/step-edit.html b/local/modules/Recettes/templates/backOffice/default/modal/step-edit.html
index 10bc56a1..c7bc1308 100644
--- a/local/modules/Recettes/templates/backOffice/default/modal/step-edit.html
+++ b/local/modules/Recettes/templates/backOffice/default/modal/step-edit.html
@@ -2,12 +2,19 @@
{form_hidden_fields form=$form}
- {render_form_field form=$form field="success_url" value={$success_url|default:{url path="/admin/content/update/$contentId?current_tab=recipe"}}}
+ {render_form_field form=$form field="success_url" value={url path="/admin/content/update/$content_id?current_tab=recipe"}}
+ {render_form_field form=$form field="error_url" value={url path="/admin/content/update/$content_id?current_tab=recipe"}}
+
+ {form_field form=$form field="recipe_id"}
+
+
+
+ {/form_field}
{form_field form=$form field="step"}
-
+
{/form_field}
@@ -17,10 +24,10 @@
{intl l=$label d="recettes"}
{if $required}*{/if}
-
{form_error form=$form field="description"}{$message}{/form_error}
-
+
+ {intl l="No need to step number" d="recettes"}
{/form_field}
-{/form}
\ No newline at end of file
+{/form}
diff --git a/local/modules/Recettes/templates/backOffice/default/recette-tab.html b/local/modules/Recettes/templates/backOffice/default/recette-tab.html
index ccdc9da4..734598aa 100644
--- a/local/modules/Recettes/templates/backOffice/default/recette-tab.html
+++ b/local/modules/Recettes/templates/backOffice/default/recette-tab.html
@@ -9,6 +9,12 @@
{assign var="other_ingredients" value=$OTHER_INGREDIENTS}
{/loop}
+{assign var="last_step" value="0"}
+{loop name="steps-loop" type="recipe_steps" recipe_id=$recipe_id}
+ {if $LOOP_COUNT=$LOOP_TOTAL}{assign var="last_step" value="$STEP"}{/if}
+{/loop}
+
+
{form name="recette_create_form"}
{/form}
-
\ No newline at end of file
+
+
+{* CREATE Modal *}
+{form name="recette-step-create"}
+ {capture "step_create"}
+ {include file="modal/step-edit.html" form_name="recette-step-create" next_step=($last_step+1) recipe_id=$recipe_id content_id=$content_id}
+ {/capture}
+
+ {include file="includes/generic-create-dialog.html"
+ dialog_id = "add-step-modal"
+ dialog_title = {intl l="Create a new step" d="recettes"}
+ dialog_body = {$smarty.capture.step_create nofilter}
+ dialog_ok_label = {intl l="Create"}
+ dialog_cancel_label = {intl l="Cancel"}
+ form_action = {url path="/admin/module/Recettes/add-step"}
+ form_enctype = {form_enctype form=$form}
+ }
+{/form}
\ No newline at end of file
diff --git a/templates/frontOffice/custom/assets/src/css/custom.css b/templates/frontOffice/custom/assets/src/css/custom.css
index cf16f5a1..14b3f9e7 100644
--- a/templates/frontOffice/custom/assets/src/css/custom.css
+++ b/templates/frontOffice/custom/assets/src/css/custom.css
@@ -347,4 +347,7 @@ span.product-categorie {
margin: auto !important;
line-height: 1rem !important;
height: 1.5rem;
+}
+.autres-ingredients {
+ text-align: left;
}
\ No newline at end of file
diff --git a/templates/frontOffice/custom/recette.html b/templates/frontOffice/custom/recette.html
index b0cdc66d..13c42fca 100644
--- a/templates/frontOffice/custom/recette.html
+++ b/templates/frontOffice/custom/recette.html
@@ -99,7 +99,7 @@
{loop type="recipe_steps" name="steps-loop" recipe_id=$ID}
| {$STEP} |
- {$DESCRIPTION} |
+ {$DESCRIPTION|unescape:"html" nofilter} |
{/loop}