/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26