Skip to content

Commit

Permalink
Add delete button in list
Browse files Browse the repository at this point in the history
  • Loading branch information
julescournut committed Mar 8, 2022
1 parent 9784e5c commit b89585e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>1.2.4</version>
<version>1.2.5</version>
<author>
<name>Julien Chanséaume</name>
<email>julien@thelia.net</email>
Expand Down
3 changes: 3 additions & 0 deletions Config/routing.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@
<default key="_controller">StockAlert\Controller\StockAlertBackOfficeController::configuration</default>
</route>

<route id="stockalert.back.delete.email" path="/admin/module/stockalert/delete" methods="get">
<default key="_controller">StockAlert\Controller\StockAlertBackOfficeController::deleteEmail</default>
</route>
</routes>
14 changes: 14 additions & 0 deletions Controller/StockAlertBackOfficeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
namespace StockAlert\Controller;


use StockAlert\Model\RestockingAlert;
use StockAlert\Model\RestockingAlertQuery;
use StockAlert\StockAlert;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Thelia\Controller\Admin\BaseAdminController;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\ConfigQuery;
use Thelia\Tools\URL;

/**
* Class StockAlertBackOfficeController
Expand Down Expand Up @@ -61,4 +65,14 @@ public function configuration()
]
);
}

public function deleteEmail()
{
$restockingAlertId = $this->getRequest()->get("id");
if ($restockingAlertId) {
$restockingAlert = RestockingAlertQuery::create()->filterById($restockingAlertId)->findOne();
$restockingAlert->delete();
}
return new RedirectResponse(URL::getInstance()->absoluteUrl($this->getSession()->getReturnToUrl()));
}
}
7 changes: 5 additions & 2 deletions templates/backOffice/default/configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<div class="col-md-12 title title-without-tabs">
{intl d='stockalert.bo.default' l='List of current subscriptions.'}
</div>
{$limit={$smarty.get.limit|default:100}}
{$limit={$smarty.get.limit|default:10}}
{$page={$smarty.get.page|default:1}}

{if {count type="restocking-alert"} < $limit * $page}
Expand All @@ -66,7 +66,7 @@
<th>{intl d='stockalert.bo.default' l='Date'}</th>
<th>{intl d='stockalert.bo.default' l='Email'}</th>
<th>{intl d='stockalert.bo.default' l='Product'}</th>
{*<th class="actions">{intl l='Actions'}</th>*}
<th class="actions">{intl l='Actions'}</th>
</tr>
</thead>
<tbody>
Expand All @@ -81,6 +81,9 @@
{/loop}
{/loop}
</td>
<td class="text-right">
<a class="btn btn-danger" href="{url path='/admin/module/stockalert/delete' id=$ID}"><i class="glyphicon glyphicon-trash"></i></a>
</td>
</tr>
{/loop}
</tbody>
Expand Down

0 comments on commit b89585e

Please sign in to comment.