- Edit country view creation

- Delete and edit modalbox creation
- Countries routes management
This commit is contained in:
mespeche
2013-09-16 12:55:34 +02:00
parent 76dc9609b6
commit 5e8749e054
8 changed files with 355 additions and 10 deletions

View File

@@ -82,6 +82,9 @@
<form name="thelia.admin.template.creation" class="Thelia\Form\TemplateCreationForm"/>
<form name="thelia.admin.template.modification" class="Thelia\Form\TemplateModificationForm"/>
<form name="thelia.admin.country.creation" class="Thelia\Form\CountryCreationForm"/>
<form name="thelia.admin.country.modification" class="Thelia\Form\CountryModificationForm"/>
</forms>

View File

@@ -302,6 +302,11 @@
<default key="_controller">Thelia\Controller\Admin\CountryController::createAction</default>
</route>
<route id="admin.configuration.countries.update.view" path="/admin/configuration/countries/update/{country_id}" methods="get">
<default key="_controller">Thelia\Controller\Admin\CountryController::updateAction</default>
<requirement key="country_id">\d+</requirement>
</route>
<!-- end countries routes management -->
<!-- feature and features value management -->

View File

@@ -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
));
}
}

View File

@@ -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"
)
))
;
}

View File

@@ -0,0 +1,107 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
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";
}
}

View File

@@ -206,7 +206,6 @@
- <a href="http://www.openstudio.fr/" target="_blank">{intl l='Édité par OpenStudio'}</a>
- <a href="http://forum.thelia.net/" target="_blank">{intl l='Forum Thelia'}</a>
- <a href="http://contrib.thelia.net/" target="_blank">{intl l='Contributions Thelia'}</a>
<span class="pull-right">{intl l='interface par <a target="_blank" href="http://www.steaw-webdesign.com/">Steaw-Webdesign</a>'}</span>
</p>
{module_include location='in_footer'}

View File

@@ -124,11 +124,42 @@
<input type="hidden" name="{$name}" value="{url path='/admin/country/update' country_id='_ID_'}" />
{/form_field}
{form_field form=$form field='parent'}
<input type="hidden" name="{$name}" value="{$current_country_id}" />
{form_field form=$form field='title'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Country title'}">
</div>
{/form_field}
{form_field form=$form field='area'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<select name="{$name}" id="{$label_attr.for}" class="form-control">
<option value="{$ID}">{$TITLE}</option>
</select>
</div>
{/form_field}
{form_field form=$form field='isocode'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='ISO Code'}">
</div>
{/form_field}
{form_field form=$form field='isoalpha2'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Alpha code 2'}">
</div>
{/form_field}
{form_field form=$form field='isoalpha3'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Alpha code 3'}">
</div>
{/form_field}
{module_include location='country_create_form'}
@@ -150,6 +181,27 @@
}
{/form}
{* Delete confirmation dialog *}
{capture "delete_dialog"}
<input type="hidden" name="country_id" id="country_delete_id" value="" />
{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"}

View File

@@ -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"}
<div class="countries edit-country">
<div id="wrapper" class="container">
{loop name="country_edit" type="country" id="$country_id" backend_context="1" lang="$edit_language_id"}
<ul class="breadcrumb">
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a></li>
<li><a href="{url path='/admin/configuration'}">{intl l="Configuration"}</a></li>
<li><a href="{url path='/admin/configuration/countries'}">{intl l="Countries"}</a></li>
<li>{intl l='Editing country "%name"' name="{$TITLE}"}</li>
</ul>
<div class="row">
<div class="col-md-12 general-block-decorator">
<div class="row">
<div class="col-md-12 title title-without-tabs">
{intl l="Edit country $TITLE"}
</div>
<div class="form-container">
<div class="col-md-12">
{form name="thelia.admin.country.modification"}
<form method="POST" action="{url path='/admin/configuration/countries/save'}" {form_enctype form=$form} class="clearfix">
<div class="row">
<div class="col-md-12">
{* Be sure to get the country ID, even if the form could not be validated *}
<input type="hidden" name="country_id" value="{$country_id}" />
{form_hidden_fields form=$form}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/countries'}" />
{/form_field}
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
{form_field form=$form field='area'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<select name="{$name}" id="{$label_attr.for}" class="form-control">
<option value="{$ID}">{$TITLE}</option>
</select>
</div>
{/form_field}
{form_field form=$form field='isocode'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='ISO Code'}">
</div>
{/form_field}
{form_field form=$form field='isoalpha2'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Alpha code 2'}">
</div>
{/form_field}
{form_field form=$form field='isoalpha3'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Alpha code 3'}">
</div>
{/form_field}
</div>
<div class="col-md-12 title title-without-tabs">
{intl l="Translations"}
</div>
{loop type="lang" name="lang"}
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}"> {$TITLE}
</h3>
</div>
<div class="panel-body">
{form_field form=$form field='title'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Country title'}">
</div>
{/form_field}
{form_field form=$form field='short-description'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{intl l="{$label}"}" placeholder="{intl l='Country short description'}"></textarea>
</div>
{/form_field}
{form_field form=$form field='description'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{intl l="{$label}"}" placeholder="{intl l='Country description'}"></textarea>
</div>
{/form_field}
</div>
</div>
</div>
{/loop}
</div>
</form>
{/form}
</div>
</div>
</div>
</div>
</div>
{/loop}
{elseloop rel="country_edit"}
<div class="row">
<div class="col-md-12">
<div class="alert alert-error">
{intl l="Sorry, country ID=$country_id was not found."}
</div>
</div>
</div>
{/elseloop}
</div>
</div>
{/block}