Ignore:
Timestamp:
09/05/12 06:35:14 (12 years ago)
Author:
nanardon
Message:

AttrFilter? don't automatically fill stash anymore

Location:
trunk/LATMOS-Accounts-Web
Files:
3 edited

Legend:

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

    r1082 r1131  
    3535    $new->{c} = $c; 
    3636    $new->{otype} = $otype; 
    37     $c->stash->{filter} = { 
    38         otype => $otype, 
    39     } unless($c->stash->{filter}); 
    40     $c->stash->{ofilter} = bless($new, __PACKAGE__); 
     37    $new->{base} = $c->model('Accounts')->db; 
     38    $self = bless($new, __PACKAGE__); 
    4139 
    42     $c->stash->{db} ||= $c->model('Accounts')->db; # need in stash ? 
    43     my $base = $c->stash->{db}; 
     40    my $base = $new->{base}; 
    4441 
    4542    my @objlist = (); 
     
    5451        } 
    5552    } elsif (exists($c->req->params->{'attr'})) { 
    56         $c->stash->{filter}{'attr'} = [ $c->req->param('attr') ]; 
    57         $c->stash->{filter}{'attrval'} = [ $c->req->param('attrval') ]; 
    58         my @filter = $c->stash->{ofilter}->filter; 
     53        $self->{filter}{'attr'} = [ $c->req->param('attr') ]; 
     54        $self->{filter}{'attrval'} = [ $c->req->param('attrval') ]; 
     55        my @filter = $self->filter; 
    5956        @objlist = $base->search_objects($otype, @filter); 
    6057    } else { 
     
    6259    } 
    6360 
    64     $c->stash->{objectslist} = \@objlist; 
     61    $self->{objectslist} = \@objlist; 
    6562 
    6663    my $start = $c->req->param('start'); 
    67     $c->stash->{uparams} = { %{ $c->req->params || {} } }; 
     64    $self->{uparams} = { %{ $c->req->params || {} } }; 
    6865    my %initials; 
    6966    my @sublist; 
    70     foreach (@{ $c->stash->{objectslist} }) { 
     67    foreach (@{ $self->{objectslist} }) { 
    7168        $initials{substr($_, 0, 1)} = 1; 
    7269        if ($start) { 
     
    7673        } 
    7774    } 
    78     $c->stash->{sublist} = [ @sublist ]; 
    79     $c->stash->{initials} = [ sort keys %initials ]; 
     75    $self->{sublist} = [ @sublist ]; 
     76    $self->{initials} = [ sort keys %initials ]; 
    8077 
    81     $c->stash->{ofilter} 
     78    $self 
    8279} 
    8380 
     
    9794sub current_value { 
    9895    my ($self) = @_; 
    99     my @vals = @{ $self->{c}->stash->{filter}{attrval} || [] }; 
    100     my @fies = @{ $self->{c}->stash->{filter}{attr} || [] }; 
     96    my @vals = @{ $self->{filter}{attrval} || [] }; 
     97    my @fies = @{ $self->{filter}{attr} || [] }; 
    10198    my @couples; 
    10299    foreach (@fies) { 
     
    143140} 
    144141 
     142sub objectslist { 
     143    my ($self) = @_; 
     144    warn $self->{objectslist}; 
     145    $self->{objectslist}; 
     146} 
     147 
    145148=head1 AUTHOR 
    146149 
  • trunk/LATMOS-Accounts-Web/root/html/includes/list_objects.tt

    r1108 r1131  
    11 
     2[% objectslist = ofilter.objectslist %] 
    23[% IF objectslist.size > 20 %] 
    34 
    4 [% FOREACH initial = initials %] 
     5[% FOREACH initial = ofilter.initials %] 
    56[% IF c.req.param('start') == initial %] 
    67< [% initial %] > 
    78[% ELSE %] 
    8 [% uparams.start = initial %] 
    9 <a href="[% c.uri_for('/' _ c.forward('/obj_to_uri', [ ofilter.otype ]), uparams) %]">[% initial %]</a> 
     9[% ofilter.uparams.start = initial %] 
     10<a href="[% c.uri_for('/' _ c.forward('/obj_to_uri', [ ofilter.otype ]), ofilter.uparams) %]">[% initial %]</a> 
    1011[% END %] 
    1112[% END %] 
     
    2728 
    2829[% IF c.req.param('start') %] 
    29 [% objectslist = sublist %] 
     30[% objectslist = ofilter.sublist %] 
    3031[% END %] 
    3132 
    3233[% IF objectslist.size < 20 OR c.req.param('start') %] 
    3334[% FOREACH name = objectslist %] 
    34 [% object = db.get_object(ofilter.otype, name) %] 
     35[% object = c.model('Accounts').db.get_object(ofilter.otype, name) %] 
    3536<tr> 
    3637    <td> 
  • trunk/LATMOS-Accounts-Web/root/html/includes/select_objects_list.tt

    r1110 r1131  
     1[% objectslist = ofilter.objectslist %] 
    12<select name="obj" id="obj"> 
    23[% IF objectslist.size > 1 %] 
     
    78 
    89[% IF objectslist.size < 20 %] 
    9 [% object = db.get_object(ofilter.otype, name) %] 
     10[% object = c.model('Accounts').db.get_object(ofilter.otype, name) %] 
    1011<option value="[% name | html %]">[% name | html %] ([% 
    1112object.get_attributes('displayName') | html %])</option> 
Note: See TracChangeset for help on using the changeset viewer.