remove country from area and start creating postage management
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Action;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\Area\AreaAddCountryEvent;
|
||||
use Thelia\Core\Event\Area\AreaRemoveCountryEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\AreaQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
@@ -48,6 +49,14 @@ class Area extends BaseAction implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function removeCountry(AreaRemoveCountryEvent $event)
|
||||
{
|
||||
if (null !== $country = CountryQuery::create()->findPk($event->getCountryId())) {
|
||||
$country->setAreaId(null)
|
||||
->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber wants to listen to.
|
||||
@@ -72,7 +81,8 @@ class Area extends BaseAction implements EventSubscriberInterface
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::AREA_ADD_COUNTRY => array('addCountry', 128)
|
||||
TheliaEvents::AREA_ADD_COUNTRY => array('addCountry', 128),
|
||||
TheliaEvents::AREA_REMOVE_COUNTRY => array('removeCountry', 128)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -128,6 +128,7 @@
|
||||
<form name="thelia.admin.area.create" class="Thelia\Form\Area\AreaCreateForm"/>
|
||||
<form name="thelia.admin.area.modification" class="Thelia\Form\Area\AreaModificationForm"/>
|
||||
<form name="thelia.admin.area.country" class="Thelia\Form\Area\AreaCountryForm"/>
|
||||
<form name="thelia.admin.area.postage" class="Thelia\Form\Area\AreaPostageForm"/>
|
||||
|
||||
</forms>
|
||||
|
||||
|
||||
@@ -696,10 +696,19 @@
|
||||
<requirement key="area_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.update.postage" path="/admin/configuration/shipping_configuration/update_postage/{area_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\AreaController::updatePostageAction</default>
|
||||
<requirement key="area_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.country.add" path="/admin/configuration/shipping_configuration/country/add" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Admin\AreaController::addCountry</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.country.remove" path="/admin/configuration/shipping_configuration/country/remove" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Admin\AreaController::removeCountry</default>
|
||||
</route>
|
||||
|
||||
<!-- end shipping routes management -->
|
||||
|
||||
<!-- Countries routes management -->
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Thelia\Controller\Admin;
|
||||
use Thelia\Core\Event\Area\AreaAddCountryEvent;
|
||||
use Thelia\Core\Event\Area\AreaCreateEvent;
|
||||
use Thelia\Core\Event\Area\AreaDeleteEvent;
|
||||
use Thelia\Core\Event\Area\AreaRemoveCountryEvent;
|
||||
use Thelia\Core\Event\Area\AreaUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\Area\AreaCountryForm;
|
||||
@@ -271,4 +272,16 @@ class AreaController extends AbstractCrudController
|
||||
// At this point, the form has errors, and should be redisplayed.
|
||||
return $this->renderEditionTemplate();
|
||||
}
|
||||
|
||||
public function removeCountry()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
|
||||
$request = $this->getRequest();
|
||||
$removeCountryEvent = new AreaRemoveCountryEvent($request->request->get('areai_id', 0), $request->request->get('country_id', 0));
|
||||
|
||||
$this->dispatch(TheliaEvents::AREA_REMOVE_COUNTRY, $removeCountryEvent);
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,7 +237,9 @@ final class TheliaEvents
|
||||
const AREA_CREATE = 'action.createArea';
|
||||
const AREA_UPDATE = 'action.updateArea';
|
||||
const AREA_DELETE = 'action.deleteArea';
|
||||
|
||||
const AREA_ADD_COUNTRY = 'action.area.addCountry';
|
||||
const AREA_REMOVE_COUNTRY = 'action.area.removeCountry';
|
||||
|
||||
// -- Categories Associated Content ----------------------------------------
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
<tr>
|
||||
<td>{$TITLE}</td>
|
||||
<td>
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Delete this country'}" href="#delete_country_dialog" data-id="{$ID}" data-toggle="modal">
|
||||
<a class="btn btn-default btn-xs btn-delete-country" title="{intl l='Delete this country'}" href="#delete_country_dialog" data-id="{$ID}" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
</a>
|
||||
</td>
|
||||
@@ -81,16 +81,29 @@
|
||||
<tfoot>
|
||||
<tr class="active">
|
||||
<td colspan="2">
|
||||
<form method="POST" action="">
|
||||
<label for="" class="control-label">{intl l="Postage"}</label>
|
||||
{form name="thelia.admin.area.postage"}
|
||||
<form method="POST" action="{url path="/admin/configuration/shipping_configuration/update_postage/{$area_id}"}">
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{url path="/admin/configuration/shipping_configuration/update/{$area_id}"}" >
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='area_id'}
|
||||
<input type="hidden" name="{$name}" value="{$area_id}">
|
||||
{/form_field}
|
||||
{form_field form=$form field='postage'}
|
||||
<label for="{$label_attr.for}" class="control-label">{$label}</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" name="" id="" placeholder="Postage">
|
||||
<input type="text" class="form-control" name="{$name}" value="{$value}" id="{$label_attr.for}" placeholder="Postage">
|
||||
<span class="input-group-addon">€</span>
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span></button>
|
||||
</span>
|
||||
</div>
|
||||
{/form_field}
|
||||
</form>
|
||||
{/form}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
@@ -117,7 +130,8 @@
|
||||
{* Delete related content confirmation dialog *}
|
||||
|
||||
{capture "delete_country_dialog"}
|
||||
|
||||
<input type="hidden" name="area_id" value="{$area_id}">
|
||||
<input type="hidden" name="country_id" id="delete-country-id" value="">
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
@@ -127,7 +141,7 @@
|
||||
dialog_title = {intl l="Remove country"}
|
||||
dialog_message = {intl l="Do you really want to remove this country ?"}
|
||||
|
||||
form_action = {url path=''}
|
||||
form_action = {url path='/admin/configuration/shipping_configuration/country/remove'}
|
||||
form_content = {$smarty.capture.delete_country_dialog nofilter}
|
||||
}
|
||||
{/block}
|
||||
@@ -139,4 +153,12 @@
|
||||
{javascripts file='assets/js/bootstrap-select/bootstrap-select.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$(".btn-delete-country").click(function(e){
|
||||
$("#delete-country-id").val($(this).data("id"));
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
Reference in New Issue
Block a user