[Rt-commit] r4001 - in rtir/branches/1.9-EXPERIMENTAL: .
html/RTIR/Elements
ruz at bestpractical.com
ruz at bestpractical.com
Mon Oct 31 10:50:21 EST 2005
Author: ruz
Date: Mon Oct 31 10:50:21 2005
New Revision: 4001
Added:
rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/States
Modified:
rtir/branches/1.9-EXPERIMENTAL/ (props changed)
rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/Type
Log:
r218 at cubic-pc: cubic | 2005-10-31 18:49:24 +0300
r205 at cubic-pc: cubic | 2005-10-31 02:49:53 +0300
* new element that return available states for the RTIR queues
* refactor Type element to use it
* refactor Type element to use hash instead of if-else chain
Added: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/States
==============================================================================
--- (empty file)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/States Mon Oct 31 10:50:21 2005
@@ -0,0 +1,29 @@
+<%ONCE>
+my %meta = (
+ 'Incidents' => { Active => ['new', 'open'], Inactive => [] },
+ 'Incident Reports' => { Active => ['new', 'open'], Inactive => ['rejected'] },
+ 'Investigations' => { Active => ['open'], Inactive => ['stalled'] },
+ 'Blocks' => { Active => ['pending activation', 'active', 'pending removal'], Inactive => [] },
+);
+</%ONCE>
+<%INIT>
+my @states;
+if( $Queue ) {
+ push @states, @{ $meta{ $Queue }->{'Active'} } if $Active;
+ push @states, @{ $meta{ $Queue }->{'Inactive'} } if $Inactive;
+} else {
+ foreach ( values %meta ) {
+ push @states, @{ $_->{'Active'} || [] } if $Active;
+ push @states, @{ $_->{'Inactive'} || [] } if $Inactive;
+ }
+}
+
+my %seen = ();
+return sort grep !$seen{$_}++, @states;
+
+</%INIT>
+<%ARGS>
+$Queue => undef
+$Active => 1,
+$Inactive => 0,
+</%ARGS>
Modified: rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/Type
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/Type (original)
+++ rtir/branches/1.9-EXPERIMENTAL/html/RTIR/Elements/Type Mon Oct 31 10:50:21 2005
@@ -22,37 +22,31 @@
%#
%#
%# END LICENSE BLOCK
+<%ONCE>
+my %type = (
+ 'Incidents' => 'Incident',
+ 'Incident Reports' => 'Report',
+ 'Investigations' => 'Investigation',
+ 'Blocks' => 'Block',
+);
+</%ONCE>
<%INIT>
-my $name;
-if ($Ticket) {
- my $TicketObj = new RT::Ticket($session{'CurrentUser'});
- $TicketObj = LoadTicket($Ticket);
- $name = $TicketObj->QueueObj->Name;
-} else {
- $name = $Queue;
+unless( $Queue ) {
+ $TicketObj = LoadTicket($Ticket) if $Ticket && !$TicketObj;
+ if( $TicketObj ) {
+ $Queue = $TicketObj->QueueObj->Name;
+ }
}
-my ($Type, @states);
-if ($name eq "Incidents") {
- $Type = 'Incident';
- @states = ('new', 'open');
-} elsif ($name eq "Incident Reports") {
- $Type = 'Report';
- @states = ('new', 'open');
-} elsif ($name eq "Investigations") {
- $Type = 'Investigation';
- @states = ('open', 'stalled');
-} if ($name eq "Blocks") {
- $Type = 'Block';
- @states = ('pending activation', 'active', 'pending removal');
-}
-
-return ($Type, @states);
+my $type = $type{$Queue} || '';
+my @states = $m->comp("/RTIR/Elements/States", Queue => $Queue);
+return ($type, @states);
</%INIT>
<%ARGS>
$Ticket => undef
+$TicketObj => undef
$Queue => undef
</%ARGS>
More information about the Rt-commit
mailing list