[Bps-public-commit] r9797 - in RT-Client-Console: trunk/lib/RT/Client/Console/Session trunk/lib/RT/Client/Console/Session/Ticket

dams at bestpractical.com dams at bestpractical.com
Mon Dec 3 06:21:55 EST 2007


Author: dams
Date: Mon Dec  3 06:21:46 2007
New Revision: 9797

Modified:
   RT-Client-Console/   (props changed)
   RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket.pm
   RT-Client-Console/trunk/lib/RT/Client/Console/Session/Ticket/Links.pm

Log:
 r15 at pundit:  dams | 2007-12-03 11:21:38 +0000
 more ticket methods, debug


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	Mon Dec  3 06:21:46 2007
@@ -16,7 +16,7 @@
 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
+input : 
 
 =cut
 
@@ -25,14 +25,7 @@
 	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->set_current_id($id);
-			$class->_set_visibility();
+			$class->load_from_id($id);
 		}
 	} otherwise {
 		$class->error("problem opening/retrieving rt $rt_num : " . $@);
@@ -40,6 +33,24 @@
 	return;
 }
 
+sub load_from_id {
+	my ($class, $id) = @_;
+	use Error qw(:try);
+	try {
+		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->set_current_id($id);
+		$class->_set_visibility();
+	} otherwise {
+		$class->error("problem opening/retrieving rt $rt_num : " . $@);
+	};
+	return;
+}
+
 sub _set_visibility {
 	my ($class) = @_;
 	foreach my $ticket (@{$class->GLOBAL_HEAP->{rt}{tickets}{list}}) {
@@ -52,6 +63,23 @@
 	}
 }
 
+=head2 open_from_id
+
+simply return the REST ticket, don't display it, nor add it to the tab, or list of loaded tickets.
+
+=cut
+
+sub open_from_id {
+	my ($class, $id) = @_;
+	use RT::Client::REST::Ticket;
+	my $ticket = RT::Client::REST::Ticket->new(
+												rt  => $class->GLOBAL_HEAP->{rt}{cnx}{handler},
+												id  => $id,
+											  );
+	$ticket->retrieve();
+	return $ticket;
+}
+
 =head2 new
 
 Creates a new ticket object, even if it is already loaded. You probably don't
@@ -62,12 +90,7 @@
 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();
+	my $self = $class->open_from_id($id);
 
 	use RT::Client::Console::Session::Ticket::Header;
 	use RT::Client::Console::Session::Ticket::CustFields;

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	Mon Dec  3 06:21:46 2007
@@ -76,6 +76,8 @@
 
 			my $ticket = RT::Client::Console::Session::Ticket->get_current_ticket();
 
+print STDERR "LINKS ---> got $ticket \n";
+
 			if (!defined($heap->{parents})) {
 				$class->_generate_job($kernel, $heap, 'parents', q(HasMember=') . $ticket->id() . q('))
 			}
@@ -113,6 +115,7 @@
 								  [ 'Depended on by:' => $_ticket_to_label->($d2[0]) ],
 								  map { [ '' => $_ticket_to_label->($_) ] } @d2[1..$#d2]
 								 );
+print STDERR "----> parents : " . Dumper(\@p); use Data::Dumper;
 			my @p = @{$heap->{parents}};
 			my @parents = (
 						   [ 'Parents:' => $_ticket_to_label->($p[0]) ],
@@ -198,8 +201,9 @@
 			},
 			code => sub { my $id = $ids[$idx++];
 						  defined $id or return;
+print STDERR "->>>>>> got id : [$id]\n";
 						  push @{$heap->{$element}},
-							RT::Client::Console::Session::Ticket->load($rt_handler, $id);
+							RT::Client::Console::Session::Ticket->open_from_id($id);
 						  #										   $kernel->post('ticket_links', 'draw');
 						  return 1;
 					  },



More information about the Bps-public-commit mailing list