From 666b19a6ff9501a984bd5a0b1801c41d48b14c67 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 4 Oct 2013 17:33:48 +0200 Subject: [PATCH] update address process --- .../Thelia/Config/Resources/routing/admin.xml | 5 ++ .../Controller/Admin/AddressController.php | 50 +++++++------------ .../default/ajax/address-update-modal.html | 2 +- templates/default/layout.tpl | 18 ------- templates/default/product.html | 2 +- 5 files changed, 25 insertions(+), 52 deletions(-) diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index c856c1a90..2f85b57bc 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -142,6 +142,11 @@ \d+ + + Thelia\Controller\Admin\AddressController::processUpdateAction + \d+ + + diff --git a/core/lib/Thelia/Controller/Admin/AddressController.php b/core/lib/Thelia/Controller/Admin/AddressController.php index 6f4622598..c6af8102c 100644 --- a/core/lib/Thelia/Controller/Admin/AddressController.php +++ b/core/lib/Thelia/Controller/Admin/AddressController.php @@ -60,31 +60,6 @@ class AddressController extends AbstractCrudController ); } -/* public function deleteAddressAction() - { - if (null !== $response = $this->checkAuth("admin.customer.update")) return $response; - - $address_id = $this->getRequest()->request->get('address_id'); - - try { - $address = AddressQuery::create()->findPk($address_id); - - if (null === $address) { - throw new \InvalidArgumentException(sprintf('%d address does not exists', $address_id)); - } - - $addressEvent = new AddressEvent($address); - - $this->dispatch(TheliaEvents::ADDRESS_DELETE, $addressEvent); - - $this->adminLogAppend(sprintf("address %d for customer %d removal", $address_id, $address->getCustomerId())); - } catch(\Exception $e) { - \Thelia\Log\Tlog::getInstance()->error(sprintf("error during address removal with message %s", $e->getMessage())); - } - - $this->redirectToRoute('admin.customer.update.view', array(), array('customer_id' => $address->getCustomerId())); - }*/ - public function useAddressAction() { if (null !== $response = $this->checkAuth("admin.customer.update")) return $response; @@ -159,7 +134,13 @@ class AddressController extends AbstractCrudController */ protected function getCreationEvent($formData) { - return $this->getCreateOrUpdateEvent($formData); + $event = $this->getCreateOrUpdateEvent($formData); + + $customer = CustomerQuery::create()->findPk($this->getRequest()->get("customer_id")); + + $event->setCustomer($customer); + + return $event; } /** @@ -169,7 +150,9 @@ class AddressController extends AbstractCrudController */ protected function getUpdateEvent($formData) { - return $this->getCreateOrUpdateEvent($formData); + $event = $this->getCreateOrUpdateEvent($formData); + + $event->setAddress($this->getExistingObject()); } protected function getCreateOrUpdateEvent($formData) @@ -191,9 +174,7 @@ class AddressController extends AbstractCrudController $formData["is_default"] ); - $customer = CustomerQuery::create()->findPk($this->getRequest()->get("customer_id")); - $event->setCustomer($customer); return $event; @@ -281,7 +262,8 @@ class AddressController extends AbstractCrudController */ protected function redirectToEditionTemplate() { - // TODO: Implement redirectToEditionTemplate() method. + $address = $this->getExistingObject(); + $this->redirectToRoute('admin.customer.update.view', array(), array('customer_id' => $address->getCustomerId())); } /** @@ -312,7 +294,11 @@ class AddressController extends AbstractCrudController */ protected function performAdditionalCreateAction($createEvent) { - $address = $createEvent->getAddress(); - $this->redirectToRoute('admin.customer.update.view', array(), array('customer_id' => $address->getCustomerId())); + $this->redirectToEditionTemplate(); + } + + protected function performAdditionalUpdateAction($event) + { + $this->redirectToEditionTemplate(); } } \ No newline at end of file diff --git a/templates/admin/default/ajax/address-update-modal.html b/templates/admin/default/ajax/address-update-modal.html index d6a329118..39bafccea 100644 --- a/templates/admin/default/ajax/address-update-modal.html +++ b/templates/admin/default/ajax/address-update-modal.html @@ -103,7 +103,7 @@ dialog_ok_label = {intl l="Edit this address"} dialog_cancel_label = {intl l="Cancel"} -form_action = {url path='/admin/address/update'} +form_action = {url path="/admin/address/save/{$address_id}"} form_enctype = {form_enctype form=$form} form_error_message = $form_error_message } diff --git a/templates/default/layout.tpl b/templates/default/layout.tpl index 731c6f685..2c8a56d44 100644 --- a/templates/default/layout.tpl +++ b/templates/default/layout.tpl @@ -62,24 +62,6 @@ URL: http://www.thelia.net