/[Frey]/trunk/lib/Frey/ORM/Browser.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 /trunk/lib/Frey/ORM/Browser.pm

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

revision 60 by dpavlin, Tue Jul 8 12:20:08 2008 UTC revision 93 by dpavlin, Fri Jul 11 09:25:02 2008 UTC
# Line 21  sub process_links { Line 21  sub process_links {
21          }          }
22  }  }
23    
24  use Data::Dumper;  #use Data::Dumper;
25  $Data::Dumper::Deparse = 1;  #$Data::Dumper::Deparse = 1;
26    use Data::Dump qw/dump/;
27    use Data::Structure::Util qw(unbless);
28    
29    
30  #method 'html' => positional(  #method 'html' => positional(
31  #       isa => 'Continuity::RequestHolder',  #       isa => 'Continuity::RequestHolder',
# Line 31  $Data::Dumper::Deparse = 1; Line 34  $Data::Dumper::Deparse = 1;
34  sub html {  sub html {
35          my ( $self, $req ) = @_;          my ( $self, $req ) = @_;
36    
37          my $params = $req->param;          my $f = { $req->params };
38          warn Dumper( $params );          my $layout = delete( $f->{layout} ) || 'div';
39    
40            use Strix::User;
41            use Strix::View::User;
42    
43            my $s = Strix::User->rows();
44            #warn "# s = ",dump( $s );
45    
46            my @w;
47    
48            while ( my $u = $s->next ) {
49                    my $w = Strix::View::User->new( %{ $u } );
50                    $w->_fey( $u );
51                    $w->_layout( $layout );
52                    warn "# w = ",dump( $w ) if $self->debug;
53                    push @w, $w;
54            }
55    
56            while ( 1 ) {
57            
58                    warn "# got $#w elements: ",dump( map { $_->id } @w );
59                    warn "<<< GOT REQUEST ",dump( $f );
60    
61                    # re-apply (changed?) layout to elements
62                    if ( defined $f->{layout} ) {
63                            $layout = delete( $f->{layout} );
64                            warn "# new layout = $layout\n";
65                    }
66    
67                    my $rows_delimiter = '<hr/>';
68                    $rows_delimiter = '' if $layout eq 'table';
69    
70                    my $form = join($rows_delimiter, map {
71                            $_->_layout( $layout );
72                            $_->process($f) || ''
73                    } @w );
74    
75                    if ( $w[ $#w ]->_fey ) {
76                            warn "+++ added new item widget\n";
77                            my $w = Strix::View::User->new( render_as => 'edit' );
78                            $w->_layout( $layout );
79                            $form .= $rows_delimiter . $w->process;
80                            push @w, $w;
81                    }
82    
83                    $form = qq|<table>$form</table>| if $layout eq 'table';
84    
85    
86                my $doc = Continuity::Widget::DomNode->create(
87                            html => [
88                                    head => [
89                                            link  => { rel=>"stylesheet", href=>"/static/form.css", type=>"text/css" }
90                                    ],
91                                    body => [
92                                            h1 => [ 'Strix::User' ],
93                                            $layout eq 'table' ?
94                                                    # gen_link doesn't work since Widngets have it's own scope of layout
95    #                                               gen_link( 'div layout', sub { $layout = 'div' } ) :
96    #                                               gen_link( 'table layout', sub { $layout = 'table' } ),
97                                                    qq|<a href="?layout=div">div layout</a>| :
98                                                    qq|<a href="?layout=table">table layout</a>|,
99                                            form => { method=>'post' } => [
100                                                    $form,
101                                            ],
102                                    ],
103                            ]
104                    )->to_string;
105    
106                    warn ">>> $layout ",length( $doc ),"\n";
107    
108                    $req->print( $doc );
109                    $req->next;
110    
111          $req->print( Dumper( $params ) );                  $f = { $req->params };
112    
113                    process_links( $req );
114            }
115    
116          $req->next;          warn "NO WAY OUT!";
117  };  };
118    
119  1;  1;

Legend:
Removed from v.60  
changed lines
  Added in v.93

  ViewVC Help
Powered by ViewVC 1.1.26