--- lib/A3C/View/Strix.pm 2008/06/20 12:27:13 210 +++ lib/A3C/View/Strix.pm 2008/06/20 15:35:21 211 @@ -119,10 +119,6 @@ return Strix->new({ instance => $instance }); } -=head2 navigation - -=cut - sub strix_link { my ( $url, $label ) = @_; hyperlink( @@ -132,6 +128,10 @@ ); } +=head2 navigation + +=cut + template 'navigation' => page { title is _('Site navigation'); @@ -142,8 +142,8 @@ ); render_region( - name => 'select-strix-site', - path => '/strix/select-site' + name => 'strix-site', + path => '/strix/site' ); }; @@ -152,7 +152,7 @@ =cut -template 'layout' => page { +template 'layout' => sub { my $url = get('url') || '/'; @@ -160,16 +160,6 @@ warn dump( $category ); - title is _('Layout %1 : %2', - $category->{sitename}, - $category->{naziv}, - ); - - render_region( - name => 'selected-instances', - path => '/strix/selected-instances' - ); - strix_link( $category->{url}, $category->{naziv} ); my $layout = strix->layout( $url ); @@ -270,7 +260,8 @@ # warn "## IN selected-instances ",dump( @_ ); if ( my $op = get 'op' ) { - my $op_instance = get 'op_instance' or die "no op_instance?"; + my $op_instance = get 'op_instance'; + return unless $op_instance; warn "# selected-instances $op on $op_instance"; my $a; @@ -370,11 +361,11 @@ }; -=head2 select-site +=head2 site =cut -template 'select-site' => sub { +template 'site' => sub { my $action = new_action( class => 'StrixSelectSite', @@ -396,7 +387,8 @@ # this is basically a closure { refresh => 'selected-instances', path => '/strix/selected-instances', args => { instance => { result_of => $action, name => 'instance' } - } } + } }, + { refresh => 'strix-site-layout', path => '/__jifty/empty' }, ]; form { @@ -407,6 +399,11 @@ warn "## select-site action ",dump( $action->result ); + render_region( + name => 'layout', + path => '/__jifty/empty', + ); + if ( my $site_id = $action->result->content('site_id') ) { show('strix-site-navigation-tree', $action->result->content('instance'), $site_id); } @@ -420,6 +417,28 @@ =cut +private template 'select-category' => sub { + my $self = shift; + my $p = shift; + strix_link( $p->{url}, $p->{naziv} ); + if ( $p->{type} eq 'category' ) { + outs_raw(' '); + hyperlink( +# url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'), + onclick => { + region => 'strix-site-layout', # FIXME do we have to hard-code region name here? + replace_with => '/strix/layout', + args => { + url => $p->{url}, + instance => get('instance'), + } + }, + label => _('layout'), + class => 'layout', + ); + } +}; + private template 'strix-site-navigation-tree' => sub { my $self = shift; my ( $instance, $site_id ) = @_; @@ -428,18 +447,6 @@ set 'instance' => $instance; - sub full_url { - my $p = shift; - strix_link( $p->{url}, $p->{naziv} ); - if ( $p->{type} eq 'category' ) { - outs_raw(' '); - hyperlink( - url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'), - label => _('layout'), - class => 'layout', - ); - } - } sub children { my $c = shift; @@ -448,7 +455,7 @@ foreach my $p ( @{ $c->{children} } ) { li { { class is $p->{class} }; - full_url( $p ); + show( 'select-category', $p ); children( $p ); } } @@ -462,7 +469,7 @@ ul { foreach my $p ( @navigation ) { li { - full_url( $p ); + show( 'select-category', $p ); children( $p ); } }