From 5e8749e0543005128fbc6167ea7cad95262ec026 Mon Sep 17 00:00:00 2001 From: mespeche Date: Mon, 16 Sep 2013 12:55:34 +0200 Subject: [PATCH] - Edit country view creation - Delete and edit modalbox creation - Countries routes management --- core/lib/Thelia/Config/Resources/config.xml | 3 + .../Thelia/Config/Resources/routing/admin.xml | 5 + .../Controller/Admin/CountryController.php | 13 ++ core/lib/Thelia/Form/CountryCreationForm.php | 38 ++++- .../Thelia/Form/CountryModificationForm.php | 107 +++++++++++++ templates/admin/default/admin-layout.tpl | 1 - templates/admin/default/countries.html | 58 +++++++- templates/admin/default/country-edit.html | 140 ++++++++++++++++++ 8 files changed, 355 insertions(+), 10 deletions(-) create mode 100644 core/lib/Thelia/Form/CountryModificationForm.php diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index d8211c6cc..691cf2198 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -82,6 +82,9 @@
+ + + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 839d84756..eb2fbf3ca 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -302,6 +302,11 @@ Thelia\Controller\Admin\CountryController::createAction + + Thelia\Controller\Admin\CountryController::updateAction + \d+ + + diff --git a/core/lib/Thelia/Controller/Admin/CountryController.php b/core/lib/Thelia/Controller/Admin/CountryController.php index 172552893..fadca1e92 100644 --- a/core/lib/Thelia/Controller/Admin/CountryController.php +++ b/core/lib/Thelia/Controller/Admin/CountryController.php @@ -36,4 +36,17 @@ class CountryController extends BaseAdminController return $this->render("countries", array("display_country" => 20)); } + /** + * update country action + * + * @param $country_id + * @return mixed|\Symfony\Component\HttpFoundation\Response + */ + public function updateAction($country_id) + { + return $this->render("country-edit", array( + "country_id" => $country_id + )); + } + } \ No newline at end of file diff --git a/core/lib/Thelia/Form/CountryCreationForm.php b/core/lib/Thelia/Form/CountryCreationForm.php index 2c56a1b6a..ad6701a64 100644 --- a/core/lib/Thelia/Form/CountryCreationForm.php +++ b/core/lib/Thelia/Form/CountryCreationForm.php @@ -34,21 +34,47 @@ class CountryCreationForm extends BaseForm "constraints" => array( new NotBlank() ), - "label" => Translator::getInstance()->trans("Category title *"), + "label" => Translator::getInstance()->trans("Country title *"), "label_attr" => array( "for" => "title" ) - )) - ->add("parent", "integer", array( + )) + ->add("area", "text", array( "constraints" => array( new NotBlank() + ), + "label" => Translator::getInstance()->trans("Country area *"), + "label_attr" => array( + "for" => "area" ) - )) - ->add("locale", "text", array( + )) + ->add("isocode", "text", array( "constraints" => array( new NotBlank() + ), + "label" => Translator::getInstance()->trans("ISO Code *"), + "label_attr" => array( + "for" => "isocode" ) - )) + )) + ->add("isoalpha2", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Alpha code 2 *"), + "label_attr" => array( + "for" => "isoalpha2" + ) + )) + ->add("isoalpha3", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Alpha code 3 *"), + "label_attr" => array( + "for" => "isoalpha3" + ) + )) ; } diff --git a/core/lib/Thelia/Form/CountryModificationForm.php b/core/lib/Thelia/Form/CountryModificationForm.php new file mode 100644 index 000000000..4c1581664 --- /dev/null +++ b/core/lib/Thelia/Form/CountryModificationForm.php @@ -0,0 +1,107 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\GreaterThan; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +class CountryModificationForm extends CurrencyCreationForm +{ + protected function buildForm() + { + parent::buildForm(true); + + $this->formBuilder + ->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) + ->add("title", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Country title *"), + "label_attr" => array( + "for" => "title" + ) + )) + ->add("short-description", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Country short description *"), + "label_attr" => array( + "for" => "short-description" + ) + )) + ->add("description", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Country description *"), + "label_attr" => array( + "for" => "description" + ) + )) + ->add("area", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Country area *"), + "label_attr" => array( + "for" => "area" + ) + )) + ->add("isocode", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("ISO Code *"), + "label_attr" => array( + "for" => "isocode" + ) + )) + ->add("isoalpha2", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Alpha code 2 *"), + "label_attr" => array( + "for" => "isoalpha2" + ) + )) + ->add("isoalpha3", "text", array( + "constraints" => array( + new NotBlank() + ), + "label" => Translator::getInstance()->trans("Alpha code 3 *"), + "label_attr" => array( + "for" => "isoalpha3" + ) + )) + ; + } + + public function getName() + { + return "thelia_country_modification"; + } +} diff --git a/templates/admin/default/admin-layout.tpl b/templates/admin/default/admin-layout.tpl index 3b97c069b..4cad798fb 100644 --- a/templates/admin/default/admin-layout.tpl +++ b/templates/admin/default/admin-layout.tpl @@ -206,7 +206,6 @@ - {intl l='Édité par OpenStudio'} - {intl l='Forum Thelia'} - {intl l='Contributions Thelia'} - {intl l='interface par Steaw-Webdesign'}

{module_include location='in_footer'} diff --git a/templates/admin/default/countries.html b/templates/admin/default/countries.html index b3e2254b8..982db557f 100644 --- a/templates/admin/default/countries.html +++ b/templates/admin/default/countries.html @@ -124,11 +124,42 @@ {/form_field} - {form_field form=$form field='parent'} - + {form_field form=$form field='title'} +
+ + +
{/form_field} - + {form_field form=$form field='area'} +
+ + +
+ {/form_field} + + {form_field form=$form field='isocode'} +
+ + +
+ {/form_field} + + {form_field form=$form field='isoalpha2'} +
+ + +
+ {/form_field} + + {form_field form=$form field='isoalpha3'} +
+ + +
+ {/form_field} {module_include location='country_create_form'} @@ -150,6 +181,27 @@ } {/form} + + {* Delete confirmation dialog *} + + {capture "delete_dialog"} + + + {module_include location='country_delete_form'} + + {/capture} + + {include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_dialog" + dialog_title = {intl l="Delete country"} + dialog_message = {intl l="Do you really want to delete this country ?"} + + form_action = {url path='/admin/configuration/countries/delete'} + form_content = {$smarty.capture.delete_dialog nofilter} + } + {/block} {block name="javascript-initialization"} diff --git a/templates/admin/default/country-edit.html b/templates/admin/default/country-edit.html index e69de29bb..cac7ec0b1 100644 --- a/templates/admin/default/country-edit.html +++ b/templates/admin/default/country-edit.html @@ -0,0 +1,140 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Edit a country'}{/block} + +{block name="check-permissions"}admin.configuration.countries.edit{/block} + +{block name="main-content"} +
+ +
+ + {loop name="country_edit" type="country" id="$country_id" backend_context="1" lang="$edit_language_id"} + + + +
+
+
+ +
+ {intl l="Edit country $TITLE"} +
+ +
+
+ + {form name="thelia.admin.country.modification"} + + +
+
+ {* Be sure to get the country ID, even if the form could not be validated *} + + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + + {/form_field} + + {if $form_error}
{$form_error_message}
{/if} + + {form_field form=$form field='area'} +
+ + +
+ {/form_field} + + {form_field form=$form field='isocode'} +
+ + +
+ {/form_field} + + {form_field form=$form field='isoalpha2'} +
+ + +
+ {/form_field} + + {form_field form=$form field='isoalpha3'} +
+ + +
+ {/form_field} +
+ +
+ {intl l="Translations"} +
+ + {loop type="lang" name="lang"} +
+
+
+

+ {intl l=$TITLE} {$TITLE} +

+
+
+ {form_field form=$form field='title'} +
+ + +
+ {/form_field} + {form_field form=$form field='short-description'} +
+ + +
+ {/form_field} + {form_field form=$form field='description'} +
+ + +
+ {/form_field} +
+
+
+ {/loop} +
+ + {/form} + +
+
+ +
+
+ +
+ + {/loop} + + {elseloop rel="country_edit"} +
+
+
+ {intl l="Sorry, country ID=$country_id was not found."} +
+
+
+ {/elseloop} + +
+
+{/block} \ No newline at end of file