Correction de quelques bogues dans Recettes (backOffice)
This commit is contained in:
@@ -23,9 +23,10 @@
|
|||||||
<default key="_controller">Recettes\Controller\BackController::searchProduct</default>
|
<default key="_controller">Recettes\Controller\BackController::searchProduct</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="recipe.add_product" path="/admin/module/Recettes/add-product/{contentId}">
|
<route id="recipe.add_product" path="/admin/module/Recettes/add-product/{contentId}/{recipeId}">
|
||||||
<default key="_controller">Recettes\Controller\BackController::addProduct</default>
|
<default key="_controller">Recettes\Controller\BackController::addProduct</default>
|
||||||
<requirement key="contentId">\d+</requirement>
|
<requirement key="contentId">\d+</requirement>
|
||||||
|
<requirement key="recipeId">\d+</requirement>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="recipe.add_step" path="/admin/module/Recettes/add-step" methods="post">
|
<route id="recipe.add_step" path="/admin/module/Recettes/add-step" methods="post">
|
||||||
|
|||||||
@@ -165,11 +165,10 @@ class BackController extends BaseAdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function addProduct($contentId)
|
public function addProduct($contentId, $recipeId)
|
||||||
{
|
{
|
||||||
$pseId = (int) $this->getRequest()->get('pse_id');
|
$pseId = (int) $this->getRequest()->get('pse_id');
|
||||||
$quantityNeeded = (string) $this->getRequest()->get('quantity_needed');
|
$quantityNeeded = (string) $this->getRequest()->get('quantity_needed');
|
||||||
$recipeId = (int) $this->getRequest()->get('recipe_id');
|
|
||||||
$quantityProposed = (int) $this->getRequest()->get('quantity_proposed');
|
$quantityProposed = (int) $this->getRequest()->get('quantity_proposed');
|
||||||
|
|
||||||
(new RecipeProducts())
|
(new RecipeProducts())
|
||||||
@@ -179,7 +178,7 @@ class BackController extends BaseAdminController
|
|||||||
->setNbOfProducts($quantityProposed)
|
->setNbOfProducts($quantityProposed)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
return $this->render('includes/related-products', [ 'content_id' => $contentId ]);
|
return $this->render('includes/related-products', [ 'recipe_id' => $recipeId, 'content_id' => $contentId ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
namespace Recettes\EventListener;
|
namespace Recettes\EventListener;
|
||||||
|
|
||||||
|
use Propel\Runtime\Exception\PropelException;
|
||||||
use Propel\Runtime\Propel;
|
use Propel\Runtime\Propel;
|
||||||
use Recettes\Model\RecipeProductsQuery;
|
use Recettes\Model\RecipeProductsQuery;
|
||||||
use Recettes\Model\RecipeQuery;
|
use Recettes\Model\RecipeQuery;
|
||||||
use Recettes\Model\RecipeStepsQuery;
|
use Recettes\Model\RecipeStepsQuery;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Thelia\Action\BaseAction;
|
use Thelia\Action\BaseAction;
|
||||||
|
use Thelia\Log\Tlog;
|
||||||
use Thelia\Model\Event\ContentEvent;
|
use Thelia\Model\Event\ContentEvent;
|
||||||
use Thelia\Core\HttpFoundation\Request;
|
use Thelia\Core\HttpFoundation\Request;
|
||||||
|
|
||||||
@@ -36,9 +38,13 @@ class ContentListener extends BaseAction implements EventSubscriberInterface
|
|||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$contentId = $this->request->request->get('content_id');
|
$contentId = $this->request->request->get('content_id');
|
||||||
$recipeId = RecipeQuery::create()
|
try {
|
||||||
->findOneByContentId($contentId)
|
$recipe = RecipeQuery::create()
|
||||||
->getId();
|
->findOneByContentId($contentId);
|
||||||
|
if ($recipe)
|
||||||
|
$recipeId = $recipe->getId();
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
if ($recipeId)
|
if ($recipeId)
|
||||||
{
|
{
|
||||||
@@ -57,5 +63,10 @@ class ContentListener extends BaseAction implements EventSubscriberInterface
|
|||||||
->delete();
|
->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
|
Tlog::getInstance()->error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,16 @@ class RecetteCreateForm extends BaseForm
|
|||||||
"content_id",
|
"content_id",
|
||||||
"integer",
|
"integer",
|
||||||
[
|
[
|
||||||
"constraints" => [ new NotBlank() ]
|
"constraints" => [ new NotBlank() ],
|
||||||
|
"required" => true
|
||||||
|
]
|
||||||
|
)
|
||||||
|
->add(
|
||||||
|
"recipe_id",
|
||||||
|
"integer",
|
||||||
|
[
|
||||||
|
"constraints" => [ new NotBlank() ],
|
||||||
|
"required" => true
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
->add(
|
->add(
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ use Thelia\Model\ProductSaleElementsQuery;
|
|||||||
*/
|
*/
|
||||||
class ProductsLoop extends BaseLoop implements PropelSearchLoopInterface
|
class ProductsLoop extends BaseLoop implements PropelSearchLoopInterface
|
||||||
{
|
{
|
||||||
public $countable = false;
|
public $countable = true;
|
||||||
public $timestampable = false;
|
public $timestampable = false;
|
||||||
public $versionable = false;
|
public $versionable = false;
|
||||||
|
|
||||||
@@ -83,9 +83,10 @@ class ProductsLoop extends BaseLoop implements PropelSearchLoopInterface
|
|||||||
{
|
{
|
||||||
$products = RecipeProductsQuery::create();
|
$products = RecipeProductsQuery::create();
|
||||||
|
|
||||||
if (null != $recipeId = $this->getRecipeId()) {
|
if (null != $recipeId = $this->getRecipeId())
|
||||||
$products->filterByRecipeId($recipeId);
|
$products->filterByRecipeId($recipeId);
|
||||||
}
|
else
|
||||||
|
return null;
|
||||||
|
|
||||||
return $products;
|
return $products;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,9 +57,11 @@ class StepsLoop extends BaseLoop implements PropelSearchLoopInterface
|
|||||||
{
|
{
|
||||||
$steps = RecipeStepsQuery::create();
|
$steps = RecipeStepsQuery::create();
|
||||||
|
|
||||||
if (null != $id = $this->getRecipeId()) {
|
if (null != $id = $this->getRecipeId())
|
||||||
$steps->filterByRecipeId($id);
|
$steps->filterByRecipeId($id);
|
||||||
}
|
else
|
||||||
|
return null;
|
||||||
|
|
||||||
$steps->orderByStep();
|
$steps->orderByStep();
|
||||||
|
|
||||||
return $steps;
|
return $steps;
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
<th colspan="2">{intl l="Quantity proposed" d="recettes"}</th>
|
<th colspan="2">{intl l="Quantity proposed" d="recettes"}</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
|
{ifloop rel="products-loop"}
|
||||||
{loop type="recipe_products" name="products-loop" recipe_id=$recipe_id}
|
{loop type="recipe_products" name="products-loop" recipe_id=$recipe_id}
|
||||||
{loop type="product" visible="*" name="related-product" id=$PRODUCT_ID}
|
{loop type="product" visible="*" name="related-product" id=$PRODUCT_ID}
|
||||||
<tr>
|
<tr>
|
||||||
@@ -18,6 +20,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{/loop}
|
{/loop}
|
||||||
{/loop}
|
{/loop}
|
||||||
|
{/ifloop}
|
||||||
{elseloop rel="products-loop"}
|
{elseloop rel="products-loop"}
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="99">
|
<td colspan="99">
|
||||||
@@ -51,7 +54,7 @@
|
|||||||
<input class="form-control" type="text" id="quantity_proposed" autocomplete="off" placeholder="Quantité proposée, en fonction de la déclinaison">
|
<input class="form-control" type="text" id="quantity_proposed" autocomplete="off" placeholder="Quantité proposée, en fonction de la déclinaison">
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<a href="{url path='/admin/module/Recettes/add-product/%contentId' contentId=$content_id}" class="btn btn-sm btn-primary add-product"><i class="glyphicon glyphicon-plus-sign"></i></a>
|
<a href="{url path='/admin/module/Recettes/add-product/%contentId/%recipeId' contentId=$content_id recipeId=$recipe_id}" class="btn btn-sm btn-primary add-product"><i class="glyphicon glyphicon-plus-sign"></i></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -24,7 +24,9 @@
|
|||||||
{form_field form=$form field="content_id"}
|
{form_field form=$form field="content_id"}
|
||||||
<input type="hidden" name="{$name}" value="{$content_id}">
|
<input type="hidden" name="{$name}" value="{$content_id}">
|
||||||
{/form_field}
|
{/form_field}
|
||||||
<input type="hidden" class="form-control" name="recipe_id" value="{$recipe_id}">
|
{form_field form=$form field="recipe_id"}
|
||||||
|
<input type="hidden" class="form-control" name="{$name}" value="{$recipe_id}">
|
||||||
|
{/form_field}
|
||||||
<br>
|
<br>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user