[Rt-commit] rt branch, 4.2/add-scrips-menu, created. rt-4.2.4-15-gaa89bc9
Wallace Reis
wreis at bestpractical.com
Tue May 20 17:42:03 EDT 2014
The branch, 4.2/add-scrips-menu has been created
at aa89bc9d6ab999131999d8c21bddaf31a669f56e (commit)
- Log -----------------------------------------------------------------
commit aa89bc9d6ab999131999d8c21bddaf31a669f56e
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, except it addes query params when from global or queue
listing pages.
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index f9b24be..b8ef3e4 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2963,8 +2963,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/Create.html b/share/html/Admin/Scrips/Create.html
index cb52f8d..0a3c120 100644
--- a/share/html/Admin/Scrips/Create.html
+++ b/share/html/Admin/Scrips/Create.html
@@ -51,6 +51,7 @@
<form method="post" action="Create.html" id="CreateScrip" name="CreateScrip">
<input type="hidden" class="hidden" name="Queue" value="<% $Queue %>" />
+<input type="hidden" class="hidden" name="Global" value="<% $Global || q{} %>" />
<&| /Widgets/TitleBox, title => loc('Basics') &>
<table>
@@ -86,6 +87,7 @@
<%ARGS>
$Queue => 0
$Create => undef
+$Global => undef
</%ARGS>
<%INIT>
my @results;
@@ -129,7 +131,14 @@ if ( $Create ) {
Force => 1,
Actions => [ $msg ],
Path => 'Admin/Scrips/Modify.html',
- Arguments => { id => $scrip->id },
+ Arguments => {
+ id => $scrip->id,
+ $Queue ? (
+ From => $Queue,
+ ) : $Global ? (
+ From => 'Global',
+ ) : ()
+ },
) if $status;
push @results, $msg;
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/Admin/Scrips/Objects.html b/share/html/Admin/Scrips/Objects.html
index 6033506..7cb681a 100644
--- a/share/html/Admin/Scrips/Objects.html
+++ b/share/html/Admin/Scrips/Objects.html
@@ -51,6 +51,7 @@
<form action="Objects.html" method="post" name="AddRemoveScrip">
<input type="hidden" class="hidden" name="id" value="<% $id %>" />
+<input type="hidden" class="hidden" name="From" value="<% $From || q{} %>" />
% if ( $global ) {
<h2><&|/l&>Applies to all objects</&></h2>
@@ -120,6 +121,7 @@ $id => undef
$Stage => undef
$Template => ''
$Update => 0
+$From => undef
</%ARGS>
<%INIT>
my $scrip = RT::Scrip->new( $session{'CurrentUser'} );
@@ -152,7 +154,10 @@ if ( $Update ) {
}
MaybeRedirectForResults(
Actions => \@results,
- Arguments => { id => $id },
+ Arguments => {
+ id => $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..881bace 100644
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -119,7 +119,7 @@ my $build_admin_menu = sub {
path => '/Admin/Global/Scrips.html',
);
$scrips->child( select => title => loc('Select'), path => "/Admin/Global/Scrips.html" );
- $scrips->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html" );
+ $scrips->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html?Global=1" );
my $templates = $admin_global->child( templates =>
title => loc('Templates'),
@@ -380,8 +380,30 @@ my $build_admin_menu = sub {
$obj->Load($id);
my $tabs = PageMenu();
- $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 );
+
+ my ( $admin_cat, $create_path_arg, $from_query_param );
+ 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";
+ $from_query_param = "&From=$from_queue";
+ }
+ elsif ( $from_arg eq 'Global' ) {
+ $admin_cat = 'Global/Scrips.html';
+ $create_path_arg = '?Global=1';
+ $from_query_param = '&From=Global';
+ }
+ else {
+ $admin_cat = 'Scrips';
+ $from_query_param = $create_path_arg = q{};
+ }
+ 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 . $from_query_param );
+ $tabs->child( 'applies-to' => title => loc('Applies to'), path => "/Admin/Scrips/Objects.html?id=" . $id . $from_query_param );
}
elsif ( $request_path =~ m{^/Admin/Scrips/(index\.html)?$} ) {
PageMenu->child( select => title => loc('Select') => path => "/Admin/Scrips/" );
@@ -389,11 +411,15 @@ my $build_admin_menu = sub {
}
elsif ( $request_path =~ m{^/Admin/Scrips/Create\.html$} ) {
my ($queue) = $DECODED_ARGS->{'Queue'} && $DECODED_ARGS->{'Queue'} =~ /^(\d+)$/;
+ my $global_arg = $DECODED_ARGS->{'Global'};
if ($queue) {
PageMenu->child( select => title => loc('Select') => path => "/Admin/Queues/Scrips.html?id=$queue" );
PageMenu->child( create => title => loc('Create') => path => "/Admin/Scrips/Create.html?Queue=$queue" );
- } else {
+ } elsif ($global_arg) {
PageMenu->child( select => title => loc('Select') => path => "/Admin/Global/Scrips.html" );
+ PageMenu->child( create => title => loc('Create') => path => "/Admin/Scrips/Create.html?Global=1" );
+ } else {
+ PageMenu->child( select => title => loc('Select') => path => "/Admin/Scrips" );
PageMenu->child( create => title => loc('Create') => path => "/Admin/Scrips/Create.html" );
}
}
@@ -402,7 +428,7 @@ my $build_admin_menu = sub {
if ( $request_path =~ m{^/Admin/Global/Scrips\.html} ) {
my $tabs = PageMenu();
$tabs->child( select => title => loc('Select'), path => "/Admin/Global/Scrips.html" );
- $tabs->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html" );
+ $tabs->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html?Global=1" );
}
if ( $request_path =~ m{^/Admin/Global/Templates?\.html} ) {
-----------------------------------------------------------------------
More information about the rt-commit
mailing list