Changeset 1329 for trunk


Ignore:
Timestamp:
04/29/15 20:24:15 (9 years ago)
Author:
nanardon
Message:

Merge branch 'jquery'

Location:
trunk
Files:
38 added
7 deleted
16 edited
1 copied

Legend:

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

    r1302 r1329  
    5151    objects => { 
    5252        user => { 
    53             quick_search => [ qw(cn sn givenName) ], 
     53            quick_search => [ qw(cn sn givenName description) ], 
    5454            list => [ qw(sn givenName mail) ], 
    5555        }, 
     
    5959        }, 
    6060        nethost => { 
    61             quick_search => [ qw(cn description ip cname otherName) ], 
     61            quick_search => [ qw(cn description ip cname otherName macaddr serialNumber) ], 
    6262            list => [ qw(description owner) ], 
    6363        }, 
     
    301301        related => { 
    302302            label => 'Voir aussi:', 
     303        }, 
     304        SerialNumber => { 
     305            label => 'Numéro de série', 
    303306        }, 
    304307    }, 
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Ajax.pm

    r1193 r1329  
    5151    my $attribute = $c->model('Accounts')->db->attribute($otype, $attr) or return; 
    5252    $c->stash->{value} = $attribute->display($c->req->param('id')); 
    53 } 
    54  
    55 sub attrvalues : Local { 
    56     my ($self, $c, $otype, $attr) = @_; 
    57  
    58     my $base = $c->model('Accounts')->db; 
    59     my $val = $c->req->param('val') || ''; 
    60     $c->stash->{values} = [ 
    61         sort 
    62         grep { /^\Q$val\E/ } $base->attributes_summary($otype, $attr) 
    63     ]; 
    64  
    6553} 
    6654 
     
    207195} 
    208196 
    209 sub search_adv : Local { 
    210     my ($self, $c) = @_; 
    211     $c->stash->{db} = $c->model('Accounts')->db; 
    212     $c->stash->{otype} = $c->req->param('otype'); 
    213 } 
    214  
    215197sub end : Private { 
    216198    my ( $self, $c ) = @_; 
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Json.pm

    r1328 r1329  
    1 package LATMOS::Accounts::Web::Controller::Search::Adv; 
     1package LATMOS::Accounts::Web::Controller::Json; 
    22use Moose; 
    33use namespace::autoclean; 
     
    77=head1 NAME 
    88 
    9 LATMOS::Accounts::Web::Controller::Search::Adv - Catalyst Controller 
     9LATMOS::Accounts::Web::Controller::Json - Catalyst Controller 
    1010 
    1111=head1 DESCRIPTION 
     
    2525    my ( $self, $c ) = @_; 
    2626 
    27     $c->stash->{db} = $c->model('Accounts')->db; 
     27    $c->response->body('Matched LATMOS::Accounts::Web::Controller::Json in Json.'); 
    2828} 
    2929 
     30sub end : Private { 
     31    my ( $self, $c ) = @_; 
     32    $c->forward($c->view('Json')); 
     33} 
     34 
     35=encoding utf8 
    3036 
    3137=head1 AUTHOR 
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Search/Adv.pm

    r1191 r1329  
    2626 
    2727    $c->stash->{db} = $c->model('Accounts')->db; 
     28 
     29    if ($c->req->param('otype')) { 
     30        $c->session->{searchOtype} = $c->req->param('otype'); 
     31    } elsif ($c->req->param('attr')) { 
     32        push(@{$c->session->{searchValues}}, sprintf('%s~%s', $c->req->param('attr'), $c->req->param('attrval'))); 
     33    } elsif ($c->req->param('delval')) { 
     34        my @delvals = $c->req->param('delval'); 
     35        my @newvals = (); 
     36        foreach my $v (@{$c->session->{searchValues} || []}) { 
     37            grep { $_ eq $v } @delvals and next; 
     38            push(@newvals, $v); 
     39        } 
     40        $c->session->{searchValues} = \@newvals; 
     41    } elsif(grep { $_ && $_ eq 'new' } $c->req->query_keywords) { 
     42        $c->session->{searchOtype} = undef; 
     43        $c->session->{searchValues} = []; 
     44    } 
     45     
     46    if ($c->session->{searchOtype}) { 
     47        $c->stash->{objs} = [ $c->stash->{db}->search_objects( 
     48            $c->session->{searchOtype}, 
     49            @{ $c->session->{searchValues} || []}, 
     50        ) ]; 
     51    } 
     52 
    2853} 
    2954 
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrForms.pm

    r1305 r1329  
    9797            unexported 
    9898            description 
     99            facsimileTelephoneNumber 
    99100        ) ], 
    100101    }, 
     
    217218    $new->{base} = $base || (ref $object ? $object->base : undef) or return $self; 
    218219    $new->{otype} = ref $object ? $object->type : $object; 
     220 
     221 
     222    foreach (@{ $forms->{$form}->{attrs} }) { 
     223        $new->{_attr}{$_} = $c->model('AttrFormsA', $_, ($object 
     224                ? ($object) 
     225                : ($base, $new->{otype}))) 
     226            or die "Cannot get attribute $_"; 
     227    } 
     228 
    219229    bless($new, __PACKAGE__); 
    220230} 
     
    240250    grep { $self->base->attribute($self->otype, $_) } 
    241251    @{ $forms->{$self->{form}}->{attrs} }; 
    242 } 
    243  
    244 sub attr_label { 
    245     my ($self, $attr, $label, $hint) = @_; 
    246     $label ||= ''; 
    247     $hint ||= ''; 
    248     LATMOS::Accounts::Web->config->{attrs} ||= {}; 
    249     my $attribute = $self->base->attribute($self->otype, $attr); 
    250     my $htmlname = $self->escape($self->attr_field_name($attr)); 
    251     if (my $attr_config = LATMOS::Accounts::Web->config->{attrs}{$attr}) { 
    252         $label ||= $attr_config->{label} || ''; 
    253         #utf8::is_utf8($label) && utf8::encode($label); 
    254         $hint ||= $attr_config->{hint} || ''; 
    255         #utf8::is_utf8($hint) && utf8::encode($hint); 
    256     } 
    257     return sprintf('<label %sfor="%s">%s</label>', 
    258         ($hint ? sprintf('title="%s"', $self->escape($hint)) : ''), 
    259         $self->escape($htmlname), 
    260         $self->escape($label || $attr), 
    261     ); 
    262 } 
    263  
    264 sub attr_hint { 
    265     my ($self, $attr) = @_; 
    266     LATMOS::Accounts::Web->config->{attrs} ||= {}; 
    267     if (my $attr_config = LATMOS::Accounts::Web->config->{attrs}{$attr}) { 
    268         return $attr_config->{hint} || ''; 
    269     } 
    270     return; 
    271 } 
    272  
    273 sub attr_raw_value { 
    274     my ($self, $attribute) = @_; 
    275     my @val = grep { $_ }   
    276         ($self->{c}->req->param($attribute->name)) 
    277         || ($self->{object} 
    278             ? ($self->{object}->get_attributes($attribute->name)) 
    279             : ()); 
    280  
    281     if (@val) { 
    282         return @val; 
    283     } else { 
    284         return (grep { $_ } ($attribute->default_value)) 
    285     } 
    286 } 
    287  
    288 sub attr_field_name { 
    289     my ($self, $attr) = @_; 
    290     my $id = $self->{object} 
    291         ? ($self->{object}->id || '') 
    292         : ''; 
    293     $id .= '_' if ($id); 
    294     $id =~ s/\./_/g; 
    295     $id =~ s/-/_/g; 
    296     $id . $attr; 
    297 } 
    298  
    299 sub attr_item { 
    300     my ($self, $attribute, $value, $htmlid) = @_; 
    301  
    302     my $html = $self->_attr_item($attribute, $value, $htmlid); 
    303      
    304     if ($attribute->uniq) { 
    305         $html .= qq|<span class="inputvalidate" id="${htmlid}_uniq"></span>|; 
    306     } 
    307     if (my $ref = $attribute->reference) { 
    308         my $uri_part = $self->_uri_part($ref); 
    309         if ($self->base->attribute($ref, 'displayName')) { 
    310             my $text = ''; 
    311             if ($value && 
    312                 (my $obj = $self->base->get_object($ref, $value))) { 
    313                 $text = $obj->get_attributes('displayName'); 
    314             } 
    315             $html .= sprintf( 
    316                 qq|<span id="${htmlid}_ref" style="margin-left: 1em">$text</span>|, 
    317                 $self->escape($text), 
    318             ); 
    319         } elsif($value && $uri_part) { 
    320             $html .= sprintf( 
    321                 '<a href="%s"><img class="attr" src="%s" title="%s"></a>', 
    322                 $self->{c}->uri_for('/', $uri_part, $value), 
    323                 $self->{c}->uri_for('/static', 'images', 'arrow-right.png'), 
    324                 $value, 
    325             ); 
    326         } 
    327     } 
    328  
    329     $html 
    330 } 
    331  
    332 sub _attr_item { 
    333     my ($self, $attribute, $value, $htmlid) = @_; 
    334  
    335     my $htmlname = $self->escape($self->attr_field_name($attribute->name)); 
    336     $htmlid ||= $htmlname; 
    337  
    338     for ($attribute->form_type) { 
    339             /^textarea$/i and do { 
    340                 return sprintf( 
    341                     '<textarea id="%s" name="%s" cols="40">%s</textarea>', 
    342                     $self->escape($htmlid), 
    343                     $self->escape($htmlname), 
    344                     $self->escape($value || ''), 
    345                 ); 
    346                 last; 
    347             }; 
    348  
    349             /^label$/i and do { 
    350                 $value or last; 
    351                 my $html_field = $self->escape($value); 
    352                 $html_field =~ s/\n/<br>/g; 
    353                 $html_field .= sprintf('<input type="hidden" name="%s" value="%s">', 
    354                     $self->escape($htmlname), ($value || '')); 
    355                 return $html_field; 
    356                 last; 
    357             }; 
    358  
    359             /^date$/i and do { 
    360                 my ($date, $time) = split(/ /, $value || ''); 
    361                 if ($date && $date =~ /^(\d+)-(\d+)-(\d+)$/) { 
    362                     $date = "$3/$2/$1"; 
    363                 } 
    364                 my $html = "\n" . q{<SCRIPT LANGUAGE="JavaScript" ID="js13"> 
    365                 var cal13 = new CalendarPopup(); 
    366                 </SCRIPT>} . "\n"; 
    367                 $html .= sprintf( 
    368                     '<input type="text" id="%s" name="%s" value="%s" size="12">', 
    369                     $self->escape($htmlid), 
    370                     $self->escape($htmlname), 
    371                     $self->escape($date) 
    372                 ); 
    373                 $html .= q{<DIV ID="testdiv1" STYLE="position:absolute;visibility:hidden;background-color:white;layer-background-color:white;"></DIV>}; 
    374                 $html .= qq| 
    375                 <A HREF="#" 
    376                     onClick="cal13.select(document.getElementById('$htmlid'),'${htmlid}_anc','dd/MM/yyyy');return false;" 
    377                     TITLE="Date" 
    378                     NAME="${htmlid}_anc" ID="${htmlid}_anc"> 
    379                     <img class="attr" src="| . $self->{c}->uri_for(qw(/static images view-calendar-day.png)) 
    380                     . qq{" style="ref"></A> 
    381                     } . "\n"; 
    382                 return $html; 
    383                 last; 
    384             }; 
    385  
    386             /^checkbox/i and do { 
    387                 my $options = $1 || ''; 
    388                 my $html = sprintf('<input type="checkbox" id="%s" name="%s"%s>', 
    389                     $htmlid, 
    390                     $self->escape($htmlname), 
    391                     $value ? '  checked="yes"' : '' 
    392                 );  
    393                 $html .= sprintf('<input type="hidden" name="%s">', 
    394                     $self->escape($htmlname)); 
    395                 if ($attribute->form_option('rawvalue')) { 
    396                     $html .= $value 
    397                         ? ' ' . $value 
    398                         : '';  
    399                 } 
    400                 return $html; 
    401                 last; 
    402             }; 
    403  
    404             /^LIST/i and do { 
    405                 my $select = sprintf('<select id="%s" name="%s">', 
    406                     $self->escape($htmlid), 
    407                     $self->escape($htmlname)) . "\n"; 
    408                 $select .= '<option value="">--</option>' . "\n" 
    409                     unless($attribute->mandatory); 
    410                 $value ||= ''; 
    411                 my $initial_observed = ''; 
    412                 my @valslist; 
    413                 foreach my $val (sort $attribute->can_values) { 
    414                     push(@valslist, { 
    415                         val => $val, 
    416                         disp => $attribute->display($val || ''), 
    417                     }); 
    418                 } 
    419                 foreach (sort { $a->{disp} cmp $b->{disp} } @valslist) { 
    420                     $select .= sprintf( 
    421                         '    <option value="%s"%s>%s</option>', 
    422                         $self->escape($_->{val} || ''), 
    423                         $value eq $_->{val} ? ' selected="selected"' : '', 
    424                         $self->escape($_->{disp} || ''), 
    425                     ); 
    426                     $select .= "\n"; 
    427                 } 
    428                 $select .= "</select>\n"; 
    429  
    430                 return $select; 
    431                 last; 
    432             }; 
    433  
    434             /^text/i and do { 
    435                 return sprintf( 
    436                     '<input type="text" id="%s" name="%s" value="%s" size="%d">', 
    437                     $self->escape($htmlid), 
    438                     $self->escape($htmlname), 
    439                     $self->escape($value), 
    440                     $attribute->form_option('length') || 30, 
    441                 ); 
    442                 last; 
    443             }; 
    444         } 
    445     return ''; 
    446252} 
    447253 
     
    458264} 
    459265 
    460 sub attr_js { 
    461     my ($self, $attribute, $value, $htmlid) = @_; 
    462  
    463     my (@js); 
    464  
    465     if (my $ref = $attribute->reference) { 
    466         my $uri_part = $self->_uri_part($ref); 
    467         if ($self->base->attribute($ref, 'displayName')) { 
    468             push(@js,  
    469                 $self->{c}->prototype->observe_field( $htmlid, 
    470                     { 
    471                         update => "${htmlid}_ref", 
    472                         url => $self->{c}->uri_for('/ajax', 'rawattr', $ref), 
    473                         frequency => 1, 
    474                         with   => "'attr=displayName&id=' + element.options[element.selectedIndex].text", 
    475                     } 
    476                 ) 
    477             ) if ($attribute->form_type =~ /list/i); 
    478         } 
    479     } 
    480  
    481     if ($attribute->uniq) { 
    482         push(@js, 
    483             $self->{c}->prototype->observe_field( $htmlid, 
    484                 { 
    485                     update => "${htmlid}_uniq", 
    486                     url => $self->{c}->uri_for('/ajax', 'objattrexist', 
    487                         $self->otype, $attribute->name), 
    488                     frequency => 1, 
    489                     with => "'val='+element.value" . 
    490                     ($self->{object} ? 
    491                         "+'&exclude=" . ($self->{object}->id || '') . "'"  
    492                         : ''), 
    493                 } 
    494             ) 
    495         ); 
    496     } 
    497  
    498     return(join("\n", @js)); 
     266sub attr_label { 
     267    my ($self, $attr, $label, $hint) = @_; 
     268 
     269    if ($label) { 
     270        return $label; 
     271    } elsif (my $hash = LATMOS::Accounts::Web->config->{attrs}{$attr}) { 
     272        return $hash->{label}; 
     273    } else { 
     274       retrun $attr; 
     275    }  
     276} 
     277 
     278sub attr_hint { 
     279    my ($self, $attr) = @_; 
     280 
     281    $self->{_attr}{$attr}->attr_hint; 
    499282} 
    500283 
     
    502285    my ($self, $attr, $type) = @_; 
    503286 
    504     my $attribute; 
    505     if ($type) { 
    506         if (ref $type) { 
    507             $attribute = $self->base->attribute( 
    508                 $self->otype, 
    509                 { %$type, name => $attr }, 
    510             ); 
    511         } else { 
    512             $attribute =  $self->base->attribute( 
    513                 $self->otype, 
    514                 { formtype => $type , name => $attr }, 
    515             ); 
    516         } 
    517     } else { 
    518         if ($self->{object}) { 
    519             $attribute = $self->{object}->attribute($attr); 
    520         } else { 
    521             $attribute = $self->base->attribute( 
    522                 $self->otype, $attr, 
    523                 { formtype => $type } 
    524             ); 
    525         } 
    526     } 
    527     $attribute ||= $self->base->attribute($self->otype, { name => $attr }); 
    528  
    529  
    530     my $htmlname = $self->escape($self->attr_field_name($attr)); 
    531  
    532     my @html_fields; 
    533  
    534     # Force Array context: 
    535     my @attr_raw_value = (); 
    536  
    537     if ($attribute->multiple) { 
    538         @attr_raw_value = grep { $_ } $self->attr_raw_value($attribute); 
    539     } else { 
    540         my ($val) = $self->attr_raw_value($attribute); 
    541         @attr_raw_value = ($val || ''); 
    542     } 
    543  
    544     foreach my $attr_raw_value (@attr_raw_value) { 
    545  
    546         my $html_id = $htmlname . 
    547             (scalar(@html_fields) ? scalar(@html_fields) : ''); 
    548         push(@html_fields, 
    549             join("\n", 
    550                 $self->attr_item( 
    551                     $attribute, $attr_raw_value, $html_id 
    552                 ), 
    553                 $self->attr_js( 
    554                     $attribute, $attr_raw_value, $html_id 
    555                 ) 
    556             ) 
    557         ); 
    558     } 
    559  
    560     if ($attribute->{multiple} && !$attribute->readonly) { 
    561         my $html_id = $htmlname . '_m_SUBID'; 
    562  
    563         my $attr = $self->attr_item($attribute, '', $html_id); 
    564         # JS: string are on the line only 
    565         $attr =~ s/\n//mg; 
    566         $attr =~ s/'/\'/g; 
    567  
    568         my $js = $self->attr_js($attribute, '', 'NANAR'); 
    569         $js =~ s!'NANAR([_\w]*)'!('$html_id$1'.replace(/SUBID/g, cn))!gm; 
    570         $js =~ s!<script[^>]+>!!gm; 
    571         $js =~ s!</script>!!gm; 
    572         $js =~ s!-->!!gm; 
    573         $js =~ s/<!--//gm; 
    574  
    575         my $addempty = sprintf('<div id="%s"></div>', "${htmlname}_div_0"); 
    576         $addempty .= "\n"; 
    577         $addempty .= sprintf(qq# 
    578             <script type="text/javascript"> 
    579             var cn_${htmlname} = 0; 
    580             function add_${htmlname} () { 
    581             cn_${htmlname}++; 
    582             // It work only using temporary variable 
    583             var cn = cn_${htmlname}; 
    584             document.getElementById('${htmlname}_div_' + (cn - 1)).innerHTML += 
    585                 '$attr'.replace(/SUBID/g, cn ); 
    586             document.getElementById('${htmlname}_div_' + (cn - 1)).innerHTML += 
    587                 '<div id="${htmlname}_div_'+ cn +'" style="display:block"></div>'; 
    588             %s 
    589             } 
    590             </script> 
    591             #, $js 
    592         ); 
    593  
    594         $addempty .= "\n"; 
    595         $addempty .= 
    596             qq|<button type="button" style="display:block" onclick="add_${htmlname}()">+</button>|, 
    597  
    598         push(@html_fields, $addempty); 
    599     } 
    600  
    601     return join("<br>\n", @html_fields); 
    602 } 
    603  
    604 sub submit { 
    605     my ($self) = @_; 
    606     return sprintf( 
    607         '<input type="submit" name="%s" value="Enregistrer">', 
    608         $self->escape($self->label), 
    609     ); 
    610 } 
     287    $self->{_attr}{$attr}->attr_field($type); 
     288} 
     289 
    611290 
    612291sub write_attributes { 
    613292    my ($self) = @_; 
    614293    my @attrs; 
    615     foreach ($self->attributes) { 
    616         my $attr = ($self->{object} 
    617             ? $self->{object}->attribute($_) 
    618             : $self->base->attribute($self->otype, $_)) or next; 
    619         $attr->readonly and next; 
     294    foreach (values %{ $self->{_attr} }) { 
     295        $_->readonly and next; 
    620296        push(@attrs, $_); 
    621297    } 
     
    626302    my ($self, $attrs) = @_; 
    627303    $self->{c}->req->param($self->label) || $attrs or return; 
    628     my $prefix = $self->attr_field_name(''); 
    629304    my %fields; 
    630305    foreach ($attrs ? @{ $attrs } : $self->write_attributes) { 
    631         my $attr = ($self->{object} 
    632             ? $self->{object}->attribute($_) 
    633             : $self->base->attribute($self->otype, $_)) or next; 
     306        my $attr = ref $_ ? $_ : $self->{_attr}{$_}; 
    634307        if ($attr->{multiple}) { 
    635             $fields{$_} = [ grep { $_ } $self->{c}->req->param("$prefix$_") ]; 
     308            $fields{$attr->name} = [ grep { $_ } $self->{c}->req->param($attr->htmlname) ]; 
    636309        } else { 
    637             $fields{$_} = $self->{c}->req->param("$prefix$_"); 
     310            $fields{$attr->name} = $self->{c}->req->param($attr->htmlname); 
    638311        } 
    639312    } 
     
    647320} 
    648321 
     322sub submit { 
     323    my ($self) = @_; 
     324    return sprintf( 
     325        '<input type="submit" name="%s" value="Enregistrer">', 
     326        $self->escape($self->label), 
     327    ); 
     328} 
     329 
     330 
    649331=head1 AUTHOR 
    650332 
  • trunk/LATMOS-Accounts-Web/root/html/includes/wrapper.tt

    r1326 r1329  
    88<link rel="icon" href="[%- c.uri_for('/static', 'images', 'favicon.ico') -%]" type="image/x-icon"> 
    99 
    10 <script type="text/javascript" language="JavaScript" src="[% c.uri_for('/static', 'js', 'CalendarPopup.js') %]"></script> 
    11 <script type="text/javascript" language="JavaScript" src="[% c.uri_for('/static', 'js', 'prototype.js') %]"></script> 
    12 <script type="text/javascript" language="JavaScript" src="[% c.uri_for('/static', 'js', 'effects.js') %]"></script> 
    13 <script type="text/javascript" language="JavaScript" src="[% c.uri_for('/static', 'js', 'dragdrop.js') %]"></script> 
    14 <script type="text/javascript" language="JavaScript" src="[% c.uri_for('/static', 'js', 'controls.js') %]"></script> 
     10<script src="[% c.uri_for('/static', 'js', 'jquery', 'external/jquery/jquery.js') %]"></script> 
     11<script src="[% c.uri_for('/static', 'js', 'jquery', 'jquery-ui.js') %]"></script> 
     12<link rel="stylesheet" href="[% c.uri_for('/static/js/jquery/jquery-ui.css') %]" type="text/css"> 
     13 
    1514<script type="text/javascript" language="JavaScript"> 
     15 
    1616function resetmenu() { 
    1717    document.getElementById('menui').innerHTML = '[% page.title | html %]'; 
  • trunk/LATMOS-Accounts-Web/root/html/nethosts/default.tt

    r1304 r1329  
    3838</select><br> 
    3939 
    40 [% c.prototype.observe_field('zone', { 
    41     update => 'zone_span', 
    42     url => c.uri_for('/ajax', 'select_freeip_select'), 
    43     frequency => 1, 
    44     with => "'zone='+element.options[element.selectedIndex].value", 
    45 } ) %] 
    46 <span id="zone_span"></span><br> 
     40<input id=ipselect type=text name=newip><br> 
    4741<input type="submit" name="addip"> 
    4842</form> 
    4943</fieldset> 
     44 
     45<script> 
     46$(function() { 
     47    $( '#zone' ).on( "change", function() { 
     48        $( '#ipselect' ).autocomplete({ 
     49            minLength: 0, 
     50            delay: 0, 
     51            source: '[% c.uri_for('/json', 'freeip') %]?zone=' + $( '#zone' ).val(), 
     52        }); 
     53    $( "#ipselect" ).focus(function() { $( "#ipselect" ).autocomplete("search", "" ); }); 
     54    $( "#ipselect" ).click(function() { $( "#ipselect" ).autocomplete("search", "" ); }); 
     55        return false; 
     56    }); 
     57}); 
     58</script> 
    5059[% END %] 
    5160 
  • trunk/LATMOS-Accounts-Web/root/html/search/adv/index.tt

    r1192 r1329  
    1 [% otype = c.req.param('otype') || 'user' %] [% # Default value %] 
     1[% IF NOT c.session.searchOtype %] 
    22 
     3[% otype = 'user' %] [% # Default value %] 
    34<form action="[% c.uri_for('/search', 'adv') %]"> 
    4 <select name=otype id=otype onChange=" 
    5     new Ajax.Updater( 'search_form', '[% c.uri_for('/ajax/search_adv') %]', 
    6     { 
    7         parameters: 'otype='+value,asynchronous: 1 
    8     } )"> 
     5<select name=otype id=otype> 
    96[% FOREACH totype = ['user', 'group', 'nethost', 'aliases' ] %] 
    10 <option value="[% totype %]"[% " selected" IF totype == otype %]>[% totype %]</option> 
     7<option value="[% totype %]">[% totype %]</option> 
    118[% END %] 
    129</select> 
    13  
    14 [% ofilter = c.model('AttrFilter', otype) %] 
    15  
    16 <div id="search_form"> 
    17 [% INCLUDE 'ajax/search_adv.tt' %] 
    18 </div> 
    19  
    2010<input type=submit> 
    2111</form> 
    2212 
    23 [% INCLUDE 'includes/list_objects.tt' %] 
     13[% ELSE %] 
     14 
     15 
     16<div id="search-form"> 
     17<p>Rechercher des object de type: [% c.forward('/obj_to_label', [ 
     18c.session.searchOtype ]) |html %]</p> 
     19<div class="bloc-box"> 
     20<p>Ajouter un filtre:</p> 
     21<form action="[% c.uri_for('/search', 'adv') %]"> 
     22<select name=attr> 
     23[% FOREACH attr = c.stash.db.list_canonical_fields(c.session.searchOtype) %] 
     24<option name="[% attr |html %]">[% attr | html %]</option> 
     25[% END %] 
     26</select> 
     27contient: <input type="text" name="attrval"> 
     28<br> 
     29<input type=submit value="Ajouter"> 
     30</form> 
     31</div> 
     32 
     33<div class="bloc-box"> 
     34<p>Filtre actuels:</p> 
     35<form action="[% c.uri_for('/search', 'adv') %]"> 
     36<select multiple id="search-adv-filter" name=delval> 
     37[% FOREACH v = c.session.searchValues %] 
     38<option value="[% v | html %]">[% v | html %]</option> 
     39[% END %] 
     40</select> 
     41<input type=submit value="Supprimer la selection..."> 
     42</form> 
     43</div> 
     44</div> 
     45 
     46[% END %] 
     47 
     48<div> 
     49[% FOREACH res = c.stash.objs %] 
     50[% "<ul>\n" IF loop.first %] 
     51[% obj = c.stash.db.get_object(c.session.searchOtype, res ) %] 
     52<li><a href="[% c.uri_for('/', c.forward('/obj_to_uri', [ c.session.searchOtype ]), res) %]">[% obj %]</a></li> 
     53[% "</ul>\n" IF loop.last %] 
     54[% END %] 
     55</div> 
     56 
  • trunk/LATMOS-Accounts-Web/root/html/users/groups.tt

    r1211 r1329  
    4444<form action="#"> 
    4545filter:<br> 
    46 <input type="text" name="gfilter" id="gfilter" value="[% c.req.param('gfilter') | html %]"> 
    47 <hr> 
     46<input type="text" name="addgroup" id="gfilter" value="[% c.req.param('gfilter') | html %]"> 
     47<input type=submit> 
     48<script> 
     49$(function() { 
     50    $('#gfilter').autocomplete({ 
     51        delay: 200, 
     52        minLength: 0, 
     53        source: '[% c.uri_for('/json/refval', 'user', 'memberOf') %]', 
     54    }) 
     55    .autocomplete( "instance" )._renderItem = function( ul, item ) { 
     56        return $( "<li>" ) 
     57            .append( "<a>" + item.label + " (" + item.value +  ")</a>" ) 
     58            .appendTo( ul ); 
     59    }; 
     60    $( "#gfilter" ).focus(function() { $( "#gfilter" ).autocomplete("search", "" ); }); 
     61    $( "#gfilter" ).click(function() { $( "#gfilter" ).autocomplete("search", "" ); }); 
     62}); 
     63</script> 
    4864</form> 
    4965<br> 
    50 [% c.prototype.observe_field('gfilter', { 
    51     url => c.uri_for('/ajax', 'user_to_group_form', username), 
    52     with   => "'gfilter='+value", 
    53     update => 'user_group_form', 
    54     frequency => 1, 
    55     min_chars => 1, 
    56 }) %] 
    57 <div id="user_group_form"> 
    58 </div> 
    59 <script> 
    60 new Ajax.Updater( 
    61     'user_group_form', 
    62     '[% c.uri_for('/ajax', 'user_to_group_form', username) %]', 
    63     { asynchronous: 1 } ); 
    64 </script> 
    6566[% END %] 
    6667</td> 
  • trunk/LATMOS-Accounts-Web/root/html/users/passwd.tt

    r1211 r1329  
    44<script type="text/javascript"> 
    55function check_passwd() { 
    6     new Ajax.Updater( 
    7         'perror', 
    8         '[% c.uri_for('/ajax', 'cracklib', username) %]', 
    9         { parameters: 'passwd=' + document.getElementById("passwd").value + 
    10             '&cpasswd=' + document.getElementById("cpasswd").value } 
    11     ) 
     6    $.ajax({ 
     7        url: '[% c.uri_for('/ajax', 'cracklib', username) %]', 
     8        data: { passwd: $("#passwd").val(), cpasswd: $("#cpasswd").val() }, 
     9    }).done(function(msg) { 
     10        $('#perror').html(msg); 
     11    }); 
    1212} 
    1313</script> 
     
    4040copier/coller. Pensez à le noter.</p> 
    4141 
    42 [% c.prototype.form_remote_tag({ 
    43     update => 'randpasswd', 
    44     url    => c.uri_for('/ajax', 'random_password') 
    45 } ) %] 
     42<form id="fgenpasswd"> 
    4643<input type=submit value="Générer !"> 
    4744<span id="randpasswd">----</span> 
     
    5350</ul> 
    5451</form> 
     52<script> 
     53$(function() { 
     54    $('#fgenpasswd').submit(function() { 
     55        $.ajax({ 
     56            url: '[% c.uri_for('/ajax', 'random_password') %]', 
     57            data: $('#fgenpasswd').serialize(), 
     58    }).done(function(msg) { 
     59        $('#randpasswd').html(msg); 
     60    }); 
     61    return false; 
     62    }); 
     63}); 
     64</script> 
    5565 
    5666[% ELSE %] 
  • trunk/LATMOS-Accounts-Web/root/static/style.css

    r1211 r1329  
    55    vertical-align: middle; 
    66    padding: 0em 
     7} 
     8 
     9.ui-autocomplete { 
     10     max-height: 8em; 
     11     overflow-y: auto; 
     12     /* prevent horizontal scrollbar */ 
     13     overflow-x: hidden; 
     14} 
     15 
     16* html .ui-autocomplete { 
     17     height: 8em; 
    718} 
    819 
     
    6778} 
    6879 
     80.bloc-box { 
     81    display: inline-block; 
     82    padding: 2px; 
     83    margin: auto; 
     84    vertical-align: middle; 
     85} 
     86 
     87#search-adv-filter { 
     88    width: 100%; 
     89} 
     90 
     91div#search-adv-filter { 
     92} 
    6993 
    7094#header { 
     
    215239 
    216240 
    217     /* 
    218  
    219 span.hint { 
    220     vertical-align: super; 
    221 } 
    222  
    223 .pmenu { 
    224     padding: 0.5em; 
    225     font-size: 2em; 
    226 } 
    227  
    228 .permdenied { 
    229     padding: 0.5em; 
    230 } 
    231  
    232 #oinfo div { 
    233     float: left; 
    234     padding: 0.5em; 
    235 } 
    236  
    237 #oname { 
    238     padding: 0em; 
    239     margin: 0em; 
    240 } 
    241  
    242 .inputvalidate img { 
    243     width: 1em; 
    244     height:1em; 
    245 } 
    246  
    247 div#login { 
    248     margin-top: 1em; 
    249     margin-left: auto; 
    250     margin-right: auto; 
    251     width: 50%; 
    252     border-style: outset; 
    253     text-align: center; 
    254     padding: 0.5em; 
    255 } 
    256  
    257 div#filter { 
    258     border-style: inset; 
    259     margin-top: 0.5em; 
    260     padding: 0.5em; 
    261 } 
    262  
    263  
    264  
    265     */ 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Attributes.pm

    r1315 r1329  
    396396sub delayed { $_[0]->{delayed} || 0 } 
    397397 
    398 =head2 get($attr) 
     398=head2 get 
    399399 
    400400Return the value for this attribute 
     
    405405    my ($self) = @_; 
    406406 
    407     if (ref $self->{get} eq 'CODE') { 
     407    if (ref($self->{get}) eq 'CODE') { 
    408408        return $self->{get}->($self); 
    409     } else { 
     409    } elsif (defined($self->object)) { 
    410410        return $self->object->get_field($self->iname); 
    411     } 
    412 } 
     411    } else { 
     412        return; 
     413    } 
     414} 
     415 
     416=head2 getValues 
     417 
     418Return value for this attribute, results are always return as an array 
     419 
     420=cut 
     421 
     422sub getValues { 
     423    my ($self) = @_; 
     424 
     425    my $res = $self->get(); 
     426 
     427    return ref $res ? grep { $_ } @{ $res } : $res; 
     428} 
     429 
    413430 
    414431=head2 set ($values) 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Objects.pm

    r1316 r1329  
    44use strict; 
    55use warnings; 
     6 
     7use overload '""' => 'stringify'; 
     8 
    69use LATMOS::Accounts::Log; 
    710use LATMOS::Accounts::Bases::Attributes; 
     
    130133} 
    131134 
    132  
    133135=head2 Iid 
    134136 
     
    140142    my ($self) = @_; 
    141143    $self->id 
     144} 
     145 
     146sub stringify { 
     147    my ($self) = @_; 
     148 
     149    return $self->id 
    142150} 
    143151 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Address.pm

    r1315 r1329  
    2020 
    2121=cut 
     22 
     23sub stringify { 
     24    my ($self) = @_; 
     25 
     26    my $user = $self->base->get_object('user', $self->_get_c_field('user')) 
     27        or return $self->id; 
     28 
     29    return join(', ', grep { $_ } 
     30        ( 
     31            $user, 
     32            $self->get_c_field('l'), 
     33        ) 
     34    ); 
     35} 
    2236 
    2337sub _object_table { 'address' } 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Nethost.pm

    r1315 r1329  
    6767                    my @elem = split(/[:-]/, $_[0]); 
    6868                    return join(':', map { sprintf("%02x", hex($_)) } @elem); 
     69                }, 
     70                checkinput => sub { 
     71                    return $_[0] =~ /^([0-9a-f]{2}([:-]|$)){6}$/i ? 1 : undef; 
    6972                }, 
    7073            }, 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm

    r1315 r1329  
    44use strict; 
    55use warnings; 
     6use overload '""' => 'stringify'; 
    67 
    78use LATMOS::Accounts::Utils; 
     
    3940 
    4041sub _has_extended_attributes { 1 } 
     42 
     43sub stringify { 
     44    my ($self) = @_; 
     45 
     46    return join(' ', grep { $_ } 
     47        ( 
     48            $self->get_field('givenName'), 
     49            $self->get_field('sn') 
     50        ) 
     51    ) 
     52    || $self->get_field('description') 
     53    || $self->id; 
     54} 
    4155 
    4256sub _get_attr_schema { 
     
    170184            }, 
    171185            memberOf  => { 
     186                reference => 'group', 
    172187                multiple => 1, delayed => 1, 
    173188                get => sub { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm

    r1328 r1329  
    620620        my $attribute = $base->attribute($class->type, $attr) or do { 
    621621            $base->log(LA_ERR, "Unknown attribute $attr"); 
    622             next; 
     622            return; 
    623623        }; 
    624624        defined($val) or $val =  ''; 
     625 
     626        # Invalid filter due to impossible value: 
     627        $attribute->checkinput($val) or do { 
     628            $base->log(LA_ERR, "Invalid value $val for attribute $attr"); 
     629            return; 
     630        }; 
     631 
    625632        $val = $attribute->input($val); 
    626633 
     
    665672        push(@{ $attrsql{$attr} }, $sql); 
    666673    } 
     674 
    667675    # building the query 
    668676    my @sqlintersec; 
Note: See TracChangeset for help on using the changeset viewer.