--- lib/A3C/View/Strix.pm 2008/06/16 21:33:59 183 +++ lib/A3C/View/Strix.pm 2008/06/17 10:15:13 189 @@ -115,7 +115,7 @@ }; sub strix { - my $instance = get('instance') || shift || 'new'; + my $instance = get('instance'); return Strix->new({ instance => $instance }); } @@ -123,9 +123,18 @@ =cut +sub strix_link { + my ( $url, $label ) = @_; + hyperlink( + url => 'http://' . get('instance') . '.cms-qa.skole.hr' . $url, + label => $label || $url, + target => 'strix', + ); +} + template 'sitemap' => page { - title is _('Sitemap'); + title is _('Sitemap %1', get('instance')); render_region( name => 'selected-instances', @@ -138,15 +147,13 @@ sub full_url { my $p = shift; - hyperlink( - url => 'http://new.cms-qa.skole.hr' . $p->{url}, - label => $p->{naziv}, - ); + strix_link( $p->{url}, $p->{naziv} ); if ( $p->{type} eq 'category' ) { outs_raw(' '); hyperlink( - url => '/strix/layout?url=' . $p->{url}, - label => '[layout]', + url => '/strix/layout?url=' . $p->{url} . ';instance=' . get('instance'), + label => _('layout'), + class => 'layout', ); } } @@ -193,11 +200,13 @@ $category->{naziv}, ); - hyperlink( - url => 'http://' . $category->{sitename} . '/' . $category->{url}, - label => $category->{naziv}, + render_region( + name => 'selected-instances', + path => '/strix/selected-instances' ); + strix_link( $category->{url}, $category->{naziv} ); + my $layout = strix->layout( $url ); pre { @@ -274,9 +283,9 @@ table { while (my $strix = $search->next) { row { + cell { show( 'instance-op', 'Create', '+', $strix->instance ) } cell { tt { $strix->instance } } cell { $strix->_site_name } - cell { show( 'instance-op', 'Create', '+', $strix->instance ) } } } } @@ -293,11 +302,11 @@ template 'selected-instances' => sub { my $self = shift; - warn "## IN selected-instances ",dump( @_ ); +# warn "## IN selected-instances ",dump( @_ ); if ( my $op = get 'op' ) { - my $instance = get 'instance' or die "no instance?"; - warn "# selected-instances $op on $instance"; + my $op_instance = get 'op_instance' or die "no op_instance?"; + warn "# selected-instances $op on $op_instance"; my $a; @@ -307,7 +316,7 @@ class => $op . 'StrixInstanceSelection', moniker => $op, arguments => { - instance => $instance, + instance => $op_instance, by_user => $self->current_user->id, }, ); @@ -315,14 +324,22 @@ } elsif ( $op eq 'Delete' ) { my $strix = A3C::Model::StrixInstanceSelection->new; - $strix->load_by_cols( instance => $instance, by_user => $self->current_user->id ); - die "can't find instance $instance" unless $strix->id; + $strix->load_by_cols( instance => $op_instance, by_user => $self->current_user->id ); + warn "can't find instance $op_instance" unless $strix->id; $a = $strix->as_delete_action; } - warn "# argument_values = ",dump( $a->argument_values ); +# warn "# argument_values = ",dump( $a->argument_values ); $a->run; - warn "can't $op instance $instance" unless $a->result->success; + + if ( $a->result->error ) { + div { + { class is 'note error' } + $a->result->error; + } + } + + set( op => '' ); } my $selected = A3C::Model::StrixInstanceSelectionCollection->new; @@ -330,15 +347,21 @@ if ( $selected->count > 0 ) { + my $instance = get('instance'); + div { _('%1 instances selected', $selected->count ) }; table { while (my $s = $selected->next) { row { - cell { tt { - hyperlink( - url => '?instance=' . $s->instance->instance, - label => $s->instance->instance - ) + cell { tt { + if ( $s->instance->instance eq $instance ) { + b { $instance } + } else { + hyperlink( + url => '?instance=' . $s->instance->instance, + label => $s->instance->instance + ) + } } } cell { $s->instance->_site_name } cell { show( 'instance-op', 'Delete', '-', $s->instance->instance ) } @@ -361,7 +384,7 @@ template 'instance-op' => sub { my $self = shift; - warn "# instance-op = ",dump( @_ ); +# warn "# instance-op = ",dump( @_ ); my ( $op, $label, $instance ) = @_; @@ -372,7 +395,7 @@ refresh => 'selected-instances', path => '/strix/selected-instances', args => { - instance => $instance, + op_instance => $instance, op => $op, } },