Changeset 873


Ignore:
Timestamp:
12/26/11 14:57:54 (13 years ago)
Author:
nanardon
Message:
  • add filter to group list in user form
Location:
LATMOS-Accounts-Web
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Ajax.pm

    r861 r873  
    138138} 
    139139 
     140sub user_to_group_form : Local { 
     141    my ($self, $c, $user) = @_; 
     142     
     143    my $base = $c->model('Accounts')->db; 
     144 
     145    $c->stash->{user} = $base->get_object('user', $user) or do { 
     146        return; 
     147    }; 
     148 
     149    my %ingroups = 
     150        map { $_ => 1 }  
     151        @{ $c->stash->{user}->get_c_field('memberOf') || []}; 
     152 
     153   $c->stash->{othergroups} = [ grep { ! $ingroups{$_} } 
     154       $base->search_objects('group', 'cn~' . ($c->req->param('gfilter') || '*')) ];  
     155} 
     156 
    140157sub goto : Local { 
    141158    my ($self, $c) = @_; 
  • LATMOS-Accounts-Web/root/html/users/groups.tt

    r861 r873  
    4141<td valign="TOP"> 
    4242[% IF c.model('Accounts').db.check_acl(user, 'memberOf', 'r') %] 
    43 [% FOREACH g = othergroups %] 
    44 [% IF modallow %] 
    45 <form action="[% c.uri_for(username, subform) %]" method="POST"> 
    46 <input type="hidden" name="addgroup" value="[% g | html %]"> 
    47 <input type="image" src="[% c.uri_for('/static', 'icons', 'user-group-new.png') %]" width="24" height="24"> 
    48 [% END %] 
    49 <a href="[% c.uri_for('/groups', g) %]">[% g | html %]</a><br> 
    50 [% IF modallow %] 
     43<form action="#"> 
     44filter:<br> 
     45<input type="text" name="gfilter" id="gfilter" value="[% c.req.param('gfilter') | html %]"> 
     46<hr> 
    5147</form> 
    52 [% END %] 
    53 [% END %] 
     48[% c.prototype.observe_field('gfilter', { 
     49    url => c.uri_for('/ajax', 'user_to_group_form', username), 
     50    with   => "'gfilter='+value", 
     51    update => 'user_group_form', 
     52    frequency => 1, 
     53    min_chars => 1, 
     54}) %] 
     55<div id="user_group_form"> 
     56</div> 
     57<script> 
     58new Ajax.Updater( 
     59    'user_group_form', 
     60    '[% c.uri_for('/ajax', 'user_to_group_form', username) %]', 
     61    { asynchronous: 1 } ); 
     62</script> 
    5463[% END %] 
    5564</td> 
Note: See TracChangeset for help on using the changeset viewer.