[Rt-commit] rt branch, 4.2/add-scrips-menu, created. rt-4.2.3-169-gbf6654b
Wallace Reis
wreis at bestpractical.com
Fri May 2 16:16:33 EDT 2014
The branch, 4.2/add-scrips-menu has been created
at bf6654b986bab35a6b543fff69ec3c0cb2d84a64 (commit)
- Log -----------------------------------------------------------------
commit bf6654b986bab35a6b543fff69ec3c0cb2d84a64
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 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/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/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..527aaad 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,6 +380,26 @@ my $build_admin_menu = sub {
$obj->Load($id);
my $tabs = PageMenu();
+
+ my ( $admin_cat, $create_path_arg );
+ 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';
+ $create_path_arg = '?Global=1';
+ }
+ else {
+ $admin_cat = 'Scrips';
+ $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 );
$tabs->child( 'applies-to' => title => loc('Applies to'), path => "/Admin/Scrips/Objects.html?id=" . $id );
}
@@ -389,11 +409,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 +426,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