[Rt-commit] rt branch, 4.2/add-scrips-menu, created. rt-4.2.3-169-g019fa96

Wallace Reis wreis at bestpractical.com
Wed Apr 30 10:16:27 EDT 2014


The branch, 4.2/add-scrips-menu has been created
        at  019fa96b4bfb38b641d5cfdc04bcd78ecb25c6c6 (commit)

- Log -----------------------------------------------------------------
commit 019fa96b4bfb38b641d5cfdc04bcd78ecb25c6c6
Author: Wallace Reis <wreis at bestpractical.com>
Date:   Thu Mar 13 18:01:44 2014 -0300

    I#28787: Add Scrips menu
    
    Add Scrips menu with 'Select' and 'Create' options. The 'Select' opt
    defaults to Admin/Scrips path unless the user comes from Global or
    Queue's Scrips listing page. The 'Create' one points to the same place
    for all cases.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index d01d1c7..81e72be 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2946,8 +2946,8 @@ Set(%AdminSearchResultFormat,
         .q{,__AddedTo__, __FriendlyType__, __FriendlyPattern__},
 
     Scrips =>
-        q{'<a href="__WebPath__/Admin/Scrips/Modify.html?id=__id__">__id__</a>/TITLE:#'}
-        .q{,'<a href="__WebPath__/Admin/Scrips/Modify.html?id=__id__">__Description__</a>/TITLE:Description'}
+        q{'<a href="__WebPath__/Admin/Scrips/Modify.html?id=__id____From__">__id__</a>/TITLE:#'}
+        .q{,'<a href="__WebPath__/Admin/Scrips/Modify.html?id=__id____From__">__Description__</a>/TITLE:Description'}
         .q{,__Condition__, __Action__, __Template__, __Disabled__},
 
     Templates =>
diff --git a/share/html/Admin/Scrips/Modify.html b/share/html/Admin/Scrips/Modify.html
index ad0e18f..d43c462 100644
--- a/share/html/Admin/Scrips/Modify.html
+++ b/share/html/Admin/Scrips/Modify.html
@@ -51,6 +51,7 @@
 
 <form method="post" action="Modify.html" id="ModifyScrip" name="ModifyScrip">
 <input type="hidden" class="hidden" name="id" value="<% $id %>" />
+<input type="hidden" class="hidden" name="From" value="<% $From || q{} %>" />
 
 <&| /Widgets/TitleBox, title => loc('Basics') &>
 <table>
@@ -96,6 +97,7 @@
 <%ARGS>
 $id     => undef
 $Update => undef
+$From   => undef
 </%ARGS>
 <%INIT>
 my $scrip = RT::Scrip->new( $session{'CurrentUser'} );
@@ -123,7 +125,10 @@ if ( $Update ) {
     );
     MaybeRedirectForResults(
         Actions   => \@results,
-        Arguments => { id => $scrip->id },
+        Arguments => {
+            id => $scrip->id,
+            From => $From,
+        },
     );
 }
 
diff --git a/share/html/Elements/RT__Scrip/ColumnMap b/share/html/Elements/RT__Scrip/ColumnMap
index b6b3348..92e934d 100644
--- a/share/html/Elements/RT__Scrip/ColumnMap
+++ b/share/html/Elements/RT__Scrip/ColumnMap
@@ -66,6 +66,21 @@ my $COLUMN_MAP = {
             return join(", ", map {$_->Id} @{$_[0]->AddedTo->ItemsArrayRef});
         },
     },
+    From => {
+        title     => 'Queue',
+        value     => sub {
+            my $request_path = $HTML::Mason::Commands::r->path_info;
+            my $queue_id = $m->request_args->{'id'};
+            if ( $request_path =~ m{/Admin/Queues/Scrips\.html} and $queue_id ) {
+                return '&From=' . $queue_id;
+            } elsif ( $request_path =~ m{/Admin/Global/Scrips\.html} ) {
+                return '&From=Global';
+            }
+            else {
+                return q{};
+            }
+        },
+    },
     Condition => {
         title     => 'Condition', # loc
         value     => sub { return $_[0]->loc( $_[0]->ScripConditionObj->Name ) },
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 0b3a50e..bbaa3af 100644
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -380,6 +380,24 @@ my $build_admin_menu = sub {
             $obj->Load($id);
 
             my $tabs = PageMenu();
+
+            my ( $admin_cat, $create_path_arg ) = ( q{}, q{} );
+            my $from_arg = $DECODED_ARGS->{'From'} || q{};
+            my ($from_queue) =  $from_arg =~ /^(\d+)$/;
+            if ( $from_queue ) {
+                $admin_cat = "Queues/Scrips.html?id=$from_queue";
+                $create_path_arg = '?Queue=$from_queue';
+            }
+            elsif ( $from_arg eq 'Global' ) {
+                $admin_cat = 'Global/Scrips.html';
+            }
+            else {
+                $admin_cat = 'Scrips';
+            }
+            my $scrips = $tabs->child( scrips => title => loc('Scrips'), path => "/Admin/${admin_cat}" );
+            $scrips->child( select => title => loc('Select'), path => "/Admin/${admin_cat}" );
+            $scrips->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html${create_path_arg}" );
+
             $tabs->child( basics => title => loc('Basics') => path => "/Admin/Scrips/Modify.html?id=".$id );
             $tabs->child( 'applies-to' => title => loc('Applies to'), path => "/Admin/Scrips/Objects.html?id=" . $id );
         }

-----------------------------------------------------------------------


More information about the rt-commit mailing list