/[A3C]/lib/A3C/View/Organization.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /lib/A3C/View/Organization.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 138 - (hide annotations)
Fri May 30 21:02:04 2008 UTC (11 years, 2 months ago) by dpavlin
File size: 2858 byte(s)
cleanup, some documentation, seems to work
1 dpavlin 125 package A3C::View::Organization;
2    
3 dpavlin 138 =head1 NAME
4    
5     A3C::View::Organization
6    
7     =head1 DESCRIPTION
8    
9     Provide search and display form using table
10    
11     =cut
12    
13 dpavlin 125 use strict;
14     use warnings;
15    
16     use Jifty::View::Declare -base;
17     use base qw/ Jifty::View::Declare::CRUD /;
18    
19     use Data::Dump qw/dump/;
20    
21     sub display_columns {
22     return (
23     'o',
24     'cn',
25     'hrEduOrgUniqueNumber',
26 dpavlin 127 # 'hrEduOrgType',
27 dpavlin 125 'postalAddress',
28     'l',
29     );
30     }
31    
32 dpavlin 127 sub create_columns {
33     my $self = shift;
34     my $action = shift;
35     return $action->argument_names;
36     #return grep { !( m/_confirm/ || $action->arguments->{$_}{unreadable} ) } $action->argument_names;
37     }
38    
39 dpavlin 125 template 'search' => sub {
40     my $self = shift;
41     my ($object_type) = ( $self->object_type );
42     my $search = $self->record_class->as_search_action(
43     moniker => 'search',
44     sticky_on_success => 1,
45     );
46    
47     div {
48     { class is "jifty_admin" };
49     render_action( $search => [
50     'o_contains',
51     'dc_contains',
52     'hrEduOrgUniqueNumber_contains',
53     'l_contains',
54     'hrEduOrgType',
55     ] );
56    
57     $search->button(
58     label => _('Search'),
59     onclick => {
60     submit => $search,
61     # removed because we don't use search toggle region
62     #refresh => Jifty->web->current_region->parent,
63     args => { page => 1 }
64     }
65     );
66    
67     }
68     };
69    
70    
71     template 'list' => sub {
72     my $self = shift;
73    
74     my ( $page ) = get('page');
75     my $item_path = get('item_path') || $self->fragment_for("view");
76     my $collection = $self->_current_collection();
77     div { {class is 'crud-'.$self->object_type};
78     show('./search');
79     show( './paging_top', $collection, $page );
80     show( './list_items', $collection, $item_path );
81     show( './paging_bottom', $collection, $page );
82     };
83     };
84    
85    
86     private template 'list_items' => sub {
87     my $self = shift;
88     my $collection = shift;
89     my $item_path = shift;
90     my $callback = shift;
91     my $object_type = $self->object_type;
92     $collection->_do_search(); # we're going to need the results.
93     # XXX TODO, should use a real API to force the search
94     if ( $collection->count == 0 ) {
95     show('./no_items_found');
96     }
97    
98     my $o = $self->record_class->new;
99     my $name2label;
100     map {
101     $name2label->{ $_->name } = $_->label;
102     } $o->columns;
103     #warn "# name2label = ",dump( $name2label );
104    
105 dpavlin 127 div { class is 'note message'; _('Found %1 results', $collection->pager->total_entries ) }
106 dpavlin 125 table {
107     { class is 'list' };
108     row {
109     th { $name2label->{$_} } foreach $self->display_columns;
110     };
111     while (my $item = $collection->next) {
112     row {
113     cell { $item->$_ } foreach $self->display_columns;
114     }
115     }
116     };
117    
118     };
119    
120     sub per_page { 10 }
121    
122 dpavlin 127 template 'new' => page {
123     my $self = shift;
124     title is $self->object_type;
125     form {
126 dpavlin 138 render_region(
127     name => $self->object_type.'-list',
128     path => $self->fragment_base_path.'/new-list'
129     );
130 dpavlin 127 }
131 dpavlin 138 };
132 dpavlin 127
133 dpavlin 138 # in Jifty's template, it's included on bottom of list
134     template 'new-list' => sub {
135     div {
136     { class is 'list' };
137     }
138     show( './new_item_region');
139 dpavlin 127 };
140    
141 dpavlin 125 1;

  ViewVC Help
Powered by ViewVC 1.1.26