Permalink
Browse files

Implementation of a web view of replica history

  • Loading branch information...
1 parent 8b30d09 commit 97fced574f7af4be040fca959f798894ca6eff7e @obra obra committed Jul 16, 2009
Showing with 161 additions and 6 deletions.
  1. +3 −1 lib/App/SD/Server/Dispatcher.pm
  2. +101 −5 lib/App/SD/Server/View.pm
  3. +57 −0 share/web/static/css/main.css
@@ -15,6 +15,7 @@ on qr'.' => sub {
on qr'.' => sub {
my $self = shift;
+ $self->server->nav->child( history => label => 'History', url => '/history');
my $tickets = $self->server->nav->child( tickets => label => 'Tickets', url => '/');
$tickets->child( go => label => '<form method="GET" action="/ticket/"><a href="#">Show ticket # <input type=text name=id size=3></a></form>', escape_label => 0) unless($self->server->static);
@@ -64,7 +65,8 @@ under { method => 'GET' } => sub {
my $type = $2;
shift->show_template( $name => $type );
};
-
+
+ on qr'^/history/?(\d*)/?$' => sub {my $since = $1; shift->show_template('history', $since)};
on qr'^/tickets/all$' => sub {shift->show_template('all_tickets')};
under qr'^/ticket/' => sub {
on '' => sub {
View
@@ -437,6 +437,88 @@ private template 'ticket_list' => sub {
};
+template 'history' => page {
+ my $self = shift;
+ 'History';
+}
+content {
+ my $self = shift;
+ my $latest = $self->app_handle->handle->latest_sequence_no;
+ my $start = shift || $latest;
+ my $end = $start - 20;
+
+ my @changesets;
+ $self->app_handle->handle->traverse_changesets(
+ reverse => 1,
+ after => $end,
+ until => $start,
+ callback => sub {
+ my %args = (@_);
+ push @changesets, $args{changeset};
+ }
+ );
+
+ div { { class is 'log'};
+ my $nav = sub {
+ div {{ class is 'nav'};
+ if ($end > 1 ) {
+ a {{ class is 'prev', href is '/history/'.($end-1) }; 'Earlier' };
+ }
+ if ($start < $latest) {
+ a {{ class is 'next', href is '/history/'.(( $start+21 < $latest) ? ($start+21) : $latest) }; 'Later' };
+ }
+ }
+ };
+
+ $nav->();
+
+ show(
+ 'format_history',
+ changesets => \@changesets,
+ change_filter => sub {1},
+ sort_changesets => sub { sort {$b->sequence_no <=> $a->sequence_no} @_ },
+ change_header => sub {
+ my $change = shift;
+ if ( $change->record_type eq 'ticket' ) {
+ my $ticket = App::SD::Model::Ticket->new(
+ app_handle => $self->app_handle,
+ handle => $self->app_handle->handle
+ );
+ $ticket->load( uuid => $change->record_uuid );
+
+ h2 {
+ a {{ href is '/ticket/' . $ticket->uuid; class is 'ticket-summary'; }; $ticket->prop('summary') };
+ span { { class is 'ticket-id'}; ' (' . $ticket->luid . ')'};
+ }
+ } elsif ($change->record_type eq 'comment') {
+ my $ticket = App::SD::Model::Ticket->new(
+ app_handle => $self->app_handle,
+ handle => $self->app_handle->handle
+ );
+
+ my $id;
+ for ( $change->prop_changes ) {
+ if ( $_->name eq 'ticket' ) { $id = $_->new_value }
+
+ }
+ $ticket->load( uuid => $id ) ;
+
+ h2 {
+ outs('Comment on: ');
+ a {{ href is '/ticket/' . $ticket->uuid; class is 'ticket-summary'; }; $ticket->prop('summary') };
+ span { { class is 'ticket-id'}; ' (' . $ticket->luid . ')'};
+ }
+
+
+ }
+ }
+ );
+
+ $nav->();
+ }
+};
+
+
template 'show_ticket_history' => page {
my $self = shift;
my $id = shift;
@@ -458,7 +540,9 @@ template 'show_ticket_history' => page {
$self->ticket_page_actions($ticket);
- show ticket_history => $ticket;
+ show('format_history', changesets => [$ticket->changesets], change_filter => sub { my $change = shift; return $ticket->uuid eq $change->record_uuid ? 1 : 0},
+
+ );
};
template 'show_ticket' => page {
@@ -550,13 +634,22 @@ template ticket_attachments => sub {
};
-template ticket_history => sub {
+
+
+
+
+
+private template format_history => sub {
my $self = shift;
- my $ticket = shift;
+ my %args = (changesets => undef,
+ change_filter => undef,
+ change_header => undef,
+ sort_changesets => sub { sort {$a->created cmp $b->created} @_ },
+ @_);
dl {
{ class is 'history' };
- for my $changeset ( sort { $a->created cmp $b->created } $ticket->changesets ) {
+ for my $changeset ( $args{sort_changesets}->( @{$args{changesets}} )) {
dt {
span {
{ class is 'created' };
@@ -579,7 +672,10 @@ template ticket_history => sub {
};
dd {
for my $change ( $changeset->changes ) {
- if ( $change->record_uuid eq $ticket->uuid ) {
+ if ( $args{change_filter}->($change)) {
+ if ($args{change_header}) {
+ $args{change_header}->($change);
+ }
ul {
li { outs_raw($_) }
@@ -88,6 +88,63 @@ h2 {
}
+.log h2 {
+ font-weight: normal;
+}
+
+.log h2 a.ticket-summary {
+ font-weight: normal;
+ text-decoration: none;
+ color: #700;
+}
+
+.log h2 a:hover {
+ text-decoration: underline;
+}
+
+
+h2 .ticket-id {
+ color: #ccc;
+}
+
+
+.log .nav {
+ text-align: center;
+padding-top: 0.25em;
+padding-bottom: 0.25em;
+
+}
+.log .nav a:hover {
+ text-decoration: underline;
+ background: #aaa;
+ color: #333;
+
+}
+.log .nav a {
+padding: 0.5em;
+background: #ccc;
+width: 5em;
+display: inline-block;
+text-align: center;
+color: #666;
+text-decoration: none;
+}
+.log .nav .prev {
+ -moz-border-radius-bottomleft: 0.5em;
+ -webkit-border-bottom-left-radius: 0.5em;
+ -moz-border-radius-topleft: 0.5em;
+ -webkit-border-top-left-radius: 0.5em;
+
+}
+.log .nav .next {
+ -moz-border-radius-bottomright: 0.5em;
+ -webkit-border-bottom-right-radius: 0.5em;
+ -moz-border-radius-topright: 0.5em;
+ -webkit-border-top-right-radius: 0.5em;
+
+}
+
+
ul.actions {
align: center;
display: block;

0 comments on commit 97fced5

Please sign in to comment.