diff --git a/core/lib/Thelia/Action/Area.php b/core/lib/Thelia/Action/Area.php
index 14fcfa87b..d3aa5bbc5 100644
--- a/core/lib/Thelia/Action/Area.php
+++ b/core/lib/Thelia/Action/Area.php
@@ -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)
);
}
}
\ No newline at end of file
diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml
index aa8236000..aafaa85b7 100755
--- a/core/lib/Thelia/Config/Resources/config.xml
+++ b/core/lib/Thelia/Config/Resources/config.xml
@@ -128,6 +128,7 @@
+
diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml
index 1cb3486d8..e69853d99 100755
--- a/core/lib/Thelia/Config/Resources/routing/admin.xml
+++ b/core/lib/Thelia/Config/Resources/routing/admin.xml
@@ -696,10 +696,19 @@
\d+
+
+ Thelia\Controller\Admin\AreaController::updatePostageAction
+ \d+
+
+
Thelia\Controller\Admin\AreaController::addCountry
+
+ Thelia\Controller\Admin\AreaController::removeCountry
+
+
diff --git a/core/lib/Thelia/Controller/Admin/AreaController.php b/core/lib/Thelia/Controller/Admin/AreaController.php
index 46f90d40b..62333fb7b 100644
--- a/core/lib/Thelia/Controller/Admin/AreaController.php
+++ b/core/lib/Thelia/Controller/Admin/AreaController.php
@@ -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();
+ }
}
diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php
index 8145a247f..6b8cfddc0 100755
--- a/core/lib/Thelia/Core/Event/TheliaEvents.php
+++ b/core/lib/Thelia/Core/Event/TheliaEvents.php
@@ -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 ----------------------------------------
diff --git a/templates/admin/default/shipping-configuration-edit.html b/templates/admin/default/shipping-configuration-edit.html
index 78dfe4e7c..e8275dc15 100644
--- a/templates/admin/default/shipping-configuration-edit.html
+++ b/templates/admin/default/shipping-configuration-edit.html
@@ -71,7 +71,7 @@
| {$TITLE} |
-
+
|
@@ -81,16 +81,29 @@
|
-
+ {/form}
|
@@ -117,7 +130,8 @@
{* Delete related content confirmation dialog *}
{capture "delete_country_dialog"}
-
+
+
{/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'}
{/javascripts}
+
+
{/block}
\ No newline at end of file