Changeset 272


Ignore:
Timestamp:
07/25/09 19:50:20 (15 years ago)
Author:
nanardon
Message:
  • add ajax functionnality
Location:
LATMOS-Accounts-Web
Files:
11 added
6 edited

Legend:

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

    r229 r272  
    2121    Session::Store::FastMmap 
    2222    Authentication 
     23    Prototype 
    2324    /; 
    2425 
  • LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller.pm

    r240 r272  
    5555sub end : ActionClass('RenderView') { 
    5656    my ($self, $c) = @_; 
     57    $c->forward($c->view('TT')); 
    5758    $c->model('Accounts')->db->rollback; 
    5859} 
  • LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Users.pm

    r240 r272  
    3030 
    3131sub default : LocalPath { 
    32     my ( $self, $c, undef, $username, $subform ) = @_; 
     32    my ( $self, $c, undef, $username, $subform, $arg ) = @_; 
    3333 
    3434    my $base = $c->model('Accounts')->db; 
  • LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrForms.pm

    r237 r272  
    2424    givenName => [ 'Prénom' ], 
    2525    homeDirectory => [ 'Home' ], 
    26     loginShell => [ 'Shell' ], 
     26    loginShell => [ 'Shell', 'text-A' ], 
    2727    physicalDeliveryOfficeName => [ 'Bureau' ], 
    2828    telephoneNumber => [ 'Téléphone' ], 
    2929    otherTelephone => [ 'Téléphone (autre)' ], 
    30     company => [ 'Société' ], 
     30    company => [ 'Société', 'text-A' ], 
    3131    l => [ 'Ville' ], 
    3232    postalCode => [ 'Code postal' ], 
     
    154154sub attr_label { 
    155155    my ($self, $attr) = @_; 
    156     return $self->escape($attrs->{$attr}[0] || $attr); 
     156    my $htmlname = ($self->{object} ? $self->{object}->id . '_' : '') . $attr; 
     157    return sprintf('<label for="%s">%s</label>', 
     158        $self->escape($htmlname), 
     159        $self->escape($attrs->{$attr}[0] || $attr) 
     160    ); 
    157161} 
    158162 
     
    175179    for ($type) { 
    176180        /^textarea$/ and return sprintf( 
    177             '<textarea name="%s" cols="40">%s</textarea>', 
     181            '<textarea id="%s" name="%s" cols="40">%s</textarea>', 
     182            $self->escape($htmlname), 
    178183            $self->escape($htmlname), 
    179184            $self->escape($self->attr_raw_value($attr)), 
     
    191196            </SCRIPT>} . "\n"; 
    192197            $html .= sprintf( 
    193                 '<input type="text" name="%s" value="%s" size="12">', 
    194                 $htmlname, 
     198                '<input type="text" id="%s" name="%s" value="%s" size="12">', 
     199                $self->escape($htmlname), 
     200                $self->escape($htmlname), 
    195201                $self->escape($date) 
    196202            ); 
     
    198204            $html .= qq{ 
    199205            <A HREF="#" 
    200                 onClick="cal13.select(document.forms[0].$htmlname,'anchor13','dd/MM/yyyy');return false;" 
    201                 TITLE="cal13.select(document.forms[0].$htmlname,'anchor13','dd/MM/yyyy'); return false;" 
    202                 NAME="anchor13" ID="anchor13"> 
     206                onClick="cal13.select(document.forms[0].$htmlname,'${htmlname}_anc','dd/MM/yyyy');return false;" 
     207                TITLE="cal13.select(document.forms[0].$htmlname,'${htmlname}_anc','dd/MM/yyyy');return false;" 
     208                NAME="${htmlname}_anc" ID="${htmlname}_anc"> 
    203209                <img src="} . $self->{c}->uri_for(qw(/static icons view-calendar-day.png)) 
    204210                . qq{" style="ref"></A>} . "\n"; 
     
    215221            my $otype = $2; 
    216222            my $keyfield = $3; 
    217             my $select = sprintf('<select name="%s">', 
     223            my $select = sprintf('<select id="%s" name="%s">', 
     224                $self->escape($htmlname), 
    218225                $self->escape($htmlname)) . "\n"; 
    219226            $select .= '<option value="">--</option>' . "\n" if ($options =~ /N/); 
     
    231238            } 
    232239            $select .= "</select>\n"; 
     240            $select .= $self->{c}->prototype->observe_field( $htmlname, { 
     241                update => "${htmlname}_span", 
     242                url => $self->{c}->uri_for('/ajax', 'rawattr', $otype), 
     243                frequency => 1, 
     244                with   => "'attr=displayName&id='+value", 
     245            }) . 
     246            qq{<span id="${htmlname}_span"></span>}; 
    233247            return $select; 
    234248        }; 
    235         /^text(?::(\d+))?/ and do { 
    236             return sprintf( 
    237                 '<input type="text" name="%s" value="%s" size="%d">', 
     249        /^text(-\w+)?(?::(\d+))?/ and do { 
     250            my $flag = $1 || ''; 
     251            my $textf = sprintf( 
     252                '<input type="text" id="%s" name="%s" value="%s" size="%d">', 
     253                $self->escape($htmlname), 
    238254                $self->escape($htmlname), 
    239255                $self->escape($self->attr_raw_value($attr)), 
    240                 $1 || 30, 
     256                $2 || 30, 
    241257            ); 
     258            if ($flag =~ /A/) { 
     259            $textf .= qq{<span id="${htmlname}_auto_complete"></span>}; 
     260            $textf .= "\n"; 
     261            $textf .= $self->{c}->prototype->auto_complete_field( 
     262                $htmlname, 
     263                {  
     264                url => $self->{c}->uri_for('/ajax', 'attrvalues', $self->otype, $attr), 
     265                indicator => "${htmlname}_stat", min_chars => 1, 
     266                with => "'val='+document.getElementById('$htmlname').value", 
     267                } 
     268            ) . 
     269            qq{<span style="display:none" id="${htmlname}_stat">Searching...</span>}; 
     270            } 
     271            return $textf; 
    242272        }; 
    243273    } 
  • LATMOS-Accounts-Web/root/html/create/user.tt

    r246 r272  
    33<form action="[% c.uri_for('/create', 'user') %]" method="POST"> 
    44<table border="0"> 
     5[% IF step %] 
    56<tr><td>[% IF idexists %]<img src="[% c.uri_for('/static', 'icons', 'dialog-cancel.png') %]">[% END %] 
    6 Login:</th><td><input type="text" name="id" value="[% c.req.param('id') | html %]"></td></tr> 
     7Login:</td><td><input type="text" name="id" value="[% c.req.param('id') | html %]"></td></tr> 
     8[% END %] 
    79<tr><td>[% form.attr_label('sn') %]</td><td>[% form.attr_field('sn') %]</td></tr> 
    810<tr><td>[% form.attr_label('givenName') %]</td><td>[% form.attr_field('givenName') %]</td></tr> 
    911<tr><td>[% form.attr_label('description') %]</td><td>[% form.attr_field('description') %]</td></tr> 
    1012[% IF ! step %] 
    11  
     13<tr><td>Login (si pas de nom)</th><td><input type="text" name="id" value="[% c.req.param('id') | html %]"></td></tr> 
    1214<input type="hidden" name="step" value="1"> 
    1315 
     
    1618<input type="hidden" name="step" value="2"> 
    1719<tr><td>[% form.attr_label('gidNumber') %]</td><td>[% form.attr_field('gidNumber') %]</td></tr> 
    18 <tr><td>[% form.attr_label('uidNumber') %]</td><td>[% form.attr_field('uidNumber') %]</td></tr> 
     20<tr><td>[% form.attr_label('uidNumber') %] (attribué)</td><td>[% form.attr_field('uidNumber') %]</td></tr> 
    1921<tr><td>[% form.attr_label('exported') %]</td><td>[% form.attr_field('exported') %]</td></tr> 
    2022 
  • LATMOS-Accounts-Web/root/html/includes/header.tt

    r246 r272  
    88 
    99<script language="JavaScript" src="[% c.uri_for('/static', 'js', 'CalendarPopup.js') %]"></SCRIPT> 
     10<script language="JavaScript" src="[% c.uri_for('/static', 'js', 'prototype.js') %]"></SCRIPT> 
     11<script language="JavaScript" src="[% c.uri_for('/static', 'js', 'effects.js') %]"></SCRIPT> 
     12<script language="JavaScript" src="[% c.uri_for('/static', 'js', 'dragdrop.js') %]"></SCRIPT> 
     13<script language="JavaScript" src="[% c.uri_for('/static', 'js', 'controls.js') %]"></SCRIPT> 
     14 
    1015 
    1116</head> 
Note: See TracChangeset for help on using the changeset viewer.