Changeset 927 for LATMOS-Accounts-Web


Ignore:
Timestamp:
04/18/12 19:49:34 (12 years ago)
Author:
nanardon
Message:
  • add form on "my" page for basic management
Location:
LATMOS-Accounts-Web
Files:
1 added
3 edited

Legend:

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

    r884 r927  
    165165} 
    166166 
     167sub set_attrs : Local { 
     168    my ($self, $c, $otype, $name) = @_; 
     169 
     170    my $base = $c->model('Accounts')->db; 
     171    my $object = $base->get_object($otype, $name) or do { 
     172        return; 
     173    }; 
     174    my $form = $c->model('AttrForms', '', $object); 
     175    $form->set_attrs([ $c->req->param('attrs') ]); 
     176 
     177} 
    167178 
    168179sub end : Private { 
  • LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrForms.pm

    r926 r927  
    177177    $new->{base} = $base || ($object ? $object->base : undef) or return $self; 
    178178    $new->{otype} = ref $object ? $object->type : $object; 
    179     bless($new, '__PACKAGE__'); 
     179    bless($new, __PACKAGE__); 
    180180} 
    181181 
     
    469469 
    470470sub set_attrs { 
    471     my ($self) = @_; 
    472     $self->{c}->req->param($self->label) or return; 
     471    my ($self, $attrs) = @_; 
     472    $self->{c}->req->param($self->label) || $attrs or return; 
    473473    my $prefix = $self->{object}->id . '_'; 
    474474    my %fields; 
    475     foreach ($self->write_attributes) { 
     475    foreach ($attrs ? @{ $attrs } : $self->write_attributes) { 
    476476        my $attr = ($self->{object} 
    477477            ? $self->{object}->attribute($_) 
  • LATMOS-Accounts-Web/root/html/users/my.tt

    r861 r927  
    77[% INCLUDE 'users/menu.tt' %] 
    88 
    9 [% INCLUDE 'includes/form.tt' 
    10     form = form 
    11     form_uri = c.uri_for(username, subform) %] 
    12  
    139<div class="oform"> 
    14 <table border="1"> 
    15 <tr> 
    16  
    17 [% FOREACH h = db.search_objects('nethost', 'owner=' _ username) %] 
    18 [% IF loop.first %] 
    19 <td> 
    20 <p>Mes ordinateurs</p> 
    21 <ul> 
    22 [% END %] 
    23 <li><a href="[% c.uri_for('/nethosts', h) %]">[% h | html %]</a></li> 
    24 [% IF loop.last %] 
    25 </ul> 
    26 </td> 
    27 </div> 
    28 [% END %] 
    29 [% END %] 
    3010 
    3111[% FOREACH h = db.search_objects('group', 'managedBy=' _ username) %] 
    3212[% IF loop.first %] 
     13<p>Mes groupes</p> 
     14<table border=1> 
     15<tr> 
     16<th>Groupe:</th> 
     17<th>Desc.</th> 
     18<th>Donner à</th> 
     19</tr> 
     20[% END %] 
     21[% ogroup = db.get_object('group', h) %] 
     22<tr><td> 
     23<a href="[% c.uri_for('/groups', h) %]">[% h | html %]</a> 
     24</td> 
    3325<td> 
    34 <p>Mes groupes</p> 
    35 <ul> 
    36 [% END %] 
    37 <li><a href="[% c.uri_for('/groups', h) %]">[% h | html %]</a></li> 
     26[% ogroup.get_attributes('description') | truncate(30) | html %] 
     27</td> 
     28<td> 
     29[% c.prototype.form_remote_tag( 
     30    { 
     31        url => c.uri_for('/ajax/set_attrs/group/' _ h), 
     32        update => 'posts', 
     33    }, 
     34) %] 
     35[% form = c.model('AttrForms', '', ogroup) %] 
     36[% form.attr_field('managedBy') %] 
     37<input type=hidden name=attrs value=managedBy> 
     38<input type=submit> 
     39<input type=reset> 
     40</form> 
     41</td></tr> 
    3842[% IF loop.last %] 
    39 </ul> 
    40 </td> 
    41 </div> 
     43</table> 
    4244[% END %] 
    4345[% END %] 
     
    4547[% FOREACH h = db.search_objects('user', 'manager=' _ username) %] 
    4648[% IF loop.first %] 
    47 <td> 
    4849<p>Personnels gérés</p> 
    49 <ul> 
     50<table border=1> 
     51<tr> 
     52<th>Nom:</th> 
     53<th>Changer le responsable</th> 
     54</tr> 
    5055[% END %] 
    5156[% ouser = db.get_object('user', h) %] 
    52 <li> 
     57<tr><td> 
    5358<a href="[% c.uri_for('/users', h) %]">[% ouser.get_attributes('displayName') | html %]</a> 
    5459[% INCLUDE user_flag ouser = ouser %] 
    55 </li> 
     60</td> 
     61<td> 
     62[% c.prototype.form_remote_tag( 
     63    { 
     64        url => c.uri_for('/ajax/set_attrs/user/' _ h), 
     65        update => 'posts', 
     66    }, 
     67) %] 
     68[% form = c.model('AttrForms', '', ouser) %] 
     69[% form.attr_field('manager') %] 
     70<input type=hidden name=attrs value=manager> 
     71<input type=submit> 
     72<input type=reset> 
     73</form> 
     74</td></tr> 
    5675[% IF loop.last %] 
    57 </ul> 
    58 </td> 
    59 </div> 
     76</table> 
    6077[% END %] 
    6178[% END %] 
    6279 
     80[% FOREACH h = db.search_objects('nethost', 'owner=' _ username) %] 
     81[% IF loop.first %] 
     82<p>Mes ordinateurs</p> 
     83<table border=1> 
     84<tr> 
     85<th>Nom:</th> 
     86<th>Changer le responsable</th> 
    6387</tr> 
     88[% END %] 
     89[% ohost = db.get_object('nethost', h) %] 
     90<tr> 
     91<td> 
     92<a href="[% c.uri_for('/nethosts', h) %]">[% h | html %]</a> 
     93</td> 
     94<td> 
     95[% c.prototype.form_remote_tag( 
     96    { 
     97        url => c.uri_for('/ajax/set_attrs/nethost/' _ h), 
     98        update => 'posts', 
     99    }, 
     100) %] 
     101[% form = c.model('AttrForms', '', ohost) %] 
     102[% form.attr_label('owner') %]: [% form.attr_field('owner') %]<br> 
     103[% form.attr_label('user') %]:[% form.attr_field('user') %]<br> 
     104<input type=hidden name=attrs value=owner> 
     105<input type=hidden name=attrs value=user> 
     106<input type=submit> 
     107<input type=reset> 
     108</form> 
     109</td> 
     110</tr> 
     111[% IF loop.last %] 
    64112</table> 
     113[% END %] 
     114[% END %] 
     115 
    65116</div> 
    66117 
Note: See TracChangeset for help on using the changeset viewer.