[Bps-public-commit] rtx-calendar branch, master, updated. 087a16dd2a2d70d8ce6cdc5c65111f7483e0f06d
Kevin Falcone
falcone at bestpractical.com
Thu Dec 8 13:43:22 EST 2011
The branch, master has been updated
via 087a16dd2a2d70d8ce6cdc5c65111f7483e0f06d (commit)
from b000c680e951204424115a57ecc3dbb9cf3e7863 (commit)
Summary of changes:
.../RTx-Calendar/Elements/Tabs/Privileged | 18 ++-------------
lib/RTx/Calendar.pm | 23 ++++++++++++++++++++
2 files changed, 26 insertions(+), 15 deletions(-)
- Log -----------------------------------------------------------------
commit 087a16dd2a2d70d8ce6cdc5c65111f7483e0f06d
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Thu Dec 8 13:41:53 2011 -0500
Clone the add_after code from 4.0-trunk
This will become irrelevant after 4.0.5 (hopefully) but will
let me write 1 line of code to add this menu item, rather than 12.
And this extension will work on earlier versions of 4.0
diff --git a/html/Callbacks/RTx-Calendar/Elements/Tabs/Privileged b/html/Callbacks/RTx-Calendar/Elements/Tabs/Privileged
index 7ec8754..31ed90a 100644
--- a/html/Callbacks/RTx-Calendar/Elements/Tabs/Privileged
+++ b/html/Callbacks/RTx-Calendar/Elements/Tabs/Privileged
@@ -57,21 +57,9 @@ my $query_string = sub {
if ( $request_path =~ qr{^/Search/} && $m->request_args->{Query} ) {
my $tabs = PageMenu;
- my $sort_order;
- # we want to sort ourselves after the Charts link
- # this involves shifting any other tabs (like feeds) off to the right
- for my $child ($tabs->children) {
- if ( $child->key eq 'chart' ) {
- $sort_order = $child->sort_order + 1;
- next;
- }
- if ( $sort_order ) {
- $child->sort_order( $child->sort_order + 1 );
- }
- }
- $tabs->child( 'calendar' => title => loc('Calendar'),
- path => '/Search/Calendar.html?' . $query_string->( %{$m->request_args} ),
- sort_order => $sort_order );
+ my $chart = $tabs->child('chart');
+ $chart->add_after( 'calendar' => title => loc('Calendar'),
+ path => '/Search/Calendar.html?' . $query_string->( %{$m->request_args} ) );
}
my $about_me = Menu->child( 'preferences' );
diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index d7ab6be..13dba15 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -101,6 +101,29 @@ sub SearchDefaultCalendar {
}
}
+package RT::Interface::Web::Menu;
+
+# we should get an add_after method in 4.0.5, but until then
+# shim this in so I don't copy the code.
+unless (RT::Interface::Web::Menu->can('add_after')) {
+ *RT::Interface::Web::Menu::add_after = sub {
+ warn "Running from extension";
+ my $self = shift;
+ my $parent = $self->parent;
+ my $sort_order;
+ for my $contemporary ($parent->children) {
+ if ( $contemporary->key eq $self->key ) {
+ $sort_order = $contemporary->sort_order + 1;
+ next;
+ }
+ if ( $sort_order ) {
+ $contemporary->sort_order( $contemporary->sort_order + 1 );
+ }
+ }
+ $parent->child( @_, sort_order => $sort_order );
+ };
+}
+
1;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list