/[A3C]/lib/A3C/View/Strix.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

Diff of /lib/A3C/View/Strix.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 153 by dpavlin, Sat Jun 14 12:31:35 2008 UTC revision 157 by dpavlin, Sun Jun 15 10:51:57 2008 UTC
# Line 8  A3C::View::Strix Line 8  A3C::View::Strix
8    
9  Display information about Strix sites  Display information about Strix sites
10    
11    =head1 TEMPLATES
12    
13  =cut  =cut
14    
15  use strict;  use strict;
# Line 16  use warnings; Line 18  use warnings;
18  use Jifty::View::Declare -base;  use Jifty::View::Declare -base;
19  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
20    
21    =head2 /
22    
23    Display sites search and some stats
24    
25    =cut
26    
27  template 'index.html' => page {  template 'index.html' => page {
28    
29          title is _('Strix sites');          title is _('Strix sites');
30    
31            render_region(
32                    name => 'user-selected-sites',
33                    path => '/strix/selected-sites'
34            );
35    
36            render_region(
37                    name => 'search_sites',
38                    path => '/strix/search_sites',
39            );
40    
41          h1 { _('Statistics') }          h1 { _('Statistics') }
42    
43          my $orgs = A3C::Model::StrixSiteCollection->new;          my $orgs = A3C::Model::StrixSiteCollection->new;
# Line 30  template 'index.html' => page { Line 48  template 'index.html' => page {
48    
49  };  };
50    
51    =head2 name_diff
52    
53    =cut
54    
55  template 'name_diff' => page {  template 'name_diff' => page {
56    
57          title is _('Strix sites');          title is _('Strix sites | name differences between php config and internal state');
58    
59          my $name_diff = A3C::SQL->new({ query => qq{          my $name_diff = A3C::SQL->new({ query => qq{
60                  select                  select
# Line 63  template 'name_diff' => page { Line 85  template 'name_diff' => page {
85    
86  };  };
87    
88    =head1 REGIONS
89    
90    =head2 search_sites
91    
92    =cut
93    
94    template 'search_sites' => sub {
95    
96            h1 { _('Find site') }
97    
98            my $action = new_action(
99                    class   => 'SearchStrixSite',
100                    moniker => 'search-strix-site',
101                    sticky_on_success => 1,
102                    sticky_on_failure => 1,
103            );
104    
105    
106            form {
107                    render_action( $action => [ 'site_contains', '_site_name_contains' ] );
108                    form_submit( label => _('Search') );
109            };
110    
111    #       warn dump( $action->result->content );
112    
113            if ( my $search = $action->result->content('search') ) {
114                    div { _('Found %1 results', $search->count ) }
115                    table {
116                            while (my $strix = $search->next) {
117                                    row {
118                                            cell { tt { $strix->site } }
119                                            cell { $strix->_site_name }
120                                            cell { show( 'site_selection', 'Create', '+', $strix->site ) }
121                                    }
122                            }
123                    }
124            }
125    
126    };
127    
128    =head2 selected_sites
129    
130    Show Selected sites for current user
131    
132    =cut
133    
134    template 'selected-sites' => sub {
135            my $self = shift;
136    
137            warn "## IN selected-sites ",dump( @_ );
138    
139            if ( my $op = get 'op' ) {
140                    my $site = get 'site' or die "no site?";
141                    warn "# selected-sites $op on $site";
142    
143                    my $a;
144    
145                    if ( $op eq 'Create' ) {
146    
147                            $a = new_action(
148                                    class => $op . 'StrixSiteSelection',
149                                    moniker => $op,
150                                    arguments => {
151                                            strix => $site,
152                                            by_user => $self->current_user->id,
153                                    },
154                            );
155    
156                    } elsif ( $op eq 'Delete' ) {
157    
158                            my $strix = A3C::Model::StrixSiteSelection->new;
159                            $strix->load_by_cols( strix => $site, by_user => $self->current_user->id );
160                            die "can't find site $site" unless $strix->id;
161                            $a = $strix->as_delete_action;
162    
163                    }
164                    warn "# argument_values = ",dump( $a->argument_values );
165                    $a->run;
166                    warn "can't $op site $site" unless $a->result->success;
167            }
168    
169            my $selected = A3C::Model::StrixSiteSelectionCollection->new;
170            $selected->limit( column => 'by_user', value => Jifty->web->current_user->id );
171    
172            if ( $selected->count > 0 ) {
173    
174                    div { _('%1 sites selected', $selected->count ) }
175                    table {
176                            while (my $s = $selected->next) {
177                                    row {
178                                            cell { tt { $s->strix->site } }
179                                            cell { $s->strix->_site_name }
180                                            cell { show( 'site_selection', 'Delete', '-', $s->strix->site ) }
181                                    }
182                            }
183                    }
184            } else {
185                    div { _('No sites selected') }
186            }
187    };
188    
189    =head2 site_selection
190    
191    Display button to add/remove site from selection
192    
193      show( 'site_selection', 'Delete', '-', $strix->site );
194    
195    =cut
196    
197    template 'site_selection' => sub {
198            my $self = shift;
199    
200            warn "# site_selection = ",dump( @_ );
201    
202            my ( $op, $label, $site ) = @_;
203    
204            form {
205                    hyperlink(
206                            label => $label,
207                            onclick => {
208                                    refresh => 'user-selected-sites',
209                                    path => '/strix/selected-sites',
210                                    args => {
211                                            site => $site,
212                                            op => $op,
213                                    }
214                            },
215                    );
216            }
217    
218    };
219    
220    
221  1;  1;

Legend:
Removed from v.153  
changed lines
  Added in v.157

  ViewVC Help
Powered by ViewVC 1.1.26