[Bps-public-commit] r9611 - in RT-Client-Console/trunk/lib/RT/Client: . Console/Session Console/Session/Ticket
dams at bestpractical.com
dams at bestpractical.com
Tue Nov 6 19:30:03 EST 2007
Author: dams
Date: Tue Nov 6 19:30:02 2007
New Revision: 9611
Added:
RT-Client-Console/trunk/lib/RT/Client/Console/Session/TabBar.pm
Modified:
RT-Client-Console/trunk/lib/RT/Client/Console.pm
RT-Client-Console/trunk/lib/RT/Client/Console/Cnx.pm
RT-Client-Console/trunk/lib/RT/Client/Console/Session.pm
RT-Client-Console/trunk/lib/RT/Client/Console/Session/KeyHandler.pm
RT-Client-Console/trunk/lib/RT/Client/Console/Session/Root.pm
RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket.pm
RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Attachments.pm
RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/CustFields.pm
RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Header.pm
RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Links.pm
Log:
added tabs and multiple tickets handling
Modified: RT-Client-Console/trunk/lib/RT/Client/Console.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console.pm Tue Nov 6 19:30:02 2007
@@ -3,7 +3,6 @@
use warnings;
use strict;
use Carp;
-use version;
our $VERSION = '0.0.1';
use Params::Validate qw(:all);
@@ -11,6 +10,7 @@
# global heap to keep an application-level state
my %GLOBAL_HEAP = ( curses => {
handler => undef,
+ need_clear => 0,
},
rt => { cnx => {
handler => undef,
@@ -19,12 +19,14 @@
password => undef,
},
tickets => {
- current => undef,
- attachments => {
- current => undef,
- total => 0,
- },
- total => 0,
+ current => undef, # points to the current ticket structure
+ list => [], # arrayref containing the ordered tickets objects list
+
+# attachments => {
+# current => undef,
+# total => 0,
+# },
+# total => 0,
},
},
server => {
@@ -41,7 +43,7 @@
# current_atta => undef,
# total_tab => 0,
# current_tab => undef,
- sessions => [],
+ sessions => {},
);
sub GLOBAL_HEAP { \%GLOBAL_HEAP }
@@ -74,6 +76,11 @@
}
+sub cls {
+ my ($class) = @_;
+ $class->GLOBAL_HEAP->{curses}{need_clear} = 1;
+ return;
+}
use Curses::Forms::Dialog;
@@ -81,6 +88,7 @@
my ($class, $message) = @_;
dialog('Error', BTN_OK, $message,
qw(white red yellow));
+ $class->cls();
return;
}
@@ -90,9 +98,11 @@
my ($rv, $value) = input($title, BTN_OK | BTN_CANCEL, $message, $length || 256,
qw(white blue yellow));
# XXX bug, if one doesn't enter anything, or an empty string or 0 or '0'...
+ $class->cls();
if ( $rv == 0) {
return $value
}
+ return;
}
use Curses::Widgets::ListBox;
@@ -136,6 +146,7 @@
});
$class->my_execute($list_box, $curses_handler);
my $new_value = $name_of{$list_box->getField('VALUE')};
+ $class->cls();
return $new_value;
}
Modified: RT-Client-Console/trunk/lib/RT/Client/Console/Cnx.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console/Cnx.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console/Cnx.pm Tue Nov 6 19:30:02 2007
@@ -37,35 +37,36 @@
$class->GLOBAL_HEAP->{rt}{cnx}{username} = $params{rt_username};
$class->GLOBAL_HEAP->{rt}{cnx}{password} = $params{rt_password};
- if (@{$params{queue_ids}}) {
+# if (@{$params{queue_ids}}) {
- my $idx = 0;
- my $rt_handler = $class->GLOBAL_HEAP->{rt}{cnx}{handler};
+# my $idx = 0;
+# my $rt_handler = $class->GLOBAL_HEAP->{rt}{cnx}{handler};
- use RT::Client::Console::Session::Progress;
- RT::Client::Console::Session::Progress->add_progress(
- steps_nb => sub { scalar(@{$params{queue_ids}}) },
- caption => sub { 'generating queues' },
- initially => sub { },
- code => sub {
- my $id = $params{queue_ids}->[$idx++];
- defined $id or return;
- use RT::Client::REST::Queue;
- my $queue;
- try {
- $queue = RT::Client::REST::Queue->new( rt => $rt_handler,
- id => $id, )->retrieve();
- } catch Exception::Class::Base with { my $dummy = 0; };
- if (defined $queue) {
- $class->GLOBAL_HEAP->{server}{id_to_queue}{$id} = $queue;
- $class->GLOBAL_HEAP->{server}{name_to_queue}{$queue->name()} = $queue;
- }
- return 1;
- },
- finally => sub { },
- );
- }
+# use RT::Client::Console::Session::Progress;
+# RT::Client::Console::Session::Progress->add_progress(
+# steps_nb => sub { scalar(@{$params{queue_ids}}) },
+# caption => sub { 'generating queues' },
+# initially => sub { },
+# code => sub {
+# my $id = $params{queue_ids}->[$idx++];
+# defined $id or return;
+# use RT::Client::REST::Queue;
+# my $queue;
+# try {
+# $queue = RT::Client::REST::Queue->new( rt => $rt_handler,
+# id => $id, )->retrieve();
+# } catch Exception::Class::Base with { my $dummy = 0; };
+# if (defined $queue) {
+# $class->GLOBAL_HEAP->{server}{id_to_queue}{$id} = $queue;
+# $class->GLOBAL_HEAP->{server}{name_to_queue}{$queue->name()} = $queue;
+# }
+# return 1;
+# },
+# finally => sub { },
+# );
+# }
+ $class->cls();
} catch Exception::Class::Base with {
$class->error("problem logging in: $@" . shift->message());
# print STDERR Dumper(shift); use Data::Dumper;
@@ -80,6 +81,10 @@
undef $class->GLOBAL_HEAP->{rt}{cnx}{servername};
undef $class->GLOBAL_HEAP->{rt}{cnx}{username};
undef $class->GLOBAL_HEAP->{rt}{cnx}{password};
+ my $ticket;
+ while ($ticket = $class->GLOBAL_HEAP->{rt}{tickets}{current}) {
+ $ticket->unload();
+ }
return;
}
Modified: RT-Client-Console/trunk/lib/RT/Client/Console/Session.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console/Session.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console/Session.pm Tue Nov 6 19:30:02 2007
@@ -11,8 +11,11 @@
$kernel->alias_set($name);
$kernel->call($name, 'init');
};
- POE::Session->create(%args);
- push @{$class->GLOBAL_HEAP->{sessions}}, $name;
+ $class->GLOBAL_HEAP->{sessions}{$name} = {
+ poe_object => POE::Session->create(%args),
+ displayed => 1,
+ };
+ return $name;
}
sub run {
@@ -90,10 +93,22 @@
},
);
push @{$class->GLOBAL_HEAP->{modal_sessions}}, $modal_session_name;
-
+ return $modal_session_name;
}
}
+=head2 remove
+
+Removes a session
+
+ input : a session name
+
+=cut
+
+sub remove {
+ my ($class, $session_name) = @_;
+ delete $class->GLOBAL_HEAP->{sessions}{$session_name};
+}
1;
Modified: RT-Client-Console/trunk/lib/RT/Client/Console/Session/KeyHandler.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console/Session/KeyHandler.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console/Session/KeyHandler.pm Tue Nov 6 19:30:02 2007
@@ -17,7 +17,6 @@
inline_states => {
init => sub {
my ($kernel, $heap) = @_[ KERNEL, HEAP];
- print STDERR "key_handler : init\n";
$kernel->yield('compute_keys');
$kernel->yield('draw_all');
@@ -54,7 +53,7 @@
my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
my $status_message = '';
$heap->{key_to_action} = {};
- foreach my $session (@{$class->GLOBAL_HEAP->{sessions}}) {
+ foreach my $session (keys %{$class->GLOBAL_HEAP->{sessions}}) {
my @list = $kernel->call($session, 'available_keys');
foreach (@list) {
defined && ref or next;
@@ -70,11 +69,19 @@
draw_all => sub {
my ($kernel, $heap) = @_[ KERNEL, HEAP ];
noutrefresh();
- foreach my $session (@{$class->GLOBAL_HEAP->{sessions}}) {
- $kernel->call($session, 'draw');
- }
- foreach my $modal_session (@{$class->GLOBAL_HEAP->{modal_sessions}}) {
- $kernel->call($modal_session, 'draw');
+ if ($class->GLOBAL_HEAP->{curses}{need_clear}) {
+ clear();
+ $class->GLOBAL_HEAP->{curses}{need_clear} = 0;
+ $kernel->yield('draw_all');
+ } else {
+ while (my ($session_name, $struct) = each %{$class->GLOBAL_HEAP->{sessions}}) {
+ print STDERR "$session_name : " . $struct->{displayed} . "\n";
+ $struct->{displayed} and
+ $kernel->call($session_name, 'draw');
+ }
+ foreach my $modal_session (@{$class->GLOBAL_HEAP->{modal_sessions}}) {
+ $kernel->call($modal_session, 'draw');
+ }
}
doupdate();
}
Modified: RT-Client-Console/trunk/lib/RT/Client/Console/Session/Root.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console/Session/Root.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console/Session/Root.pm Tue Nov 6 19:30:02 2007
@@ -17,6 +17,7 @@
my ($kernel, $heap) = @_[ KERNEL, HEAP ];
print STDERR "root : init\n";
$class->GLOBAL_HEAP->{curses}{handler}->clear();
+ $kernel->yield('create_tab_bar');
$kernel->yield('create_status_session');
$kernel->yield('create_progress_session');
},
@@ -27,14 +28,19 @@
}
if ($class->GLOBAL_HEAP->{rt}{cnx}{handler}) {
push @available_list, ['d', 'disconnect from RT server', 'disconnect_server'];
+ push @available_list, ['o', 'open a ticket', 'open_ticket'];
if ($class->GLOBAL_HEAP->{rt}{tickets}{current}) {
push @available_list, ['c', 'close current ticket', 'close_ticket'];
- } else {
- push @available_list, ['o', 'open a ticket', 'open_ticket'];
+ push @available_list, ['p', 'prev. ticket', 'prev_ticket'];
+ push @available_list, ['n', 'next ticket', 'next_ticket'];
}
}
return @available_list;
},
+ create_tab_bar => sub {
+ use RT::Client::Console::Session::TabBar;
+ RT::Client::Console::Session::TabBar->create();
+ },
create_status_session => sub {
use RT::Client::Console::Session::Status;
RT::Client::Console::Session::Status->create();
@@ -52,8 +58,20 @@
RT::Client::Console::Cnx->disconnect();
},
open_ticket => sub {
+ print STDERR "root.pm : opening ticket\n";
+ use RT::Client::Console::Session::Ticket;
+ RT::Client::Console::Session::Ticket->load();
+ },
+ close_ticket => sub {
+ $class->GLOBAL_HEAP->{rt}{tickets}{current}->unload();
+ },
+ next_ticket => sub {
+ use RT::Client::Console::Session::Ticket;
+ RT::Client::Console::Session::Ticket->next_ticket();
+ },
+ prev_ticket => sub {
use RT::Client::Console::Session::Ticket;
- RT::Client::Console::Session::Ticket->create();
+ RT::Client::Console::Session::Ticket->prev_ticket();
},
}
);
Added: RT-Client-Console/trunk/lib/RT/Client/Console/Session/TabBar.pm
==============================================================================
--- (empty file)
+++ RT-Client-Console/trunk/lib/RT/Client/Console/Session/TabBar.pm Tue Nov 6 19:30:02 2007
@@ -0,0 +1,107 @@
+package RT::Client::Console::Session::TabBar;
+
+use strict;
+use warnings;
+
+use base qw(RT::Client::Console::Session);
+
+use POE;
+
+# class method
+sub create {
+ my ($class) = @_;
+
+ $class->SUPER::create(
+ 'tabbar',
+ inline_states => {
+ init => sub {
+ my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
+ # Get the main screen max y & X
+ my ($screen_w, $screen_h);
+ $class->GLOBAL_HEAP->{curses}{handler}->getmaxyx($screen_h, $screen_w);
+
+ $heap->{width} = $screen_w;
+ },
+ draw => sub {
+ my ($kernel,$heap) = @_[ KERNEL, HEAP ];
+ my $curses_handler = $class->GLOBAL_HEAP->{curses}{handler};
+
+ my @tickets = @{$class->GLOBAL_HEAP->{rt}{tickets}{list}};
+ @tickets > 0 or return;
+
+ # clear the tab bar
+ use Curses::Widgets::Label;
+ my $label = Curses::Widgets::Label->new({
+ BORDER => 0,
+ X => 0,
+ Y => 0,
+ COLUMNS => $heap->{width},
+ LINES => 1,
+ VALUE => '',
+ FOREGROUND => 'black',
+ BACKGROUND => 'black',
+ });
+ $label->draw($curses_handler);
+
+ my $current_id = $class->GLOBAL_HEAP->{rt}{tickets}{current}->id();
+ my @visible_tickets = @tickets;
+ while (! _is_visible($current_id, @visible_tickets, $heap->{width})) {
+ shift @visible_tickets;
+ }
+
+ my $widgets = {};
+ my $current_pos_x = 0;
+ foreach my $index (0.. at visible_tickets-1) {
+ print STDERR "-- in loop : $index \n";
+ my $ticket = $visible_tickets[$index];
+ my $string = '[ ' . $ticket->id() . ' ]';
+ $current_pos_x + length($string) > $heap->{width} and last;
+ $widgets->{"tab_$index"} =
+ {
+ TYPE => 'Label',
+ X => $current_pos_x,
+ Y => 0,
+ COLUMNS => length($string),
+ LINES => 1,
+ FOREGROUND => $ticket->id() eq $current_id ? 'yellow' : 'white',
+ BACKGROUND => 'blue',
+ VALUE => $string,
+ ALIGNMENT => 'C',
+ };
+ $current_pos_x += length($string);
+ }
+ use Curses::Forms;
+ my $form = Curses::Forms->new({
+ X => 0,
+ Y => 0,
+ COLUMNS => $heap->{width},
+ LINES => 1,
+ BORDER => 0,
+ FOREGROUND => 'white',
+ BACKGROUND => 'blue',
+ DERIVED => 1,
+ # AUTOCENTER => 1,
+ TABORDER => [],
+ WIDGETS => $widgets,
+ },
+ );
+ $form->draw($curses_handler);
+ },
+ },
+ heap => { 'width' => 0 },
+ );
+}
+
+sub _is_visible {
+ my ($id, @visible_tickets, $max_width) = @_;
+ my $current_pos_x = 0;
+ foreach my $ticket (@visible_tickets) {
+ $current_pos_x += length "[ $id ]";
+ if ( $ticket->id() == $id ) {
+ return ($current_pos_x > $max_width);
+ }
+ }
+ die "shouldn't reach here";
+}
+
+1;
Modified: RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket.pm Tue Nov 6 19:30:02 2007
@@ -1,6 +1,7 @@
package RT::Client::Console::Session::Ticket;
-use base qw(RT::Client::Console::Session);
+use base qw(RT::Client::Console::Session
+ RT::Client::REST::Ticket);
use Params::Validate qw(:all);
@@ -8,48 +9,159 @@
use POE;
-sub load_ticket {
- my ($class, $rt_handler, $id) = @_;
+=head1 CONSTRUCTORS
- use RT::Client::REST::Ticket;
- my $t = RT::Client::REST::Ticket->new(
- rt => $rt_handler,
- id => $id,
- );
- $t->retrieve();
- return $t;
+=head2 load
+
+Loads a new ticket, or if already created, make sur it's made visible. If
+needed, it adds it in the list of tickets.
+
+input : id : the ticket id
+
+=cut
+
+sub load {
+ my ($class) = @_;
+ use Error qw(:try);
+ try {
+ if (my $id = $class->input_ok_cancel('Open a ticket', 'Ticket number')) {
+ my $ticket;
+ if (! ($ticket = $class->_is_loaded($id)) ) {
+ $ticket = $class->new($id);
+ push @{$class->GLOBAL_HEAP->{rt}{tickets}{list}}, $ticket;
+ $class->GLOBAL_HEAP->{rt}{tickets}{total}++;
+ }
+ $class->GLOBAL_HEAP->{rt}{tickets}{current} = $ticket;
+ $class->_set_visibility();
+ }
+ } otherwise {
+ $class->error("problem opening/retrieving rt $rt_num : " . $@);
+ };
+ return;
}
-# class method
-sub create {
+sub _set_visibility {
my ($class) = @_;
+ foreach my $ticket (@{$class->GLOBAL_HEAP->{rt}{tickets}{list}}) {
+ foreach my $session (@{$ticket->{sessions}}) {
+ $class->GLOBAL_HEAP->{sessions}{$session}{displayed} = 0;
+ }
+ }
+ foreach my $session (@{$class->GLOBAL_HEAP->{rt}{tickets}{current}->{sessions}}) {
+ $class->GLOBAL_HEAP->{sessions}{$session}{displayed} = 1;
+ }
+}
- if (my $id = $class->input_ok_cancel('Open a ticket', 'Ticket number')) {
+=head2 new
- use Error qw(:try);
- try {
+Creates a new ticket object, even if it is already loaded. You probably don't
+want to use that. Use load instead
- my $ticket = $class->load_ticket($class->GLOBAL_HEAP->{rt}{cnx}{handler}, $id);
- $class->GLOBAL_HEAP->{rt}{tickets}{current} = $ticket;
+=cut
+
+sub new {
+ my ($class, $id) = @_;
+
+ use RT::Client::REST::Ticket;
+ my $self = RT::Client::REST::Ticket->new(
+ rt => $class->GLOBAL_HEAP->{rt}{cnx}{handler},
+ id => $id,
+ );
+ $self->retrieve();
+
+ use RT::Client::Console::Session::Ticket::Header;
+ use RT::Client::Console::Session::Ticket::CustFields;
+ use RT::Client::Console::Session::Ticket::Links;
+ use RT::Client::Console::Session::Ticket::Attachments;
+
+ # the 'create' methods returns the name of the session, so the array
+ # contains keep the list of child sessions.
+ $self->{sessions} = [ RT::Client::Console::Session::Ticket::Header->create($id),
+ RT::Client::Console::Session::Ticket::CustFields->create($id),
+ RT::Client::Console::Session::Ticket::Links->create($id),
+ RT::Client::Console::Session::Ticket::Attachments->create($id),
+ ];
+ return bless $self, $class;
+}
+
+=head1 METHODS
+
+=head2 unload
+
+unload a ticket
- use RT::Client::Console::Session::Ticket::Header;
- RT::Client::Console::Session::Ticket::Header->create();
+=cut
- use RT::Client::Console::Session::Ticket::CustFields;
- RT::Client::Console::Session::Ticket::CustFields->create();
+sub unload {
+ my ($self) = @_;
+ # break references
+ foreach my $session_name (@{$self->{sessions}}) {
+ RT::Client::Console::Session->remove($session_name);
+ }
+ # remove from the list of tickets
+ @{$self->GLOBAL_HEAP->{rt}{tickets}{list}} = grep { $_ ne $self } @{$self->GLOBAL_HEAP->{rt}{tickets}{list}};
+ # display the next visible ticket
+ if ($self->GLOBAL_HEAP->{rt}{tickets}{current} == $self) {
+ if (@{$self->GLOBAL_HEAP->{rt}{tickets}{list}} > 0) {
+ $self->GLOBAL_HEAP->{rt}{tickets}{current} = $self->GLOBAL_HEAP->{rt}{tickets}{list}->[-1];
+ $self->cls();
+ } else {
+ $self->GLOBAL_HEAP->{rt}{tickets}{current} = undef;
+ $self->cls();
+ }
+ }
+ $class->_set_visibility();
+}
+
+=head1 METHODS
+
+=head2 next
+
+show the next ticket from the list
+
+=cut
+
+sub next_ticket {
+ my ($class) = @_;
- use RT::Client::Console::Session::Ticket::Links;
- RT::Client::Console::Session::Ticket::Links->create();
+ foreach my $index (0..@{$class->GLOBAL_HEAP->{rt}{tickets}{list}}-1) {
+ if ($class == $class->GLOBAL_HEAP->{rt}{tickets}{list}->[$index]
+ && exists $class->GLOBAL_HEAP->{rt}{tickets}{list}->[$index+1] ){
+ $class->GLOBAL_HEAP->{rt}{tickets}{current} =
+ $class->GLOBAL_HEAP->{rt}{tickets}{list}->[$index+1];
+ }
+ $class->_set_visibility();
+ }
+ return;
+}
+
+=head2 next
- use RT::Client::Console::Session::Ticket::Attachments;
- RT::Client::Console::Session::Ticket::Attachments->create();
-
- } catch Exception::Class::Base with {
- $class->error("problem opening/retrieving rt $rt_num : " . shift->message());
- return;
- };
+show the previous ticket from the list
+=cut
+
+sub prev_ticket {
+ my ($class) = @_;
+
+ foreach my $index (0..@{$class->GLOBAL_HEAP->{rt}{tickets}{list}}-1) {
+ if ($class == $class->GLOBAL_HEAP->{rt}{tickets}{list}->[$index]
+ && $index > 0 ){
+ $class->GLOBAL_HEAP->{rt}{tickets}{current} =
+ $class->GLOBAL_HEAP->{rt}{tickets}{list}->[$index-1];
+ }
+ $class->_set_visibility();
}
+ return;
+}
+
+# returns the ticket object if it's already loaded, empty list otherwise
+
+sub _is_loaded {
+ my ($class, $id) = @_;
+ my @matches = grep { $_->{id} eq $id } @{$class->GLOBAL_HEAP->{rt}{tickets}{list}};
+ @matches <= 1 or die "tickets loaded twice, shouldn't happen";
+ return @matches;
}
1;
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 Tue Nov 6 19:30:02 2007
@@ -9,9 +9,9 @@
# class method
sub create {
- my ($class) = @_;
+ my ($class, $id) = @_;
$class->SUPER::create(
- 'ticket_attachments',
+ "ticket_attachments_$id",
inline_states => {
init => sub {
my ($kernel, $heap) = @_[ KERNEL, HEAP ];
Modified: RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/CustFields.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/CustFields.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/CustFields.pm Tue Nov 6 19:30:02 2007
@@ -8,9 +8,9 @@
# class method
sub create {
- my ($class) = @_;
+ my ($class, $id) = @_;
$class->SUPER::create(
- 'ticket_custfields',
+ "ticket_custfields_$id",
inline_states => {
init => sub {
my ($kernel, $heap) = @_[ KERNEL, HEAP ];
@@ -30,45 +30,11 @@
},
change_custfields => sub {
my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
- $heap->{change_custfields_mode} = 1;
- my $text = qq(
-
- c : cancel
-);
- my $height = scalar( () = $text =~ /(\n)/g) + 1;
- use List::Util qw(max);
- my $title = ' Change ticket custom fields ';
- my $width = max (map { length } (split(/\n/, $text), $title));
- my ($screen_w, $screen_h);
- my $curses_handler = $class->GLOBAL_HEAP->{curses}{handler};
- $curses_handler->getmaxyx($screen_h, $screen_w);
-
- use Curses::Widgets::Label;
- my $label = Curses::Widgets::Label->new({
- CAPTION => $title,
- CAPTIONCOL => 'yellow',
- BORDER => 1,
- LINES => $height,
- COLUMNS => $width,
- Y => $screen_h/2-($height+2)/2,
- X => $screen_w/2-($width+2)/2,,
- VALUE => $text,
- FOREGROUND => 'white',
- BACKGROUND => 'blue',
- BORDERCOL => 'white',
- });
- $label->draw($curses_handler);
- $class->GLOBAL_HEAP->{modal_session} = 'ticket_custfields';
- },
- modal_handler => sub {
- my ( $kernel, $heap, $keystroke) = @_[ KERNEL, HEAP, ARG0 ];
- my $ticket = $class->GLOBAL_HEAP->{rt}{tickets}{current};
- if ($keystroke eq 'c' || $keystroke eq '<^[>') {
- delete $class->GLOBAL_HEAP->{modal_session};
- } else {
- $kernel->yield('change_custfields');
- }
- return;
+ $class->create_modal( title => ' Change Custom fields ',
+ text => '',
+ keys => {
+ },
+ );
},
draw => sub {
my ( $kernel, $heap) = @_[ KERNEL, HEAP ];
@@ -126,7 +92,6 @@
'pos_y' => 0,
'width' => 0,
'height' => 0,
- change_custfields_mode => 0,
},
);
}
Modified: RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Header.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Header.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Header.pm Tue Nov 6 19:30:02 2007
@@ -8,10 +8,10 @@
# class method
sub create {
- my ($class) = @_;
+ my ($class, $id) = @_;
$class->SUPER::create(
- 'ticket_header',
+ "ticket_header_$id",
inline_states => {
init => sub {
my ($kernel, $heap) = @_[ KERNEL, HEAP ];
@@ -56,25 +56,30 @@
q => { text => 'change queue',
code => sub {
- my $queues = $class->GLOBAL_HEAP->{server}{id_to_queue};
-
- my @queues_list_items;
- while (my ($id, $queue) = each %$queues) {
- push @queues_list_items, { text => $queue->name() . ' - ' . $queue->description(),
- value => $id,
- };
- };
- @queues_list_items = sort { $a->{text} cmp $b->{text} } @queues_list_items;
-
- if (my $new_queue_id = $class->input_list(title => ' Change queue ',
- items => [ @queues_list_items ],
- value => $class->GLOBAL_HEAP->{server}{name_to_queue}{$ticket->queue()}->id(),
- )) {
-
- my $new_queue_name = $class->GLOBAL_HEAP->{server}{id_to_queue}{$new_queue_id}->name();
- $ticket->queue($new_queue_name);
+ if (my $new_queue = $class->input_ok_cancel(' Change queue ', $ticket->queue(), 500)) {
+ $ticket->queue($new_queue);
return 1; # stop modal mode
}
+
+# my $queues = $class->GLOBAL_HEAP->{server}{id_to_queue};
+
+# my @queues_list_items;
+# while (my ($id, $queue) = each %$queues) {
+# push @queues_list_items, { text => $queue->name() . ' - ' . $queue->description(),
+# value => $id,
+# };
+# };
+# @queues_list_items = sort { $a->{text} cmp $b->{text} } @queues_list_items;
+
+# if (my $new_queue_id = $class->input_list(title => ' Change queue ',
+# items => [ @queues_list_items ],
+# value => $class->GLOBAL_HEAP->{server}{name_to_queue}{$ticket->queue()}->id(),
+# )) {
+
+# my $new_queue_name = $class->GLOBAL_HEAP->{server}{id_to_queue}{$new_queue_id}->name();
+# $ticket->queue($new_queue_name);
+# return 1; # stop modal mode
+# }
}
},
p => { text => 'change priority',
Modified: RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Links.pm
==============================================================================
--- RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Links.pm (original)
+++ RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Links.pm Tue Nov 6 19:30:02 2007
@@ -8,9 +8,9 @@
# class method
sub create {
- my ($class) = @_;
+ my ($class, $id) = @_;
$class->SUPER::create(
- 'ticket_links',
+ "ticket_links_$id",
inline_states => {
init => sub {
my ($kernel, $heap) = @_[ KERNEL, HEAP ];
More information about the Bps-public-commit
mailing list