Fix #142 : add ability to apply template from user rights view

This commit is contained in:
Romain Neutron
2012-01-03 13:49:13 +01:00
parent 9c15b5d900
commit 745d27b821
4 changed files with 57 additions and 21 deletions

View File

@@ -88,6 +88,12 @@ class Controller_Admin_Users implements ControllerProviderInterface
$request = $app['request'];
$rights = new module_admin_route_users_edit($request);
$rights->apply_rights();
if ($app['request']->get('template'))
{
$rights->apply_template();
}
$rights->apply_infos();
$datas = array('error' => false);

View File

@@ -179,13 +179,19 @@ class module_admin_route_users_edit
}
}
$query = new User_Query($appbox);
$templates = $query
->only_templates(true)
->execute()->get_results();
$this->users_datas = $rs;
$out = array(
'datas' => $this->users_datas,
'users' => $this->users,
'users_serial' => implode(';', $this->users),
'base_id' => $this->base_id,
'main_user' => null
'main_user' => null,
'templates'=>$templates
);
if (count($this->users) == 1)

View File

@@ -106,20 +106,23 @@
</script>
<div>
<div class="tabs PNB10" style="bottom:40px;">
<div class="tabs PNB" style="bottom:40px;">
<ul>
<li>
<a href="#rights_tab">Droits</a>
<a href="#rights_tab">{% trans 'Rights' %}</a>
</li>
{% if main_user is not empty and main_user.is_template is empty %}
<li>
<a href="#user_infos_tab">Fiche</a>
<a href="#user_infos_tab">{% trans 'Infos' %}</a>
</li>
{% endif %}
</ul>
<div id="rights_tab" class="PNB" style="top:40px;">
<div class="PNB10" style="height:30px;bottom:auto;">
<h1>
<form id="users_rights_form" method="post" action="/admin/users/rights/apply/">
<input type="hidden" name="users" value="{{users_serial}}"/>
<table style="width:100%;" cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
{% if main_user is not empty %}
{% set display_name = main_user.get_display_name() %}
{% trans %}
@@ -131,10 +134,18 @@
Edition des droits de {{ number }} utilisateurs
{% endtrans %}
{% endif %}
</h1>
</div>
<form id="users_rights_form" method="post" action="/admin/users/rights/apply/">
<input type="hidden" name="users" value="{{users_serial}}"/>
</td>
<td style="text-align:right;">
{% trans 'Apply a template' %}
<select name="template">
<option value="">{% trans 'boutton::choisir' %}</option>
{% for template in templates %}
<option value="{{ template.get_id() }}">{{ template.get_display_name() }}</option>
{% endfor %}
</select>
</td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" style="table-layout: auto;width:820px;height:67px;bottom:auto;top:50px;" class="PNB10">
<thead>
<tr>
@@ -522,5 +533,6 @@
</div>
<div class="PNB10" style="top:auto;height:20px;">
<button class="users_rights_valid">{% trans 'boutton::valider' %}</button>
<a href="/admin/users/search/" class="users_rights_cancel">{% trans 'boutton::retour' %}</a>
</div>
</div>

View File

@@ -78,6 +78,7 @@ function ini_edit_usrs(){
var datas = {
users:$('#users_rights_form input[name="users"]').val(),
values:$('#users_rights_form').serialize(),
template:$('#users_rights_form select[name="template"]').val(),
user_infos:$('#user_infos_form').serialize()
};
$.ajax({
@@ -95,6 +96,17 @@ function ini_edit_usrs(){
return false;
});
$('#right-ajax .users_rights_cancel').bind('click', function(){
var $this = $(this);
$('#right-ajax').empty().addClass('loading').parent().show();
$('#right').hide();
$.get($this.attr('href'), function(data) {
$('#right-ajax').removeClass('loading').html(data);
});
return false;
});
var time_buttons = {
'Ok':function(){
save_time();