[Bps-public-commit] r10017 - in RT-Client-Console: trunk/lib/RT/Client/Console/Session/Ticket
dams at bestpractical.com
dams at bestpractical.com
Wed Dec 19 18:41:30 EST 2007
Author: dams
Date: Wed Dec 19 18:41:28 2007
New Revision: 10017
Modified:
RT-Client-Console/ (props changed)
RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Attachments.pm
Log:
r29 at pundit: dams | 2007-12-13 10:57:32 +0000
. added better page scroll (from Maddingue's patch)
. added transaction retrieval and display
Modified: RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Attachments.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Attachments.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Attachments.pm Wed Dec 19 18:41:28 2007
@@ -31,12 +31,15 @@
},
available_keys => sub {
- return (['<KEY_NPAGE>', 'next attachment', 'next_attachment'],
- ['<KEY_PPAGE>', 'previous attachment', 'prev_attachment'],
- ['<KEY_UP>', 'previous attachment', 'scroll_up'],
- ['<KEY_DOWN>', 'previous attachment', 'scroll_down'],
+ return (['<KEY_NPAGE>', 'next attachment', 'next_attachment'],
+ ['<KEY_PPAGE>', 'prev. attachment', 'prev_attachment'],
+ ['<KEY_UP>', 'scroll up', 'scroll_up' ],
+ ['<KEY_DOWN>', 'scroll down', 'scroll_down' ],
+ ['b', 'page up', 'page_up' ],
+ [' ', 'page down', 'page_down' ],
);
},
+
next_attachment => sub {
my ( $kernel, $heap) = @_[ KERNEL, HEAP ];
$heap->{current}++;
@@ -44,6 +47,7 @@
and $heap->{current} = $heap->{total} - 1;
$heap->{positions}[$heap->{current}]->{current} = 0;
},
+
prev_attachment => sub {
my ( $kernel, $heap) = @_[ KERNEL, HEAP ];
$heap->{current}--;
@@ -51,45 +55,62 @@
and $heap->{current} = 0;
$heap->{positions}[$heap->{current}]->{current} = 0;
},
+
scroll_down => sub {
- my ($kernel, $heap) = @_[ KERNEL, HEAP ];
+ my ($kernel, $heap, $offset) = @_[ KERNEL, HEAP, ARG0 ];
+ $offset ||= 1;
my $idx = $heap->{current};
my $positions = $heap->{positions}[$idx];
defined $positions or return -1;
- if ($positions->{current} >= @{$positions->{array}} - 1) {
+ if ($positions->{current} >= @{$positions->{array}} - $offset) {
if ($heap->{current} < $heap->{total} - 1 ) {
$heap->{current}++;
- if (defined $heap->{positions}[$idx+1]) {
- $heap->{positions}[$idx+1]->{current} = 0;
+ if (defined $heap->{positions}[$idx + 1]) {
+ $heap->{positions}[$idx + 1]->{current} = 0;
}
$kernel->call("ticket_attachments_$ticket_id", 'draw');
}
return -1;
}
- $positions->{current}++;
- $kernel->call("ticket_attachments_$ticket_id", 'draw');
+ $positions->{current} += $offset;
+ $kernel->call("ticket_attachments_$ticket_id", 'draw');
return -1;
},
+
scroll_up => sub {
- my ($kernel, $heap) = @_[ KERNEL, HEAP ];
+ my ($kernel, $heap, $offset) = @_[ KERNEL, HEAP, ARG0 ];
+ $offset ||= 1;
my $idx = $heap->{current};
my $positions = $heap->{positions}[$idx];
defined $positions or return -1;
- if ($positions->{current} <= 0) {
+ if ($positions->{current} <= ($offset-1)) {
if ($heap->{current} > 0) {
$heap->{current}--;
- if (defined $heap->{positions}[$idx-1]) {
- $heap->{positions}[$idx-1]->{current} =
- @{$heap->{positions}[$idx-1]->{array}} - 1;
+ if (defined $heap->{positions}[$idx - 1]) {
+ $heap->{positions}[$idx - 1]->{current} =
+ @{$heap->{positions}[$idx - 1]->{array}} - 1;
}
$kernel->call("ticket_attachments_$ticket_id", 'draw');
}
return -1;
}
- $positions->{current}--;
+ $positions->{current} -= $offset;
$kernel->call("ticket_attachments_$ticket_id", 'draw');
return -1;
},
+
+ page_down => sub {
+ my ($kernel, $heap) = @_[ KERNEL, HEAP ];
+ my $offset = int($heap->{height} / 2);
+ $kernel->call("ticket_attachments_$ticket_id", 'scroll_down', $offset);
+ },
+
+ page_up => sub {
+ my ($kernel, $heap) = @_[ KERNEL, HEAP ];
+ my $offset = int($heap->{height} / 2);
+ $kernel->call("ticket_attachments_$ticket_id", 'scroll_up', $offset);
+ },
+
draw => sub {
my ($kernel, $heap) = @_[ KERNEL, HEAP ];
my $label;
@@ -127,7 +148,7 @@
warn ref($e), ": ", $e->message || $e->description, "\n";
};
- $text = $class->as_text($heap, $attachment, $idx, $heap->{width});
+ $text = $class->as_text($heap, $attachment, $idx, $heap->{width}, $ticket_id);
}
my $title = '[ Attachment ' . ($idx + 1) . " / $total - $user_details ]";
$title =~ s/\s+/ /g;
@@ -203,11 +224,31 @@
}
sub as_text {
- my ($class, $heap, $attachment, $idx, $width) = @_;
+ my ($class, $heap, $attachment, $idx, $width, $ticket_id) = @_;
defined $heap->{text}[$idx] and return $heap->{text}[$idx];
my $s = 'content :(' . $attachment->content_type() . ')' . "\n"
. 'subject :{' . $attachment->subject() . '}' . "\n"
- . 'filename:{' . $attachment->file_name() . '}';
+ . 'filename:{' . $attachment->file_name() . '}' . "\n"
+ . 'created :{' . $attachment->created() . '}' . "\n"
+ . 'transac :{' . $attachment->transaction_id() . '}' . "\n"
+ . 'message :{' . $attachment->message_id() . '}';
+ if (defined $attachment->transaction_id()) {
+ my $id = $attachment->transaction_id();
+ $s .= "\n--- transaction $id ----\n";
+ my $rt_handler = RT::Client::Console::Cnx->get_cnx_data()->{handler};
+ my $transaction = $rt_handler->get_transaction(parent_id => $ticket_id,
+ id => $id);
+
+# my $ticket = RT::Client::Console::Session::Ticket->get_ticket_from_id($ticket_id);
+#RT::Client::REST::Ticket
+# my $transaction = RT::Client::REST($ticket,parent_id => $ticket_id,
+# id => $id);
+# my $transaction = $ticket->get_transaction(parent_id => $ticket_id,
+# id => $id);
+ use Data::Dumper;
+ $s .= Dumper($transaction);
+ $s .= "\n------------\n";
+ }
my $text;
if ($attachment->content_type eq 'text/plain') {
$text = $s . "\n\n" . $attachment->content();
More information about the Bps-public-commit
mailing list